babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486
  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. get 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 get 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 set LogLevels(level: 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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1053. * @param fallback defines the fallback internal texture if any
  1054. * @param isBase64 defines whether the texture is encoded as a base64
  1055. * @param isBuffer defines whether the texture data are stored as a buffer
  1056. * @returns true if the loader can load the specified file
  1057. */
  1058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1059. /**
  1060. * Transform the url before loading if required.
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the transformed texture
  1064. */
  1065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1066. /**
  1067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1068. * @param rootUrl the url of the texture
  1069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1070. * @returns the fallback texture
  1071. */
  1072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1073. /**
  1074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1075. * @param data contains the texture data
  1076. * @param texture defines the BabylonJS internal texture
  1077. * @param createPolynomials will be true if polynomials have been requested
  1078. * @param onLoad defines the callback to trigger once the texture is ready
  1079. * @param onError defines the callback to trigger in case of error
  1080. */
  1081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1082. /**
  1083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1084. * @param data contains the texture data
  1085. * @param texture defines the BabylonJS internal texture
  1086. * @param callback defines the method to call once ready to upload
  1087. */
  1088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1089. }
  1090. }
  1091. declare module "babylonjs/Engines/IPipelineContext" {
  1092. /**
  1093. * Class used to store and describe the pipeline context associated with an effect
  1094. */
  1095. export interface IPipelineContext {
  1096. /**
  1097. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1098. */
  1099. isAsync: boolean;
  1100. /**
  1101. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1102. */
  1103. isReady: boolean;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module "babylonjs/Meshes/dataBuffer" {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1143. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1144. /** @hidden */
  1145. export interface ProcessingOptions {
  1146. defines: string[];
  1147. indexParameters: any;
  1148. isFragment: boolean;
  1149. shouldUseHighPrecisionShader: boolean;
  1150. supportsUniformBuffers: boolean;
  1151. shadersRepository: string;
  1152. includesShadersStore: {
  1153. [key: string]: string;
  1154. };
  1155. processor?: IShaderProcessor;
  1156. version: string;
  1157. platformName: string;
  1158. lookForClosingBracketForUniformBuffer?: boolean;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1162. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1163. /** @hidden */
  1164. export class ShaderCodeNode {
  1165. line: string;
  1166. children: ShaderCodeNode[];
  1167. additionalDefineKey?: string;
  1168. additionalDefineValue?: string;
  1169. isValid(preprocessors: {
  1170. [key: string]: string;
  1171. }): boolean;
  1172. process(preprocessors: {
  1173. [key: string]: string;
  1174. }, options: ProcessingOptions): string;
  1175. }
  1176. }
  1177. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1178. /** @hidden */
  1179. export class ShaderCodeCursor {
  1180. private _lines;
  1181. lineIndex: number;
  1182. get currentLine(): string;
  1183. get canRead(): boolean;
  1184. set lines(value: string[]);
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1190. /** @hidden */
  1191. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1192. process(preprocessors: {
  1193. [key: string]: string;
  1194. }, options: ProcessingOptions): string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1198. /** @hidden */
  1199. export class ShaderDefineExpression {
  1200. isTrue(preprocessors: {
  1201. [key: string]: string;
  1202. }): boolean;
  1203. }
  1204. }
  1205. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1206. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1207. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1208. /** @hidden */
  1209. export class ShaderCodeTestNode extends ShaderCodeNode {
  1210. testExpression: ShaderDefineExpression;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. not: boolean;
  1222. constructor(define: string, not?: boolean);
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1254. define: string;
  1255. operand: string;
  1256. testValue: string;
  1257. constructor(define: string, operand: string, testValue: string);
  1258. isTrue(preprocessors: {
  1259. [key: string]: string;
  1260. }): boolean;
  1261. }
  1262. }
  1263. declare module "babylonjs/Offline/IOfflineProvider" {
  1264. /**
  1265. * Class used to enable access to offline support
  1266. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1267. */
  1268. export interface IOfflineProvider {
  1269. /**
  1270. * Gets a boolean indicating if scene must be saved in the database
  1271. */
  1272. enableSceneOffline: boolean;
  1273. /**
  1274. * Gets a boolean indicating if textures must be saved in the database
  1275. */
  1276. enableTexturesOffline: boolean;
  1277. /**
  1278. * Open the offline support and make it available
  1279. * @param successCallback defines the callback to call on success
  1280. * @param errorCallback defines the callback to call on error
  1281. */
  1282. open(successCallback: () => void, errorCallback: () => void): void;
  1283. /**
  1284. * Loads an image from the offline support
  1285. * @param url defines the url to load from
  1286. * @param image defines the target DOM image
  1287. */
  1288. loadImage(url: string, image: HTMLImageElement): void;
  1289. /**
  1290. * Loads a file from offline support
  1291. * @param url defines the URL to load from
  1292. * @param sceneLoaded defines a callback to call on success
  1293. * @param progressCallBack defines a callback to call when progress changed
  1294. * @param errorCallback defines a callback to call on error
  1295. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1296. */
  1297. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/filesInputStore" {
  1301. /**
  1302. * Class used to help managing file picking and drag'n'drop
  1303. * File Storage
  1304. */
  1305. export class FilesInputStore {
  1306. /**
  1307. * List of files ready to be loaded
  1308. */
  1309. static FilesToLoad: {
  1310. [key: string]: File;
  1311. };
  1312. }
  1313. }
  1314. declare module "babylonjs/Misc/retryStrategy" {
  1315. import { WebRequest } from "babylonjs/Misc/webRequest";
  1316. /**
  1317. * Class used to define a retry strategy when error happens while loading assets
  1318. */
  1319. export class RetryStrategy {
  1320. /**
  1321. * Function used to defines an exponential back off strategy
  1322. * @param maxRetries defines the maximum number of retries (3 by default)
  1323. * @param baseInterval defines the interval between retries
  1324. * @returns the strategy function to use
  1325. */
  1326. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1327. }
  1328. }
  1329. declare module "babylonjs/Misc/baseError" {
  1330. /**
  1331. * @ignore
  1332. * Application error to support additional information when loading a file
  1333. */
  1334. export abstract class BaseError extends Error {
  1335. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1336. }
  1337. }
  1338. declare module "babylonjs/Misc/fileTools" {
  1339. import { WebRequest } from "babylonjs/Misc/webRequest";
  1340. import { Nullable } from "babylonjs/types";
  1341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1343. import { BaseError } from "babylonjs/Misc/baseError";
  1344. /** @ignore */
  1345. export class LoadFileError extends BaseError {
  1346. request?: WebRequest;
  1347. file?: File;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, object?: WebRequest | File);
  1355. }
  1356. /** @ignore */
  1357. export class RequestFileError extends BaseError {
  1358. request: WebRequest;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. */
  1364. constructor(message: string, request: WebRequest);
  1365. }
  1366. /** @ignore */
  1367. export class ReadFileError extends BaseError {
  1368. file: File;
  1369. /**
  1370. * Creates a new ReadFileError
  1371. * @param message defines the message of the error
  1372. * @param file defines the optional file
  1373. */
  1374. constructor(message: string, file: File);
  1375. }
  1376. /**
  1377. * @hidden
  1378. */
  1379. export class FileTools {
  1380. /**
  1381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1382. */
  1383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1384. /**
  1385. * Gets or sets the base URL to use to load assets
  1386. */
  1387. static BaseUrl: string;
  1388. /**
  1389. * Default behaviour for cors in the application.
  1390. * It can be a string if the expected behavior is identical in the entire app.
  1391. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1392. */
  1393. static CorsBehavior: string | ((url: string | string[]) => string);
  1394. /**
  1395. * Gets or sets a function used to pre-process url before using them to load assets
  1396. */
  1397. static PreprocessUrl: (url: string) => string;
  1398. /**
  1399. * Removes unwanted characters from an url
  1400. * @param url defines the url to clean
  1401. * @returns the cleaned url
  1402. */
  1403. private static _CleanUrl;
  1404. /**
  1405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1406. * @param url define the url we are trying
  1407. * @param element define the dom element where to configure the cors policy
  1408. */
  1409. static SetCorsBehavior(url: string | string[], element: {
  1410. crossOrigin: string | null;
  1411. }): void;
  1412. /**
  1413. * Loads an image as an HTMLImageElement.
  1414. * @param input url string, ArrayBuffer, or Blob to load
  1415. * @param onLoad callback called when the image successfully loads
  1416. * @param onError callback called when the image fails to load
  1417. * @param offlineProvider offline provider for caching
  1418. * @param mimeType optional mime type
  1419. * @returns the HTMLImageElement of the loaded image
  1420. */
  1421. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1422. /**
  1423. * Reads a file from a File object
  1424. * @param file defines the file to load
  1425. * @param onSuccess defines the callback to call when data is loaded
  1426. * @param onProgress defines the callback to call during loading process
  1427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1428. * @param onError defines the callback to call when an error occurs
  1429. * @returns a file request object
  1430. */
  1431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file from a url
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param offlineProvider defines the offline provider for caching
  1438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1439. * @param onError callback called when the file fails to load
  1440. * @returns a file request object
  1441. */
  1442. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @param onOpened callback called when the web request is opened
  1451. * @returns a file request object
  1452. */
  1453. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1454. /**
  1455. * Checks if the loaded document was accessed via `file:`-Protocol.
  1456. * @returns boolean
  1457. */
  1458. static IsFileURL(): boolean;
  1459. }
  1460. }
  1461. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1462. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1463. import { WebRequest } from "babylonjs/Misc/webRequest";
  1464. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module "babylonjs/Maths/math.like" {
  1495. import { float, int, DeepImmutable } from "babylonjs/types";
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IColor4Like {
  1500. r: float;
  1501. g: float;
  1502. b: float;
  1503. a: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IColor3Like {
  1509. r: float;
  1510. g: float;
  1511. b: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector4Like {
  1517. x: float;
  1518. y: float;
  1519. z: float;
  1520. w: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IVector3Like {
  1526. x: float;
  1527. y: float;
  1528. z: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IVector2Like {
  1534. x: float;
  1535. y: float;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IMatrixLike {
  1541. toArray(): DeepImmutable<Float32Array>;
  1542. updateFlag: int;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IViewportLike {
  1548. x: float;
  1549. y: float;
  1550. width: float;
  1551. height: float;
  1552. }
  1553. /**
  1554. * @hidden
  1555. */
  1556. export interface IPlaneLike {
  1557. normal: IVector3Like;
  1558. d: float;
  1559. normalize(): void;
  1560. }
  1561. }
  1562. declare module "babylonjs/Materials/iEffectFallbacks" {
  1563. import { Effect } from "babylonjs/Materials/effect";
  1564. /**
  1565. * Interface used to define common properties for effect fallbacks
  1566. */
  1567. export interface IEffectFallbacks {
  1568. /**
  1569. * Removes the defines that should be removed when falling back.
  1570. * @param currentDefines defines the current define statements for the shader.
  1571. * @param effect defines the current effect we try to compile
  1572. * @returns The resulting defines with defines of the current rank removed.
  1573. */
  1574. reduce(currentDefines: string, effect: Effect): string;
  1575. /**
  1576. * Removes the fallback from the bound mesh.
  1577. */
  1578. unBindMesh(): void;
  1579. /**
  1580. * Checks to see if more fallbacks are still availible.
  1581. */
  1582. hasMoreFallbacks: boolean;
  1583. }
  1584. }
  1585. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1586. /**
  1587. * Class used to evalaute queries containing `and` and `or` operators
  1588. */
  1589. export class AndOrNotEvaluator {
  1590. /**
  1591. * Evaluate a query
  1592. * @param query defines the query to evaluate
  1593. * @param evaluateCallback defines the callback used to filter result
  1594. * @returns true if the query matches
  1595. */
  1596. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1597. private static _HandleParenthesisContent;
  1598. private static _SimplifyNegation;
  1599. }
  1600. }
  1601. declare module "babylonjs/Misc/tags" {
  1602. /**
  1603. * Class used to store custom tags
  1604. */
  1605. export class Tags {
  1606. /**
  1607. * Adds support for tags on the given object
  1608. * @param obj defines the object to use
  1609. */
  1610. static EnableFor(obj: any): void;
  1611. /**
  1612. * Removes tags support
  1613. * @param obj defines the object to use
  1614. */
  1615. static DisableFor(obj: any): void;
  1616. /**
  1617. * Gets a boolean indicating if the given object has tags
  1618. * @param obj defines the object to use
  1619. * @returns a boolean
  1620. */
  1621. static HasTags(obj: any): boolean;
  1622. /**
  1623. * Gets the tags available on a given object
  1624. * @param obj defines the object to use
  1625. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1626. * @returns the tags
  1627. */
  1628. static GetTags(obj: any, asString?: boolean): any;
  1629. /**
  1630. * Adds tags to an object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1633. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1634. */
  1635. static AddTagsTo(obj: any, tagsString: string): void;
  1636. /**
  1637. * @hidden
  1638. */
  1639. static _AddTagTo(obj: any, tag: string): void;
  1640. /**
  1641. * Removes specific tags from a specific object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tags to remove
  1644. */
  1645. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _RemoveTagFrom(obj: any, tag: string): void;
  1650. /**
  1651. * Defines if tags hosted on an object match a given query
  1652. * @param obj defines the object to use
  1653. * @param tagsQuery defines the tag query
  1654. * @returns a boolean
  1655. */
  1656. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1657. }
  1658. }
  1659. declare module "babylonjs/Maths/math.scalar" {
  1660. /**
  1661. * Scalar computation library
  1662. */
  1663. export class Scalar {
  1664. /**
  1665. * Two pi constants convenient for computation.
  1666. */
  1667. static TwoPi: number;
  1668. /**
  1669. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. * @param a number
  1671. * @param b number
  1672. * @param epsilon (default = 1.401298E-45)
  1673. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1674. */
  1675. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1676. /**
  1677. * Returns a string : the upper case translation of the number i to hexadecimal.
  1678. * @param i number
  1679. * @returns the upper case translation of the number i to hexadecimal.
  1680. */
  1681. static ToHex(i: number): string;
  1682. /**
  1683. * Returns -1 if value is negative and +1 is value is positive.
  1684. * @param value the value
  1685. * @returns the value itself if it's equal to zero.
  1686. */
  1687. static Sign(value: number): number;
  1688. /**
  1689. * Returns the value itself if it's between min and max.
  1690. * Returns min if the value is lower than min.
  1691. * Returns max if the value is greater than max.
  1692. * @param value the value to clmap
  1693. * @param min the min value to clamp to (default: 0)
  1694. * @param max the max value to clamp to (default: 1)
  1695. * @returns the clamped value
  1696. */
  1697. static Clamp(value: number, min?: number, max?: number): number;
  1698. /**
  1699. * the log2 of value.
  1700. * @param value the value to compute log2 of
  1701. * @returns the log2 of value.
  1702. */
  1703. static Log2(value: number): number;
  1704. /**
  1705. * Loops the value, so that it is never larger than length and never smaller than 0.
  1706. *
  1707. * This is similar to the modulo operator but it works with floating point numbers.
  1708. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1709. * With t = 5 and length = 2.5, the result would be 0.0.
  1710. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1711. * @param value the value
  1712. * @param length the length
  1713. * @returns the looped value
  1714. */
  1715. static Repeat(value: number, length: number): number;
  1716. /**
  1717. * Normalize the value between 0.0 and 1.0 using min and max values
  1718. * @param value value to normalize
  1719. * @param min max to normalize between
  1720. * @param max min to normalize between
  1721. * @returns the normalized value
  1722. */
  1723. static Normalize(value: number, min: number, max: number): number;
  1724. /**
  1725. * Denormalize the value from 0.0 and 1.0 using min and max values
  1726. * @param normalized value to denormalize
  1727. * @param min max to denormalize between
  1728. * @param max min to denormalize between
  1729. * @returns the denormalized value
  1730. */
  1731. static Denormalize(normalized: number, min: number, max: number): number;
  1732. /**
  1733. * Calculates the shortest difference between two given angles given in degrees.
  1734. * @param current current angle in degrees
  1735. * @param target target angle in degrees
  1736. * @returns the delta
  1737. */
  1738. static DeltaAngle(current: number, target: number): number;
  1739. /**
  1740. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1741. * @param tx value
  1742. * @param length length
  1743. * @returns The returned value will move back and forth between 0 and length
  1744. */
  1745. static PingPong(tx: number, length: number): number;
  1746. /**
  1747. * Interpolates between min and max with smoothing at the limits.
  1748. *
  1749. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1750. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1751. * @param from from
  1752. * @param to to
  1753. * @param tx value
  1754. * @returns the smooth stepped value
  1755. */
  1756. static SmoothStep(from: number, to: number, tx: number): number;
  1757. /**
  1758. * Moves a value current towards target.
  1759. *
  1760. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1761. * Negative values of maxDelta pushes the value away from target.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting value
  1766. */
  1767. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. *
  1771. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1772. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting angle
  1777. */
  1778. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1781. * @param start start value
  1782. * @param end target value
  1783. * @param amount amount to lerp between
  1784. * @returns the lerped value
  1785. */
  1786. static Lerp(start: number, end: number, amount: number): number;
  1787. /**
  1788. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1789. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1790. * @param start start value
  1791. * @param end target value
  1792. * @param amount amount to lerp between
  1793. * @returns the lerped value
  1794. */
  1795. static LerpAngle(start: number, end: number, amount: number): number;
  1796. /**
  1797. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1798. * @param a start value
  1799. * @param b target value
  1800. * @param value value between a and b
  1801. * @returns the inverseLerp value
  1802. */
  1803. static InverseLerp(a: number, b: number, value: number): number;
  1804. /**
  1805. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1806. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1807. * @param value1 spline value
  1808. * @param tangent1 spline value
  1809. * @param value2 spline value
  1810. * @param tangent2 spline value
  1811. * @param amount input value
  1812. * @returns hermite result
  1813. */
  1814. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1815. /**
  1816. * Returns a random float number between and min and max values
  1817. * @param min min value of random
  1818. * @param max max value of random
  1819. * @returns random value
  1820. */
  1821. static RandomRange(min: number, max: number): number;
  1822. /**
  1823. * This function returns percentage of a number in a given range.
  1824. *
  1825. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1826. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1827. * @param number to convert to percentage
  1828. * @param min min range
  1829. * @param max max range
  1830. * @returns the percentage
  1831. */
  1832. static RangeToPercent(number: number, min: number, max: number): number;
  1833. /**
  1834. * This function returns number that corresponds to the percentage in a given range.
  1835. *
  1836. * PercentToRange(0.34,0,100) will return 34.
  1837. * @param percent to convert to number
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the number
  1841. */
  1842. static PercentToRange(percent: number, min: number, max: number): number;
  1843. /**
  1844. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1845. * @param angle The angle to normalize in radian.
  1846. * @return The converted angle.
  1847. */
  1848. static NormalizeRadians(angle: number): number;
  1849. }
  1850. }
  1851. declare module "babylonjs/Maths/math.constants" {
  1852. /**
  1853. * Constant used to convert a value to gamma space
  1854. * @ignorenaming
  1855. */
  1856. export const ToGammaSpace: number;
  1857. /**
  1858. * Constant used to convert a value to linear space
  1859. * @ignorenaming
  1860. */
  1861. export const ToLinearSpace = 2.2;
  1862. /**
  1863. * Constant used to define the minimal number value in Babylon.js
  1864. * @ignorenaming
  1865. */
  1866. let Epsilon: number;
  1867. export { Epsilon };
  1868. }
  1869. declare module "babylonjs/Maths/math.viewport" {
  1870. /**
  1871. * Class used to represent a viewport on screen
  1872. */
  1873. export class Viewport {
  1874. /** viewport left coordinate */
  1875. x: number;
  1876. /** viewport top coordinate */
  1877. y: number;
  1878. /**viewport width */
  1879. width: number;
  1880. /** viewport height */
  1881. height: number;
  1882. /**
  1883. * Creates a Viewport object located at (x, y) and sized (width, height)
  1884. * @param x defines viewport left coordinate
  1885. * @param y defines viewport top coordinate
  1886. * @param width defines the viewport width
  1887. * @param height defines the viewport height
  1888. */
  1889. constructor(
  1890. /** viewport left coordinate */
  1891. x: number,
  1892. /** viewport top coordinate */
  1893. y: number,
  1894. /**viewport width */
  1895. width: number,
  1896. /** viewport height */
  1897. height: number);
  1898. /**
  1899. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @returns a new Viewport
  1903. */
  1904. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1905. /**
  1906. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1907. * @param renderWidth defines the rendering width
  1908. * @param renderHeight defines the rendering height
  1909. * @param ref defines the target viewport
  1910. * @returns the current viewport
  1911. */
  1912. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1913. /**
  1914. * Returns a new Viewport copied from the current one
  1915. * @returns a new Viewport
  1916. */
  1917. clone(): Viewport;
  1918. }
  1919. }
  1920. declare module "babylonjs/Misc/arrayTools" {
  1921. /**
  1922. * Class containing a set of static utilities functions for arrays.
  1923. */
  1924. export class ArrayTools {
  1925. /**
  1926. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1927. * @param size the number of element to construct and put in the array
  1928. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1929. * @returns a new array filled with new objects
  1930. */
  1931. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1932. }
  1933. }
  1934. declare module "babylonjs/Maths/math.vector" {
  1935. import { Viewport } from "babylonjs/Maths/math.viewport";
  1936. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1937. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1938. /**
  1939. * Class representing a vector containing 2 coordinates
  1940. */
  1941. export class Vector2 {
  1942. /** defines the first coordinate */
  1943. x: number;
  1944. /** defines the second coordinate */
  1945. y: number;
  1946. /**
  1947. * Creates a new Vector2 from the given x and y coordinates
  1948. * @param x defines the first coordinate
  1949. * @param y defines the second coordinate
  1950. */
  1951. constructor(
  1952. /** defines the first coordinate */
  1953. x?: number,
  1954. /** defines the second coordinate */
  1955. y?: number);
  1956. /**
  1957. * Gets a string with the Vector2 coordinates
  1958. * @returns a string with the Vector2 coordinates
  1959. */
  1960. toString(): string;
  1961. /**
  1962. * Gets class name
  1963. * @returns the string "Vector2"
  1964. */
  1965. getClassName(): string;
  1966. /**
  1967. * Gets current vector hash code
  1968. * @returns the Vector2 hash code as a number
  1969. */
  1970. getHashCode(): number;
  1971. /**
  1972. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1973. * @param array defines the source array
  1974. * @param index defines the offset in source array
  1975. * @returns the current Vector2
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector2;
  1978. /**
  1979. * Copy the current vector to an array
  1980. * @returns a new array with 2 elements: the Vector2 coordinates.
  1981. */
  1982. asArray(): number[];
  1983. /**
  1984. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1985. * @param source defines the source Vector2
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. copyFromFloats(x: number, y: number): Vector2;
  1996. /**
  1997. * Sets the Vector2 coordinates with the given floats
  1998. * @param x defines the first coordinate
  1999. * @param y defines the second coordinate
  2000. * @returns the current updated Vector2
  2001. */
  2002. set(x: number, y: number): Vector2;
  2003. /**
  2004. * Add another vector with the current one
  2005. * @param otherVector defines the other vector
  2006. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2007. */
  2008. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2009. /**
  2010. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2011. * @param otherVector defines the other vector
  2012. * @param result defines the target vector
  2013. * @returns the unmodified current Vector2
  2014. */
  2015. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2016. /**
  2017. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. addVector3(otherVector: Vector3): Vector2;
  2028. /**
  2029. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2030. * @param otherVector defines the other vector
  2031. * @returns a new Vector2
  2032. */
  2033. subtract(otherVector: Vector2): Vector2;
  2034. /**
  2035. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2036. * @param otherVector defines the other vector
  2037. * @param result defines the target vector
  2038. * @returns the unmodified current Vector2
  2039. */
  2040. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2041. /**
  2042. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Multiplies in place the current Vector2 coordinates by the given ones
  2049. * @param otherVector defines the other vector
  2050. * @returns the current updated Vector2
  2051. */
  2052. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns a new Vector2
  2057. */
  2058. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @param result defines the target vector
  2063. * @returns the unmodified current Vector2
  2064. */
  2065. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2066. /**
  2067. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns a new Vector2
  2071. */
  2072. multiplyByFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @returns a new Vector2
  2077. */
  2078. divide(otherVector: Vector2): Vector2;
  2079. /**
  2080. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2081. * @param otherVector defines the other vector
  2082. * @param result defines the target vector
  2083. * @returns the unmodified current Vector2
  2084. */
  2085. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2086. /**
  2087. * Divides the current Vector2 coordinates by the given ones
  2088. * @param otherVector defines the other vector
  2089. * @returns the current updated Vector2
  2090. */
  2091. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2092. /**
  2093. * Gets a new Vector2 with current Vector2 negated coordinates
  2094. * @returns a new Vector2
  2095. */
  2096. negate(): Vector2;
  2097. /**
  2098. * Negate this vector in place
  2099. * @returns this
  2100. */
  2101. negateInPlace(): Vector2;
  2102. /**
  2103. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2104. * @param result defines the Vector3 object where to store the result
  2105. * @returns the current Vector2
  2106. */
  2107. negateToRef(result: Vector2): Vector2;
  2108. /**
  2109. * Multiply the Vector2 coordinates by scale
  2110. * @param scale defines the scaling factor
  2111. * @returns the current updated Vector2
  2112. */
  2113. scaleInPlace(scale: number): Vector2;
  2114. /**
  2115. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2116. * @param scale defines the scaling factor
  2117. * @returns a new Vector2
  2118. */
  2119. scale(scale: number): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2129. * @param scale defines the scale factor
  2130. * @param result defines the Vector2 object where to store the result
  2131. * @returns the unmodified current Vector2
  2132. */
  2133. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2134. /**
  2135. * Gets a boolean if two vectors are equals
  2136. * @param otherVector defines the other vector
  2137. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2138. */
  2139. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2140. /**
  2141. * Gets a boolean if two vectors are equals (using an epsilon value)
  2142. * @param otherVector defines the other vector
  2143. * @param epsilon defines the minimal distance to consider equality
  2144. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2145. */
  2146. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2147. /**
  2148. * Gets a new Vector2 from current Vector2 floored values
  2149. * @returns a new Vector2
  2150. */
  2151. floor(): Vector2;
  2152. /**
  2153. * Gets a new Vector2 from current Vector2 floored values
  2154. * @returns a new Vector2
  2155. */
  2156. fract(): Vector2;
  2157. /**
  2158. * Gets the length of the vector
  2159. * @returns the vector length (float)
  2160. */
  2161. length(): number;
  2162. /**
  2163. * Gets the vector squared length
  2164. * @returns the vector squared length (float)
  2165. */
  2166. lengthSquared(): number;
  2167. /**
  2168. * Normalize the vector
  2169. * @returns the current updated Vector2
  2170. */
  2171. normalize(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 copied from the Vector2
  2174. * @returns a new Vector2
  2175. */
  2176. clone(): Vector2;
  2177. /**
  2178. * Gets a new Vector2(0, 0)
  2179. * @returns a new Vector2
  2180. */
  2181. static Zero(): Vector2;
  2182. /**
  2183. * Gets a new Vector2(1, 1)
  2184. * @returns a new Vector2
  2185. */
  2186. static One(): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @returns a new Vector2
  2192. */
  2193. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2194. /**
  2195. * Sets "result" from the given index element of the given array
  2196. * @param array defines the data source
  2197. * @param offset defines the offset in the data source
  2198. * @param result defines the target vector
  2199. */
  2200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2201. /**
  2202. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2203. * @param value1 defines 1st point of control
  2204. * @param value2 defines 2nd point of control
  2205. * @param value3 defines 3rd point of control
  2206. * @param value4 defines 4th point of control
  2207. * @param amount defines the interpolation factor
  2208. * @returns a new Vector2
  2209. */
  2210. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2211. /**
  2212. * 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".
  2213. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2214. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2215. * @param value defines the value to clamp
  2216. * @param min defines the lower limit
  2217. * @param max defines the upper limit
  2218. * @returns a new Vector2
  2219. */
  2220. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2223. * @param value1 defines the 1st control point
  2224. * @param tangent1 defines the outgoing tangent
  2225. * @param value2 defines the 2nd control point
  2226. * @param tangent2 defines the incoming tangent
  2227. * @param amount defines the interpolation factor
  2228. * @returns a new Vector2
  2229. */
  2230. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2233. * @param start defines the start vector
  2234. * @param end defines the end vector
  2235. * @param amount defines the interpolation factor
  2236. * @returns a new Vector2
  2237. */
  2238. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2239. /**
  2240. * Gets the dot product of the vector "left" and the vector "right"
  2241. * @param left defines first vector
  2242. * @param right defines second vector
  2243. * @returns the dot product (float)
  2244. */
  2245. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2246. /**
  2247. * Returns a new Vector2 equal to the normalized given vector
  2248. * @param vector defines the vector to normalize
  2249. * @returns a new Vector2
  2250. */
  2251. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2261. * @param left defines 1st vector
  2262. * @param right defines 2nd vector
  2263. * @returns a new Vector2
  2264. */
  2265. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2266. /**
  2267. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @returns a new Vector2
  2271. */
  2272. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2273. /**
  2274. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2275. * @param vector defines the vector to transform
  2276. * @param transformation defines the matrix to apply
  2277. * @param result defines the target vector
  2278. */
  2279. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2280. /**
  2281. * Determines if a given vector is included in a triangle
  2282. * @param p defines the vector to test
  2283. * @param p0 defines 1st triangle point
  2284. * @param p1 defines 2nd triangle point
  2285. * @param p2 defines 3rd triangle point
  2286. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2287. */
  2288. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2289. /**
  2290. * Gets the distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the distance between vectors
  2294. */
  2295. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Returns the squared distance between the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns the squared distance between vectors
  2301. */
  2302. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2303. /**
  2304. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2305. * @param value1 defines first vector
  2306. * @param value2 defines second vector
  2307. * @returns a new Vector2
  2308. */
  2309. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2310. /**
  2311. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2312. * @param p defines the middle point
  2313. * @param segA defines one point of the segment
  2314. * @param segB defines the other point of the segment
  2315. * @returns the shortest distance
  2316. */
  2317. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2318. }
  2319. /**
  2320. * Class used to store (x,y,z) vector representation
  2321. * A Vector3 is the main object used in 3D geometry
  2322. * It can represent etiher the coordinates of a point the space, either a direction
  2323. * Reminder: js uses a left handed forward facing system
  2324. */
  2325. export class Vector3 {
  2326. /**
  2327. * Defines the first coordinates (on X axis)
  2328. */
  2329. x: number;
  2330. /**
  2331. * Defines the second coordinates (on Y axis)
  2332. */
  2333. y: number;
  2334. /**
  2335. * Defines the third coordinates (on Z axis)
  2336. */
  2337. z: number;
  2338. private static _UpReadOnly;
  2339. private static _ZeroReadOnly;
  2340. /**
  2341. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2342. * @param x defines the first coordinates (on X axis)
  2343. * @param y defines the second coordinates (on Y axis)
  2344. * @param z defines the third coordinates (on Z axis)
  2345. */
  2346. constructor(
  2347. /**
  2348. * Defines the first coordinates (on X axis)
  2349. */
  2350. x?: number,
  2351. /**
  2352. * Defines the second coordinates (on Y axis)
  2353. */
  2354. y?: number,
  2355. /**
  2356. * Defines the third coordinates (on Z axis)
  2357. */
  2358. z?: number);
  2359. /**
  2360. * Creates a string representation of the Vector3
  2361. * @returns a string with the Vector3 coordinates.
  2362. */
  2363. toString(): string;
  2364. /**
  2365. * Gets the class name
  2366. * @returns the string "Vector3"
  2367. */
  2368. getClassName(): string;
  2369. /**
  2370. * Creates the Vector3 hash code
  2371. * @returns a number which tends to be unique between Vector3 instances
  2372. */
  2373. getHashCode(): number;
  2374. /**
  2375. * Creates an array containing three elements : the coordinates of the Vector3
  2376. * @returns a new array of numbers
  2377. */
  2378. asArray(): number[];
  2379. /**
  2380. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2381. * @param array defines the destination array
  2382. * @param index defines the offset in the destination array
  2383. * @returns the current Vector3
  2384. */
  2385. toArray(array: FloatArray, index?: number): Vector3;
  2386. /**
  2387. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2388. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2389. */
  2390. toQuaternion(): Quaternion;
  2391. /**
  2392. * Adds the given vector to the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the given coordinates to the current Vector3
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the current updated Vector3
  2403. */
  2404. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2407. * @param otherVector defines the second operand
  2408. * @returns the resulting Vector3
  2409. */
  2410. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2411. /**
  2412. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2413. * @param otherVector defines the second operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2418. /**
  2419. * Subtract the given vector from the current Vector3
  2420. * @param otherVector defines the second operand
  2421. * @returns the current updated Vector3
  2422. */
  2423. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2424. /**
  2425. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2426. * @param otherVector defines the second operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2430. /**
  2431. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2432. * @param otherVector defines the second operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2439. * @param x defines the x coordinate of the operand
  2440. * @param y defines the y coordinate of the operand
  2441. * @param z defines the z coordinate of the operand
  2442. * @returns the resulting Vector3
  2443. */
  2444. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2445. /**
  2446. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2447. * @param x defines the x coordinate of the operand
  2448. * @param y defines the y coordinate of the operand
  2449. * @param z defines the z coordinate of the operand
  2450. * @param result defines the Vector3 object where to store the result
  2451. * @returns the current Vector3
  2452. */
  2453. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2454. /**
  2455. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2456. * @returns a new Vector3
  2457. */
  2458. negate(): Vector3;
  2459. /**
  2460. * Negate this vector in place
  2461. * @returns this
  2462. */
  2463. negateInPlace(): Vector3;
  2464. /**
  2465. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. negateToRef(result: Vector3): Vector3;
  2470. /**
  2471. * Multiplies the Vector3 coordinates by the float "scale"
  2472. * @param scale defines the multiplier factor
  2473. * @returns the current updated Vector3
  2474. */
  2475. scaleInPlace(scale: number): Vector3;
  2476. /**
  2477. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2478. * @param scale defines the multiplier factor
  2479. * @returns a new Vector3
  2480. */
  2481. scale(scale: number): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2484. * @param scale defines the multiplier factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. scaleToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the unmodified current Vector3
  2494. */
  2495. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2496. /**
  2497. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2498. * @param otherVector defines the second operand
  2499. * @returns true if both vectors are equals
  2500. */
  2501. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2504. * @param otherVector defines the second operand
  2505. * @param epsilon defines the minimal distance to define values as equals
  2506. * @returns true if both vectors are distant less than epsilon
  2507. */
  2508. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2509. /**
  2510. * Returns true if the current Vector3 coordinates equals the given floats
  2511. * @param x defines the x coordinate of the operand
  2512. * @param y defines the y coordinate of the operand
  2513. * @param z defines the z coordinate of the operand
  2514. * @returns true if both vectors are equals
  2515. */
  2516. equalsToFloats(x: number, y: number, z: number): boolean;
  2517. /**
  2518. * Multiplies the current Vector3 coordinates by the given ones
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2523. /**
  2524. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2525. * @param otherVector defines the second operand
  2526. * @returns the new Vector3
  2527. */
  2528. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2531. * @param otherVector defines the second operand
  2532. * @param result defines the Vector3 object where to store the result
  2533. * @returns the current Vector3
  2534. */
  2535. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2536. /**
  2537. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the new Vector3
  2542. */
  2543. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2546. * @param otherVector defines the second operand
  2547. * @returns the new Vector3
  2548. */
  2549. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2552. * @param otherVector defines the second operand
  2553. * @param result defines the Vector3 object where to store the result
  2554. * @returns the current Vector3
  2555. */
  2556. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2557. /**
  2558. * Divides the current Vector3 coordinates by the given ones.
  2559. * @param otherVector defines the second operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. divideInPlace(otherVector: Vector3): Vector3;
  2563. /**
  2564. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2565. * @param other defines the second operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2571. * @param other defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2577. * @param x defines the x coordinate of the operand
  2578. * @param y defines the y coordinate of the operand
  2579. * @param z defines the z coordinate of the operand
  2580. * @returns the current updated Vector3
  2581. */
  2582. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2583. /**
  2584. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the current updated Vector3
  2589. */
  2590. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2593. * Check if is non uniform within a certain amount of decimal places to account for this
  2594. * @param epsilon the amount the values can differ
  2595. * @returns if the the vector is non uniform to a certain number of decimal places
  2596. */
  2597. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2598. /**
  2599. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2600. */
  2601. get isNonUniform(): boolean;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. floor(): Vector3;
  2607. /**
  2608. * Gets a new Vector3 from current Vector3 floored values
  2609. * @returns a new Vector3
  2610. */
  2611. fract(): Vector3;
  2612. /**
  2613. * Gets the length of the Vector3
  2614. * @returns the length of the Vector3
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Gets the squared length of the Vector3
  2619. * @returns squared length of the Vector3
  2620. */
  2621. lengthSquared(): number;
  2622. /**
  2623. * Normalize the current Vector3.
  2624. * Please note that this is an in place operation.
  2625. * @returns the current updated Vector3
  2626. */
  2627. normalize(): Vector3;
  2628. /**
  2629. * Reorders the x y z properties of the vector in place
  2630. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2631. * @returns the current updated vector
  2632. */
  2633. reorderInPlace(order: string): this;
  2634. /**
  2635. * Rotates the vector around 0,0,0 by a quaternion
  2636. * @param quaternion the rotation quaternion
  2637. * @param result vector to store the result
  2638. * @returns the resulting vector
  2639. */
  2640. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2641. /**
  2642. * Rotates a vector around a given point
  2643. * @param quaternion the rotation quaternion
  2644. * @param point the point to rotate around
  2645. * @param result vector to store the result
  2646. * @returns the resulting vector
  2647. */
  2648. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2649. /**
  2650. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2651. * The cross product is then orthogonal to both current and "other"
  2652. * @param other defines the right operand
  2653. * @returns the cross product
  2654. */
  2655. cross(other: Vector3): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 with the given input length.
  2658. * Please note that this is an in place operation.
  2659. * @param len the length of the vector
  2660. * @returns the current updated Vector3
  2661. */
  2662. normalizeFromLength(len: number): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to a new vector
  2665. * @returns the new Vector3
  2666. */
  2667. normalizeToNew(): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 to the reference
  2670. * @param reference define the Vector3 to update
  2671. * @returns the updated Vector3
  2672. */
  2673. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Creates a new Vector3 copied from the current Vector3
  2676. * @returns the new Vector3
  2677. */
  2678. clone(): Vector3;
  2679. /**
  2680. * Copies the given vector coordinates to the current Vector3 ones
  2681. * @param source defines the source Vector3
  2682. * @returns the current updated Vector3
  2683. */
  2684. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Copies the given floats to the current Vector3 coordinates
  2687. * @param x defines the x coordinate of the operand
  2688. * @param y defines the y coordinate of the operand
  2689. * @param z defines the z coordinate of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. copyFromFloats(x: number, y: number, z: number): Vector3;
  2693. /**
  2694. * Copies the given floats to the current Vector3 coordinates
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. set(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Copies the given float to the current Vector3 coordinates
  2703. * @param v defines the x, y and z coordinates of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. setAll(v: number): Vector3;
  2707. /**
  2708. * Get the clip factor between two vectors
  2709. * @param vector0 defines the first operand
  2710. * @param vector1 defines the second operand
  2711. * @param axis defines the axis to use
  2712. * @param size defines the size along the axis
  2713. * @returns the clip factor
  2714. */
  2715. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2716. /**
  2717. * Get angle between two vectors
  2718. * @param vector0 angle between vector0 and vector1
  2719. * @param vector1 angle between vector0 and vector1
  2720. * @param normal direction of the normal
  2721. * @return the angle between vector0 and vector1
  2722. */
  2723. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. */
  2730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2733. * @param array defines the source array
  2734. * @param offset defines the offset in the source array
  2735. * @returns the new Vector3
  2736. * @deprecated Please use FromArray instead.
  2737. */
  2738. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. */
  2745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2746. /**
  2747. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2748. * @param array defines the source array
  2749. * @param offset defines the offset in the source array
  2750. * @param result defines the Vector3 where to store the result
  2751. * @deprecated Please use FromArrayToRef instead.
  2752. */
  2753. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2754. /**
  2755. * Sets the given vector "result" with the given floats.
  2756. * @param x defines the x coordinate of the source
  2757. * @param y defines the y coordinate of the source
  2758. * @param z defines the z coordinate of the source
  2759. * @param result defines the Vector3 where to store the result
  2760. */
  2761. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2764. * @returns a new empty Vector3
  2765. */
  2766. static Zero(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2769. * @returns a new unit Vector3
  2770. */
  2771. static One(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2774. * @returns a new up Vector3
  2775. */
  2776. static Up(): Vector3;
  2777. /**
  2778. * Gets a up Vector3 that must not be updated
  2779. */
  2780. static get UpReadOnly(): DeepImmutable<Vector3>;
  2781. /**
  2782. * Gets a zero Vector3 that must not be updated
  2783. */
  2784. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2787. * @returns a new down Vector3
  2788. */
  2789. static Down(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Forward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2797. * @returns a new forward Vector3
  2798. */
  2799. static Backward(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2802. * @returns a new right Vector3
  2803. */
  2804. static Right(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2807. * @returns a new left Vector3
  2808. */
  2809. static Left(): Vector3;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2812. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the transformed Vector3
  2816. */
  2817. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2820. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2828. * This method computes tranformed coordinates only, not transformed direction vectors
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2839. * @param vector defines the Vector3 to transform
  2840. * @param transformation defines the transformation matrix
  2841. * @returns the new Vector3
  2842. */
  2843. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2844. /**
  2845. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2846. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2847. * @param vector defines the Vector3 to transform
  2848. * @param transformation defines the transformation matrix
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2852. /**
  2853. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2854. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2855. * @param x define the x coordinate of the source vector
  2856. * @param y define the y coordinate of the source vector
  2857. * @param z define the z coordinate of the source vector
  2858. * @param transformation defines the transformation matrix
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2864. * @param value1 defines the first control point
  2865. * @param value2 defines the second control point
  2866. * @param value3 defines the third control point
  2867. * @param value4 defines the fourth control point
  2868. * @param amount defines the amount on the spline to use
  2869. * @returns the new Vector3
  2870. */
  2871. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2872. /**
  2873. * 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"
  2874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2876. * @param value defines the current value
  2877. * @param min defines the lower range value
  2878. * @param max defines the upper range value
  2879. * @returns the new Vector3
  2880. */
  2881. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * 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"
  2884. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2885. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2886. * @param value defines the current value
  2887. * @param min defines the lower range value
  2888. * @param max defines the upper range value
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2892. /**
  2893. * Checks if a given vector is inside a specific range
  2894. * @param v defines the vector to test
  2895. * @param min defines the minimum range
  2896. * @param max defines the maximum range
  2897. */
  2898. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2899. /**
  2900. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2901. * @param value1 defines the first control point
  2902. * @param tangent1 defines the first tangent vector
  2903. * @param value2 defines the second control point
  2904. * @param tangent2 defines the second tangent vector
  2905. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2906. * @returns the new Vector3
  2907. */
  2908. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2909. /**
  2910. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2911. * @param start defines the start value
  2912. * @param end defines the end value
  2913. * @param amount max defines amount between both (between 0 and 1)
  2914. * @returns the new Vector3
  2915. */
  2916. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2917. /**
  2918. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2919. * @param start defines the start value
  2920. * @param end defines the end value
  2921. * @param amount max defines amount between both (between 0 and 1)
  2922. * @param result defines the Vector3 where to store the result
  2923. */
  2924. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2925. /**
  2926. * Returns the dot product (float) between the vectors "left" and "right"
  2927. * @param left defines the left operand
  2928. * @param right defines the right operand
  2929. * @returns the dot product
  2930. */
  2931. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2932. /**
  2933. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2934. * The cross product is then orthogonal to both "left" and "right"
  2935. * @param left defines the left operand
  2936. * @param right defines the right operand
  2937. * @returns the cross product
  2938. */
  2939. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the cross product of "left" and "right"
  2942. * The cross product is then orthogonal to both "left" and "right"
  2943. * @param left defines the left operand
  2944. * @param right defines the right operand
  2945. * @param result defines the Vector3 where to store the result
  2946. */
  2947. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2948. /**
  2949. * Returns a new Vector3 as the normalization of the given vector
  2950. * @param vector defines the Vector3 to normalize
  2951. * @returns the new Vector3
  2952. */
  2953. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2954. /**
  2955. * Sets the given vector "result" with the normalization of the given first vector
  2956. * @param vector defines the Vector3 to normalize
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2960. /**
  2961. * Project a Vector3 onto screen space
  2962. * @param vector defines the Vector3 to project
  2963. * @param world defines the world matrix to use
  2964. * @param transform defines the transform (view x projection) matrix to use
  2965. * @param viewport defines the screen viewport to use
  2966. * @returns the new Vector3
  2967. */
  2968. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2969. /** @hidden */
  2970. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2971. /**
  2972. * Unproject from screen space to object space
  2973. * @param source defines the screen space Vector3 to use
  2974. * @param viewportWidth defines the current width of the viewport
  2975. * @param viewportHeight defines the current height of the viewport
  2976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2977. * @param transform defines the transform (view x projection) matrix to use
  2978. * @returns the new Vector3
  2979. */
  2980. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param source defines the screen space Vector3 to use
  2984. * @param viewportWidth defines the current width of the viewport
  2985. * @param viewportHeight defines the current height of the viewport
  2986. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2987. * @param view defines the view matrix to use
  2988. * @param projection defines the projection matrix to use
  2989. * @returns the new Vector3
  2990. */
  2991. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2992. /**
  2993. * Unproject from screen space to object space
  2994. * @param source defines the screen space Vector3 to use
  2995. * @param viewportWidth defines the current width of the viewport
  2996. * @param viewportHeight defines the current height of the viewport
  2997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2998. * @param view defines the view matrix to use
  2999. * @param projection defines the projection matrix to use
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3003. /**
  3004. * Unproject from screen space to object space
  3005. * @param sourceX defines the screen space x coordinate to use
  3006. * @param sourceY defines the screen space y coordinate to use
  3007. * @param sourceZ defines the screen space z coordinate to use
  3008. * @param viewportWidth defines the current width of the viewport
  3009. * @param viewportHeight defines the current height of the viewport
  3010. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3011. * @param view defines the view matrix to use
  3012. * @param projection defines the projection matrix to use
  3013. * @param result defines the Vector3 where to store the result
  3014. */
  3015. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3016. /**
  3017. * Gets the minimal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Gets the maximal coordinate values between two Vector3
  3025. * @param left defines the first operand
  3026. * @param right defines the second operand
  3027. * @returns the new Vector3
  3028. */
  3029. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3030. /**
  3031. * Returns the distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the distance
  3035. */
  3036. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns the squared distance between the vectors "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the squared distance
  3042. */
  3043. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3044. /**
  3045. * Returns a new Vector3 located at the center between "value1" and "value2"
  3046. * @param value1 defines the first operand
  3047. * @param value2 defines the second operand
  3048. * @returns the new Vector3
  3049. */
  3050. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3053. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3054. * to something in order to rotate it from its local system to the given target system
  3055. * Note: axis1, axis2 and axis3 are normalized during this operation
  3056. * @param axis1 defines the first axis
  3057. * @param axis2 defines the second axis
  3058. * @param axis3 defines the third axis
  3059. * @returns a new Vector3
  3060. */
  3061. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3062. /**
  3063. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3064. * @param axis1 defines the first axis
  3065. * @param axis2 defines the second axis
  3066. * @param axis3 defines the third axis
  3067. * @param ref defines the Vector3 where to store the result
  3068. */
  3069. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3070. }
  3071. /**
  3072. * Vector4 class created for EulerAngle class conversion to Quaternion
  3073. */
  3074. export class Vector4 {
  3075. /** x value of the vector */
  3076. x: number;
  3077. /** y value of the vector */
  3078. y: number;
  3079. /** z value of the vector */
  3080. z: number;
  3081. /** w value of the vector */
  3082. w: number;
  3083. /**
  3084. * Creates a Vector4 object from the given floats.
  3085. * @param x x value of the vector
  3086. * @param y y value of the vector
  3087. * @param z z value of the vector
  3088. * @param w w value of the vector
  3089. */
  3090. constructor(
  3091. /** x value of the vector */
  3092. x: number,
  3093. /** y value of the vector */
  3094. y: number,
  3095. /** z value of the vector */
  3096. z: number,
  3097. /** w value of the vector */
  3098. w: number);
  3099. /**
  3100. * Returns the string with the Vector4 coordinates.
  3101. * @returns a string containing all the vector values
  3102. */
  3103. toString(): string;
  3104. /**
  3105. * Returns the string "Vector4".
  3106. * @returns "Vector4"
  3107. */
  3108. getClassName(): string;
  3109. /**
  3110. * Returns the Vector4 hash code.
  3111. * @returns a unique hash code
  3112. */
  3113. getHashCode(): number;
  3114. /**
  3115. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3116. * @returns the resulting array
  3117. */
  3118. asArray(): number[];
  3119. /**
  3120. * Populates the given array from the given index with the Vector4 coordinates.
  3121. * @param array array to populate
  3122. * @param index index of the array to start at (default: 0)
  3123. * @returns the Vector4.
  3124. */
  3125. toArray(array: FloatArray, index?: number): Vector4;
  3126. /**
  3127. * Adds the given vector to the current Vector4.
  3128. * @param otherVector the vector to add
  3129. * @returns the updated Vector4.
  3130. */
  3131. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3132. /**
  3133. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3134. * @param otherVector the vector to add
  3135. * @returns the resulting vector
  3136. */
  3137. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3138. /**
  3139. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3140. * @param otherVector the vector to add
  3141. * @param result the vector to store the result
  3142. * @returns the current Vector4.
  3143. */
  3144. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3145. /**
  3146. * Subtract in place the given vector from the current Vector4.
  3147. * @param otherVector the vector to subtract
  3148. * @returns the updated Vector4.
  3149. */
  3150. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3151. /**
  3152. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3153. * @param otherVector the vector to add
  3154. * @returns the new vector with the result
  3155. */
  3156. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3157. /**
  3158. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @param result the vector to store the result
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. */
  3167. /**
  3168. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3169. * @param x value to subtract
  3170. * @param y value to subtract
  3171. * @param z value to subtract
  3172. * @param w value to subtract
  3173. * @returns new vector containing the result
  3174. */
  3175. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3176. /**
  3177. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. * @param x value to subtract
  3179. * @param y value to subtract
  3180. * @param z value to subtract
  3181. * @param w value to subtract
  3182. * @param result the vector to store the result in
  3183. * @returns the current Vector4.
  3184. */
  3185. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3188. * @returns a new vector with the negated values
  3189. */
  3190. negate(): Vector4;
  3191. /**
  3192. * Negate this vector in place
  3193. * @returns this
  3194. */
  3195. negateInPlace(): Vector4;
  3196. /**
  3197. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3198. * @param result defines the Vector3 object where to store the result
  3199. * @returns the current Vector4
  3200. */
  3201. negateToRef(result: Vector4): Vector4;
  3202. /**
  3203. * Multiplies the current Vector4 coordinates by scale (float).
  3204. * @param scale the number to scale with
  3205. * @returns the updated Vector4.
  3206. */
  3207. scaleInPlace(scale: number): Vector4;
  3208. /**
  3209. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3210. * @param scale the number to scale with
  3211. * @returns a new vector with the result
  3212. */
  3213. scale(scale: number): Vector4;
  3214. /**
  3215. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3216. * @param scale the number to scale with
  3217. * @param result a vector to store the result in
  3218. * @returns the current Vector4.
  3219. */
  3220. scaleToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3223. * @param scale defines the scale factor
  3224. * @param result defines the Vector4 object where to store the result
  3225. * @returns the unmodified current Vector4
  3226. */
  3227. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3228. /**
  3229. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3230. * @param otherVector the vector to compare against
  3231. * @returns true if they are equal
  3232. */
  3233. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3234. /**
  3235. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3236. * @param otherVector vector to compare against
  3237. * @param epsilon (Default: very small number)
  3238. * @returns true if they are equal
  3239. */
  3240. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3241. /**
  3242. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3243. * @param x x value to compare against
  3244. * @param y y value to compare against
  3245. * @param z z value to compare against
  3246. * @param w w value to compare against
  3247. * @returns true if equal
  3248. */
  3249. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3250. /**
  3251. * Multiplies in place the current Vector4 by the given one.
  3252. * @param otherVector vector to multiple with
  3253. * @returns the updated Vector4.
  3254. */
  3255. multiplyInPlace(otherVector: Vector4): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3258. * @param otherVector vector to multiple with
  3259. * @returns resulting new vector
  3260. */
  3261. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3271. * @param x x value multiply with
  3272. * @param y y value multiply with
  3273. * @param z z value multiply with
  3274. * @param w w value multiply with
  3275. * @returns resulting new vector
  3276. */
  3277. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3278. /**
  3279. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3280. * @param otherVector vector to devide with
  3281. * @returns resulting new vector
  3282. */
  3283. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3284. /**
  3285. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3286. * @param otherVector vector to devide with
  3287. * @param result vector to store the result
  3288. * @returns the current Vector4.
  3289. */
  3290. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3291. /**
  3292. * Divides the current Vector3 coordinates by the given ones.
  3293. * @param otherVector vector to devide with
  3294. * @returns the updated Vector3.
  3295. */
  3296. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3297. /**
  3298. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3299. * @param other defines the second operand
  3300. * @returns the current updated Vector4
  3301. */
  3302. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3305. * @param other defines the second operand
  3306. * @returns the current updated Vector4
  3307. */
  3308. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Gets a new Vector4 from current Vector4 floored values
  3311. * @returns a new Vector4
  3312. */
  3313. floor(): Vector4;
  3314. /**
  3315. * Gets a new Vector4 from current Vector3 floored values
  3316. * @returns a new Vector4
  3317. */
  3318. fract(): Vector4;
  3319. /**
  3320. * Returns the Vector4 length (float).
  3321. * @returns the length
  3322. */
  3323. length(): number;
  3324. /**
  3325. * Returns the Vector4 squared length (float).
  3326. * @returns the length squared
  3327. */
  3328. lengthSquared(): number;
  3329. /**
  3330. * Normalizes in place the Vector4.
  3331. * @returns the updated Vector4.
  3332. */
  3333. normalize(): Vector4;
  3334. /**
  3335. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3336. * @returns this converted to a new vector3
  3337. */
  3338. toVector3(): Vector3;
  3339. /**
  3340. * Returns a new Vector4 copied from the current one.
  3341. * @returns the new cloned vector
  3342. */
  3343. clone(): Vector4;
  3344. /**
  3345. * Updates the current Vector4 with the given one coordinates.
  3346. * @param source the source vector to copy from
  3347. * @returns the updated Vector4.
  3348. */
  3349. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the current Vector4 coordinates with the given floats.
  3352. * @param x float to copy from
  3353. * @param y float to copy from
  3354. * @param z float to copy from
  3355. * @param w float to copy from
  3356. * @returns the updated Vector4.
  3357. */
  3358. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Updates the current Vector4 coordinates with the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @returns the updated Vector4.
  3366. */
  3367. set(x: number, y: number, z: number, w: number): Vector4;
  3368. /**
  3369. * Copies the given float to the current Vector3 coordinates
  3370. * @param v defines the x, y, z and w coordinates of the operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. setAll(v: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @returns the new vector
  3379. */
  3380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" from the starting index of the given Float32Array.
  3390. * @param array the array to pull values from
  3391. * @param offset the offset into the array to start at
  3392. * @param result the vector to store the result in
  3393. */
  3394. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3395. /**
  3396. * Updates the given vector "result" coordinates from the given floats.
  3397. * @param x float to set from
  3398. * @param y float to set from
  3399. * @param z float to set from
  3400. * @param w float to set from
  3401. * @param result the vector to the floats in
  3402. */
  3403. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3404. /**
  3405. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3406. * @returns the new vector
  3407. */
  3408. static Zero(): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3411. * @returns the new vector
  3412. */
  3413. static One(): Vector4;
  3414. /**
  3415. * Returns a new normalized Vector4 from the given one.
  3416. * @param vector the vector to normalize
  3417. * @returns the vector
  3418. */
  3419. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Updates the given vector "result" from the normalization of the given one.
  3422. * @param vector the vector to normalize
  3423. * @param result the vector to store the result in
  3424. */
  3425. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3426. /**
  3427. * Returns a vector with the minimum values from the left and right vectors
  3428. * @param left left vector to minimize
  3429. * @param right right vector to minimize
  3430. * @returns a new vector with the minimum of the left and right vector values
  3431. */
  3432. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns a vector with the maximum values from the left and right vectors
  3435. * @param left left vector to maximize
  3436. * @param right right vector to maximize
  3437. * @returns a new vector with the maximum of the left and right vector values
  3438. */
  3439. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Returns the distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors
  3445. */
  3446. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the distance between
  3450. * @param value2 value to calulate the distance between
  3451. * @return the distance between the two vectors squared
  3452. */
  3453. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3454. /**
  3455. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3456. * @param value1 value to calulate the center between
  3457. * @param value2 value to calulate the center between
  3458. * @return the center between the two vectors
  3459. */
  3460. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param vector the vector to transform
  3465. * @param transformation the transformation matrix to apply
  3466. * @returns the new vector
  3467. */
  3468. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3469. /**
  3470. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3471. * This methods computes transformed normalized direction vectors only.
  3472. * @param vector the vector to transform
  3473. * @param transformation the transformation matrix to apply
  3474. * @param result the vector to store the result in
  3475. */
  3476. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3477. /**
  3478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3479. * This methods computes transformed normalized direction vectors only.
  3480. * @param x value to transform
  3481. * @param y value to transform
  3482. * @param z value to transform
  3483. * @param w value to transform
  3484. * @param transformation the transformation matrix to apply
  3485. * @param result the vector to store the results in
  3486. */
  3487. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3488. /**
  3489. * Creates a new Vector4 from a Vector3
  3490. * @param source defines the source data
  3491. * @param w defines the 4th component (default is 0)
  3492. * @returns a new Vector4
  3493. */
  3494. static FromVector3(source: Vector3, w?: number): Vector4;
  3495. }
  3496. /**
  3497. * Class used to store quaternion data
  3498. * @see https://en.wikipedia.org/wiki/Quaternion
  3499. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3500. */
  3501. export class Quaternion {
  3502. /** defines the first component (0 by default) */
  3503. x: number;
  3504. /** defines the second component (0 by default) */
  3505. y: number;
  3506. /** defines the third component (0 by default) */
  3507. z: number;
  3508. /** defines the fourth component (1.0 by default) */
  3509. w: number;
  3510. /**
  3511. * Creates a new Quaternion from the given floats
  3512. * @param x defines the first component (0 by default)
  3513. * @param y defines the second component (0 by default)
  3514. * @param z defines the third component (0 by default)
  3515. * @param w defines the fourth component (1.0 by default)
  3516. */
  3517. constructor(
  3518. /** defines the first component (0 by default) */
  3519. x?: number,
  3520. /** defines the second component (0 by default) */
  3521. y?: number,
  3522. /** defines the third component (0 by default) */
  3523. z?: number,
  3524. /** defines the fourth component (1.0 by default) */
  3525. w?: number);
  3526. /**
  3527. * Gets a string representation for the current quaternion
  3528. * @returns a string with the Quaternion coordinates
  3529. */
  3530. toString(): string;
  3531. /**
  3532. * Gets the class name of the quaternion
  3533. * @returns the string "Quaternion"
  3534. */
  3535. getClassName(): string;
  3536. /**
  3537. * Gets a hash code for this quaternion
  3538. * @returns the quaternion hash code
  3539. */
  3540. getHashCode(): number;
  3541. /**
  3542. * Copy the quaternion to an array
  3543. * @returns a new array populated with 4 elements from the quaternion coordinates
  3544. */
  3545. asArray(): number[];
  3546. /**
  3547. * Check if two quaternions are equals
  3548. * @param otherQuaternion defines the second operand
  3549. * @return true if the current quaternion and the given one coordinates are strictly equals
  3550. */
  3551. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3552. /**
  3553. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3554. * @param otherQuaternion defines the other quaternion
  3555. * @param epsilon defines the minimal distance to consider equality
  3556. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3557. */
  3558. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3559. /**
  3560. * Clone the current quaternion
  3561. * @returns a new quaternion copied from the current one
  3562. */
  3563. clone(): Quaternion;
  3564. /**
  3565. * Copy a quaternion to the current one
  3566. * @param other defines the other quaternion
  3567. * @returns the updated current quaternion
  3568. */
  3569. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Updates the current quaternion with the given float coordinates
  3572. * @param x defines the x coordinate
  3573. * @param y defines the y coordinate
  3574. * @param z defines the z coordinate
  3575. * @param w defines the w coordinate
  3576. * @returns the updated current quaternion
  3577. */
  3578. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3579. /**
  3580. * Updates the current quaternion from the given float coordinates
  3581. * @param x defines the x coordinate
  3582. * @param y defines the y coordinate
  3583. * @param z defines the z coordinate
  3584. * @param w defines the w coordinate
  3585. * @returns the updated current quaternion
  3586. */
  3587. set(x: number, y: number, z: number, w: number): Quaternion;
  3588. /**
  3589. * Adds two quaternions
  3590. * @param other defines the second operand
  3591. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3592. */
  3593. add(other: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Add a quaternion to the current one
  3596. * @param other defines the quaternion to add
  3597. * @returns the current quaternion
  3598. */
  3599. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Subtract two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the subtraction result of the given one from the current one
  3604. */
  3605. subtract(other: Quaternion): Quaternion;
  3606. /**
  3607. * Multiplies the current quaternion by a scale factor
  3608. * @param value defines the scale factor
  3609. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3610. */
  3611. scale(value: number): Quaternion;
  3612. /**
  3613. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3614. * @param scale defines the scale factor
  3615. * @param result defines the Quaternion object where to store the result
  3616. * @returns the unmodified current quaternion
  3617. */
  3618. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3619. /**
  3620. * Multiplies in place the current quaternion by a scale factor
  3621. * @param value defines the scale factor
  3622. * @returns the current modified quaternion
  3623. */
  3624. scaleInPlace(value: number): Quaternion;
  3625. /**
  3626. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3627. * @param scale defines the scale factor
  3628. * @param result defines the Quaternion object where to store the result
  3629. * @returns the unmodified current quaternion
  3630. */
  3631. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3632. /**
  3633. * Multiplies two quaternions
  3634. * @param q1 defines the second operand
  3635. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3636. */
  3637. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3638. /**
  3639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @param result defines the target quaternion
  3642. * @returns the current quaternion
  3643. */
  3644. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3645. /**
  3646. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3647. * @param q1 defines the second operand
  3648. * @returns the currentupdated quaternion
  3649. */
  3650. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3651. /**
  3652. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3653. * @param ref defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. conjugateToRef(ref: Quaternion): Quaternion;
  3657. /**
  3658. * Conjugates in place (1-q) the current quaternion
  3659. * @returns the current updated quaternion
  3660. */
  3661. conjugateInPlace(): Quaternion;
  3662. /**
  3663. * Conjugates in place (1-q) the current quaternion
  3664. * @returns a new quaternion
  3665. */
  3666. conjugate(): Quaternion;
  3667. /**
  3668. * Gets length of current quaternion
  3669. * @returns the quaternion length (float)
  3670. */
  3671. length(): number;
  3672. /**
  3673. * Normalize in place the current quaternion
  3674. * @returns the current updated quaternion
  3675. */
  3676. normalize(): Quaternion;
  3677. /**
  3678. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns a new Vector3 containing the Euler angles
  3681. */
  3682. toEulerAngles(order?: string): Vector3;
  3683. /**
  3684. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3685. * @param result defines the vector which will be filled with the Euler angles
  3686. * @param order is a reserved parameter and is ignore for now
  3687. * @returns the current unchanged quaternion
  3688. */
  3689. toEulerAnglesToRef(result: Vector3): Quaternion;
  3690. /**
  3691. * Updates the given rotation matrix with the current quaternion values
  3692. * @param result defines the target matrix
  3693. * @returns the current unchanged quaternion
  3694. */
  3695. toRotationMatrix(result: Matrix): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given rotation matrix values
  3698. * @param matrix defines the source matrix
  3699. * @returns the current updated quaternion
  3700. */
  3701. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from a rotation matrix
  3704. * @param matrix defines the source matrix
  3705. * @returns a new quaternion created from the given rotation matrix values
  3706. */
  3707. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3708. /**
  3709. * Updates the given quaternion with the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @param result defines the target quaternion
  3712. */
  3713. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3714. /**
  3715. * Returns the dot product (float) between the quaternions "left" and "right"
  3716. * @param left defines the left operand
  3717. * @param right defines the right operand
  3718. * @returns the dot product
  3719. */
  3720. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3721. /**
  3722. * Checks if the two quaternions are close to each other
  3723. * @param quat0 defines the first quaternion to check
  3724. * @param quat1 defines the second quaternion to check
  3725. * @returns true if the two quaternions are close to each other
  3726. */
  3727. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates an empty quaternion
  3730. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3731. */
  3732. static Zero(): Quaternion;
  3733. /**
  3734. * Inverse a given quaternion
  3735. * @param q defines the source quaternion
  3736. * @returns a new quaternion as the inverted current quaternion
  3737. */
  3738. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Inverse a given quaternion
  3741. * @param q defines the source quaternion
  3742. * @param result the quaternion the result will be stored in
  3743. * @returns the result quaternion
  3744. */
  3745. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3746. /**
  3747. * Creates an identity quaternion
  3748. * @returns the identity quaternion
  3749. */
  3750. static Identity(): Quaternion;
  3751. /**
  3752. * Gets a boolean indicating if the given quaternion is identity
  3753. * @param quaternion defines the quaternion to check
  3754. * @returns true if the quaternion is identity
  3755. */
  3756. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3757. /**
  3758. * Creates a quaternion from a rotation around an axis
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3762. */
  3763. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3764. /**
  3765. * Creates a rotation around an axis and stores it into the given quaternion
  3766. * @param axis defines the axis to use
  3767. * @param angle defines the angle to use
  3768. * @param result defines the target quaternion
  3769. * @returns the target quaternion
  3770. */
  3771. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Creates a new quaternion from data stored into an array
  3774. * @param array defines the data source
  3775. * @param offset defines the offset in the source array where the data starts
  3776. * @returns a new quaternion
  3777. */
  3778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * 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)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * 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
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. 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;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. 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;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * 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"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * 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".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * 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"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * 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".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * 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.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4958. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. 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, divisor?: number);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. }
  7245. }
  7246. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7247. import { FloatArray, Nullable } from "babylonjs/types";
  7248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7250. module "babylonjs/Engines/thinEngine" {
  7251. interface ThinEngine {
  7252. /**
  7253. * Create an uniform buffer
  7254. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7255. * @param elements defines the content of the uniform buffer
  7256. * @returns the webGL uniform buffer
  7257. */
  7258. createUniformBuffer(elements: FloatArray): DataBuffer;
  7259. /**
  7260. * Create a dynamic uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Update an existing uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param uniformBuffer defines the target uniform buffer
  7270. * @param elements defines the content to update
  7271. * @param offset defines the offset in the uniform buffer where update should start
  7272. * @param count defines the size of the data to update
  7273. */
  7274. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7275. /**
  7276. * Bind an uniform buffer to the current webGL context
  7277. * @param buffer defines the buffer to bind
  7278. */
  7279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7280. /**
  7281. * Bind a buffer to the current webGL context at a given location
  7282. * @param buffer defines the buffer to bind
  7283. * @param location defines the index where to bind the buffer
  7284. */
  7285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7286. /**
  7287. * Bind a specific block at a given index in a specific shader program
  7288. * @param pipelineContext defines the pipeline context to use
  7289. * @param blockName defines the block name
  7290. * @param index defines the index where to bind the block
  7291. */
  7292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7293. }
  7294. }
  7295. }
  7296. declare module "babylonjs/Materials/uniformBuffer" {
  7297. import { Nullable, FloatArray } from "babylonjs/types";
  7298. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7299. import { Engine } from "babylonjs/Engines/engine";
  7300. import { Effect } from "babylonjs/Materials/effect";
  7301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7302. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7303. import { Color3 } from "babylonjs/Maths/math.color";
  7304. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7305. /**
  7306. * Uniform buffer objects.
  7307. *
  7308. * Handles blocks of uniform on the GPU.
  7309. *
  7310. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7311. *
  7312. * For more information, please refer to :
  7313. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7314. */
  7315. export class UniformBuffer {
  7316. private _engine;
  7317. private _buffer;
  7318. private _data;
  7319. private _bufferData;
  7320. private _dynamic?;
  7321. private _uniformLocations;
  7322. private _uniformSizes;
  7323. private _uniformLocationPointer;
  7324. private _needSync;
  7325. private _noUBO;
  7326. private _currentEffect;
  7327. /** @hidden */
  7328. _alreadyBound: boolean;
  7329. private static _MAX_UNIFORM_SIZE;
  7330. private static _tempBuffer;
  7331. /**
  7332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7337. /**
  7338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7343. /**
  7344. * Lambda to Update a single float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat: (name: string, x: number) => void;
  7349. /**
  7350. * Lambda to Update a vec2 of float in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a vec3 of float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7361. /**
  7362. * Lambda to Update a vec4 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateMatrix: (name: string, mat: Matrix) => void;
  7373. /**
  7374. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateVector3: (name: string, vector: Vector3) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateVector4: (name: string, vector: Vector4) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7397. /**
  7398. * Instantiates a new Uniform buffer objects.
  7399. *
  7400. * Handles blocks of uniform on the GPU.
  7401. *
  7402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7403. *
  7404. * For more information, please refer to :
  7405. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7406. * @param engine Define the engine the buffer is associated with
  7407. * @param data Define the data contained in the buffer
  7408. * @param dynamic Define if the buffer is updatable
  7409. */
  7410. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7411. /**
  7412. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7413. * or just falling back on setUniformXXX calls.
  7414. */
  7415. get useUbo(): boolean;
  7416. /**
  7417. * Indicates if the WebGL underlying uniform buffer is in sync
  7418. * with the javascript cache data.
  7419. */
  7420. get isSync(): boolean;
  7421. /**
  7422. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7423. * Also, a dynamic UniformBuffer will disable cache verification and always
  7424. * update the underlying WebGL uniform buffer to the GPU.
  7425. * @returns if Dynamic, otherwise false
  7426. */
  7427. isDynamic(): boolean;
  7428. /**
  7429. * The data cache on JS side.
  7430. * @returns the underlying data as a float array
  7431. */
  7432. getData(): Float32Array;
  7433. /**
  7434. * The underlying WebGL Uniform buffer.
  7435. * @returns the webgl buffer
  7436. */
  7437. getBuffer(): Nullable<DataBuffer>;
  7438. /**
  7439. * std140 layout specifies how to align data within an UBO structure.
  7440. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7441. * for specs.
  7442. */
  7443. private _fillAlignment;
  7444. /**
  7445. * Adds an uniform in the buffer.
  7446. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7447. * for the layout to be correct !
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param size Data size, or data directly.
  7450. */
  7451. addUniform(name: string, size: number | number[]): void;
  7452. /**
  7453. * Adds a Matrix 4x4 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. * @param mat A 4x4 matrix.
  7456. */
  7457. addMatrix(name: string, mat: Matrix): void;
  7458. /**
  7459. * Adds a vec2 to the uniform buffer.
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param x Define the x component value of the vec2
  7462. * @param y Define the y component value of the vec2
  7463. */
  7464. addFloat2(name: string, x: number, y: number): void;
  7465. /**
  7466. * Adds a vec3 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec3
  7469. * @param y Define the y component value of the vec3
  7470. * @param z Define the z component value of the vec3
  7471. */
  7472. addFloat3(name: string, x: number, y: number, z: number): void;
  7473. /**
  7474. * Adds a vec3 to the uniform buffer.
  7475. * @param name Name of the uniform, as used in the uniform block in the shader.
  7476. * @param color Define the vec3 from a Color
  7477. */
  7478. addColor3(name: string, color: Color3): void;
  7479. /**
  7480. * Adds a vec4 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. * @param color Define the rgb components from a Color
  7483. * @param alpha Define the a component of the vec4
  7484. */
  7485. addColor4(name: string, color: Color3, alpha: number): void;
  7486. /**
  7487. * Adds a vec3 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param vector Define the vec3 components from a Vector
  7490. */
  7491. addVector3(name: string, vector: Vector3): void;
  7492. /**
  7493. * Adds a Matrix 3x3 to the uniform buffer.
  7494. * @param name Name of the uniform, as used in the uniform block in the shader.
  7495. */
  7496. addMatrix3x3(name: string): void;
  7497. /**
  7498. * Adds a Matrix 2x2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. */
  7501. addMatrix2x2(name: string): void;
  7502. /**
  7503. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7504. */
  7505. create(): void;
  7506. /** @hidden */
  7507. _rebuild(): void;
  7508. /**
  7509. * Updates the WebGL Uniform Buffer on the GPU.
  7510. * If the `dynamic` flag is set to true, no cache comparison is done.
  7511. * Otherwise, the buffer will be updated only if the cache differs.
  7512. */
  7513. update(): void;
  7514. /**
  7515. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7516. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7517. * @param data Define the flattened data
  7518. * @param size Define the size of the data.
  7519. */
  7520. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7521. private _valueCache;
  7522. private _cacheMatrix;
  7523. private _updateMatrix3x3ForUniform;
  7524. private _updateMatrix3x3ForEffect;
  7525. private _updateMatrix2x2ForEffect;
  7526. private _updateMatrix2x2ForUniform;
  7527. private _updateFloatForEffect;
  7528. private _updateFloatForUniform;
  7529. private _updateFloat2ForEffect;
  7530. private _updateFloat2ForUniform;
  7531. private _updateFloat3ForEffect;
  7532. private _updateFloat3ForUniform;
  7533. private _updateFloat4ForEffect;
  7534. private _updateFloat4ForUniform;
  7535. private _updateMatrixForEffect;
  7536. private _updateMatrixForUniform;
  7537. private _updateVector3ForEffect;
  7538. private _updateVector3ForUniform;
  7539. private _updateVector4ForEffect;
  7540. private _updateVector4ForUniform;
  7541. private _updateColor3ForEffect;
  7542. private _updateColor3ForUniform;
  7543. private _updateColor4ForEffect;
  7544. private _updateColor4ForUniform;
  7545. /**
  7546. * Sets a sampler uniform on the effect.
  7547. * @param name Define the name of the sampler.
  7548. * @param texture Define the texture to set in the sampler
  7549. */
  7550. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7551. /**
  7552. * Directly updates the value of the uniform in the cache AND on the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. */
  7556. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7557. /**
  7558. * Binds this uniform buffer to an effect.
  7559. * @param effect Define the effect to bind the buffer to
  7560. * @param name Name of the uniform block in the shader.
  7561. */
  7562. bindToEffect(effect: Effect, name: string): void;
  7563. /**
  7564. * Disposes the uniform buffer.
  7565. */
  7566. dispose(): void;
  7567. }
  7568. }
  7569. declare module "babylonjs/Misc/iInspectable" {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4,
  7594. /**
  7595. * String
  7596. */
  7597. String = 5
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/timingTools" {
  7632. /**
  7633. * Class used to provide helper for timing
  7634. */
  7635. export class TimingTools {
  7636. /**
  7637. * Polyfill for setImmediate
  7638. * @param action defines the action to execute after the current execution block
  7639. */
  7640. static SetImmediate(action: () => void): void;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/instantiationTools" {
  7644. /**
  7645. * Class used to enable instatition of objects by class name
  7646. */
  7647. export class InstantiationTools {
  7648. /**
  7649. * Use this object to register external classes like custom textures or material
  7650. * to allow the laoders to instantiate them
  7651. */
  7652. static RegisteredExternalClasses: {
  7653. [key: string]: Object;
  7654. };
  7655. /**
  7656. * Tries to instantiate a new object from a given class name
  7657. * @param className defines the class name to instantiate
  7658. * @returns the new object or null if the system was not able to do the instantiation
  7659. */
  7660. static Instantiate(className: string): any;
  7661. }
  7662. }
  7663. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7664. /**
  7665. * Define options used to create a depth texture
  7666. */
  7667. export class DepthTextureCreationOptions {
  7668. /** Specifies whether or not a stencil should be allocated in the texture */
  7669. generateStencil?: boolean;
  7670. /** Specifies whether or not bilinear filtering is enable on the texture */
  7671. bilinearFiltering?: boolean;
  7672. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7673. comparisonFunction?: number;
  7674. /** Specifies if the created texture is a cube texture */
  7675. isCube?: boolean;
  7676. }
  7677. }
  7678. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7680. import { Nullable } from "babylonjs/types";
  7681. import { Scene } from "babylonjs/scene";
  7682. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7683. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7684. module "babylonjs/Engines/thinEngine" {
  7685. interface ThinEngine {
  7686. /**
  7687. * Creates a depth stencil cube texture.
  7688. * This is only available in WebGL 2.
  7689. * @param size The size of face edge in the cube texture.
  7690. * @param options The options defining the cube texture.
  7691. * @returns The cube texture
  7692. */
  7693. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7694. /**
  7695. * Creates a cube texture
  7696. * @param rootUrl defines the url where the files to load is located
  7697. * @param scene defines the current scene
  7698. * @param files defines the list of files to load (1 per face)
  7699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7700. * @param onLoad defines an optional callback raised when the texture is loaded
  7701. * @param onError defines an optional callback raised if there is an issue to load the texture
  7702. * @param format defines the format of the data
  7703. * @param forcedExtension defines the extension to use to pick the right loader
  7704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. 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;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. 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;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. 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;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. 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);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * 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;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * 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).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * 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).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * 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.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * 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.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * 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.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * 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.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * 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.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * 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).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * 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.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * 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.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * 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.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * 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).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * 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.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * 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.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * 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.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * 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.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * 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).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * 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.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * 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.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * 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.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * 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.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Define the current target of the camera as an object or a position.
  8662. */
  8663. lockedTarget: any;
  8664. /** @hidden */
  8665. _currentTarget: Vector3;
  8666. /** @hidden */
  8667. _initialFocalDistance: number;
  8668. /** @hidden */
  8669. _viewMatrix: Matrix;
  8670. /** @hidden */
  8671. _camMatrix: Matrix;
  8672. /** @hidden */
  8673. _cameraTransformMatrix: Matrix;
  8674. /** @hidden */
  8675. _cameraRotationMatrix: Matrix;
  8676. /** @hidden */
  8677. _referencePoint: Vector3;
  8678. /** @hidden */
  8679. _transformedReferencePoint: Vector3;
  8680. protected _globalCurrentTarget: Vector3;
  8681. protected _globalCurrentUpVector: Vector3;
  8682. /** @hidden */
  8683. _reset: () => void;
  8684. private _defaultUp;
  8685. /**
  8686. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8687. * This is the base of the follow, arc rotate cameras and Free camera
  8688. * @see http://doc.babylonjs.com/features/cameras
  8689. * @param name Defines the name of the camera in the scene
  8690. * @param position Defines the start position of the camera in the scene
  8691. * @param scene Defines the scene the camera belongs to
  8692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8693. */
  8694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8695. /**
  8696. * Gets the position in front of the camera at a given distance.
  8697. * @param distance The distance from the camera we want the position to be
  8698. * @returns the position
  8699. */
  8700. getFrontPosition(distance: number): Vector3;
  8701. /** @hidden */
  8702. _getLockedTargetPosition(): Nullable<Vector3>;
  8703. private _storedPosition;
  8704. private _storedRotation;
  8705. private _storedRotationQuaternion;
  8706. /**
  8707. * Store current camera state of the camera (fov, position, rotation, etc..)
  8708. * @returns the camera
  8709. */
  8710. storeState(): Camera;
  8711. /**
  8712. * Restored camera state. You must call storeState() first
  8713. * @returns whether it was successful or not
  8714. * @hidden
  8715. */
  8716. _restoreStateValues(): boolean;
  8717. /** @hidden */
  8718. _initCache(): void;
  8719. /** @hidden */
  8720. _updateCache(ignoreParentClass?: boolean): void;
  8721. /** @hidden */
  8722. _isSynchronizedViewMatrix(): boolean;
  8723. /** @hidden */
  8724. _computeLocalCameraSpeed(): number;
  8725. /**
  8726. * Defines the target the camera should look at.
  8727. * @param target Defines the new target as a Vector or a mesh
  8728. */
  8729. setTarget(target: Vector3): void;
  8730. /**
  8731. * Return the current target position of the camera. This value is expressed in local space.
  8732. * @returns the target position
  8733. */
  8734. getTarget(): Vector3;
  8735. /** @hidden */
  8736. _decideIfNeedsToMove(): boolean;
  8737. /** @hidden */
  8738. _updatePosition(): void;
  8739. /** @hidden */
  8740. _checkInputs(): void;
  8741. protected _updateCameraRotationMatrix(): void;
  8742. /**
  8743. * 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)
  8744. * @returns the current camera
  8745. */
  8746. private _rotateUpVectorWithCameraRotationMatrix;
  8747. private _cachedRotationZ;
  8748. private _cachedQuaternionRotationZ;
  8749. /** @hidden */
  8750. _getViewMatrix(): Matrix;
  8751. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8752. /**
  8753. * @hidden
  8754. */
  8755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8756. /**
  8757. * @hidden
  8758. */
  8759. _updateRigCameras(): void;
  8760. private _getRigCamPositionAndTarget;
  8761. /**
  8762. * Gets the current object class name.
  8763. * @return the class name
  8764. */
  8765. getClassName(): string;
  8766. }
  8767. }
  8768. declare module "babylonjs/Events/keyboardEvents" {
  8769. /**
  8770. * Gather the list of keyboard event types as constants.
  8771. */
  8772. export class KeyboardEventTypes {
  8773. /**
  8774. * The keydown event is fired when a key becomes active (pressed).
  8775. */
  8776. static readonly KEYDOWN: number;
  8777. /**
  8778. * The keyup event is fired when a key has been released.
  8779. */
  8780. static readonly KEYUP: number;
  8781. }
  8782. /**
  8783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8784. */
  8785. export class KeyboardInfo {
  8786. /**
  8787. * Defines the type of event (KeyboardEventTypes)
  8788. */
  8789. type: number;
  8790. /**
  8791. * Defines the related dom event
  8792. */
  8793. event: KeyboardEvent;
  8794. /**
  8795. * Instantiates a new keyboard info.
  8796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8797. * @param type Defines the type of event (KeyboardEventTypes)
  8798. * @param event Defines the related dom event
  8799. */
  8800. constructor(
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number,
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent);
  8809. }
  8810. /**
  8811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8813. */
  8814. export class KeyboardInfoPre extends KeyboardInfo {
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number;
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent;
  8823. /**
  8824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8825. */
  8826. skipOnPointerObservable: boolean;
  8827. /**
  8828. * Instantiates a new keyboard pre info.
  8829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8830. * @param type Defines the type of event (KeyboardEventTypes)
  8831. * @param event Defines the related dom event
  8832. */
  8833. constructor(
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number,
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent);
  8842. }
  8843. }
  8844. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8845. import { Nullable } from "babylonjs/types";
  8846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8848. /**
  8849. * Manage the keyboard inputs to control the movement of a free camera.
  8850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8851. */
  8852. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8853. /**
  8854. * Defines the camera the input is attached to.
  8855. */
  8856. camera: FreeCamera;
  8857. /**
  8858. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8859. */
  8860. keysUp: number[];
  8861. /**
  8862. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8863. */
  8864. keysDown: number[];
  8865. /**
  8866. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8867. */
  8868. keysLeft: number[];
  8869. /**
  8870. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8871. */
  8872. keysRight: number[];
  8873. private _keys;
  8874. private _onCanvasBlurObserver;
  8875. private _onKeyboardObserver;
  8876. private _engine;
  8877. private _scene;
  8878. /**
  8879. * Attach the input controls to a specific dom element to get the input from.
  8880. * @param element Defines the element the controls should be listened from
  8881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8882. */
  8883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8884. /**
  8885. * Detach the current controls from the specified dom element.
  8886. * @param element Defines the element to stop listening the inputs from
  8887. */
  8888. detachControl(element: Nullable<HTMLElement>): void;
  8889. /**
  8890. * Update the current camera state depending on the inputs that have been used this frame.
  8891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8892. */
  8893. checkInputs(): void;
  8894. /**
  8895. * Gets the class name of the current intput.
  8896. * @returns the class name
  8897. */
  8898. getClassName(): string;
  8899. /** @hidden */
  8900. _onLostFocus(): void;
  8901. /**
  8902. * Get the friendly name associated with the input class.
  8903. * @returns the input friendly name
  8904. */
  8905. getSimpleName(): string;
  8906. }
  8907. }
  8908. declare module "babylonjs/Lights/shadowLight" {
  8909. import { Camera } from "babylonjs/Cameras/camera";
  8910. import { Scene } from "babylonjs/scene";
  8911. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8913. import { Light } from "babylonjs/Lights/light";
  8914. /**
  8915. * Interface describing all the common properties and methods a shadow light needs to implement.
  8916. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8917. * as well as binding the different shadow properties to the effects.
  8918. */
  8919. export interface IShadowLight extends Light {
  8920. /**
  8921. * The light id in the scene (used in scene.findLighById for instance)
  8922. */
  8923. id: string;
  8924. /**
  8925. * The position the shdow will be casted from.
  8926. */
  8927. position: Vector3;
  8928. /**
  8929. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8930. */
  8931. direction: Vector3;
  8932. /**
  8933. * The transformed position. Position of the light in world space taking parenting in account.
  8934. */
  8935. transformedPosition: Vector3;
  8936. /**
  8937. * The transformed direction. Direction of the light in world space taking parenting in account.
  8938. */
  8939. transformedDirection: Vector3;
  8940. /**
  8941. * The friendly name of the light in the scene.
  8942. */
  8943. name: string;
  8944. /**
  8945. * Defines the shadow projection clipping minimum z value.
  8946. */
  8947. shadowMinZ: number;
  8948. /**
  8949. * Defines the shadow projection clipping maximum z value.
  8950. */
  8951. shadowMaxZ: number;
  8952. /**
  8953. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8954. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8955. */
  8956. computeTransformedInformation(): boolean;
  8957. /**
  8958. * Gets the scene the light belongs to.
  8959. * @returns The scene
  8960. */
  8961. getScene(): Scene;
  8962. /**
  8963. * Callback defining a custom Projection Matrix Builder.
  8964. * This can be used to override the default projection matrix computation.
  8965. */
  8966. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8967. /**
  8968. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8969. * @param matrix The materix to updated with the projection information
  8970. * @param viewMatrix The transform matrix of the light
  8971. * @param renderList The list of mesh to render in the map
  8972. * @returns The current light
  8973. */
  8974. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8975. /**
  8976. * Gets the current depth scale used in ESM.
  8977. * @returns The scale
  8978. */
  8979. getDepthScale(): number;
  8980. /**
  8981. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8982. * @returns true if a cube texture needs to be use
  8983. */
  8984. needCube(): boolean;
  8985. /**
  8986. * Detects if the projection matrix requires to be recomputed this frame.
  8987. * @returns true if it requires to be recomputed otherwise, false.
  8988. */
  8989. needProjectionMatrixCompute(): boolean;
  8990. /**
  8991. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8992. */
  8993. forceProjectionMatrixCompute(): void;
  8994. /**
  8995. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8996. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8997. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8998. */
  8999. getShadowDirection(faceIndex?: number): Vector3;
  9000. /**
  9001. * Gets the minZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the min for
  9003. * @returns the depth min z
  9004. */
  9005. getDepthMinZ(activeCamera: Camera): number;
  9006. /**
  9007. * Gets the maxZ used for shadow according to both the scene and the light.
  9008. * @param activeCamera The camera we are returning the max for
  9009. * @returns the depth max z
  9010. */
  9011. getDepthMaxZ(activeCamera: Camera): number;
  9012. }
  9013. /**
  9014. * Base implementation IShadowLight
  9015. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9016. */
  9017. export abstract class ShadowLight extends Light implements IShadowLight {
  9018. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9019. protected _position: Vector3;
  9020. protected _setPosition(value: Vector3): void;
  9021. /**
  9022. * Sets the position the shadow will be casted from. Also use as the light position for both
  9023. * point and spot lights.
  9024. */
  9025. get position(): Vector3;
  9026. /**
  9027. * Sets the position the shadow will be casted from. Also use as the light position for both
  9028. * point and spot lights.
  9029. */
  9030. set position(value: Vector3);
  9031. protected _direction: Vector3;
  9032. protected _setDirection(value: Vector3): void;
  9033. /**
  9034. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9035. * Also use as the light direction on spot and directional lights.
  9036. */
  9037. get direction(): Vector3;
  9038. /**
  9039. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9040. * Also use as the light direction on spot and directional lights.
  9041. */
  9042. set direction(value: Vector3);
  9043. protected _shadowMinZ: number;
  9044. /**
  9045. * Gets the shadow projection clipping minimum z value.
  9046. */
  9047. get shadowMinZ(): number;
  9048. /**
  9049. * Sets the shadow projection clipping minimum z value.
  9050. */
  9051. set shadowMinZ(value: number);
  9052. protected _shadowMaxZ: number;
  9053. /**
  9054. * Sets the shadow projection clipping maximum z value.
  9055. */
  9056. get shadowMaxZ(): number;
  9057. /**
  9058. * Gets the shadow projection clipping maximum z value.
  9059. */
  9060. set shadowMaxZ(value: number);
  9061. /**
  9062. * Callback defining a custom Projection Matrix Builder.
  9063. * This can be used to override the default projection matrix computation.
  9064. */
  9065. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9066. /**
  9067. * The transformed position. Position of the light in world space taking parenting in account.
  9068. */
  9069. transformedPosition: Vector3;
  9070. /**
  9071. * The transformed direction. Direction of the light in world space taking parenting in account.
  9072. */
  9073. transformedDirection: Vector3;
  9074. private _needProjectionMatrixCompute;
  9075. /**
  9076. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9077. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9078. */
  9079. computeTransformedInformation(): boolean;
  9080. /**
  9081. * Return the depth scale used for the shadow map.
  9082. * @returns the depth scale.
  9083. */
  9084. getDepthScale(): number;
  9085. /**
  9086. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9087. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9088. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9089. */
  9090. getShadowDirection(faceIndex?: number): Vector3;
  9091. /**
  9092. * Returns the ShadowLight absolute position in the World.
  9093. * @returns the position vector in world space
  9094. */
  9095. getAbsolutePosition(): Vector3;
  9096. /**
  9097. * Sets the ShadowLight direction toward the passed target.
  9098. * @param target The point to target in local space
  9099. * @returns the updated ShadowLight direction
  9100. */
  9101. setDirectionToTarget(target: Vector3): Vector3;
  9102. /**
  9103. * Returns the light rotation in euler definition.
  9104. * @returns the x y z rotation in local space.
  9105. */
  9106. getRotation(): Vector3;
  9107. /**
  9108. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9109. * @returns true if a cube texture needs to be use
  9110. */
  9111. needCube(): boolean;
  9112. /**
  9113. * Detects if the projection matrix requires to be recomputed this frame.
  9114. * @returns true if it requires to be recomputed otherwise, false.
  9115. */
  9116. needProjectionMatrixCompute(): boolean;
  9117. /**
  9118. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9119. */
  9120. forceProjectionMatrixCompute(): void;
  9121. /** @hidden */
  9122. _initCache(): void;
  9123. /** @hidden */
  9124. _isSynchronized(): boolean;
  9125. /**
  9126. * Computes the world matrix of the node
  9127. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9128. * @returns the world matrix
  9129. */
  9130. computeWorldMatrix(force?: boolean): Matrix;
  9131. /**
  9132. * Gets the minZ used for shadow according to both the scene and the light.
  9133. * @param activeCamera The camera we are returning the min for
  9134. * @returns the depth min z
  9135. */
  9136. getDepthMinZ(activeCamera: Camera): number;
  9137. /**
  9138. * Gets the maxZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the max for
  9140. * @returns the depth max z
  9141. */
  9142. getDepthMaxZ(activeCamera: Camera): number;
  9143. /**
  9144. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9145. * @param matrix The materix to updated with the projection information
  9146. * @param viewMatrix The transform matrix of the light
  9147. * @param renderList The list of mesh to render in the map
  9148. * @returns The current light
  9149. */
  9150. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9151. }
  9152. }
  9153. declare module "babylonjs/Materials/effectFallbacks" {
  9154. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9155. import { Effect } from "babylonjs/Materials/effect";
  9156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9157. /**
  9158. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9159. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9160. */
  9161. export class EffectFallbacks implements IEffectFallbacks {
  9162. private _defines;
  9163. private _currentRank;
  9164. private _maxRank;
  9165. private _mesh;
  9166. /**
  9167. * Removes the fallback from the bound mesh.
  9168. */
  9169. unBindMesh(): void;
  9170. /**
  9171. * Adds a fallback on the specified property.
  9172. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9173. * @param define The name of the define in the shader
  9174. */
  9175. addFallback(rank: number, define: string): void;
  9176. /**
  9177. * Sets the mesh to use CPU skinning when needing to fallback.
  9178. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9179. * @param mesh The mesh to use the fallbacks.
  9180. */
  9181. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9182. /**
  9183. * Checks to see if more fallbacks are still availible.
  9184. */
  9185. get hasMoreFallbacks(): boolean;
  9186. /**
  9187. * Removes the defines that should be removed when falling back.
  9188. * @param currentDefines defines the current define statements for the shader.
  9189. * @param effect defines the current effect we try to compile
  9190. * @returns The resulting defines with defines of the current rank removed.
  9191. */
  9192. reduce(currentDefines: string, effect: Effect): string;
  9193. }
  9194. }
  9195. declare module "babylonjs/Materials/materialHelper" {
  9196. import { Nullable } from "babylonjs/types";
  9197. import { Scene } from "babylonjs/scene";
  9198. import { Engine } from "babylonjs/Engines/engine";
  9199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9200. import { Light } from "babylonjs/Lights/light";
  9201. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9202. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9204. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9205. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9206. /**
  9207. * "Static Class" containing the most commonly used helper while dealing with material for
  9208. * rendering purpose.
  9209. *
  9210. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9211. *
  9212. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9213. */
  9214. export class MaterialHelper {
  9215. /**
  9216. * Bind the current view position to an effect.
  9217. * @param effect The effect to be bound
  9218. * @param scene The scene the eyes position is used from
  9219. */
  9220. static BindEyePosition(effect: Effect, scene: Scene): void;
  9221. /**
  9222. * Helps preparing the defines values about the UVs in used in the effect.
  9223. * UVs are shared as much as we can accross channels in the shaders.
  9224. * @param texture The texture we are preparing the UVs for
  9225. * @param defines The defines to update
  9226. * @param key The channel key "diffuse", "specular"... used in the shader
  9227. */
  9228. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9229. /**
  9230. * Binds a texture matrix value to its corrsponding uniform
  9231. * @param texture The texture to bind the matrix for
  9232. * @param uniformBuffer The uniform buffer receivin the data
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9236. /**
  9237. * Gets the current status of the fog (should it be enabled?)
  9238. * @param mesh defines the mesh to evaluate for fog support
  9239. * @param scene defines the hosting scene
  9240. * @returns true if fog must be enabled
  9241. */
  9242. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9243. /**
  9244. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9245. * @param mesh defines the current mesh
  9246. * @param scene defines the current scene
  9247. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9248. * @param pointsCloud defines if point cloud rendering has to be turned on
  9249. * @param fogEnabled defines if fog has to be turned on
  9250. * @param alphaTest defines if alpha testing has to be turned on
  9251. * @param defines defines the current list of defines
  9252. */
  9253. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9256. * @param scene defines the current scene
  9257. * @param engine defines the current engine
  9258. * @param defines specifies the list of active defines
  9259. * @param useInstances defines if instances have to be turned on
  9260. * @param useClipPlane defines if clip plane have to be turned on
  9261. */
  9262. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9263. /**
  9264. * Prepares the defines for bones
  9265. * @param mesh The mesh containing the geometry data we will draw
  9266. * @param defines The defines to update
  9267. */
  9268. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9269. /**
  9270. * Prepares the defines for morph targets
  9271. * @param mesh The mesh containing the geometry data we will draw
  9272. * @param defines The defines to update
  9273. */
  9274. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9275. /**
  9276. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9277. * @param mesh The mesh containing the geometry data we will draw
  9278. * @param defines The defines to update
  9279. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9280. * @param useBones Precise whether bones should be used or not (override mesh info)
  9281. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9282. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9283. * @returns false if defines are considered not dirty and have not been checked
  9284. */
  9285. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9286. /**
  9287. * Prepares the defines related to multiview
  9288. * @param scene The scene we are intending to draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9292. /**
  9293. * Prepares the defines related to the light information passed in parameter
  9294. * @param scene The scene we are intending to draw
  9295. * @param mesh The mesh the effect is compiling for
  9296. * @param light The light the effect is compiling for
  9297. * @param lightIndex The index of the light
  9298. * @param defines The defines to update
  9299. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9300. * @param state Defines the current state regarding what is needed (normals, etc...)
  9301. */
  9302. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9303. needNormals: boolean;
  9304. needRebuild: boolean;
  9305. shadowEnabled: boolean;
  9306. specularEnabled: boolean;
  9307. lightmapMode: boolean;
  9308. }): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param defines The defines to update
  9314. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9315. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9316. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9317. * @returns true if normals will be required for the rest of the effect
  9318. */
  9319. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9320. /**
  9321. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9322. * @param lightIndex defines the light index
  9323. * @param uniformsList The uniform list
  9324. * @param samplersList The sampler list
  9325. * @param projectedLightTexture defines if projected texture must be used
  9326. * @param uniformBuffersList defines an optional list of uniform buffers
  9327. */
  9328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect
  9331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9332. * @param samplersList The sampler list
  9333. * @param defines The defines helping in the list generation
  9334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9335. */
  9336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9337. /**
  9338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9339. * @param defines The defines to update while falling back
  9340. * @param fallbacks The authorized effect fallbacks
  9341. * @param maxSimultaneousLights The maximum number of lights allowed
  9342. * @param rank the current rank of the Effect
  9343. * @returns The newly affected rank
  9344. */
  9345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9346. private static _TmpMorphInfluencers;
  9347. /**
  9348. * Prepares the list of attributes required for morph targets according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the morph targets attributes for
  9351. * @param influencers The number of influencers
  9352. */
  9353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param defines The current Defines of the effect
  9359. */
  9360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9361. /**
  9362. * Prepares the list of attributes required for bones according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the bones attributes for
  9365. * @param defines The current Defines of the effect
  9366. * @param fallbacks The current efffect fallback strategy
  9367. */
  9368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9369. /**
  9370. * Check and prepare the list of attributes required for instances according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param defines The current MaterialDefines of the effect
  9373. */
  9374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9375. /**
  9376. * Add the list of attributes required for instances to the attribs array.
  9377. * @param attribs The current list of supported attribs
  9378. */
  9379. static PushAttributesForInstances(attribs: string[]): void;
  9380. /**
  9381. * Binds the light information to the effect.
  9382. * @param light The light containing the generator
  9383. * @param effect The effect we are binding the data to
  9384. * @param lightIndex The light index in the effect used to render
  9385. */
  9386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9387. /**
  9388. * Binds the lights information from the scene to the effect for the given mesh.
  9389. * @param light Light to bind
  9390. * @param lightIndex Light index
  9391. * @param scene The scene where the light belongs to
  9392. * @param effect The effect we are binding the data to
  9393. * @param useSpecular Defines if specular is supported
  9394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9395. */
  9396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9397. /**
  9398. * Binds the lights information from the scene to the effect for the given mesh.
  9399. * @param scene The scene the lights belongs to
  9400. * @param mesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. * @param defines The generated defines for the effect
  9403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9405. */
  9406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9407. private static _tempFogColor;
  9408. /**
  9409. * Binds the fog information from the scene to the effect for the given mesh.
  9410. * @param scene The scene the lights belongs to
  9411. * @param mesh The mesh we are binding the information to render
  9412. * @param effect The effect we are binding the data to
  9413. * @param linearSpace Defines if the fog effect is applied in linear space
  9414. */
  9415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9416. /**
  9417. * Binds the bones information from the mesh to the effect.
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. */
  9421. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9422. /**
  9423. * Binds the morph targets information from the mesh to the effect.
  9424. * @param abstractMesh The mesh we are binding the information to render
  9425. * @param effect The effect we are binding the data to
  9426. */
  9427. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9428. /**
  9429. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9430. * @param defines The generated defines used in the effect
  9431. * @param effect The effect we are binding the data to
  9432. * @param scene The scene we are willing to render with logarithmic scale for
  9433. */
  9434. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9435. /**
  9436. * Binds the clip plane information from the scene to the effect.
  9437. * @param scene The scene the clip plane information are extracted from
  9438. * @param effect The effect we are binding the data to
  9439. */
  9440. static BindClipPlane(effect: Effect, scene: Scene): void;
  9441. }
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9444. /** @hidden */
  9445. export var packingFunctions: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9451. /** @hidden */
  9452. export var clipPlaneFragmentDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9458. /** @hidden */
  9459. export var clipPlaneFragment: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9468. /** @hidden */
  9469. export var shadowMapPixelShader: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9475. /** @hidden */
  9476. export var bonesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9482. /** @hidden */
  9483. export var morphTargetsVertexGlobalDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9496. /** @hidden */
  9497. export var instancesDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9503. /** @hidden */
  9504. export var helperFunctions: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9510. /** @hidden */
  9511. export var clipPlaneVertexDeclaration: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9517. /** @hidden */
  9518. export var morphTargetsVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9524. /** @hidden */
  9525. export var instancesVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9531. /** @hidden */
  9532. export var bonesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9555. /** @hidden */
  9556. export var shadowMapVertexShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9562. /** @hidden */
  9563. export var depthBoxBlurPixelShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Culling/ray" {
  9569. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9573. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9574. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9575. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9576. import { Plane } from "babylonjs/Maths/math.plane";
  9577. /**
  9578. * Class representing a ray with position and direction
  9579. */
  9580. export class Ray {
  9581. /** origin point */
  9582. origin: Vector3;
  9583. /** direction */
  9584. direction: Vector3;
  9585. /** length of the ray */
  9586. length: number;
  9587. private static readonly TmpVector3;
  9588. private _tmpRay;
  9589. /**
  9590. * Creates a new ray
  9591. * @param origin origin point
  9592. * @param direction direction
  9593. * @param length length of the ray
  9594. */
  9595. constructor(
  9596. /** origin point */
  9597. origin: Vector3,
  9598. /** direction */
  9599. direction: Vector3,
  9600. /** length of the ray */
  9601. length?: number);
  9602. /**
  9603. * Checks if the ray intersects a box
  9604. * @param minimum bound of the box
  9605. * @param maximum bound of the box
  9606. * @param intersectionTreshold extra extend to be added to the box in all direction
  9607. * @returns if the box was hit
  9608. */
  9609. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * Checks if the ray intersects a box
  9612. * @param box the bounding box to check
  9613. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9614. * @returns if the box was hit
  9615. */
  9616. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9617. /**
  9618. * If the ray hits a sphere
  9619. * @param sphere the bounding sphere to check
  9620. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9621. * @returns true if it hits the sphere
  9622. */
  9623. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9624. /**
  9625. * If the ray hits a triange
  9626. * @param vertex0 triangle vertex
  9627. * @param vertex1 triangle vertex
  9628. * @param vertex2 triangle vertex
  9629. * @returns intersection information if hit
  9630. */
  9631. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9632. /**
  9633. * Checks if ray intersects a plane
  9634. * @param plane the plane to check
  9635. * @returns the distance away it was hit
  9636. */
  9637. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9638. /**
  9639. * Calculate the intercept of a ray on a given axis
  9640. * @param axis to check 'x' | 'y' | 'z'
  9641. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9642. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9643. */
  9644. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9645. /**
  9646. * Checks if ray intersects a mesh
  9647. * @param mesh the mesh to check
  9648. * @param fastCheck if only the bounding box should checked
  9649. * @returns picking info of the intersecton
  9650. */
  9651. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9652. /**
  9653. * Checks if ray intersects a mesh
  9654. * @param meshes the meshes to check
  9655. * @param fastCheck if only the bounding box should checked
  9656. * @param results array to store result in
  9657. * @returns Array of picking infos
  9658. */
  9659. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9660. private _comparePickingInfo;
  9661. private static smallnum;
  9662. private static rayl;
  9663. /**
  9664. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9665. * @param sega the first point of the segment to test the intersection against
  9666. * @param segb the second point of the segment to test the intersection against
  9667. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9668. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9669. */
  9670. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9671. /**
  9672. * Update the ray from viewport position
  9673. * @param x position
  9674. * @param y y position
  9675. * @param viewportWidth viewport width
  9676. * @param viewportHeight viewport height
  9677. * @param world world matrix
  9678. * @param view view matrix
  9679. * @param projection projection matrix
  9680. * @returns this ray updated
  9681. */
  9682. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9683. /**
  9684. * Creates a ray with origin and direction of 0,0,0
  9685. * @returns the new ray
  9686. */
  9687. static Zero(): Ray;
  9688. /**
  9689. * Creates a new ray from screen space and viewport
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns new ray
  9698. */
  9699. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * 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
  9702. * transformed to the given world matrix.
  9703. * @param origin The origin point
  9704. * @param end The end point
  9705. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9706. * @returns the new ray
  9707. */
  9708. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * Transforms a ray by a matrix
  9711. * @param ray ray to transform
  9712. * @param matrix matrix to apply
  9713. * @returns the resulting new ray
  9714. */
  9715. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9716. /**
  9717. * Transforms a ray by a matrix
  9718. * @param ray ray to transform
  9719. * @param matrix matrix to apply
  9720. * @param result ray to store result in
  9721. */
  9722. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9723. /**
  9724. * Unproject a ray from screen space to object space
  9725. * @param sourceX defines the screen space x coordinate to use
  9726. * @param sourceY defines the screen space y coordinate to use
  9727. * @param viewportWidth defines the current width of the viewport
  9728. * @param viewportHeight defines the current height of the viewport
  9729. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9730. * @param view defines the view matrix to use
  9731. * @param projection defines the projection matrix to use
  9732. */
  9733. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9734. }
  9735. /**
  9736. * Type used to define predicate used to select faces when a mesh intersection is detected
  9737. */
  9738. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9739. module "babylonjs/scene" {
  9740. interface Scene {
  9741. /** @hidden */
  9742. _tempPickingRay: Nullable<Ray>;
  9743. /** @hidden */
  9744. _cachedRayForTransform: Ray;
  9745. /** @hidden */
  9746. _pickWithRayInverseMatrix: Matrix;
  9747. /** @hidden */
  9748. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9749. /** @hidden */
  9750. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9751. }
  9752. }
  9753. }
  9754. declare module "babylonjs/sceneComponent" {
  9755. import { Scene } from "babylonjs/scene";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9758. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9759. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9760. import { Nullable } from "babylonjs/types";
  9761. import { Camera } from "babylonjs/Cameras/camera";
  9762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9763. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9764. import { AbstractScene } from "babylonjs/abstractScene";
  9765. import { Mesh } from "babylonjs/Meshes/mesh";
  9766. /**
  9767. * Groups all the scene component constants in one place to ease maintenance.
  9768. * @hidden
  9769. */
  9770. export class SceneComponentConstants {
  9771. static readonly NAME_EFFECTLAYER: string;
  9772. static readonly NAME_LAYER: string;
  9773. static readonly NAME_LENSFLARESYSTEM: string;
  9774. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9775. static readonly NAME_PARTICLESYSTEM: string;
  9776. static readonly NAME_GAMEPAD: string;
  9777. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9778. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9779. static readonly NAME_DEPTHRENDERER: string;
  9780. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9781. static readonly NAME_SPRITE: string;
  9782. static readonly NAME_OUTLINERENDERER: string;
  9783. static readonly NAME_PROCEDURALTEXTURE: string;
  9784. static readonly NAME_SHADOWGENERATOR: string;
  9785. static readonly NAME_OCTREE: string;
  9786. static readonly NAME_PHYSICSENGINE: string;
  9787. static readonly NAME_AUDIO: string;
  9788. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9789. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9790. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9791. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9792. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9793. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9794. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9795. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9796. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9797. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9798. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9799. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9801. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9802. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9803. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9805. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9807. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9808. static readonly STEP_AFTERRENDER_AUDIO: number;
  9809. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9810. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9811. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9812. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9813. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9814. static readonly STEP_POINTERMOVE_SPRITE: number;
  9815. static readonly STEP_POINTERDOWN_SPRITE: number;
  9816. static readonly STEP_POINTERUP_SPRITE: number;
  9817. }
  9818. /**
  9819. * This represents a scene component.
  9820. *
  9821. * This is used to decouple the dependency the scene is having on the different workloads like
  9822. * layers, post processes...
  9823. */
  9824. export interface ISceneComponent {
  9825. /**
  9826. * The name of the component. Each component must have a unique name.
  9827. */
  9828. name: string;
  9829. /**
  9830. * The scene the component belongs to.
  9831. */
  9832. scene: Scene;
  9833. /**
  9834. * Register the component to one instance of a scene.
  9835. */
  9836. register(): void;
  9837. /**
  9838. * Rebuilds the elements related to this component in case of
  9839. * context lost for instance.
  9840. */
  9841. rebuild(): void;
  9842. /**
  9843. * Disposes the component and the associated ressources.
  9844. */
  9845. dispose(): void;
  9846. }
  9847. /**
  9848. * This represents a SERIALIZABLE scene component.
  9849. *
  9850. * This extends Scene Component to add Serialization methods on top.
  9851. */
  9852. export interface ISceneSerializableComponent extends ISceneComponent {
  9853. /**
  9854. * Adds all the elements from the container to the scene
  9855. * @param container the container holding the elements
  9856. */
  9857. addFromContainer(container: AbstractScene): void;
  9858. /**
  9859. * Removes all the elements in the container from the scene
  9860. * @param container contains the elements to remove
  9861. * @param dispose if the removed element should be disposed (default: false)
  9862. */
  9863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9864. /**
  9865. * Serializes the component data to the specified json object
  9866. * @param serializationObject The object to serialize to
  9867. */
  9868. serialize(serializationObject: any): void;
  9869. }
  9870. /**
  9871. * Strong typing of a Mesh related stage step action
  9872. */
  9873. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9874. /**
  9875. * Strong typing of a Evaluate Sub Mesh related stage step action
  9876. */
  9877. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9878. /**
  9879. * Strong typing of a Active Mesh related stage step action
  9880. */
  9881. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9882. /**
  9883. * Strong typing of a Camera related stage step action
  9884. */
  9885. export type CameraStageAction = (camera: Camera) => void;
  9886. /**
  9887. * Strong typing of a Camera Frame buffer related stage step action
  9888. */
  9889. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9890. /**
  9891. * Strong typing of a Render Target related stage step action
  9892. */
  9893. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9894. /**
  9895. * Strong typing of a RenderingGroup related stage step action
  9896. */
  9897. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9898. /**
  9899. * Strong typing of a Mesh Render related stage step action
  9900. */
  9901. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9902. /**
  9903. * Strong typing of a simple stage step action
  9904. */
  9905. export type SimpleStageAction = () => void;
  9906. /**
  9907. * Strong typing of a render target action.
  9908. */
  9909. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9910. /**
  9911. * Strong typing of a pointer move action.
  9912. */
  9913. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9914. /**
  9915. * Strong typing of a pointer up/down action.
  9916. */
  9917. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9918. /**
  9919. * Representation of a stage in the scene (Basically a list of ordered steps)
  9920. * @hidden
  9921. */
  9922. export class Stage<T extends Function> extends Array<{
  9923. index: number;
  9924. component: ISceneComponent;
  9925. action: T;
  9926. }> {
  9927. /**
  9928. * Hide ctor from the rest of the world.
  9929. * @param items The items to add.
  9930. */
  9931. private constructor();
  9932. /**
  9933. * Creates a new Stage.
  9934. * @returns A new instance of a Stage
  9935. */
  9936. static Create<T extends Function>(): Stage<T>;
  9937. /**
  9938. * Registers a step in an ordered way in the targeted stage.
  9939. * @param index Defines the position to register the step in
  9940. * @param component Defines the component attached to the step
  9941. * @param action Defines the action to launch during the step
  9942. */
  9943. registerStep(index: number, component: ISceneComponent, action: T): void;
  9944. /**
  9945. * Clears all the steps from the stage.
  9946. */
  9947. clear(): void;
  9948. }
  9949. }
  9950. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9951. import { Nullable } from "babylonjs/types";
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Scene } from "babylonjs/scene";
  9954. import { Sprite } from "babylonjs/Sprites/sprite";
  9955. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9956. import { Ray } from "babylonjs/Culling/ray";
  9957. import { Camera } from "babylonjs/Cameras/camera";
  9958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9959. import { ISceneComponent } from "babylonjs/sceneComponent";
  9960. module "babylonjs/scene" {
  9961. interface Scene {
  9962. /** @hidden */
  9963. _pointerOverSprite: Nullable<Sprite>;
  9964. /** @hidden */
  9965. _pickedDownSprite: Nullable<Sprite>;
  9966. /** @hidden */
  9967. _tempSpritePickingRay: Nullable<Ray>;
  9968. /**
  9969. * All of the sprite managers added to this scene
  9970. * @see http://doc.babylonjs.com/babylon101/sprites
  9971. */
  9972. spriteManagers: Array<ISpriteManager>;
  9973. /**
  9974. * An event triggered when sprites rendering is about to start
  9975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9976. */
  9977. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9978. /**
  9979. * An event triggered when sprites rendering is done
  9980. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9981. */
  9982. onAfterSpritesRenderingObservable: Observable<Scene>;
  9983. /** @hidden */
  9984. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9985. /** Launch a ray to try to pick a sprite in the scene
  9986. * @param x position on screen
  9987. * @param y position on screen
  9988. * @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
  9989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9991. * @returns a PickingInfo
  9992. */
  9993. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Use the given ray to pick a sprite in the scene
  9995. * @param ray The ray (in world space) to use to pick meshes
  9996. * @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
  9997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9998. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9999. * @returns a PickingInfo
  10000. */
  10001. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** @hidden */
  10003. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10004. /** Launch a ray to try to pick sprites in the scene
  10005. * @param x position on screen
  10006. * @param y position on screen
  10007. * @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
  10008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10009. * @returns a PickingInfo array
  10010. */
  10011. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10012. /** Use the given ray to pick sprites in the scene
  10013. * @param ray The ray (in world space) to use to pick meshes
  10014. * @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
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo array
  10017. */
  10018. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10019. /**
  10020. * Force the sprite under the pointer
  10021. * @param sprite defines the sprite to use
  10022. */
  10023. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10024. /**
  10025. * Gets the sprite under the pointer
  10026. * @returns a Sprite or null if no sprite is under the pointer
  10027. */
  10028. getPointerOverSprite(): Nullable<Sprite>;
  10029. }
  10030. }
  10031. /**
  10032. * Defines the sprite scene component responsible to manage sprites
  10033. * in a given scene.
  10034. */
  10035. export class SpriteSceneComponent implements ISceneComponent {
  10036. /**
  10037. * The component name helpfull to identify the component in the list of scene components.
  10038. */
  10039. readonly name: string;
  10040. /**
  10041. * The scene the component belongs to.
  10042. */
  10043. scene: Scene;
  10044. /** @hidden */
  10045. private _spritePredicate;
  10046. /**
  10047. * Creates a new instance of the component for the given scene
  10048. * @param scene Defines the scene to register the component in
  10049. */
  10050. constructor(scene: Scene);
  10051. /**
  10052. * Registers the component in a given scene
  10053. */
  10054. register(): void;
  10055. /**
  10056. * Rebuilds the elements related to this component in case of
  10057. * context lost for instance.
  10058. */
  10059. rebuild(): void;
  10060. /**
  10061. * Disposes the component and the associated ressources.
  10062. */
  10063. dispose(): void;
  10064. private _pickSpriteButKeepRay;
  10065. private _pointerMove;
  10066. private _pointerDown;
  10067. private _pointerUp;
  10068. }
  10069. }
  10070. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10071. /** @hidden */
  10072. export var fogFragmentDeclaration: {
  10073. name: string;
  10074. shader: string;
  10075. };
  10076. }
  10077. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10078. /** @hidden */
  10079. export var fogFragment: {
  10080. name: string;
  10081. shader: string;
  10082. };
  10083. }
  10084. declare module "babylonjs/Shaders/sprites.fragment" {
  10085. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10086. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10087. /** @hidden */
  10088. export var spritesPixelShader: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10094. /** @hidden */
  10095. export var fogVertexDeclaration: {
  10096. name: string;
  10097. shader: string;
  10098. };
  10099. }
  10100. declare module "babylonjs/Shaders/sprites.vertex" {
  10101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10102. /** @hidden */
  10103. export var spritesVertexShader: {
  10104. name: string;
  10105. shader: string;
  10106. };
  10107. }
  10108. declare module "babylonjs/Sprites/spriteManager" {
  10109. import { IDisposable, Scene } from "babylonjs/scene";
  10110. import { Nullable } from "babylonjs/types";
  10111. import { Observable } from "babylonjs/Misc/observable";
  10112. import { Sprite } from "babylonjs/Sprites/sprite";
  10113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10114. import { Camera } from "babylonjs/Cameras/camera";
  10115. import { Texture } from "babylonjs/Materials/Textures/texture";
  10116. import "babylonjs/Shaders/sprites.fragment";
  10117. import "babylonjs/Shaders/sprites.vertex";
  10118. import { Ray } from "babylonjs/Culling/ray";
  10119. /**
  10120. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10121. */
  10122. export interface ISpriteManager extends IDisposable {
  10123. /**
  10124. * Restricts the camera to viewing objects with the same layerMask.
  10125. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10126. */
  10127. layerMask: number;
  10128. /**
  10129. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10130. */
  10131. isPickable: boolean;
  10132. /**
  10133. * Specifies the rendering group id for this mesh (0 by default)
  10134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10135. */
  10136. renderingGroupId: number;
  10137. /**
  10138. * Defines the list of sprites managed by the manager.
  10139. */
  10140. sprites: Array<Sprite>;
  10141. /**
  10142. * Tests the intersection of a sprite with a specific ray.
  10143. * @param ray The ray we are sending to test the collision
  10144. * @param camera The camera space we are sending rays in
  10145. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10146. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10147. * @returns picking info or null.
  10148. */
  10149. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10150. /**
  10151. * Intersects the sprites with a ray
  10152. * @param ray defines the ray to intersect with
  10153. * @param camera defines the current active camera
  10154. * @param predicate defines a predicate used to select candidate sprites
  10155. * @returns null if no hit or a PickingInfo array
  10156. */
  10157. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10158. /**
  10159. * Renders the list of sprites on screen.
  10160. */
  10161. render(): void;
  10162. }
  10163. /**
  10164. * Class used to manage multiple sprites on the same spritesheet
  10165. * @see http://doc.babylonjs.com/babylon101/sprites
  10166. */
  10167. export class SpriteManager implements ISpriteManager {
  10168. /** defines the manager's name */
  10169. name: string;
  10170. /** Gets the list of sprites */
  10171. sprites: Sprite[];
  10172. /** Gets or sets the rendering group id (0 by default) */
  10173. renderingGroupId: number;
  10174. /** Gets or sets camera layer mask */
  10175. layerMask: number;
  10176. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10177. fogEnabled: boolean;
  10178. /** Gets or sets a boolean indicating if the sprites are pickable */
  10179. isPickable: boolean;
  10180. /** Defines the default width of a cell in the spritesheet */
  10181. cellWidth: number;
  10182. /** Defines the default height of a cell in the spritesheet */
  10183. cellHeight: number;
  10184. /** Associative array from JSON sprite data file */
  10185. private _cellData;
  10186. /** Array of sprite names from JSON sprite data file */
  10187. private _spriteMap;
  10188. /** True when packed cell data from JSON file is ready*/
  10189. private _packedAndReady;
  10190. /**
  10191. * An event triggered when the manager is disposed.
  10192. */
  10193. onDisposeObservable: Observable<SpriteManager>;
  10194. private _onDisposeObserver;
  10195. /**
  10196. * Callback called when the manager is disposed
  10197. */
  10198. set onDispose(callback: () => void);
  10199. private _capacity;
  10200. private _fromPacked;
  10201. private _spriteTexture;
  10202. private _epsilon;
  10203. private _scene;
  10204. private _vertexData;
  10205. private _buffer;
  10206. private _vertexBuffers;
  10207. private _indexBuffer;
  10208. private _effectBase;
  10209. private _effectFog;
  10210. /**
  10211. * Gets or sets the spritesheet texture
  10212. */
  10213. get texture(): Texture;
  10214. set texture(value: Texture);
  10215. /**
  10216. * Creates a new sprite manager
  10217. * @param name defines the manager's name
  10218. * @param imgUrl defines the sprite sheet url
  10219. * @param capacity defines the maximum allowed number of sprites
  10220. * @param cellSize defines the size of a sprite cell
  10221. * @param scene defines the hosting scene
  10222. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10223. * @param samplingMode defines the smapling mode to use with spritesheet
  10224. * @param fromPacked set to false; do not alter
  10225. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10226. */
  10227. constructor(
  10228. /** defines the manager's name */
  10229. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10230. private _makePacked;
  10231. private _appendSpriteVertex;
  10232. /**
  10233. * Intersects the sprites with a ray
  10234. * @param ray defines the ray to intersect with
  10235. * @param camera defines the current active camera
  10236. * @param predicate defines a predicate used to select candidate sprites
  10237. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10238. * @returns null if no hit or a PickingInfo
  10239. */
  10240. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10241. /**
  10242. * Intersects the sprites with a ray
  10243. * @param ray defines the ray to intersect with
  10244. * @param camera defines the current active camera
  10245. * @param predicate defines a predicate used to select candidate sprites
  10246. * @returns null if no hit or a PickingInfo array
  10247. */
  10248. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10249. /**
  10250. * Render all child sprites
  10251. */
  10252. render(): void;
  10253. /**
  10254. * Release associated resources
  10255. */
  10256. dispose(): void;
  10257. }
  10258. }
  10259. declare module "babylonjs/Misc/gradients" {
  10260. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10261. /** Interface used by value gradients (color, factor, ...) */
  10262. export interface IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. }
  10268. /** Class used to store color4 gradient */
  10269. export class ColorGradient implements IValueGradient {
  10270. /**
  10271. * Gets or sets the gradient value (between 0 and 1)
  10272. */
  10273. gradient: number;
  10274. /**
  10275. * Gets or sets first associated color
  10276. */
  10277. color1: Color4;
  10278. /**
  10279. * Gets or sets second associated color
  10280. */
  10281. color2?: Color4;
  10282. /**
  10283. * Will get a color picked randomly between color1 and color2.
  10284. * If color2 is undefined then color1 will be used
  10285. * @param result defines the target Color4 to store the result in
  10286. */
  10287. getColorToRef(result: Color4): void;
  10288. }
  10289. /** Class used to store color 3 gradient */
  10290. export class Color3Gradient implements IValueGradient {
  10291. /**
  10292. * Gets or sets the gradient value (between 0 and 1)
  10293. */
  10294. gradient: number;
  10295. /**
  10296. * Gets or sets the associated color
  10297. */
  10298. color: Color3;
  10299. }
  10300. /** Class used to store factor gradient */
  10301. export class FactorGradient implements IValueGradient {
  10302. /**
  10303. * Gets or sets the gradient value (between 0 and 1)
  10304. */
  10305. gradient: number;
  10306. /**
  10307. * Gets or sets first associated factor
  10308. */
  10309. factor1: number;
  10310. /**
  10311. * Gets or sets second associated factor
  10312. */
  10313. factor2?: number;
  10314. /**
  10315. * Will get a number picked randomly between factor1 and factor2.
  10316. * If factor2 is undefined then factor1 will be used
  10317. * @returns the picked number
  10318. */
  10319. getFactor(): number;
  10320. }
  10321. /**
  10322. * Helper used to simplify some generic gradient tasks
  10323. */
  10324. export class GradientHelper {
  10325. /**
  10326. * Gets the current gradient from an array of IValueGradient
  10327. * @param ratio defines the current ratio to get
  10328. * @param gradients defines the array of IValueGradient
  10329. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10330. */
  10331. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10332. }
  10333. }
  10334. declare module "babylonjs/Maths/math.size" {
  10335. /**
  10336. * Interface for the size containing width and height
  10337. */
  10338. export interface ISize {
  10339. /**
  10340. * Width
  10341. */
  10342. width: number;
  10343. /**
  10344. * Heighht
  10345. */
  10346. height: number;
  10347. }
  10348. /**
  10349. * Size containing widht and height
  10350. */
  10351. export class Size implements ISize {
  10352. /**
  10353. * Width
  10354. */
  10355. width: number;
  10356. /**
  10357. * Height
  10358. */
  10359. height: number;
  10360. /**
  10361. * Creates a Size object from the given width and height (floats).
  10362. * @param width width of the new size
  10363. * @param height height of the new size
  10364. */
  10365. constructor(width: number, height: number);
  10366. /**
  10367. * Returns a string with the Size width and height
  10368. * @returns a string with the Size width and height
  10369. */
  10370. toString(): string;
  10371. /**
  10372. * "Size"
  10373. * @returns the string "Size"
  10374. */
  10375. getClassName(): string;
  10376. /**
  10377. * Returns the Size hash code.
  10378. * @returns a hash code for a unique width and height
  10379. */
  10380. getHashCode(): number;
  10381. /**
  10382. * Updates the current size from the given one.
  10383. * @param src the given size
  10384. */
  10385. copyFrom(src: Size): void;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width of the new size
  10389. * @param height height of the new size
  10390. * @returns the updated Size.
  10391. */
  10392. copyFromFloats(width: number, height: number): Size;
  10393. /**
  10394. * Updates in place the current Size from the given floats.
  10395. * @param width width to set
  10396. * @param height height to set
  10397. * @returns the updated Size.
  10398. */
  10399. set(width: number, height: number): Size;
  10400. /**
  10401. * Multiplies the width and height by numbers
  10402. * @param w factor to multiple the width by
  10403. * @param h factor to multiple the height by
  10404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10405. */
  10406. multiplyByFloats(w: number, h: number): Size;
  10407. /**
  10408. * Clones the size
  10409. * @returns a new Size copied from the given one.
  10410. */
  10411. clone(): Size;
  10412. /**
  10413. * True if the current Size and the given one width and height are strictly equal.
  10414. * @param other the other size to compare against
  10415. * @returns True if the current Size and the given one width and height are strictly equal.
  10416. */
  10417. equals(other: Size): boolean;
  10418. /**
  10419. * The surface of the Size : width * height (float).
  10420. */
  10421. get surface(): number;
  10422. /**
  10423. * Create a new size of zero
  10424. * @returns a new Size set to (0.0, 0.0)
  10425. */
  10426. static Zero(): Size;
  10427. /**
  10428. * Sums the width and height of two sizes
  10429. * @param otherSize size to add to this size
  10430. * @returns a new Size set as the addition result of the current Size and the given one.
  10431. */
  10432. add(otherSize: Size): Size;
  10433. /**
  10434. * Subtracts the width and height of two
  10435. * @param otherSize size to subtract to this size
  10436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10437. */
  10438. subtract(otherSize: Size): Size;
  10439. /**
  10440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10441. * @param start starting size to lerp between
  10442. * @param end end size to lerp between
  10443. * @param amount amount to lerp between the start and end values
  10444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10445. */
  10446. static Lerp(start: Size, end: Size, amount: number): Size;
  10447. }
  10448. }
  10449. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10451. import { Nullable } from "babylonjs/types";
  10452. module "babylonjs/Engines/thinEngine" {
  10453. interface ThinEngine {
  10454. /**
  10455. * Creates a dynamic texture
  10456. * @param width defines the width of the texture
  10457. * @param height defines the height of the texture
  10458. * @param generateMipMaps defines if the engine should generate the mip levels
  10459. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10460. * @returns the dynamic texture inside an InternalTexture
  10461. */
  10462. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10463. /**
  10464. * Update the content of a dynamic texture
  10465. * @param texture defines the texture to update
  10466. * @param canvas defines the canvas containing the source
  10467. * @param invertY defines if data must be stored with Y axis inverted
  10468. * @param premulAlpha defines if alpha is stored as premultiplied
  10469. * @param format defines the format of the data
  10470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10471. */
  10472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10473. }
  10474. }
  10475. }
  10476. declare module "babylonjs/Misc/canvasGenerator" {
  10477. /**
  10478. * Helper class used to generate a canvas to manipulate images
  10479. */
  10480. export class CanvasGenerator {
  10481. /**
  10482. * Create a new canvas (or offscreen canvas depending on the context)
  10483. * @param width defines the expected width
  10484. * @param height defines the expected height
  10485. * @return a new canvas or offscreen canvas
  10486. */
  10487. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10488. }
  10489. }
  10490. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10491. import { Scene } from "babylonjs/scene";
  10492. import { Texture } from "babylonjs/Materials/Textures/texture";
  10493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10494. /**
  10495. * A class extending Texture allowing drawing on a texture
  10496. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10497. */
  10498. export class DynamicTexture extends Texture {
  10499. private _generateMipMaps;
  10500. private _canvas;
  10501. private _context;
  10502. private _engine;
  10503. /**
  10504. * Creates a DynamicTexture
  10505. * @param name defines the name of the texture
  10506. * @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
  10507. * @param scene defines the scene where you want the texture
  10508. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10509. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10510. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10511. */
  10512. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10513. /**
  10514. * Get the current class name of the texture useful for serialization or dynamic coding.
  10515. * @returns "DynamicTexture"
  10516. */
  10517. getClassName(): string;
  10518. /**
  10519. * Gets the current state of canRescale
  10520. */
  10521. get canRescale(): boolean;
  10522. private _recreate;
  10523. /**
  10524. * Scales the texture
  10525. * @param ratio the scale factor to apply to both width and height
  10526. */
  10527. scale(ratio: number): void;
  10528. /**
  10529. * Resizes the texture
  10530. * @param width the new width
  10531. * @param height the new height
  10532. */
  10533. scaleTo(width: number, height: number): void;
  10534. /**
  10535. * Gets the context of the canvas used by the texture
  10536. * @returns the canvas context of the dynamic texture
  10537. */
  10538. getContext(): CanvasRenderingContext2D;
  10539. /**
  10540. * Clears the texture
  10541. */
  10542. clear(): void;
  10543. /**
  10544. * Updates the texture
  10545. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10546. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10547. */
  10548. update(invertY?: boolean, premulAlpha?: boolean): void;
  10549. /**
  10550. * Draws text onto the texture
  10551. * @param text defines the text to be drawn
  10552. * @param x defines the placement of the text from the left
  10553. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10554. * @param font defines the font to be used with font-style, font-size, font-name
  10555. * @param color defines the color used for the text
  10556. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10557. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10558. * @param update defines whether texture is immediately update (default is true)
  10559. */
  10560. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10561. /**
  10562. * Clones the texture
  10563. * @returns the clone of the texture.
  10564. */
  10565. clone(): DynamicTexture;
  10566. /**
  10567. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10568. * @returns a serialized dynamic texture object
  10569. */
  10570. serialize(): any;
  10571. /** @hidden */
  10572. _rebuild(): void;
  10573. }
  10574. }
  10575. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10576. import { Nullable } from "babylonjs/types";
  10577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10578. import { Scene } from "babylonjs/scene";
  10579. module "babylonjs/Engines/engine" {
  10580. interface Engine {
  10581. /**
  10582. * Creates a raw texture
  10583. * @param data defines the data to store in the texture
  10584. * @param width defines the width of the texture
  10585. * @param height defines the height of the texture
  10586. * @param format defines the format of the data
  10587. * @param generateMipMaps defines if the engine should generate the mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10590. * @param compression defines the compression used (null by default)
  10591. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10592. * @returns the raw texture inside an InternalTexture
  10593. */
  10594. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10595. /**
  10596. * Update a raw texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store in the texture
  10599. * @param format defines the format of the data
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store in the texture
  10607. * @param format defines the format of the data
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the compression used (null by default)
  10610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10611. */
  10612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10613. /**
  10614. * Creates a new raw cube texture
  10615. * @param data defines the array of data to use to create each face
  10616. * @param size defines the size of the textures
  10617. * @param format defines the format of the data
  10618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10619. * @param generateMipMaps defines if the engine should generate the mip levels
  10620. * @param invertY defines if data must be stored with Y axis inverted
  10621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10622. * @param compression defines the compression used (null by default)
  10623. * @returns the cube texture as an InternalTexture
  10624. */
  10625. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10626. /**
  10627. * Update a raw cube texture
  10628. * @param texture defines the texture to udpdate
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10632. * @param invertY defines if data must be stored with Y axis inverted
  10633. */
  10634. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10635. /**
  10636. * Update a raw cube texture
  10637. * @param texture defines the texture to udpdate
  10638. * @param data defines the data to store
  10639. * @param format defines the data format
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the compression used (null by default)
  10643. */
  10644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10645. /**
  10646. * Update a raw cube texture
  10647. * @param texture defines the texture to udpdate
  10648. * @param data defines the data to store
  10649. * @param format defines the data format
  10650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10651. * @param invertY defines if data must be stored with Y axis inverted
  10652. * @param compression defines the compression used (null by default)
  10653. * @param level defines which level of the texture to update
  10654. */
  10655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10656. /**
  10657. * Creates a new raw cube texture from a specified url
  10658. * @param url defines the url where the data is located
  10659. * @param scene defines the current scene
  10660. * @param size defines the size of the textures
  10661. * @param format defines the format of the data
  10662. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10663. * @param noMipmap defines if the engine should avoid generating the mip levels
  10664. * @param callback defines a callback used to extract texture data from loaded data
  10665. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10666. * @param onLoad defines a callback called when texture is loaded
  10667. * @param onError defines a callback called if there is an error
  10668. * @returns the cube texture as an InternalTexture
  10669. */
  10670. 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;
  10671. /**
  10672. * Creates a new raw cube texture from a specified url
  10673. * @param url defines the url where the data is located
  10674. * @param scene defines the current scene
  10675. * @param size defines the size of the textures
  10676. * @param format defines the format of the data
  10677. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10678. * @param noMipmap defines if the engine should avoid generating the mip levels
  10679. * @param callback defines a callback used to extract texture data from loaded data
  10680. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10681. * @param onLoad defines a callback called when texture is loaded
  10682. * @param onError defines a callback called if there is an error
  10683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10684. * @param invertY defines if data must be stored with Y axis inverted
  10685. * @returns the cube texture as an InternalTexture
  10686. */
  10687. 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;
  10688. /**
  10689. * Creates a new raw 3D texture
  10690. * @param data defines the data used to create the texture
  10691. * @param width defines the width of the texture
  10692. * @param height defines the height of the texture
  10693. * @param depth defines the depth of the texture
  10694. * @param format defines the format of the texture
  10695. * @param generateMipMaps defines if the engine must generate mip levels
  10696. * @param invertY defines if data must be stored with Y axis inverted
  10697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10698. * @param compression defines the compressed used (can be null)
  10699. * @param textureType defines the compressed used (can be null)
  10700. * @returns a new raw 3D texture (stored in an InternalTexture)
  10701. */
  10702. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10703. /**
  10704. * Update a raw 3D texture
  10705. * @param texture defines the texture to update
  10706. * @param data defines the data to store
  10707. * @param format defines the data format
  10708. * @param invertY defines if data must be stored with Y axis inverted
  10709. */
  10710. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10711. /**
  10712. * Update a raw 3D texture
  10713. * @param texture defines the texture to update
  10714. * @param data defines the data to store
  10715. * @param format defines the data format
  10716. * @param invertY defines if data must be stored with Y axis inverted
  10717. * @param compression defines the used compression (can be null)
  10718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10719. */
  10720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10721. /**
  10722. * Creates a new raw 2D array texture
  10723. * @param data defines the data used to create the texture
  10724. * @param width defines the width of the texture
  10725. * @param height defines the height of the texture
  10726. * @param depth defines the number of layers of the texture
  10727. * @param format defines the format of the texture
  10728. * @param generateMipMaps defines if the engine must generate mip levels
  10729. * @param invertY defines if data must be stored with Y axis inverted
  10730. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10731. * @param compression defines the compressed used (can be null)
  10732. * @param textureType defines the compressed used (can be null)
  10733. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10734. */
  10735. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10736. /**
  10737. * Update a raw 2D array texture
  10738. * @param texture defines the texture to update
  10739. * @param data defines the data to store
  10740. * @param format defines the data format
  10741. * @param invertY defines if data must be stored with Y axis inverted
  10742. */
  10743. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10744. /**
  10745. * Update a raw 2D array texture
  10746. * @param texture defines the texture to update
  10747. * @param data defines the data to store
  10748. * @param format defines the data format
  10749. * @param invertY defines if data must be stored with Y axis inverted
  10750. * @param compression defines the used compression (can be null)
  10751. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10752. */
  10753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10754. }
  10755. }
  10756. }
  10757. declare module "babylonjs/Materials/Textures/rawTexture" {
  10758. import { Scene } from "babylonjs/scene";
  10759. import { Texture } from "babylonjs/Materials/Textures/texture";
  10760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10761. /**
  10762. * Raw texture can help creating a texture directly from an array of data.
  10763. * This can be super useful if you either get the data from an uncompressed source or
  10764. * if you wish to create your texture pixel by pixel.
  10765. */
  10766. export class RawTexture extends Texture {
  10767. /**
  10768. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10769. */
  10770. format: number;
  10771. private _engine;
  10772. /**
  10773. * Instantiates a new RawTexture.
  10774. * Raw texture can help creating a texture directly from an array of data.
  10775. * This can be super useful if you either get the data from an uncompressed source or
  10776. * if you wish to create your texture pixel by pixel.
  10777. * @param data define the array of data to use to create the texture
  10778. * @param width define the width of the texture
  10779. * @param height define the height of the texture
  10780. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10781. * @param scene define the scene the texture belongs to
  10782. * @param generateMipMaps define whether mip maps should be generated or not
  10783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10786. */
  10787. constructor(data: ArrayBufferView, width: number, height: number,
  10788. /**
  10789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10790. */
  10791. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10792. /**
  10793. * Updates the texture underlying data.
  10794. * @param data Define the new data of the texture
  10795. */
  10796. update(data: ArrayBufferView): void;
  10797. /**
  10798. * Creates a luminance texture from some data.
  10799. * @param data Define the texture data
  10800. * @param width Define the width of the texture
  10801. * @param height Define the height of the texture
  10802. * @param scene Define the scene the texture belongs to
  10803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10806. * @returns the luminance texture
  10807. */
  10808. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10809. /**
  10810. * Creates a luminance alpha texture from some data.
  10811. * @param data Define the texture data
  10812. * @param width Define the width of the texture
  10813. * @param height Define the height of the texture
  10814. * @param scene Define the scene the texture belongs to
  10815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10818. * @returns the luminance alpha texture
  10819. */
  10820. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10821. /**
  10822. * Creates an alpha texture from some data.
  10823. * @param data Define the texture data
  10824. * @param width Define the width of the texture
  10825. * @param height Define the height of the texture
  10826. * @param scene Define the scene the texture belongs to
  10827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10830. * @returns the alpha texture
  10831. */
  10832. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10833. /**
  10834. * Creates a RGB texture from some data.
  10835. * @param data Define the texture data
  10836. * @param width Define the width of the texture
  10837. * @param height Define the height of the texture
  10838. * @param scene Define the scene the texture belongs to
  10839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10843. * @returns the RGB alpha texture
  10844. */
  10845. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10846. /**
  10847. * Creates a RGBA texture from some data.
  10848. * @param data Define the texture data
  10849. * @param width Define the width of the texture
  10850. * @param height Define the height of the texture
  10851. * @param scene Define the scene the texture belongs to
  10852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10856. * @returns the RGBA texture
  10857. */
  10858. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10859. /**
  10860. * Creates a R texture from some data.
  10861. * @param data Define the texture data
  10862. * @param width Define the width of the texture
  10863. * @param height Define the height of the texture
  10864. * @param scene Define the scene the texture belongs to
  10865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10869. * @returns the R texture
  10870. */
  10871. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10872. }
  10873. }
  10874. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10875. import { Scene } from "babylonjs/scene";
  10876. import { ISceneComponent } from "babylonjs/sceneComponent";
  10877. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10878. module "babylonjs/abstractScene" {
  10879. interface AbstractScene {
  10880. /**
  10881. * The list of procedural textures added to the scene
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. */
  10884. proceduralTextures: Array<ProceduralTexture>;
  10885. }
  10886. }
  10887. /**
  10888. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10889. * in a given scene.
  10890. */
  10891. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10892. /**
  10893. * The component name helpfull to identify the component in the list of scene components.
  10894. */
  10895. readonly name: string;
  10896. /**
  10897. * The scene the component belongs to.
  10898. */
  10899. scene: Scene;
  10900. /**
  10901. * Creates a new instance of the component for the given scene
  10902. * @param scene Defines the scene to register the component in
  10903. */
  10904. constructor(scene: Scene);
  10905. /**
  10906. * Registers the component in a given scene
  10907. */
  10908. register(): void;
  10909. /**
  10910. * Rebuilds the elements related to this component in case of
  10911. * context lost for instance.
  10912. */
  10913. rebuild(): void;
  10914. /**
  10915. * Disposes the component and the associated ressources.
  10916. */
  10917. dispose(): void;
  10918. private _beforeClear;
  10919. }
  10920. }
  10921. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10923. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10924. module "babylonjs/Engines/thinEngine" {
  10925. interface ThinEngine {
  10926. /**
  10927. * Creates a new render target cube texture
  10928. * @param size defines the size of the texture
  10929. * @param options defines the options used to create the texture
  10930. * @returns a new render target cube texture stored in an InternalTexture
  10931. */
  10932. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10933. }
  10934. }
  10935. }
  10936. declare module "babylonjs/Shaders/procedural.vertex" {
  10937. /** @hidden */
  10938. export var proceduralVertexShader: {
  10939. name: string;
  10940. shader: string;
  10941. };
  10942. }
  10943. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10944. import { Observable } from "babylonjs/Misc/observable";
  10945. import { Nullable } from "babylonjs/types";
  10946. import { Scene } from "babylonjs/scene";
  10947. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10948. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10949. import { Effect } from "babylonjs/Materials/effect";
  10950. import { Texture } from "babylonjs/Materials/Textures/texture";
  10951. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10952. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10953. import "babylonjs/Shaders/procedural.vertex";
  10954. /**
  10955. * 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.
  10956. * This is the base class of any Procedural texture and contains most of the shareable code.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10958. */
  10959. export class ProceduralTexture extends Texture {
  10960. isCube: boolean;
  10961. /**
  10962. * Define if the texture is enabled or not (disabled texture will not render)
  10963. */
  10964. isEnabled: boolean;
  10965. /**
  10966. * Define if the texture must be cleared before rendering (default is true)
  10967. */
  10968. autoClear: boolean;
  10969. /**
  10970. * Callback called when the texture is generated
  10971. */
  10972. onGenerated: () => void;
  10973. /**
  10974. * Event raised when the texture is generated
  10975. */
  10976. onGeneratedObservable: Observable<ProceduralTexture>;
  10977. /** @hidden */
  10978. _generateMipMaps: boolean;
  10979. /** @hidden **/
  10980. _effect: Effect;
  10981. /** @hidden */
  10982. _textures: {
  10983. [key: string]: Texture;
  10984. };
  10985. private _size;
  10986. private _currentRefreshId;
  10987. private _frameId;
  10988. private _refreshRate;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _uniforms;
  10992. private _samplers;
  10993. private _fragment;
  10994. private _floats;
  10995. private _ints;
  10996. private _floatsArrays;
  10997. private _colors3;
  10998. private _colors4;
  10999. private _vectors2;
  11000. private _vectors3;
  11001. private _matrices;
  11002. private _fallbackTexture;
  11003. private _fallbackTextureUsed;
  11004. private _engine;
  11005. private _cachedDefines;
  11006. private _contentUpdateId;
  11007. private _contentData;
  11008. /**
  11009. * Instantiates a new procedural texture.
  11010. * 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.
  11011. * This is the base class of any Procedural texture and contains most of the shareable code.
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11013. * @param name Define the name of the texture
  11014. * @param size Define the size of the texture to create
  11015. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11016. * @param scene Define the scene the texture belongs to
  11017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11018. * @param generateMipMaps Define if the texture should creates mip maps or not
  11019. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11020. */
  11021. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11022. /**
  11023. * The effect that is created when initializing the post process.
  11024. * @returns The created effect corresponding the the postprocess.
  11025. */
  11026. getEffect(): Effect;
  11027. /**
  11028. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11029. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11030. */
  11031. getContent(): Nullable<ArrayBufferView>;
  11032. private _createIndexBuffer;
  11033. /** @hidden */
  11034. _rebuild(): void;
  11035. /**
  11036. * Resets the texture in order to recreate its associated resources.
  11037. * This can be called in case of context loss
  11038. */
  11039. reset(): void;
  11040. protected _getDefines(): string;
  11041. /**
  11042. * Is the texture ready to be used ? (rendered at least once)
  11043. * @returns true if ready, otherwise, false.
  11044. */
  11045. isReady(): boolean;
  11046. /**
  11047. * Resets the refresh counter of the texture and start bak from scratch.
  11048. * Could be useful to regenerate the texture if it is setup to render only once.
  11049. */
  11050. resetRefreshCounter(): void;
  11051. /**
  11052. * Set the fragment shader to use in order to render the texture.
  11053. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11054. */
  11055. setFragment(fragment: any): void;
  11056. /**
  11057. * Define the refresh rate of the texture or the rendering frequency.
  11058. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11059. */
  11060. get refreshRate(): number;
  11061. set refreshRate(value: number);
  11062. /** @hidden */
  11063. _shouldRender(): boolean;
  11064. /**
  11065. * Get the size the texture is rendering at.
  11066. * @returns the size (texture is always squared)
  11067. */
  11068. getRenderSize(): number;
  11069. /**
  11070. * Resize the texture to new value.
  11071. * @param size Define the new size the texture should have
  11072. * @param generateMipMaps Define whether the new texture should create mip maps
  11073. */
  11074. resize(size: number, generateMipMaps: boolean): void;
  11075. private _checkUniform;
  11076. /**
  11077. * Set a texture in the shader program used to render.
  11078. * @param name Define the name of the uniform samplers as defined in the shader
  11079. * @param texture Define the texture to bind to this sampler
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setTexture(name: string, texture: Texture): ProceduralTexture;
  11083. /**
  11084. * Set a float in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setFloat(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set a int in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setInt(name: string, value: number): ProceduralTexture;
  11097. /**
  11098. * Set an array of floats in the shader.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setFloats(name: string, value: number[]): ProceduralTexture;
  11104. /**
  11105. * Set a vec3 in the shader from a Color3.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor3(name: string, value: Color3): ProceduralTexture;
  11111. /**
  11112. * Set a vec4 in the shader from a Color4.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setColor4(name: string, value: Color4): ProceduralTexture;
  11118. /**
  11119. * Set a vec2 in the shader from a Vector2.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector2(name: string, value: Vector2): ProceduralTexture;
  11125. /**
  11126. * Set a vec3 in the shader from a Vector3.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setVector3(name: string, value: Vector3): ProceduralTexture;
  11132. /**
  11133. * Set a mat4 in the shader from a MAtrix.
  11134. * @param name Define the name of the uniform as defined in the shader
  11135. * @param value Define the value to give to the uniform
  11136. * @return the texture itself allowing "fluent" like uniform updates
  11137. */
  11138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11139. /**
  11140. * Render the texture to its associated render target.
  11141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11142. */
  11143. render(useCameraPostProcess?: boolean): void;
  11144. /**
  11145. * Clone the texture.
  11146. * @returns the cloned texture
  11147. */
  11148. clone(): ProceduralTexture;
  11149. /**
  11150. * Dispose the texture and release its asoociated resources.
  11151. */
  11152. dispose(): void;
  11153. }
  11154. }
  11155. declare module "babylonjs/Particles/baseParticleSystem" {
  11156. import { Nullable } from "babylonjs/types";
  11157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11160. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11161. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11162. import { Scene } from "babylonjs/scene";
  11163. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11164. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11165. import { Texture } from "babylonjs/Materials/Textures/texture";
  11166. import { Color4 } from "babylonjs/Maths/math.color";
  11167. import { Animation } from "babylonjs/Animations/animation";
  11168. /**
  11169. * This represents the base class for particle system in Babylon.
  11170. * 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.
  11171. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11172. * @example https://doc.babylonjs.com/babylon101/particles
  11173. */
  11174. export class BaseParticleSystem {
  11175. /**
  11176. * Source color is added to the destination color without alpha affecting the result
  11177. */
  11178. static BLENDMODE_ONEONE: number;
  11179. /**
  11180. * Blend current color and particle color using particle’s alpha
  11181. */
  11182. static BLENDMODE_STANDARD: number;
  11183. /**
  11184. * Add current color and particle color multiplied by particle’s alpha
  11185. */
  11186. static BLENDMODE_ADD: number;
  11187. /**
  11188. * Multiply current color with particle color
  11189. */
  11190. static BLENDMODE_MULTIPLY: number;
  11191. /**
  11192. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11193. */
  11194. static BLENDMODE_MULTIPLYADD: number;
  11195. /**
  11196. * List of animations used by the particle system.
  11197. */
  11198. animations: Animation[];
  11199. /**
  11200. * The id of the Particle system.
  11201. */
  11202. id: string;
  11203. /**
  11204. * The friendly name of the Particle system.
  11205. */
  11206. name: string;
  11207. /**
  11208. * The rendering group used by the Particle system to chose when to render.
  11209. */
  11210. renderingGroupId: number;
  11211. /**
  11212. * The emitter represents the Mesh or position we are attaching the particle system to.
  11213. */
  11214. emitter: Nullable<AbstractMesh | Vector3>;
  11215. /**
  11216. * The maximum number of particles to emit per frame
  11217. */
  11218. emitRate: number;
  11219. /**
  11220. * If you want to launch only a few particles at once, that can be done, as well.
  11221. */
  11222. manualEmitCount: number;
  11223. /**
  11224. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11225. */
  11226. updateSpeed: number;
  11227. /**
  11228. * The amount of time the particle system is running (depends of the overall update speed).
  11229. */
  11230. targetStopDuration: number;
  11231. /**
  11232. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11233. */
  11234. disposeOnStop: boolean;
  11235. /**
  11236. * Minimum power of emitting particles.
  11237. */
  11238. minEmitPower: number;
  11239. /**
  11240. * Maximum power of emitting particles.
  11241. */
  11242. maxEmitPower: number;
  11243. /**
  11244. * Minimum life time of emitting particles.
  11245. */
  11246. minLifeTime: number;
  11247. /**
  11248. * Maximum life time of emitting particles.
  11249. */
  11250. maxLifeTime: number;
  11251. /**
  11252. * Minimum Size of emitting particles.
  11253. */
  11254. minSize: number;
  11255. /**
  11256. * Maximum Size of emitting particles.
  11257. */
  11258. maxSize: number;
  11259. /**
  11260. * Minimum scale of emitting particles on X axis.
  11261. */
  11262. minScaleX: number;
  11263. /**
  11264. * Maximum scale of emitting particles on X axis.
  11265. */
  11266. maxScaleX: number;
  11267. /**
  11268. * Minimum scale of emitting particles on Y axis.
  11269. */
  11270. minScaleY: number;
  11271. /**
  11272. * Maximum scale of emitting particles on Y axis.
  11273. */
  11274. maxScaleY: number;
  11275. /**
  11276. * Gets or sets the minimal initial rotation in radians.
  11277. */
  11278. minInitialRotation: number;
  11279. /**
  11280. * Gets or sets the maximal initial rotation in radians.
  11281. */
  11282. maxInitialRotation: number;
  11283. /**
  11284. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11285. */
  11286. minAngularSpeed: number;
  11287. /**
  11288. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11289. */
  11290. maxAngularSpeed: number;
  11291. /**
  11292. * The texture used to render each particle. (this can be a spritesheet)
  11293. */
  11294. particleTexture: Nullable<Texture>;
  11295. /**
  11296. * The layer mask we are rendering the particles through.
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * This can help using your own shader to render the particle system.
  11301. * The according effect will be created
  11302. */
  11303. customShader: any;
  11304. /**
  11305. * By default particle system starts as soon as they are created. This prevents the
  11306. * automatic start to happen and let you decide when to start emitting particles.
  11307. */
  11308. preventAutoStart: boolean;
  11309. private _noiseTexture;
  11310. /**
  11311. * Gets or sets a texture used to add random noise to particle positions
  11312. */
  11313. get noiseTexture(): Nullable<ProceduralTexture>;
  11314. set noiseTexture(value: Nullable<ProceduralTexture>);
  11315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11316. noiseStrength: Vector3;
  11317. /**
  11318. * Callback triggered when the particle animation is ending.
  11319. */
  11320. onAnimationEnd: Nullable<() => void>;
  11321. /**
  11322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11323. */
  11324. blendMode: number;
  11325. /**
  11326. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11327. * to override the particles.
  11328. */
  11329. forceDepthWrite: boolean;
  11330. /** 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 */
  11331. preWarmCycles: number;
  11332. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11333. preWarmStepOffset: number;
  11334. /**
  11335. * 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)
  11336. */
  11337. spriteCellChangeSpeed: number;
  11338. /**
  11339. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11340. */
  11341. startSpriteCellID: number;
  11342. /**
  11343. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11344. */
  11345. endSpriteCellID: number;
  11346. /**
  11347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11348. */
  11349. spriteCellWidth: number;
  11350. /**
  11351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11352. */
  11353. spriteCellHeight: number;
  11354. /**
  11355. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11356. */
  11357. spriteRandomStartCell: boolean;
  11358. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11359. translationPivot: Vector2;
  11360. /** @hidden */
  11361. protected _isAnimationSheetEnabled: boolean;
  11362. /**
  11363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11364. */
  11365. beginAnimationOnStart: boolean;
  11366. /**
  11367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11368. */
  11369. beginAnimationFrom: number;
  11370. /**
  11371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11372. */
  11373. beginAnimationTo: number;
  11374. /**
  11375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11376. */
  11377. beginAnimationLoop: boolean;
  11378. /**
  11379. * Gets or sets a world offset applied to all particles
  11380. */
  11381. worldOffset: Vector3;
  11382. /**
  11383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11384. */
  11385. get isAnimationSheetEnabled(): boolean;
  11386. set isAnimationSheetEnabled(value: boolean);
  11387. /**
  11388. * Get hosting scene
  11389. * @returns the scene
  11390. */
  11391. getScene(): Scene;
  11392. /**
  11393. * You can use gravity if you want to give an orientation to your particles.
  11394. */
  11395. gravity: Vector3;
  11396. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11397. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11399. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11400. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11402. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11403. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11404. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11405. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11406. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11408. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11409. /**
  11410. * Defines the delay in milliseconds before starting the system (0 by default)
  11411. */
  11412. startDelay: number;
  11413. /**
  11414. * Gets the current list of drag gradients.
  11415. * You must use addDragGradient and removeDragGradient to udpate this list
  11416. * @returns the list of drag gradients
  11417. */
  11418. getDragGradients(): Nullable<Array<FactorGradient>>;
  11419. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11420. limitVelocityDamping: number;
  11421. /**
  11422. * Gets the current list of limit velocity gradients.
  11423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11424. * @returns the list of limit velocity gradients
  11425. */
  11426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11427. /**
  11428. * Gets the current list of color gradients.
  11429. * You must use addColorGradient and removeColorGradient to udpate this list
  11430. * @returns the list of color gradients
  11431. */
  11432. getColorGradients(): Nullable<Array<ColorGradient>>;
  11433. /**
  11434. * Gets the current list of size gradients.
  11435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11436. * @returns the list of size gradients
  11437. */
  11438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11439. /**
  11440. * Gets the current list of color remap gradients.
  11441. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11442. * @returns the list of color remap gradients
  11443. */
  11444. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11445. /**
  11446. * Gets the current list of alpha remap gradients.
  11447. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11448. * @returns the list of alpha remap gradients
  11449. */
  11450. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11451. /**
  11452. * Gets the current list of life time gradients.
  11453. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11454. * @returns the list of life time gradients
  11455. */
  11456. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of angular speed gradients.
  11459. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11460. * @returns the list of angular speed gradients
  11461. */
  11462. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11463. /**
  11464. * Gets the current list of velocity gradients.
  11465. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11466. * @returns the list of velocity gradients
  11467. */
  11468. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of start size gradients.
  11471. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11472. * @returns the list of start size gradients
  11473. */
  11474. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of emit rate gradients.
  11477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11478. * @returns the list of emit rate gradients
  11479. */
  11480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11484. */
  11485. get direction1(): Vector3;
  11486. set direction1(value: Vector3);
  11487. /**
  11488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11490. */
  11491. get direction2(): Vector3;
  11492. set direction2(value: Vector3);
  11493. /**
  11494. * 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.
  11495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11496. */
  11497. get minEmitBox(): Vector3;
  11498. set minEmitBox(value: Vector3);
  11499. /**
  11500. * 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.
  11501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11502. */
  11503. get maxEmitBox(): Vector3;
  11504. set maxEmitBox(value: Vector3);
  11505. /**
  11506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11507. */
  11508. color1: Color4;
  11509. /**
  11510. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11511. */
  11512. color2: Color4;
  11513. /**
  11514. * Color the particle will have at the end of its lifetime
  11515. */
  11516. colorDead: Color4;
  11517. /**
  11518. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11519. */
  11520. textureMask: Color4;
  11521. /**
  11522. * The particle emitter type defines the emitter used by the particle system.
  11523. * It can be for example box, sphere, or cone...
  11524. */
  11525. particleEmitterType: IParticleEmitterType;
  11526. /** @hidden */
  11527. _isSubEmitter: boolean;
  11528. /**
  11529. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11530. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11531. */
  11532. billboardMode: number;
  11533. protected _isBillboardBased: boolean;
  11534. /**
  11535. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11536. */
  11537. get isBillboardBased(): boolean;
  11538. set isBillboardBased(value: boolean);
  11539. /**
  11540. * The scene the particle system belongs to.
  11541. */
  11542. protected _scene: Scene;
  11543. /**
  11544. * Local cache of defines for image processing.
  11545. */
  11546. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11547. /**
  11548. * Default configuration related to image processing available in the standard Material.
  11549. */
  11550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11551. /**
  11552. * Gets the image processing configuration used either in this material.
  11553. */
  11554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11555. /**
  11556. * Sets the Default image processing configuration used either in the this material.
  11557. *
  11558. * If sets to null, the scene one is in use.
  11559. */
  11560. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11561. /**
  11562. * Attaches a new image processing configuration to the Standard Material.
  11563. * @param configuration
  11564. */
  11565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11566. /** @hidden */
  11567. protected _reset(): void;
  11568. /** @hidden */
  11569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11570. /**
  11571. * Instantiates a particle system.
  11572. * 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.
  11573. * @param name The name of the particle system
  11574. */
  11575. constructor(name: string);
  11576. /**
  11577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11580. * @returns the emitter
  11581. */
  11582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11583. /**
  11584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11585. * @param radius The radius of the hemisphere to emit from
  11586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11590. /**
  11591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11594. * @returns the emitter
  11595. */
  11596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11597. /**
  11598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11599. * @param radius The radius of the sphere to emit from
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11602. * @returns the emitter
  11603. */
  11604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11605. /**
  11606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11607. * @param radius The radius of the emission cylinder
  11608. * @param height The height of the emission cylinder
  11609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11611. * @returns the emitter
  11612. */
  11613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11614. /**
  11615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11616. * @param radius The radius of the cylinder to emit from
  11617. * @param height The height of the emission cylinder
  11618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11621. * @returns the emitter
  11622. */
  11623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11624. /**
  11625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11626. * @param radius The radius of the cone to emit from
  11627. * @param angle The base angle of the cone
  11628. * @returns the emitter
  11629. */
  11630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11631. /**
  11632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11637. * @returns the emitter
  11638. */
  11639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11640. }
  11641. }
  11642. declare module "babylonjs/Particles/subEmitter" {
  11643. import { Scene } from "babylonjs/scene";
  11644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11645. /**
  11646. * Type of sub emitter
  11647. */
  11648. export enum SubEmitterType {
  11649. /**
  11650. * Attached to the particle over it's lifetime
  11651. */
  11652. ATTACHED = 0,
  11653. /**
  11654. * Created when the particle dies
  11655. */
  11656. END = 1
  11657. }
  11658. /**
  11659. * Sub emitter class used to emit particles from an existing particle
  11660. */
  11661. export class SubEmitter {
  11662. /**
  11663. * the particle system to be used by the sub emitter
  11664. */
  11665. particleSystem: ParticleSystem;
  11666. /**
  11667. * Type of the submitter (Default: END)
  11668. */
  11669. type: SubEmitterType;
  11670. /**
  11671. * 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)
  11672. * Note: This only is supported when using an emitter of type Mesh
  11673. */
  11674. inheritDirection: boolean;
  11675. /**
  11676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11677. */
  11678. inheritedVelocityAmount: number;
  11679. /**
  11680. * Creates a sub emitter
  11681. * @param particleSystem the particle system to be used by the sub emitter
  11682. */
  11683. constructor(
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem);
  11688. /**
  11689. * Clones the sub emitter
  11690. * @returns the cloned sub emitter
  11691. */
  11692. clone(): SubEmitter;
  11693. /**
  11694. * Serialize current object to a JSON object
  11695. * @returns the serialized object
  11696. */
  11697. serialize(): any;
  11698. /** @hidden */
  11699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11700. /**
  11701. * Creates a new SubEmitter from a serialized JSON version
  11702. * @param serializationObject defines the JSON object to read from
  11703. * @param scene defines the hosting scene
  11704. * @param rootUrl defines the rootUrl for data loading
  11705. * @returns a new SubEmitter
  11706. */
  11707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11708. /** Release associated resources */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11713. /** @hidden */
  11714. export var imageProcessingDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11720. /** @hidden */
  11721. export var imageProcessingFunctions: {
  11722. name: string;
  11723. shader: string;
  11724. };
  11725. }
  11726. declare module "babylonjs/Shaders/particles.fragment" {
  11727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11729. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11732. /** @hidden */
  11733. export var particlesPixelShader: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/particles.vertex" {
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11741. /** @hidden */
  11742. export var particlesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Particles/particleSystem" {
  11748. import { Nullable } from "babylonjs/types";
  11749. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11752. import { Effect } from "babylonjs/Materials/effect";
  11753. import { Scene, IDisposable } from "babylonjs/scene";
  11754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11755. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11756. import { Particle } from "babylonjs/Particles/particle";
  11757. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11759. import "babylonjs/Shaders/particles.fragment";
  11760. import "babylonjs/Shaders/particles.vertex";
  11761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11762. /**
  11763. * This represents a particle system in Babylon.
  11764. * 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.
  11765. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11766. * @example https://doc.babylonjs.com/babylon101/particles
  11767. */
  11768. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11769. /**
  11770. * Billboard mode will only apply to Y axis
  11771. */
  11772. static readonly BILLBOARDMODE_Y: number;
  11773. /**
  11774. * Billboard mode will apply to all axes
  11775. */
  11776. static readonly BILLBOARDMODE_ALL: number;
  11777. /**
  11778. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11779. */
  11780. static readonly BILLBOARDMODE_STRETCHED: number;
  11781. /**
  11782. * This function can be defined to provide custom update for active particles.
  11783. * This function will be called instead of regular update (age, position, color, etc.).
  11784. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11785. */
  11786. updateFunction: (particles: Particle[]) => void;
  11787. private _emitterWorldMatrix;
  11788. /**
  11789. * This function can be defined to specify initial direction for every new particle.
  11790. * It by default use the emitterType defined function
  11791. */
  11792. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11793. /**
  11794. * This function can be defined to specify initial position for every new particle.
  11795. * It by default use the emitterType defined function
  11796. */
  11797. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11798. /**
  11799. * @hidden
  11800. */
  11801. _inheritedVelocityOffset: Vector3;
  11802. /**
  11803. * An event triggered when the system is disposed
  11804. */
  11805. onDisposeObservable: Observable<ParticleSystem>;
  11806. private _onDisposeObserver;
  11807. /**
  11808. * Sets a callback that will be triggered when the system is disposed
  11809. */
  11810. set onDispose(callback: () => void);
  11811. private _particles;
  11812. private _epsilon;
  11813. private _capacity;
  11814. private _stockParticles;
  11815. private _newPartsExcess;
  11816. private _vertexData;
  11817. private _vertexBuffer;
  11818. private _vertexBuffers;
  11819. private _spriteBuffer;
  11820. private _indexBuffer;
  11821. private _effect;
  11822. private _customEffect;
  11823. private _cachedDefines;
  11824. private _scaledColorStep;
  11825. private _colorDiff;
  11826. private _scaledDirection;
  11827. private _scaledGravity;
  11828. private _currentRenderId;
  11829. private _alive;
  11830. private _useInstancing;
  11831. private _started;
  11832. private _stopped;
  11833. private _actualFrame;
  11834. private _scaledUpdateSpeed;
  11835. private _vertexBufferSize;
  11836. /** @hidden */
  11837. _currentEmitRateGradient: Nullable<FactorGradient>;
  11838. /** @hidden */
  11839. _currentEmitRate1: number;
  11840. /** @hidden */
  11841. _currentEmitRate2: number;
  11842. /** @hidden */
  11843. _currentStartSizeGradient: Nullable<FactorGradient>;
  11844. /** @hidden */
  11845. _currentStartSize1: number;
  11846. /** @hidden */
  11847. _currentStartSize2: number;
  11848. private readonly _rawTextureWidth;
  11849. private _rampGradientsTexture;
  11850. private _useRampGradients;
  11851. /** Gets or sets a boolean indicating that ramp gradients must be used
  11852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11853. */
  11854. get useRampGradients(): boolean;
  11855. set useRampGradients(value: boolean);
  11856. /**
  11857. * 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.
  11858. * 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: [])
  11859. */
  11860. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11861. private _subEmitters;
  11862. /**
  11863. * @hidden
  11864. * If the particle systems emitter should be disposed when the particle system is disposed
  11865. */
  11866. _disposeEmitterOnDispose: boolean;
  11867. /**
  11868. * The current active Sub-systems, this property is used by the root particle system only.
  11869. */
  11870. activeSubSystems: Array<ParticleSystem>;
  11871. private _rootParticleSystem;
  11872. /**
  11873. * Gets the current list of active particles
  11874. */
  11875. get particles(): Particle[];
  11876. /**
  11877. * Returns the string "ParticleSystem"
  11878. * @returns a string containing the class name
  11879. */
  11880. getClassName(): string;
  11881. /**
  11882. * Instantiates a particle system.
  11883. * 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.
  11884. * @param name The name of the particle system
  11885. * @param capacity The max number of particles alive at the same time
  11886. * @param scene The scene the particle system belongs to
  11887. * @param customEffect a custom effect used to change the way particles are rendered by default
  11888. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11889. * @param epsilon Offset used to render the particles
  11890. */
  11891. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11892. private _addFactorGradient;
  11893. private _removeFactorGradient;
  11894. /**
  11895. * Adds a new life time gradient
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param factor defines the life time factor to affect to the specified gradient
  11898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11899. * @returns the current particle system
  11900. */
  11901. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11902. /**
  11903. * Remove a specific life time gradient
  11904. * @param gradient defines the gradient to remove
  11905. * @returns the current particle system
  11906. */
  11907. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11908. /**
  11909. * Adds a new size gradient
  11910. * @param gradient defines the gradient to use (between 0 and 1)
  11911. * @param factor defines the size factor to affect to the specified gradient
  11912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11913. * @returns the current particle system
  11914. */
  11915. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11916. /**
  11917. * Remove a specific size gradient
  11918. * @param gradient defines the gradient to remove
  11919. * @returns the current particle system
  11920. */
  11921. removeSizeGradient(gradient: number): IParticleSystem;
  11922. /**
  11923. * Adds a new color remap gradient
  11924. * @param gradient defines the gradient to use (between 0 and 1)
  11925. * @param min defines the color remap minimal range
  11926. * @param max defines the color remap maximal range
  11927. * @returns the current particle system
  11928. */
  11929. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11930. /**
  11931. * Remove a specific color remap gradient
  11932. * @param gradient defines the gradient to remove
  11933. * @returns the current particle system
  11934. */
  11935. removeColorRemapGradient(gradient: number): IParticleSystem;
  11936. /**
  11937. * Adds a new alpha remap gradient
  11938. * @param gradient defines the gradient to use (between 0 and 1)
  11939. * @param min defines the alpha remap minimal range
  11940. * @param max defines the alpha remap maximal range
  11941. * @returns the current particle system
  11942. */
  11943. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11944. /**
  11945. * Remove a specific alpha remap gradient
  11946. * @param gradient defines the gradient to remove
  11947. * @returns the current particle system
  11948. */
  11949. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11950. /**
  11951. * Adds a new angular speed gradient
  11952. * @param gradient defines the gradient to use (between 0 and 1)
  11953. * @param factor defines the angular speed to affect to the specified gradient
  11954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11955. * @returns the current particle system
  11956. */
  11957. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11958. /**
  11959. * Remove a specific angular speed gradient
  11960. * @param gradient defines the gradient to remove
  11961. * @returns the current particle system
  11962. */
  11963. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11964. /**
  11965. * Adds a new velocity gradient
  11966. * @param gradient defines the gradient to use (between 0 and 1)
  11967. * @param factor defines the velocity to affect to the specified gradient
  11968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11969. * @returns the current particle system
  11970. */
  11971. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11972. /**
  11973. * Remove a specific velocity gradient
  11974. * @param gradient defines the gradient to remove
  11975. * @returns the current particle system
  11976. */
  11977. removeVelocityGradient(gradient: number): IParticleSystem;
  11978. /**
  11979. * Adds a new limit velocity gradient
  11980. * @param gradient defines the gradient to use (between 0 and 1)
  11981. * @param factor defines the limit velocity value to affect to the specified gradient
  11982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11983. * @returns the current particle system
  11984. */
  11985. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11986. /**
  11987. * Remove a specific limit velocity gradient
  11988. * @param gradient defines the gradient to remove
  11989. * @returns the current particle system
  11990. */
  11991. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11992. /**
  11993. * Adds a new drag gradient
  11994. * @param gradient defines the gradient to use (between 0 and 1)
  11995. * @param factor defines the drag value to affect to the specified gradient
  11996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11997. * @returns the current particle system
  11998. */
  11999. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12000. /**
  12001. * Remove a specific drag gradient
  12002. * @param gradient defines the gradient to remove
  12003. * @returns the current particle system
  12004. */
  12005. removeDragGradient(gradient: number): IParticleSystem;
  12006. /**
  12007. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12008. * @param gradient defines the gradient to use (between 0 and 1)
  12009. * @param factor defines the emit rate value to affect to the specified gradient
  12010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12011. * @returns the current particle system
  12012. */
  12013. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12014. /**
  12015. * Remove a specific emit rate gradient
  12016. * @param gradient defines the gradient to remove
  12017. * @returns the current particle system
  12018. */
  12019. removeEmitRateGradient(gradient: number): IParticleSystem;
  12020. /**
  12021. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12022. * @param gradient defines the gradient to use (between 0 and 1)
  12023. * @param factor defines the start size value to affect to the specified gradient
  12024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12025. * @returns the current particle system
  12026. */
  12027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12028. /**
  12029. * Remove a specific start size gradient
  12030. * @param gradient defines the gradient to remove
  12031. * @returns the current particle system
  12032. */
  12033. removeStartSizeGradient(gradient: number): IParticleSystem;
  12034. private _createRampGradientTexture;
  12035. /**
  12036. * Gets the current list of ramp gradients.
  12037. * You must use addRampGradient and removeRampGradient to udpate this list
  12038. * @returns the list of ramp gradients
  12039. */
  12040. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12041. /**
  12042. * Adds a new ramp gradient used to remap particle colors
  12043. * @param gradient defines the gradient to use (between 0 and 1)
  12044. * @param color defines the color to affect to the specified gradient
  12045. * @returns the current particle system
  12046. */
  12047. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12048. /**
  12049. * Remove a specific ramp gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeRampGradient(gradient: number): ParticleSystem;
  12054. /**
  12055. * Adds a new color gradient
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param color1 defines the color to affect to the specified gradient
  12058. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12059. * @returns this particle system
  12060. */
  12061. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12062. /**
  12063. * Remove a specific color gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns this particle system
  12066. */
  12067. removeColorGradient(gradient: number): IParticleSystem;
  12068. private _fetchR;
  12069. protected _reset(): void;
  12070. private _resetEffect;
  12071. private _createVertexBuffers;
  12072. private _createIndexBuffer;
  12073. /**
  12074. * Gets the maximum number of particles active at the same time.
  12075. * @returns The max number of active particles.
  12076. */
  12077. getCapacity(): number;
  12078. /**
  12079. * Gets whether there are still active particles in the system.
  12080. * @returns True if it is alive, otherwise false.
  12081. */
  12082. isAlive(): boolean;
  12083. /**
  12084. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12085. * @returns True if it has been started, otherwise false.
  12086. */
  12087. isStarted(): boolean;
  12088. private _prepareSubEmitterInternalArray;
  12089. /**
  12090. * Starts the particle system and begins to emit
  12091. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12092. */
  12093. start(delay?: number): void;
  12094. /**
  12095. * Stops the particle system.
  12096. * @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.
  12097. */
  12098. stop(stopSubEmitters?: boolean): void;
  12099. /**
  12100. * Remove all active particles
  12101. */
  12102. reset(): void;
  12103. /**
  12104. * @hidden (for internal use only)
  12105. */
  12106. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12107. /**
  12108. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12109. * Its lifetime will start back at 0.
  12110. */
  12111. recycleParticle: (particle: Particle) => void;
  12112. private _stopSubEmitters;
  12113. private _createParticle;
  12114. private _removeFromRoot;
  12115. private _emitFromParticle;
  12116. private _update;
  12117. /** @hidden */
  12118. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12119. /** @hidden */
  12120. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12121. /** @hidden */
  12122. private _getEffect;
  12123. /**
  12124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12125. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12126. */
  12127. animate(preWarmOnly?: boolean): void;
  12128. private _appendParticleVertices;
  12129. /**
  12130. * Rebuilds the particle system.
  12131. */
  12132. rebuild(): void;
  12133. /**
  12134. * Is this system ready to be used/rendered
  12135. * @return true if the system is ready
  12136. */
  12137. isReady(): boolean;
  12138. private _render;
  12139. /**
  12140. * Renders the particle system in its current state.
  12141. * @returns the current number of particles
  12142. */
  12143. render(): number;
  12144. /**
  12145. * Disposes the particle system and free the associated resources
  12146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12147. */
  12148. dispose(disposeTexture?: boolean): void;
  12149. /**
  12150. * Clones the particle system.
  12151. * @param name The name of the cloned object
  12152. * @param newEmitter The new emitter to use
  12153. * @returns the cloned particle system
  12154. */
  12155. clone(name: string, newEmitter: any): ParticleSystem;
  12156. /**
  12157. * Serializes the particle system to a JSON object.
  12158. * @returns the JSON object
  12159. */
  12160. serialize(): any;
  12161. /** @hidden */
  12162. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12163. /** @hidden */
  12164. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12165. /**
  12166. * Parses a JSON object to create a particle system.
  12167. * @param parsedParticleSystem The JSON object to parse
  12168. * @param scene The scene to create the particle system in
  12169. * @param rootUrl The root url to use to load external dependencies like texture
  12170. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12171. * @returns the Parsed particle system
  12172. */
  12173. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12174. }
  12175. }
  12176. declare module "babylonjs/Particles/particle" {
  12177. import { Nullable } from "babylonjs/types";
  12178. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12181. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12182. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12183. /**
  12184. * A particle represents one of the element emitted by a particle system.
  12185. * This is mainly define by its coordinates, direction, velocity and age.
  12186. */
  12187. export class Particle {
  12188. /**
  12189. * The particle system the particle belongs to.
  12190. */
  12191. particleSystem: ParticleSystem;
  12192. private static _Count;
  12193. /**
  12194. * Unique ID of the particle
  12195. */
  12196. id: number;
  12197. /**
  12198. * The world position of the particle in the scene.
  12199. */
  12200. position: Vector3;
  12201. /**
  12202. * The world direction of the particle in the scene.
  12203. */
  12204. direction: Vector3;
  12205. /**
  12206. * The color of the particle.
  12207. */
  12208. color: Color4;
  12209. /**
  12210. * The color change of the particle per step.
  12211. */
  12212. colorStep: Color4;
  12213. /**
  12214. * Defines how long will the life of the particle be.
  12215. */
  12216. lifeTime: number;
  12217. /**
  12218. * The current age of the particle.
  12219. */
  12220. age: number;
  12221. /**
  12222. * The current size of the particle.
  12223. */
  12224. size: number;
  12225. /**
  12226. * The current scale of the particle.
  12227. */
  12228. scale: Vector2;
  12229. /**
  12230. * The current angle of the particle.
  12231. */
  12232. angle: number;
  12233. /**
  12234. * Defines how fast is the angle changing.
  12235. */
  12236. angularSpeed: number;
  12237. /**
  12238. * Defines the cell index used by the particle to be rendered from a sprite.
  12239. */
  12240. cellIndex: number;
  12241. /**
  12242. * The information required to support color remapping
  12243. */
  12244. remapData: Vector4;
  12245. /** @hidden */
  12246. _randomCellOffset?: number;
  12247. /** @hidden */
  12248. _initialDirection: Nullable<Vector3>;
  12249. /** @hidden */
  12250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12251. /** @hidden */
  12252. _initialStartSpriteCellID: number;
  12253. /** @hidden */
  12254. _initialEndSpriteCellID: number;
  12255. /** @hidden */
  12256. _currentColorGradient: Nullable<ColorGradient>;
  12257. /** @hidden */
  12258. _currentColor1: Color4;
  12259. /** @hidden */
  12260. _currentColor2: Color4;
  12261. /** @hidden */
  12262. _currentSizeGradient: Nullable<FactorGradient>;
  12263. /** @hidden */
  12264. _currentSize1: number;
  12265. /** @hidden */
  12266. _currentSize2: number;
  12267. /** @hidden */
  12268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12269. /** @hidden */
  12270. _currentAngularSpeed1: number;
  12271. /** @hidden */
  12272. _currentAngularSpeed2: number;
  12273. /** @hidden */
  12274. _currentVelocityGradient: Nullable<FactorGradient>;
  12275. /** @hidden */
  12276. _currentVelocity1: number;
  12277. /** @hidden */
  12278. _currentVelocity2: number;
  12279. /** @hidden */
  12280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12281. /** @hidden */
  12282. _currentLimitVelocity1: number;
  12283. /** @hidden */
  12284. _currentLimitVelocity2: number;
  12285. /** @hidden */
  12286. _currentDragGradient: Nullable<FactorGradient>;
  12287. /** @hidden */
  12288. _currentDrag1: number;
  12289. /** @hidden */
  12290. _currentDrag2: number;
  12291. /** @hidden */
  12292. _randomNoiseCoordinates1: Vector3;
  12293. /** @hidden */
  12294. _randomNoiseCoordinates2: Vector3;
  12295. /**
  12296. * Creates a new instance Particle
  12297. * @param particleSystem the particle system the particle belongs to
  12298. */
  12299. constructor(
  12300. /**
  12301. * The particle system the particle belongs to.
  12302. */
  12303. particleSystem: ParticleSystem);
  12304. private updateCellInfoFromSystem;
  12305. /**
  12306. * Defines how the sprite cell index is updated for the particle
  12307. */
  12308. updateCellIndex(): void;
  12309. /** @hidden */
  12310. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12311. /** @hidden */
  12312. _inheritParticleInfoToSubEmitters(): void;
  12313. /** @hidden */
  12314. _reset(): void;
  12315. /**
  12316. * Copy the properties of particle to another one.
  12317. * @param other the particle to copy the information to.
  12318. */
  12319. copyTo(other: Particle): void;
  12320. }
  12321. }
  12322. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12323. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12324. import { Effect } from "babylonjs/Materials/effect";
  12325. import { Particle } from "babylonjs/Particles/particle";
  12326. import { Scene } from "babylonjs/scene";
  12327. /**
  12328. * Particle emitter represents a volume emitting particles.
  12329. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12330. */
  12331. export interface IParticleEmitterType {
  12332. /**
  12333. * Called by the particle System when the direction is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param directionToUpdate is the direction vector to update with the result
  12336. * @param particle is the particle we are computed the direction for
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. */
  12345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12346. /**
  12347. * Clones the current emitter and returns a copy of it
  12348. * @returns the new emitter
  12349. */
  12350. clone(): IParticleEmitterType;
  12351. /**
  12352. * Called by the GPUParticleSystem to setup the update shader
  12353. * @param effect defines the update shader
  12354. */
  12355. applyToShader(effect: Effect): void;
  12356. /**
  12357. * Returns a string to use to update the GPU particles update shader
  12358. * @returns the effect defines string
  12359. */
  12360. getEffectDefines(): string;
  12361. /**
  12362. * Returns a string representing the class name
  12363. * @returns a string containing the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Serializes the particle system to a JSON object.
  12368. * @returns the JSON object
  12369. */
  12370. serialize(): any;
  12371. /**
  12372. * Parse properties from a JSON object
  12373. * @param serializationObject defines the JSON object
  12374. * @param scene defines the hosting scene
  12375. */
  12376. parse(serializationObject: any, scene: Scene): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12380. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12381. import { Effect } from "babylonjs/Materials/effect";
  12382. import { Particle } from "babylonjs/Particles/particle";
  12383. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12384. /**
  12385. * Particle emitter emitting particles from the inside of a box.
  12386. * It emits the particles randomly between 2 given directions.
  12387. */
  12388. export class BoxParticleEmitter implements IParticleEmitterType {
  12389. /**
  12390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12391. */
  12392. direction1: Vector3;
  12393. /**
  12394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12395. */
  12396. direction2: Vector3;
  12397. /**
  12398. * 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.
  12399. */
  12400. minEmitBox: Vector3;
  12401. /**
  12402. * 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.
  12403. */
  12404. maxEmitBox: Vector3;
  12405. /**
  12406. * Creates a new instance BoxParticleEmitter
  12407. */
  12408. constructor();
  12409. /**
  12410. * Called by the particle System when the direction is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param directionToUpdate is the direction vector to update with the result
  12413. * @param particle is the particle we are computed the direction for
  12414. */
  12415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Called by the particle System when the position is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param positionToUpdate is the position vector to update with the result
  12420. * @param particle is the particle we are computed the position for
  12421. */
  12422. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12423. /**
  12424. * Clones the current emitter and returns a copy of it
  12425. * @returns the new emitter
  12426. */
  12427. clone(): BoxParticleEmitter;
  12428. /**
  12429. * Called by the GPUParticleSystem to setup the update shader
  12430. * @param effect defines the update shader
  12431. */
  12432. applyToShader(effect: Effect): void;
  12433. /**
  12434. * Returns a string to use to update the GPU particles update shader
  12435. * @returns a string containng the defines string
  12436. */
  12437. getEffectDefines(): string;
  12438. /**
  12439. * Returns the string "BoxParticleEmitter"
  12440. * @returns a string containing the class name
  12441. */
  12442. getClassName(): string;
  12443. /**
  12444. * Serializes the particle system to a JSON object.
  12445. * @returns the JSON object
  12446. */
  12447. serialize(): any;
  12448. /**
  12449. * Parse properties from a JSON object
  12450. * @param serializationObject defines the JSON object
  12451. */
  12452. parse(serializationObject: any): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12456. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12457. import { Effect } from "babylonjs/Materials/effect";
  12458. import { Particle } from "babylonjs/Particles/particle";
  12459. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12460. /**
  12461. * Particle emitter emitting particles from the inside of a cone.
  12462. * It emits the particles alongside the cone volume from the base to the particle.
  12463. * The emission direction might be randomized.
  12464. */
  12465. export class ConeParticleEmitter implements IParticleEmitterType {
  12466. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12467. directionRandomizer: number;
  12468. private _radius;
  12469. private _angle;
  12470. private _height;
  12471. /**
  12472. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12473. */
  12474. radiusRange: number;
  12475. /**
  12476. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12477. */
  12478. heightRange: number;
  12479. /**
  12480. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12481. */
  12482. emitFromSpawnPointOnly: boolean;
  12483. /**
  12484. * Gets or sets the radius of the emission cone
  12485. */
  12486. get radius(): number;
  12487. set radius(value: number);
  12488. /**
  12489. * Gets or sets the angle of the emission cone
  12490. */
  12491. get angle(): number;
  12492. set angle(value: number);
  12493. private _buildHeight;
  12494. /**
  12495. * Creates a new instance ConeParticleEmitter
  12496. * @param radius the radius of the emission cone (1 by default)
  12497. * @param angle the cone base angle (PI by default)
  12498. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12499. */
  12500. constructor(radius?: number, angle?: number,
  12501. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12502. directionRandomizer?: number);
  12503. /**
  12504. * Called by the particle System when the direction is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param directionToUpdate is the direction vector to update with the result
  12507. * @param particle is the particle we are computed the direction for
  12508. */
  12509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Called by the particle System when the position is computed for the created particle.
  12512. * @param worldMatrix is the world matrix of the particle system
  12513. * @param positionToUpdate is the position vector to update with the result
  12514. * @param particle is the particle we are computed the position for
  12515. */
  12516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12517. /**
  12518. * Clones the current emitter and returns a copy of it
  12519. * @returns the new emitter
  12520. */
  12521. clone(): ConeParticleEmitter;
  12522. /**
  12523. * Called by the GPUParticleSystem to setup the update shader
  12524. * @param effect defines the update shader
  12525. */
  12526. applyToShader(effect: Effect): void;
  12527. /**
  12528. * Returns a string to use to update the GPU particles update shader
  12529. * @returns a string containng the defines string
  12530. */
  12531. getEffectDefines(): string;
  12532. /**
  12533. * Returns the string "ConeParticleEmitter"
  12534. * @returns a string containing the class name
  12535. */
  12536. getClassName(): string;
  12537. /**
  12538. * Serializes the particle system to a JSON object.
  12539. * @returns the JSON object
  12540. */
  12541. serialize(): any;
  12542. /**
  12543. * Parse properties from a JSON object
  12544. * @param serializationObject defines the JSON object
  12545. */
  12546. parse(serializationObject: any): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12550. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12551. import { Effect } from "babylonjs/Materials/effect";
  12552. import { Particle } from "babylonjs/Particles/particle";
  12553. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12554. /**
  12555. * Particle emitter emitting particles from the inside of a cylinder.
  12556. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12557. */
  12558. export class CylinderParticleEmitter implements IParticleEmitterType {
  12559. /**
  12560. * The radius of the emission cylinder.
  12561. */
  12562. radius: number;
  12563. /**
  12564. * The height of the emission cylinder.
  12565. */
  12566. height: number;
  12567. /**
  12568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12569. */
  12570. radiusRange: number;
  12571. /**
  12572. * How much to randomize the particle direction [0-1].
  12573. */
  12574. directionRandomizer: number;
  12575. /**
  12576. * Creates a new instance CylinderParticleEmitter
  12577. * @param radius the radius of the emission cylinder (1 by default)
  12578. * @param height the height of the emission cylinder (1 by default)
  12579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12581. */
  12582. constructor(
  12583. /**
  12584. * The radius of the emission cylinder.
  12585. */
  12586. radius?: number,
  12587. /**
  12588. * The height of the emission cylinder.
  12589. */
  12590. height?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. */
  12605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Called by the particle System when the position is computed for the created particle.
  12608. * @param worldMatrix is the world matrix of the particle system
  12609. * @param positionToUpdate is the position vector to update with the result
  12610. * @param particle is the particle we are computed the position for
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): CylinderParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "CylinderParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. /**
  12645. * Particle emitter emitting particles from the inside of a cylinder.
  12646. * It emits the particles randomly between two vectors.
  12647. */
  12648. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12649. /**
  12650. * The min limit of the emission direction.
  12651. */
  12652. direction1: Vector3;
  12653. /**
  12654. * The max limit of the emission direction.
  12655. */
  12656. direction2: Vector3;
  12657. /**
  12658. * Creates a new instance CylinderDirectedParticleEmitter
  12659. * @param radius the radius of the emission cylinder (1 by default)
  12660. * @param height the height of the emission cylinder (1 by default)
  12661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12662. * @param direction1 the min limit of the emission direction (up vector by default)
  12663. * @param direction2 the max limit of the emission direction (up vector by default)
  12664. */
  12665. constructor(radius?: number, height?: number, radiusRange?: number,
  12666. /**
  12667. * The min limit of the emission direction.
  12668. */
  12669. direction1?: Vector3,
  12670. /**
  12671. * The max limit of the emission direction.
  12672. */
  12673. direction2?: Vector3);
  12674. /**
  12675. * Called by the particle System when the direction is computed for the created particle.
  12676. * @param worldMatrix is the world matrix of the particle system
  12677. * @param directionToUpdate is the direction vector to update with the result
  12678. * @param particle is the particle we are computed the direction for
  12679. */
  12680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): CylinderDirectedParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "CylinderDirectedParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12714. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12715. import { Effect } from "babylonjs/Materials/effect";
  12716. import { Particle } from "babylonjs/Particles/particle";
  12717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12718. /**
  12719. * Particle emitter emitting particles from the inside of a hemisphere.
  12720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12721. */
  12722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12723. /**
  12724. * The radius of the emission hemisphere.
  12725. */
  12726. radius: number;
  12727. /**
  12728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12729. */
  12730. radiusRange: number;
  12731. /**
  12732. * How much to randomize the particle direction [0-1].
  12733. */
  12734. directionRandomizer: number;
  12735. /**
  12736. * Creates a new instance HemisphericParticleEmitter
  12737. * @param radius the radius of the emission hemisphere (1 by default)
  12738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12740. */
  12741. constructor(
  12742. /**
  12743. * The radius of the emission hemisphere.
  12744. */
  12745. radius?: number,
  12746. /**
  12747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12748. */
  12749. radiusRange?: number,
  12750. /**
  12751. * How much to randomize the particle direction [0-1].
  12752. */
  12753. directionRandomizer?: number);
  12754. /**
  12755. * Called by the particle System when the direction is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param directionToUpdate is the direction vector to update with the result
  12758. * @param particle is the particle we are computed the direction for
  12759. */
  12760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Called by the particle System when the position is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param positionToUpdate is the position vector to update with the result
  12765. * @param particle is the particle we are computed the position for
  12766. */
  12767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12768. /**
  12769. * Clones the current emitter and returns a copy of it
  12770. * @returns the new emitter
  12771. */
  12772. clone(): HemisphericParticleEmitter;
  12773. /**
  12774. * Called by the GPUParticleSystem to setup the update shader
  12775. * @param effect defines the update shader
  12776. */
  12777. applyToShader(effect: Effect): void;
  12778. /**
  12779. * Returns a string to use to update the GPU particles update shader
  12780. * @returns a string containng the defines string
  12781. */
  12782. getEffectDefines(): string;
  12783. /**
  12784. * Returns the string "HemisphericParticleEmitter"
  12785. * @returns a string containing the class name
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Serializes the particle system to a JSON object.
  12790. * @returns the JSON object
  12791. */
  12792. serialize(): any;
  12793. /**
  12794. * Parse properties from a JSON object
  12795. * @param serializationObject defines the JSON object
  12796. */
  12797. parse(serializationObject: any): void;
  12798. }
  12799. }
  12800. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12801. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Particle } from "babylonjs/Particles/particle";
  12804. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12805. /**
  12806. * Particle emitter emitting particles from a point.
  12807. * It emits the particles randomly between 2 given directions.
  12808. */
  12809. export class PointParticleEmitter implements IParticleEmitterType {
  12810. /**
  12811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12812. */
  12813. direction1: Vector3;
  12814. /**
  12815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12816. */
  12817. direction2: Vector3;
  12818. /**
  12819. * Creates a new instance PointParticleEmitter
  12820. */
  12821. constructor();
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): PointParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "PointParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. */
  12865. parse(serializationObject: any): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12870. import { Effect } from "babylonjs/Materials/effect";
  12871. import { Particle } from "babylonjs/Particles/particle";
  12872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12873. /**
  12874. * Particle emitter emitting particles from the inside of a sphere.
  12875. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12876. */
  12877. export class SphereParticleEmitter implements IParticleEmitterType {
  12878. /**
  12879. * The radius of the emission sphere.
  12880. */
  12881. radius: number;
  12882. /**
  12883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12884. */
  12885. radiusRange: number;
  12886. /**
  12887. * How much to randomize the particle direction [0-1].
  12888. */
  12889. directionRandomizer: number;
  12890. /**
  12891. * Creates a new instance SphereParticleEmitter
  12892. * @param radius the radius of the emission sphere (1 by default)
  12893. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12895. */
  12896. constructor(
  12897. /**
  12898. * The radius of the emission sphere.
  12899. */
  12900. radius?: number,
  12901. /**
  12902. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12903. */
  12904. radiusRange?: number,
  12905. /**
  12906. * How much to randomize the particle direction [0-1].
  12907. */
  12908. directionRandomizer?: number);
  12909. /**
  12910. * Called by the particle System when the direction is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param directionToUpdate is the direction vector to update with the result
  12913. * @param particle is the particle we are computed the direction for
  12914. */
  12915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Called by the particle System when the position is computed for the created particle.
  12918. * @param worldMatrix is the world matrix of the particle system
  12919. * @param positionToUpdate is the position vector to update with the result
  12920. * @param particle is the particle we are computed the position for
  12921. */
  12922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12923. /**
  12924. * Clones the current emitter and returns a copy of it
  12925. * @returns the new emitter
  12926. */
  12927. clone(): SphereParticleEmitter;
  12928. /**
  12929. * Called by the GPUParticleSystem to setup the update shader
  12930. * @param effect defines the update shader
  12931. */
  12932. applyToShader(effect: Effect): void;
  12933. /**
  12934. * Returns a string to use to update the GPU particles update shader
  12935. * @returns a string containng the defines string
  12936. */
  12937. getEffectDefines(): string;
  12938. /**
  12939. * Returns the string "SphereParticleEmitter"
  12940. * @returns a string containing the class name
  12941. */
  12942. getClassName(): string;
  12943. /**
  12944. * Serializes the particle system to a JSON object.
  12945. * @returns the JSON object
  12946. */
  12947. serialize(): any;
  12948. /**
  12949. * Parse properties from a JSON object
  12950. * @param serializationObject defines the JSON object
  12951. */
  12952. parse(serializationObject: any): void;
  12953. }
  12954. /**
  12955. * Particle emitter emitting particles from the inside of a sphere.
  12956. * It emits the particles randomly between two vectors.
  12957. */
  12958. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12959. /**
  12960. * The min limit of the emission direction.
  12961. */
  12962. direction1: Vector3;
  12963. /**
  12964. * The max limit of the emission direction.
  12965. */
  12966. direction2: Vector3;
  12967. /**
  12968. * Creates a new instance SphereDirectedParticleEmitter
  12969. * @param radius the radius of the emission sphere (1 by default)
  12970. * @param direction1 the min limit of the emission direction (up vector by default)
  12971. * @param direction2 the max limit of the emission direction (up vector by default)
  12972. */
  12973. constructor(radius?: number,
  12974. /**
  12975. * The min limit of the emission direction.
  12976. */
  12977. direction1?: Vector3,
  12978. /**
  12979. * The max limit of the emission direction.
  12980. */
  12981. direction2?: Vector3);
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. */
  12988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12989. /**
  12990. * Clones the current emitter and returns a copy of it
  12991. * @returns the new emitter
  12992. */
  12993. clone(): SphereDirectedParticleEmitter;
  12994. /**
  12995. * Called by the GPUParticleSystem to setup the update shader
  12996. * @param effect defines the update shader
  12997. */
  12998. applyToShader(effect: Effect): void;
  12999. /**
  13000. * Returns a string to use to update the GPU particles update shader
  13001. * @returns a string containng the defines string
  13002. */
  13003. getEffectDefines(): string;
  13004. /**
  13005. * Returns the string "SphereDirectedParticleEmitter"
  13006. * @returns a string containing the class name
  13007. */
  13008. getClassName(): string;
  13009. /**
  13010. * Serializes the particle system to a JSON object.
  13011. * @returns the JSON object
  13012. */
  13013. serialize(): any;
  13014. /**
  13015. * Parse properties from a JSON object
  13016. * @param serializationObject defines the JSON object
  13017. */
  13018. parse(serializationObject: any): void;
  13019. }
  13020. }
  13021. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13023. import { Effect } from "babylonjs/Materials/effect";
  13024. import { Particle } from "babylonjs/Particles/particle";
  13025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13026. import { Nullable } from "babylonjs/types";
  13027. /**
  13028. * Particle emitter emitting particles from a custom list of positions.
  13029. */
  13030. export class CustomParticleEmitter implements IParticleEmitterType {
  13031. /**
  13032. * Gets or sets the position generator that will create the inital position of each particle.
  13033. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13034. */
  13035. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13036. /**
  13037. * Gets or sets the destination generator that will create the final destination of each particle.
  13038. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13039. */
  13040. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13041. /**
  13042. * Creates a new instance CustomParticleEmitter
  13043. */
  13044. constructor();
  13045. /**
  13046. * Called by the particle System when the direction is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param directionToUpdate is the direction vector to update with the result
  13049. * @param particle is the particle we are computed the direction for
  13050. */
  13051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Called by the particle System when the position is computed for the created particle.
  13054. * @param worldMatrix is the world matrix of the particle system
  13055. * @param positionToUpdate is the position vector to update with the result
  13056. * @param particle is the particle we are computed the position for
  13057. */
  13058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13059. /**
  13060. * Clones the current emitter and returns a copy of it
  13061. * @returns the new emitter
  13062. */
  13063. clone(): CustomParticleEmitter;
  13064. /**
  13065. * Called by the GPUParticleSystem to setup the update shader
  13066. * @param effect defines the update shader
  13067. */
  13068. applyToShader(effect: Effect): void;
  13069. /**
  13070. * Returns a string to use to update the GPU particles update shader
  13071. * @returns a string containng the defines string
  13072. */
  13073. getEffectDefines(): string;
  13074. /**
  13075. * Returns the string "PointParticleEmitter"
  13076. * @returns a string containing the class name
  13077. */
  13078. getClassName(): string;
  13079. /**
  13080. * Serializes the particle system to a JSON object.
  13081. * @returns the JSON object
  13082. */
  13083. serialize(): any;
  13084. /**
  13085. * Parse properties from a JSON object
  13086. * @param serializationObject defines the JSON object
  13087. */
  13088. parse(serializationObject: any): void;
  13089. }
  13090. }
  13091. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13093. import { Effect } from "babylonjs/Materials/effect";
  13094. import { Particle } from "babylonjs/Particles/particle";
  13095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13096. import { Scene } from "babylonjs/scene";
  13097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13098. /**
  13099. * Particle emitter emitting particles from the inside of a box.
  13100. * It emits the particles randomly between 2 given directions.
  13101. */
  13102. export class MeshParticleEmitter implements IParticleEmitterType {
  13103. /** Defines the mesh to use as source */
  13104. mesh?: AbstractMesh | undefined;
  13105. private _indices;
  13106. private _positions;
  13107. private _normals;
  13108. private _storedNormal;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction1: Vector3;
  13113. /**
  13114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13115. */
  13116. direction2: Vector3;
  13117. /**
  13118. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13119. */
  13120. useMeshNormalsForDirection: boolean;
  13121. /**
  13122. * Creates a new instance MeshParticleEmitter
  13123. * @param mesh defines the mesh to use as source
  13124. */
  13125. constructor(
  13126. /** Defines the mesh to use as source */
  13127. mesh?: AbstractMesh | undefined);
  13128. /**
  13129. * Called by the particle System when the direction is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param directionToUpdate is the direction vector to update with the result
  13132. * @param particle is the particle we are computed the direction for
  13133. */
  13134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Called by the particle System when the position is computed for the created particle.
  13137. * @param worldMatrix is the world matrix of the particle system
  13138. * @param positionToUpdate is the position vector to update with the result
  13139. * @param particle is the particle we are computed the position for
  13140. */
  13141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13142. /**
  13143. * Clones the current emitter and returns a copy of it
  13144. * @returns the new emitter
  13145. */
  13146. clone(): MeshParticleEmitter;
  13147. /**
  13148. * Called by the GPUParticleSystem to setup the update shader
  13149. * @param effect defines the update shader
  13150. */
  13151. applyToShader(effect: Effect): void;
  13152. /**
  13153. * Returns a string to use to update the GPU particles update shader
  13154. * @returns a string containng the defines string
  13155. */
  13156. getEffectDefines(): string;
  13157. /**
  13158. * Returns the string "BoxParticleEmitter"
  13159. * @returns a string containing the class name
  13160. */
  13161. getClassName(): string;
  13162. /**
  13163. * Serializes the particle system to a JSON object.
  13164. * @returns the JSON object
  13165. */
  13166. serialize(): any;
  13167. /**
  13168. * Parse properties from a JSON object
  13169. * @param serializationObject defines the JSON object
  13170. * @param scene defines the hosting scene
  13171. */
  13172. parse(serializationObject: any, scene: Scene): void;
  13173. }
  13174. }
  13175. declare module "babylonjs/Particles/EmitterTypes/index" {
  13176. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13178. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13179. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13180. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13181. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13182. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13183. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13184. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13185. }
  13186. declare module "babylonjs/Particles/IParticleSystem" {
  13187. import { Nullable } from "babylonjs/types";
  13188. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13189. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13192. import { Texture } from "babylonjs/Materials/Textures/texture";
  13193. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13194. import { Scene } from "babylonjs/scene";
  13195. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13196. import { Animation } from "babylonjs/Animations/animation";
  13197. /**
  13198. * Interface representing a particle system in Babylon.js.
  13199. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13200. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13201. */
  13202. export interface IParticleSystem {
  13203. /**
  13204. * List of animations used by the particle system.
  13205. */
  13206. animations: Animation[];
  13207. /**
  13208. * The id of the Particle system.
  13209. */
  13210. id: string;
  13211. /**
  13212. * The name of the Particle system.
  13213. */
  13214. name: string;
  13215. /**
  13216. * The emitter represents the Mesh or position we are attaching the particle system to.
  13217. */
  13218. emitter: Nullable<AbstractMesh | Vector3>;
  13219. /**
  13220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13221. */
  13222. isBillboardBased: boolean;
  13223. /**
  13224. * The rendering group used by the Particle system to chose when to render.
  13225. */
  13226. renderingGroupId: number;
  13227. /**
  13228. * The layer mask we are rendering the particles through.
  13229. */
  13230. layerMask: number;
  13231. /**
  13232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13233. */
  13234. updateSpeed: number;
  13235. /**
  13236. * The amount of time the particle system is running (depends of the overall update speed).
  13237. */
  13238. targetStopDuration: number;
  13239. /**
  13240. * The texture used to render each particle. (this can be a spritesheet)
  13241. */
  13242. particleTexture: Nullable<Texture>;
  13243. /**
  13244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13245. */
  13246. blendMode: number;
  13247. /**
  13248. * Minimum life time of emitting particles.
  13249. */
  13250. minLifeTime: number;
  13251. /**
  13252. * Maximum life time of emitting particles.
  13253. */
  13254. maxLifeTime: number;
  13255. /**
  13256. * Minimum Size of emitting particles.
  13257. */
  13258. minSize: number;
  13259. /**
  13260. * Maximum Size of emitting particles.
  13261. */
  13262. maxSize: number;
  13263. /**
  13264. * Minimum scale of emitting particles on X axis.
  13265. */
  13266. minScaleX: number;
  13267. /**
  13268. * Maximum scale of emitting particles on X axis.
  13269. */
  13270. maxScaleX: number;
  13271. /**
  13272. * Minimum scale of emitting particles on Y axis.
  13273. */
  13274. minScaleY: number;
  13275. /**
  13276. * Maximum scale of emitting particles on Y axis.
  13277. */
  13278. maxScaleY: number;
  13279. /**
  13280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13281. */
  13282. color1: Color4;
  13283. /**
  13284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13285. */
  13286. color2: Color4;
  13287. /**
  13288. * Color the particle will have at the end of its lifetime.
  13289. */
  13290. colorDead: Color4;
  13291. /**
  13292. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13293. */
  13294. emitRate: number;
  13295. /**
  13296. * You can use gravity if you want to give an orientation to your particles.
  13297. */
  13298. gravity: Vector3;
  13299. /**
  13300. * Minimum power of emitting particles.
  13301. */
  13302. minEmitPower: number;
  13303. /**
  13304. * Maximum power of emitting particles.
  13305. */
  13306. maxEmitPower: number;
  13307. /**
  13308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13309. */
  13310. minAngularSpeed: number;
  13311. /**
  13312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13313. */
  13314. maxAngularSpeed: number;
  13315. /**
  13316. * Gets or sets the minimal initial rotation in radians.
  13317. */
  13318. minInitialRotation: number;
  13319. /**
  13320. * Gets or sets the maximal initial rotation in radians.
  13321. */
  13322. maxInitialRotation: number;
  13323. /**
  13324. * The particle emitter type defines the emitter used by the particle system.
  13325. * It can be for example box, sphere, or cone...
  13326. */
  13327. particleEmitterType: Nullable<IParticleEmitterType>;
  13328. /**
  13329. * Defines the delay in milliseconds before starting the system (0 by default)
  13330. */
  13331. startDelay: number;
  13332. /**
  13333. * 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
  13334. */
  13335. preWarmCycles: number;
  13336. /**
  13337. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13338. */
  13339. preWarmStepOffset: number;
  13340. /**
  13341. * 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)
  13342. */
  13343. spriteCellChangeSpeed: number;
  13344. /**
  13345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13346. */
  13347. startSpriteCellID: number;
  13348. /**
  13349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13350. */
  13351. endSpriteCellID: number;
  13352. /**
  13353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13354. */
  13355. spriteCellWidth: number;
  13356. /**
  13357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13358. */
  13359. spriteCellHeight: number;
  13360. /**
  13361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13362. */
  13363. spriteRandomStartCell: boolean;
  13364. /**
  13365. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13366. */
  13367. isAnimationSheetEnabled: boolean;
  13368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13369. translationPivot: Vector2;
  13370. /**
  13371. * Gets or sets a texture used to add random noise to particle positions
  13372. */
  13373. noiseTexture: Nullable<BaseTexture>;
  13374. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13375. noiseStrength: Vector3;
  13376. /**
  13377. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13378. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13379. */
  13380. billboardMode: number;
  13381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13382. limitVelocityDamping: number;
  13383. /**
  13384. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13385. */
  13386. beginAnimationOnStart: boolean;
  13387. /**
  13388. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13389. */
  13390. beginAnimationFrom: number;
  13391. /**
  13392. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13393. */
  13394. beginAnimationTo: number;
  13395. /**
  13396. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13397. */
  13398. beginAnimationLoop: boolean;
  13399. /**
  13400. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13401. */
  13402. disposeOnStop: boolean;
  13403. /**
  13404. * Gets the maximum number of particles active at the same time.
  13405. * @returns The max number of active particles.
  13406. */
  13407. getCapacity(): number;
  13408. /**
  13409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13410. * @returns True if it has been started, otherwise false.
  13411. */
  13412. isStarted(): boolean;
  13413. /**
  13414. * Animates the particle system for this frame.
  13415. */
  13416. animate(): void;
  13417. /**
  13418. * Renders the particle system in its current state.
  13419. * @returns the current number of particles
  13420. */
  13421. render(): number;
  13422. /**
  13423. * Dispose the particle system and frees its associated resources.
  13424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13425. */
  13426. dispose(disposeTexture?: boolean): void;
  13427. /**
  13428. * Clones the particle system.
  13429. * @param name The name of the cloned object
  13430. * @param newEmitter The new emitter to use
  13431. * @returns the cloned particle system
  13432. */
  13433. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13434. /**
  13435. * Serializes the particle system to a JSON object.
  13436. * @returns the JSON object
  13437. */
  13438. serialize(): any;
  13439. /**
  13440. * Rebuild the particle system
  13441. */
  13442. rebuild(): void;
  13443. /**
  13444. * Starts the particle system and begins to emit
  13445. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13446. */
  13447. start(delay?: number): void;
  13448. /**
  13449. * Stops the particle system.
  13450. */
  13451. stop(): void;
  13452. /**
  13453. * Remove all active particles
  13454. */
  13455. reset(): void;
  13456. /**
  13457. * Is this system ready to be used/rendered
  13458. * @return true if the system is ready
  13459. */
  13460. isReady(): boolean;
  13461. /**
  13462. * Adds a new color gradient
  13463. * @param gradient defines the gradient to use (between 0 and 1)
  13464. * @param color1 defines the color to affect to the specified gradient
  13465. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13466. * @returns the current particle system
  13467. */
  13468. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13469. /**
  13470. * Remove a specific color gradient
  13471. * @param gradient defines the gradient to remove
  13472. * @returns the current particle system
  13473. */
  13474. removeColorGradient(gradient: number): IParticleSystem;
  13475. /**
  13476. * Adds a new size gradient
  13477. * @param gradient defines the gradient to use (between 0 and 1)
  13478. * @param factor defines the size factor to affect to the specified gradient
  13479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13480. * @returns the current particle system
  13481. */
  13482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13483. /**
  13484. * Remove a specific size gradient
  13485. * @param gradient defines the gradient to remove
  13486. * @returns the current particle system
  13487. */
  13488. removeSizeGradient(gradient: number): IParticleSystem;
  13489. /**
  13490. * Gets the current list of color gradients.
  13491. * You must use addColorGradient and removeColorGradient to udpate this list
  13492. * @returns the list of color gradients
  13493. */
  13494. getColorGradients(): Nullable<Array<ColorGradient>>;
  13495. /**
  13496. * Gets the current list of size gradients.
  13497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13498. * @returns the list of size gradients
  13499. */
  13500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13501. /**
  13502. * Gets the current list of angular speed gradients.
  13503. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13504. * @returns the list of angular speed gradients
  13505. */
  13506. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13507. /**
  13508. * Adds a new angular speed gradient
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the angular speed to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific angular speed gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of velocity gradients.
  13523. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13524. * @returns the list of velocity gradients
  13525. */
  13526. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13527. /**
  13528. * Adds a new velocity gradient
  13529. * @param gradient defines the gradient to use (between 0 and 1)
  13530. * @param factor defines the velocity to affect to the specified gradient
  13531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13532. * @returns the current particle system
  13533. */
  13534. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13535. /**
  13536. * Remove a specific velocity gradient
  13537. * @param gradient defines the gradient to remove
  13538. * @returns the current particle system
  13539. */
  13540. removeVelocityGradient(gradient: number): IParticleSystem;
  13541. /**
  13542. * Gets the current list of limit velocity gradients.
  13543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13544. * @returns the list of limit velocity gradients
  13545. */
  13546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13547. /**
  13548. * Adds a new limit velocity gradient
  13549. * @param gradient defines the gradient to use (between 0 and 1)
  13550. * @param factor defines the limit velocity to affect to the specified gradient
  13551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13552. * @returns the current particle system
  13553. */
  13554. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13555. /**
  13556. * Remove a specific limit velocity gradient
  13557. * @param gradient defines the gradient to remove
  13558. * @returns the current particle system
  13559. */
  13560. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13561. /**
  13562. * Adds a new drag gradient
  13563. * @param gradient defines the gradient to use (between 0 and 1)
  13564. * @param factor defines the drag to affect to the specified gradient
  13565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13566. * @returns the current particle system
  13567. */
  13568. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13569. /**
  13570. * Remove a specific drag gradient
  13571. * @param gradient defines the gradient to remove
  13572. * @returns the current particle system
  13573. */
  13574. removeDragGradient(gradient: number): IParticleSystem;
  13575. /**
  13576. * Gets the current list of drag gradients.
  13577. * You must use addDragGradient and removeDragGradient to udpate this list
  13578. * @returns the list of drag gradients
  13579. */
  13580. getDragGradients(): Nullable<Array<FactorGradient>>;
  13581. /**
  13582. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13583. * @param gradient defines the gradient to use (between 0 and 1)
  13584. * @param factor defines the emit rate to affect to the specified gradient
  13585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13586. * @returns the current particle system
  13587. */
  13588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13589. /**
  13590. * Remove a specific emit rate gradient
  13591. * @param gradient defines the gradient to remove
  13592. * @returns the current particle system
  13593. */
  13594. removeEmitRateGradient(gradient: number): IParticleSystem;
  13595. /**
  13596. * Gets the current list of emit rate gradients.
  13597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13598. * @returns the list of emit rate gradients
  13599. */
  13600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13601. /**
  13602. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13603. * @param gradient defines the gradient to use (between 0 and 1)
  13604. * @param factor defines the start size to affect to the specified gradient
  13605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13606. * @returns the current particle system
  13607. */
  13608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13609. /**
  13610. * Remove a specific start size gradient
  13611. * @param gradient defines the gradient to remove
  13612. * @returns the current particle system
  13613. */
  13614. removeStartSizeGradient(gradient: number): IParticleSystem;
  13615. /**
  13616. * Gets the current list of start size gradients.
  13617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13618. * @returns the list of start size gradients
  13619. */
  13620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13621. /**
  13622. * Adds a new life time gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param factor defines the life time factor to affect to the specified gradient
  13625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13626. * @returns the current particle system
  13627. */
  13628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13629. /**
  13630. * Remove a specific life time gradient
  13631. * @param gradient defines the gradient to remove
  13632. * @returns the current particle system
  13633. */
  13634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13635. /**
  13636. * Gets the current list of life time gradients.
  13637. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13638. * @returns the list of life time gradients
  13639. */
  13640. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13641. /**
  13642. * Gets the current list of color gradients.
  13643. * You must use addColorGradient and removeColorGradient to udpate this list
  13644. * @returns the list of color gradients
  13645. */
  13646. getColorGradients(): Nullable<Array<ColorGradient>>;
  13647. /**
  13648. * Adds a new ramp gradient used to remap particle colors
  13649. * @param gradient defines the gradient to use (between 0 and 1)
  13650. * @param color defines the color to affect to the specified gradient
  13651. * @returns the current particle system
  13652. */
  13653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13654. /**
  13655. * Gets the current list of ramp gradients.
  13656. * You must use addRampGradient and removeRampGradient to udpate this list
  13657. * @returns the list of ramp gradients
  13658. */
  13659. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13660. /** Gets or sets a boolean indicating that ramp gradients must be used
  13661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13662. */
  13663. useRampGradients: boolean;
  13664. /**
  13665. * Adds a new color remap gradient
  13666. * @param gradient defines the gradient to use (between 0 and 1)
  13667. * @param min defines the color remap minimal range
  13668. * @param max defines the color remap maximal range
  13669. * @returns the current particle system
  13670. */
  13671. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13672. /**
  13673. * Gets the current list of color remap gradients.
  13674. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13675. * @returns the list of color remap gradients
  13676. */
  13677. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13678. /**
  13679. * Adds a new alpha remap gradient
  13680. * @param gradient defines the gradient to use (between 0 and 1)
  13681. * @param min defines the alpha remap minimal range
  13682. * @param max defines the alpha remap maximal range
  13683. * @returns the current particle system
  13684. */
  13685. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13686. /**
  13687. * Gets the current list of alpha remap gradients.
  13688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13689. * @returns the list of alpha remap gradients
  13690. */
  13691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13692. /**
  13693. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13696. * @returns the emitter
  13697. */
  13698. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13699. /**
  13700. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13701. * @param radius The radius of the hemisphere to emit from
  13702. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13706. /**
  13707. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13710. * @returns the emitter
  13711. */
  13712. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13713. /**
  13714. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13715. * @param radius The radius of the sphere to emit from
  13716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13718. * @returns the emitter
  13719. */
  13720. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13721. /**
  13722. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13723. * @param radius The radius of the emission cylinder
  13724. * @param height The height of the emission cylinder
  13725. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13726. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13727. * @returns the emitter
  13728. */
  13729. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13730. /**
  13731. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13732. * @param radius The radius of the cylinder to emit from
  13733. * @param height The height of the emission cylinder
  13734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13737. * @returns the emitter
  13738. */
  13739. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13740. /**
  13741. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13742. * @param radius The radius of the cone to emit from
  13743. * @param angle The base angle of the cone
  13744. * @returns the emitter
  13745. */
  13746. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13747. /**
  13748. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13751. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13752. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13753. * @returns the emitter
  13754. */
  13755. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13756. /**
  13757. * Get hosting scene
  13758. * @returns the scene
  13759. */
  13760. getScene(): Scene;
  13761. }
  13762. }
  13763. declare module "babylonjs/Meshes/transformNode" {
  13764. import { DeepImmutable } from "babylonjs/types";
  13765. import { Observable } from "babylonjs/Misc/observable";
  13766. import { Nullable } from "babylonjs/types";
  13767. import { Camera } from "babylonjs/Cameras/camera";
  13768. import { Scene } from "babylonjs/scene";
  13769. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13770. import { Node } from "babylonjs/node";
  13771. import { Bone } from "babylonjs/Bones/bone";
  13772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13773. import { Space } from "babylonjs/Maths/math.axis";
  13774. /**
  13775. * 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.
  13776. * @see https://doc.babylonjs.com/how_to/transformnode
  13777. */
  13778. export class TransformNode extends Node {
  13779. /**
  13780. * Object will not rotate to face the camera
  13781. */
  13782. static BILLBOARDMODE_NONE: number;
  13783. /**
  13784. * Object will rotate to face the camera but only on the x axis
  13785. */
  13786. static BILLBOARDMODE_X: number;
  13787. /**
  13788. * Object will rotate to face the camera but only on the y axis
  13789. */
  13790. static BILLBOARDMODE_Y: number;
  13791. /**
  13792. * Object will rotate to face the camera but only on the z axis
  13793. */
  13794. static BILLBOARDMODE_Z: number;
  13795. /**
  13796. * Object will rotate to face the camera
  13797. */
  13798. static BILLBOARDMODE_ALL: number;
  13799. /**
  13800. * Object will rotate to face the camera's position instead of orientation
  13801. */
  13802. static BILLBOARDMODE_USE_POSITION: number;
  13803. private _forward;
  13804. private _forwardInverted;
  13805. private _up;
  13806. private _right;
  13807. private _rightInverted;
  13808. private _position;
  13809. private _rotation;
  13810. private _rotationQuaternion;
  13811. protected _scaling: Vector3;
  13812. protected _isDirty: boolean;
  13813. private _transformToBoneReferal;
  13814. private _isAbsoluteSynced;
  13815. private _billboardMode;
  13816. /**
  13817. * Gets or sets the billboard mode. Default is 0.
  13818. *
  13819. * | Value | Type | Description |
  13820. * | --- | --- | --- |
  13821. * | 0 | BILLBOARDMODE_NONE | |
  13822. * | 1 | BILLBOARDMODE_X | |
  13823. * | 2 | BILLBOARDMODE_Y | |
  13824. * | 4 | BILLBOARDMODE_Z | |
  13825. * | 7 | BILLBOARDMODE_ALL | |
  13826. *
  13827. */
  13828. get billboardMode(): number;
  13829. set billboardMode(value: number);
  13830. private _preserveParentRotationForBillboard;
  13831. /**
  13832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13834. */
  13835. get preserveParentRotationForBillboard(): boolean;
  13836. set preserveParentRotationForBillboard(value: boolean);
  13837. /**
  13838. * 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
  13839. */
  13840. scalingDeterminant: number;
  13841. private _infiniteDistance;
  13842. /**
  13843. * Gets or sets the distance of the object to max, often used by skybox
  13844. */
  13845. get infiniteDistance(): boolean;
  13846. set infiniteDistance(value: boolean);
  13847. /**
  13848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13849. * By default the system will update normals to compensate
  13850. */
  13851. ignoreNonUniformScaling: boolean;
  13852. /**
  13853. * 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
  13854. */
  13855. reIntegrateRotationIntoRotationQuaternion: boolean;
  13856. /** @hidden */
  13857. _poseMatrix: Nullable<Matrix>;
  13858. /** @hidden */
  13859. _localMatrix: Matrix;
  13860. private _usePivotMatrix;
  13861. private _absolutePosition;
  13862. private _absoluteScaling;
  13863. private _absoluteRotationQuaternion;
  13864. private _pivotMatrix;
  13865. private _pivotMatrixInverse;
  13866. protected _postMultiplyPivotMatrix: boolean;
  13867. protected _isWorldMatrixFrozen: boolean;
  13868. /** @hidden */
  13869. _indexInSceneTransformNodesArray: number;
  13870. /**
  13871. * An event triggered after the world matrix is updated
  13872. */
  13873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13875. /**
  13876. * Gets a string identifying the name of the class
  13877. * @returns "TransformNode" string
  13878. */
  13879. getClassName(): string;
  13880. /**
  13881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13882. */
  13883. get position(): Vector3;
  13884. set position(newPosition: Vector3);
  13885. /**
  13886. * 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)).
  13887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13888. */
  13889. get rotation(): Vector3;
  13890. set rotation(newRotation: Vector3);
  13891. /**
  13892. * 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)).
  13893. */
  13894. get scaling(): Vector3;
  13895. set scaling(newScaling: Vector3);
  13896. /**
  13897. * 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).
  13898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13899. */
  13900. get rotationQuaternion(): Nullable<Quaternion>;
  13901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13902. /**
  13903. * The forward direction of that transform in world space.
  13904. */
  13905. get forward(): Vector3;
  13906. /**
  13907. * The up direction of that transform in world space.
  13908. */
  13909. get up(): Vector3;
  13910. /**
  13911. * The right direction of that transform in world space.
  13912. */
  13913. get right(): Vector3;
  13914. /**
  13915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13916. * @param matrix the matrix to copy the pose from
  13917. * @returns this TransformNode.
  13918. */
  13919. updatePoseMatrix(matrix: Matrix): TransformNode;
  13920. /**
  13921. * Returns the mesh Pose matrix.
  13922. * @returns the pose matrix
  13923. */
  13924. getPoseMatrix(): Matrix;
  13925. /** @hidden */
  13926. _isSynchronized(): boolean;
  13927. /** @hidden */
  13928. _initCache(): void;
  13929. /**
  13930. * Flag the transform node as dirty (Forcing it to update everything)
  13931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13932. * @returns this transform node
  13933. */
  13934. markAsDirty(property: string): TransformNode;
  13935. /**
  13936. * Returns the current mesh absolute position.
  13937. * Returns a Vector3.
  13938. */
  13939. get absolutePosition(): Vector3;
  13940. /**
  13941. * Returns the current mesh absolute scaling.
  13942. * Returns a Vector3.
  13943. */
  13944. get absoluteScaling(): Vector3;
  13945. /**
  13946. * Returns the current mesh absolute rotation.
  13947. * Returns a Quaternion.
  13948. */
  13949. get absoluteRotationQuaternion(): Quaternion;
  13950. /**
  13951. * Sets a new matrix to apply before all other transformation
  13952. * @param matrix defines the transform matrix
  13953. * @returns the current TransformNode
  13954. */
  13955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13956. /**
  13957. * Sets a new pivot matrix to the current node
  13958. * @param matrix defines the new pivot matrix to use
  13959. * @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
  13960. * @returns the current TransformNode
  13961. */
  13962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13963. /**
  13964. * Returns the mesh pivot matrix.
  13965. * Default : Identity.
  13966. * @returns the matrix
  13967. */
  13968. getPivotMatrix(): Matrix;
  13969. /**
  13970. * Instantiate (when possible) or clone that node with its hierarchy
  13971. * @param newParent defines the new parent to use for the instance (or clone)
  13972. * @param options defines options to configure how copy is done
  13973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13974. * @returns an instance (or a clone) of the current node with its hiearchy
  13975. */
  13976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13977. doNotInstantiate: boolean;
  13978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13979. /**
  13980. * Prevents the World matrix to be computed any longer
  13981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13982. * @returns the TransformNode.
  13983. */
  13984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13985. /**
  13986. * Allows back the World matrix computation.
  13987. * @returns the TransformNode.
  13988. */
  13989. unfreezeWorldMatrix(): this;
  13990. /**
  13991. * True if the World matrix has been frozen.
  13992. */
  13993. get isWorldMatrixFrozen(): boolean;
  13994. /**
  13995. * Retuns the mesh absolute position in the World.
  13996. * @returns a Vector3.
  13997. */
  13998. getAbsolutePosition(): Vector3;
  13999. /**
  14000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14001. * @param absolutePosition the absolute position to set
  14002. * @returns the TransformNode.
  14003. */
  14004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14005. /**
  14006. * Sets the mesh position in its local space.
  14007. * @param vector3 the position to set in localspace
  14008. * @returns the TransformNode.
  14009. */
  14010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14011. /**
  14012. * Returns the mesh position in the local space from the current World matrix values.
  14013. * @returns a new Vector3.
  14014. */
  14015. getPositionExpressedInLocalSpace(): Vector3;
  14016. /**
  14017. * Translates the mesh along the passed Vector3 in its local space.
  14018. * @param vector3 the distance to translate in localspace
  14019. * @returns the TransformNode.
  14020. */
  14021. locallyTranslate(vector3: Vector3): TransformNode;
  14022. private static _lookAtVectorCache;
  14023. /**
  14024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14025. * @param targetPoint the position (must be in same space as current mesh) to look at
  14026. * @param yawCor optional yaw (y-axis) correction in radians
  14027. * @param pitchCor optional pitch (x-axis) correction in radians
  14028. * @param rollCor optional roll (z-axis) correction in radians
  14029. * @param space the choosen space of the target
  14030. * @returns the TransformNode.
  14031. */
  14032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14033. /**
  14034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14035. * This Vector3 is expressed in the World space.
  14036. * @param localAxis axis to rotate
  14037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14038. */
  14039. getDirection(localAxis: Vector3): Vector3;
  14040. /**
  14041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14042. * localAxis is expressed in the mesh local space.
  14043. * result is computed in the Wordl space from the mesh World matrix.
  14044. * @param localAxis axis to rotate
  14045. * @param result the resulting transformnode
  14046. * @returns this TransformNode.
  14047. */
  14048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14049. /**
  14050. * Sets this transform node rotation to the given local axis.
  14051. * @param localAxis the axis in local space
  14052. * @param yawCor optional yaw (y-axis) correction in radians
  14053. * @param pitchCor optional pitch (x-axis) correction in radians
  14054. * @param rollCor optional roll (z-axis) correction in radians
  14055. * @returns this TransformNode
  14056. */
  14057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14058. /**
  14059. * Sets a new pivot point to the current node
  14060. * @param point defines the new pivot point to use
  14061. * @param space defines if the point is in world or local space (local by default)
  14062. * @returns the current TransformNode
  14063. */
  14064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14065. /**
  14066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14067. * @returns the pivot point
  14068. */
  14069. getPivotPoint(): Vector3;
  14070. /**
  14071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14072. * @param result the vector3 to store the result
  14073. * @returns this TransformNode.
  14074. */
  14075. getPivotPointToRef(result: Vector3): TransformNode;
  14076. /**
  14077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14079. */
  14080. getAbsolutePivotPoint(): Vector3;
  14081. /**
  14082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14083. * @param result vector3 to store the result
  14084. * @returns this TransformNode.
  14085. */
  14086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14087. /**
  14088. * Defines the passed node as the parent of the current node.
  14089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14090. * @see https://doc.babylonjs.com/how_to/parenting
  14091. * @param node the node ot set as the parent
  14092. * @returns this TransformNode.
  14093. */
  14094. setParent(node: Nullable<Node>): TransformNode;
  14095. private _nonUniformScaling;
  14096. /**
  14097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14098. */
  14099. get nonUniformScaling(): boolean;
  14100. /** @hidden */
  14101. _updateNonUniformScalingState(value: boolean): boolean;
  14102. /**
  14103. * Attach the current TransformNode to another TransformNode associated with a bone
  14104. * @param bone Bone affecting the TransformNode
  14105. * @param affectedTransformNode TransformNode associated with the bone
  14106. * @returns this object
  14107. */
  14108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14109. /**
  14110. * Detach the transform node if its associated with a bone
  14111. * @returns this object
  14112. */
  14113. detachFromBone(): TransformNode;
  14114. private static _rotationAxisCache;
  14115. /**
  14116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14119. * The passed axis is also normalized.
  14120. * @param axis the axis to rotate around
  14121. * @param amount the amount to rotate in radians
  14122. * @param space Space to rotate in (Default: local)
  14123. * @returns the TransformNode.
  14124. */
  14125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14126. /**
  14127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14129. * The passed axis is also normalized. .
  14130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14131. * @param point the point to rotate around
  14132. * @param axis the axis to rotate around
  14133. * @param amount the amount to rotate in radians
  14134. * @returns the TransformNode
  14135. */
  14136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14137. /**
  14138. * Translates the mesh along the axis vector for the passed distance in the given space.
  14139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14140. * @param axis the axis to translate in
  14141. * @param distance the distance to translate
  14142. * @param space Space to rotate in (Default: local)
  14143. * @returns the TransformNode.
  14144. */
  14145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14146. /**
  14147. * Adds a rotation step to the mesh current rotation.
  14148. * x, y, z are Euler angles expressed in radians.
  14149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14150. * This means this rotation is made in the mesh local space only.
  14151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14153. * ```javascript
  14154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14155. * ```
  14156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14157. * 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.
  14158. * @param x Rotation to add
  14159. * @param y Rotation to add
  14160. * @param z Rotation to add
  14161. * @returns the TransformNode.
  14162. */
  14163. addRotation(x: number, y: number, z: number): TransformNode;
  14164. /**
  14165. * @hidden
  14166. */
  14167. protected _getEffectiveParent(): Nullable<Node>;
  14168. /**
  14169. * Computes the world matrix of the node
  14170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14171. * @returns the world matrix
  14172. */
  14173. computeWorldMatrix(force?: boolean): Matrix;
  14174. /**
  14175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14177. */
  14178. resetLocalMatrix(independentOfChildren?: boolean): void;
  14179. protected _afterComputeWorldMatrix(): void;
  14180. /**
  14181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14182. * @param func callback function to add
  14183. *
  14184. * @returns the TransformNode.
  14185. */
  14186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14187. /**
  14188. * Removes a registered callback function.
  14189. * @param func callback function to remove
  14190. * @returns the TransformNode.
  14191. */
  14192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14193. /**
  14194. * Gets the position of the current mesh in camera space
  14195. * @param camera defines the camera to use
  14196. * @returns a position
  14197. */
  14198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14199. /**
  14200. * Returns the distance from the mesh to the active camera
  14201. * @param camera defines the camera to use
  14202. * @returns the distance
  14203. */
  14204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14205. /**
  14206. * Clone the current transform node
  14207. * @param name Name of the new clone
  14208. * @param newParent New parent for the clone
  14209. * @param doNotCloneChildren Do not clone children hierarchy
  14210. * @returns the new transform node
  14211. */
  14212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14213. /**
  14214. * Serializes the objects information.
  14215. * @param currentSerializationObject defines the object to serialize in
  14216. * @returns the serialized object
  14217. */
  14218. serialize(currentSerializationObject?: any): any;
  14219. /**
  14220. * Returns a new TransformNode object parsed from the source provided.
  14221. * @param parsedTransformNode is the source.
  14222. * @param scene the scne the object belongs to
  14223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14224. * @returns a new TransformNode object parsed from the source provided.
  14225. */
  14226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14227. /**
  14228. * Get all child-transformNodes of this node
  14229. * @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
  14230. * @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
  14231. * @returns an array of TransformNode
  14232. */
  14233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14234. /**
  14235. * Releases resources associated with this transform node.
  14236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14238. */
  14239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14240. /**
  14241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14245. * @returns the current mesh
  14246. */
  14247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14248. private _syncAbsoluteScalingAndRotation;
  14249. }
  14250. }
  14251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14252. /**
  14253. * Class used to override all child animations of a given target
  14254. */
  14255. export class AnimationPropertiesOverride {
  14256. /**
  14257. * Gets or sets a value indicating if animation blending must be used
  14258. */
  14259. enableBlending: boolean;
  14260. /**
  14261. * Gets or sets the blending speed to use when enableBlending is true
  14262. */
  14263. blendingSpeed: number;
  14264. /**
  14265. * Gets or sets the default loop mode to use
  14266. */
  14267. loopMode: number;
  14268. }
  14269. }
  14270. declare module "babylonjs/Bones/bone" {
  14271. import { Skeleton } from "babylonjs/Bones/skeleton";
  14272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14273. import { Nullable } from "babylonjs/types";
  14274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14276. import { Node } from "babylonjs/node";
  14277. import { Space } from "babylonjs/Maths/math.axis";
  14278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14279. /**
  14280. * Class used to store bone information
  14281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14282. */
  14283. export class Bone extends Node {
  14284. /**
  14285. * defines the bone name
  14286. */
  14287. name: string;
  14288. private static _tmpVecs;
  14289. private static _tmpQuat;
  14290. private static _tmpMats;
  14291. /**
  14292. * Gets the list of child bones
  14293. */
  14294. children: Bone[];
  14295. /** Gets the animations associated with this bone */
  14296. animations: import("babylonjs/Animations/animation").Animation[];
  14297. /**
  14298. * Gets or sets bone length
  14299. */
  14300. length: number;
  14301. /**
  14302. * @hidden Internal only
  14303. * Set this value to map this bone to a different index in the transform matrices
  14304. * Set this value to -1 to exclude the bone from the transform matrices
  14305. */
  14306. _index: Nullable<number>;
  14307. private _skeleton;
  14308. private _localMatrix;
  14309. private _restPose;
  14310. private _baseMatrix;
  14311. private _absoluteTransform;
  14312. private _invertedAbsoluteTransform;
  14313. private _parent;
  14314. private _scalingDeterminant;
  14315. private _worldTransform;
  14316. private _localScaling;
  14317. private _localRotation;
  14318. private _localPosition;
  14319. private _needToDecompose;
  14320. private _needToCompose;
  14321. /** @hidden */
  14322. _linkedTransformNode: Nullable<TransformNode>;
  14323. /** @hidden */
  14324. _waitingTransformNodeId: Nullable<string>;
  14325. /** @hidden */
  14326. get _matrix(): Matrix;
  14327. /** @hidden */
  14328. set _matrix(value: Matrix);
  14329. /**
  14330. * Create a new bone
  14331. * @param name defines the bone name
  14332. * @param skeleton defines the parent skeleton
  14333. * @param parentBone defines the parent (can be null if the bone is the root)
  14334. * @param localMatrix defines the local matrix
  14335. * @param restPose defines the rest pose matrix
  14336. * @param baseMatrix defines the base matrix
  14337. * @param index defines index of the bone in the hiearchy
  14338. */
  14339. constructor(
  14340. /**
  14341. * defines the bone name
  14342. */
  14343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14344. /**
  14345. * Gets the current object class name.
  14346. * @return the class name
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Gets the parent skeleton
  14351. * @returns a skeleton
  14352. */
  14353. getSkeleton(): Skeleton;
  14354. /**
  14355. * Gets parent bone
  14356. * @returns a bone or null if the bone is the root of the bone hierarchy
  14357. */
  14358. getParent(): Nullable<Bone>;
  14359. /**
  14360. * Returns an array containing the root bones
  14361. * @returns an array containing the root bones
  14362. */
  14363. getChildren(): Array<Bone>;
  14364. /**
  14365. * Gets the node index in matrix array generated for rendering
  14366. * @returns the node index
  14367. */
  14368. getIndex(): number;
  14369. /**
  14370. * Sets the parent bone
  14371. * @param parent defines the parent (can be null if the bone is the root)
  14372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14373. */
  14374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14375. /**
  14376. * Gets the local matrix
  14377. * @returns a matrix
  14378. */
  14379. getLocalMatrix(): Matrix;
  14380. /**
  14381. * Gets the base matrix (initial matrix which remains unchanged)
  14382. * @returns a matrix
  14383. */
  14384. getBaseMatrix(): Matrix;
  14385. /**
  14386. * Gets the rest pose matrix
  14387. * @returns a matrix
  14388. */
  14389. getRestPose(): Matrix;
  14390. /**
  14391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14392. */
  14393. getWorldMatrix(): Matrix;
  14394. /**
  14395. * Sets the local matrix to rest pose matrix
  14396. */
  14397. returnToRest(): void;
  14398. /**
  14399. * Gets the inverse of the absolute transform matrix.
  14400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14401. * @returns a matrix
  14402. */
  14403. getInvertedAbsoluteTransform(): Matrix;
  14404. /**
  14405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14406. * @returns a matrix
  14407. */
  14408. getAbsoluteTransform(): Matrix;
  14409. /**
  14410. * Links with the given transform node.
  14411. * The local matrix of this bone is copied from the transform node every frame.
  14412. * @param transformNode defines the transform node to link to
  14413. */
  14414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14415. /**
  14416. * Gets the node used to drive the bone's transformation
  14417. * @returns a transform node or null
  14418. */
  14419. getTransformNode(): Nullable<TransformNode>;
  14420. /** Gets or sets current position (in local space) */
  14421. get position(): Vector3;
  14422. set position(newPosition: Vector3);
  14423. /** Gets or sets current rotation (in local space) */
  14424. get rotation(): Vector3;
  14425. set rotation(newRotation: Vector3);
  14426. /** Gets or sets current rotation quaternion (in local space) */
  14427. get rotationQuaternion(): Quaternion;
  14428. set rotationQuaternion(newRotation: Quaternion);
  14429. /** Gets or sets current scaling (in local space) */
  14430. get scaling(): Vector3;
  14431. set scaling(newScaling: Vector3);
  14432. /**
  14433. * Gets the animation properties override
  14434. */
  14435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14436. private _decompose;
  14437. private _compose;
  14438. /**
  14439. * Update the base and local matrices
  14440. * @param matrix defines the new base or local matrix
  14441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14442. * @param updateLocalMatrix defines if the local matrix should be updated
  14443. */
  14444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14445. /** @hidden */
  14446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14447. /**
  14448. * Flag the bone as dirty (Forcing it to update everything)
  14449. */
  14450. markAsDirty(): void;
  14451. /** @hidden */
  14452. _markAsDirtyAndCompose(): void;
  14453. private _markAsDirtyAndDecompose;
  14454. /**
  14455. * Translate the bone in local or world space
  14456. * @param vec The amount to translate the bone
  14457. * @param space The space that the translation is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the postion of the bone in local or world space
  14463. * @param position The position to set the bone
  14464. * @param space The space that the position is in
  14465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14466. */
  14467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14468. /**
  14469. * Set the absolute position of the bone (world space)
  14470. * @param position The position to set the bone
  14471. * @param mesh The mesh that this bone is attached to
  14472. */
  14473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14474. /**
  14475. * Scale the bone on the x, y and z axes (in local space)
  14476. * @param x The amount to scale the bone on the x axis
  14477. * @param y The amount to scale the bone on the y axis
  14478. * @param z The amount to scale the bone on the z axis
  14479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14480. */
  14481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14482. /**
  14483. * Set the bone scaling in local space
  14484. * @param scale defines the scaling vector
  14485. */
  14486. setScale(scale: Vector3): void;
  14487. /**
  14488. * Gets the current scaling in local space
  14489. * @returns the current scaling vector
  14490. */
  14491. getScale(): Vector3;
  14492. /**
  14493. * Gets the current scaling in local space and stores it in a target vector
  14494. * @param result defines the target vector
  14495. */
  14496. getScaleToRef(result: Vector3): void;
  14497. /**
  14498. * Set the yaw, pitch, and roll of the bone in local or world space
  14499. * @param yaw The rotation of the bone on the y axis
  14500. * @param pitch The rotation of the bone on the x axis
  14501. * @param roll The rotation of the bone on the z axis
  14502. * @param space The space that the axes of rotation are in
  14503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14504. */
  14505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14506. /**
  14507. * Add a rotation to the bone on an axis in local or world space
  14508. * @param axis The axis to rotate the bone on
  14509. * @param amount The amount to rotate the bone
  14510. * @param space The space that the axis is in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. */
  14513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14514. /**
  14515. * Set the rotation of the bone to a particular axis angle in local or world space
  14516. * @param axis The axis to rotate the bone on
  14517. * @param angle The angle that the bone should be rotated to
  14518. * @param space The space that the axis is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the euler rotation of the bone in local of world space
  14524. * @param rotation The euler rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the quaternion rotation of the bone in local of world space
  14531. * @param quat The quaternion rotation that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14536. /**
  14537. * Set the rotation matrix of the bone in local of world space
  14538. * @param rotMat The rotation matrix that the bone should be set to
  14539. * @param space The space that the rotation is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14543. private _rotateWithMatrix;
  14544. private _getNegativeRotationToRef;
  14545. /**
  14546. * Get the position of the bone in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @returns The position of the bone
  14550. */
  14551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14552. /**
  14553. * Copy the position of the bone to a vector3 in local or world space
  14554. * @param space The space that the returned position is in
  14555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14556. * @param result The vector3 to copy the position to
  14557. */
  14558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14559. /**
  14560. * Get the absolute position of the bone (world space)
  14561. * @param mesh The mesh that this bone is attached to
  14562. * @returns The absolute position of the bone
  14563. */
  14564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14565. /**
  14566. * Copy the absolute position of the bone (world space) to the result param
  14567. * @param mesh The mesh that this bone is attached to
  14568. * @param result The vector3 to copy the absolute position to
  14569. */
  14570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14571. /**
  14572. * Compute the absolute transforms of this bone and its children
  14573. */
  14574. computeAbsoluteTransforms(): void;
  14575. /**
  14576. * Get the world direction from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @returns The world direction
  14580. */
  14581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14582. /**
  14583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14584. * @param localAxis The local direction that is used to compute the world direction
  14585. * @param mesh The mesh that this bone is attached to
  14586. * @param result The vector3 that the world direction will be copied to
  14587. */
  14588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14589. /**
  14590. * Get the euler rotation of the bone in local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @returns The euler rotation
  14594. */
  14595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14596. /**
  14597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @param result The vector3 that the rotation should be copied to
  14601. */
  14602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14603. /**
  14604. * Get the quaternion rotation of the bone in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @returns The quaternion rotation
  14608. */
  14609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14610. /**
  14611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @param result The quaternion that the rotation should be copied to
  14615. */
  14616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14617. /**
  14618. * Get the rotation matrix of the bone in local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @returns The rotation matrix
  14622. */
  14623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14624. /**
  14625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @param result The quaternion that the rotation should be copied to
  14629. */
  14630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @returns The world position
  14636. */
  14637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14638. /**
  14639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14640. * @param position The local position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @param result The vector3 that the world position should be copied to
  14643. */
  14644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14645. /**
  14646. * Get the local position of a point that is in world space
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @returns The local position
  14650. */
  14651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14652. /**
  14653. * Get the local position of a point that is in world space and copy it to the result param
  14654. * @param position The world position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @param result The vector3 that the local position should be copied to
  14657. */
  14658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14659. }
  14660. }
  14661. declare module "babylonjs/Animations/runtimeAnimation" {
  14662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14663. import { Animatable } from "babylonjs/Animations/animatable";
  14664. import { Scene } from "babylonjs/scene";
  14665. /**
  14666. * Defines a runtime animation
  14667. */
  14668. export class RuntimeAnimation {
  14669. private _events;
  14670. /**
  14671. * The current frame of the runtime animation
  14672. */
  14673. private _currentFrame;
  14674. /**
  14675. * The animation used by the runtime animation
  14676. */
  14677. private _animation;
  14678. /**
  14679. * The target of the runtime animation
  14680. */
  14681. private _target;
  14682. /**
  14683. * The initiating animatable
  14684. */
  14685. private _host;
  14686. /**
  14687. * The original value of the runtime animation
  14688. */
  14689. private _originalValue;
  14690. /**
  14691. * The original blend value of the runtime animation
  14692. */
  14693. private _originalBlendValue;
  14694. /**
  14695. * The offsets cache of the runtime animation
  14696. */
  14697. private _offsetsCache;
  14698. /**
  14699. * The high limits cache of the runtime animation
  14700. */
  14701. private _highLimitsCache;
  14702. /**
  14703. * Specifies if the runtime animation has been stopped
  14704. */
  14705. private _stopped;
  14706. /**
  14707. * The blending factor of the runtime animation
  14708. */
  14709. private _blendingFactor;
  14710. /**
  14711. * The BabylonJS scene
  14712. */
  14713. private _scene;
  14714. /**
  14715. * The current value of the runtime animation
  14716. */
  14717. private _currentValue;
  14718. /** @hidden */
  14719. _animationState: _IAnimationState;
  14720. /**
  14721. * The active target of the runtime animation
  14722. */
  14723. private _activeTargets;
  14724. private _currentActiveTarget;
  14725. private _directTarget;
  14726. /**
  14727. * The target path of the runtime animation
  14728. */
  14729. private _targetPath;
  14730. /**
  14731. * The weight of the runtime animation
  14732. */
  14733. private _weight;
  14734. /**
  14735. * The ratio offset of the runtime animation
  14736. */
  14737. private _ratioOffset;
  14738. /**
  14739. * The previous delay of the runtime animation
  14740. */
  14741. private _previousDelay;
  14742. /**
  14743. * The previous ratio of the runtime animation
  14744. */
  14745. private _previousRatio;
  14746. private _enableBlending;
  14747. private _keys;
  14748. private _minFrame;
  14749. private _maxFrame;
  14750. private _minValue;
  14751. private _maxValue;
  14752. private _targetIsArray;
  14753. /**
  14754. * Gets the current frame of the runtime animation
  14755. */
  14756. get currentFrame(): number;
  14757. /**
  14758. * Gets the weight of the runtime animation
  14759. */
  14760. get weight(): number;
  14761. /**
  14762. * Gets the current value of the runtime animation
  14763. */
  14764. get currentValue(): any;
  14765. /**
  14766. * Gets the target path of the runtime animation
  14767. */
  14768. get targetPath(): string;
  14769. /**
  14770. * Gets the actual target of the runtime animation
  14771. */
  14772. get target(): any;
  14773. /** @hidden */
  14774. _onLoop: () => void;
  14775. /**
  14776. * Create a new RuntimeAnimation object
  14777. * @param target defines the target of the animation
  14778. * @param animation defines the source animation object
  14779. * @param scene defines the hosting scene
  14780. * @param host defines the initiating Animatable
  14781. */
  14782. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14783. private _preparePath;
  14784. /**
  14785. * Gets the animation from the runtime animation
  14786. */
  14787. get animation(): Animation;
  14788. /**
  14789. * Resets the runtime animation to the beginning
  14790. * @param restoreOriginal defines whether to restore the target property to the original value
  14791. */
  14792. reset(restoreOriginal?: boolean): void;
  14793. /**
  14794. * Specifies if the runtime animation is stopped
  14795. * @returns Boolean specifying if the runtime animation is stopped
  14796. */
  14797. isStopped(): boolean;
  14798. /**
  14799. * Disposes of the runtime animation
  14800. */
  14801. dispose(): void;
  14802. /**
  14803. * Apply the interpolated value to the target
  14804. * @param currentValue defines the value computed by the animation
  14805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14806. */
  14807. setValue(currentValue: any, weight: number): void;
  14808. private _getOriginalValues;
  14809. private _setValue;
  14810. /**
  14811. * Gets the loop pmode of the runtime animation
  14812. * @returns Loop Mode
  14813. */
  14814. private _getCorrectLoopMode;
  14815. /**
  14816. * Move the current animation to a given frame
  14817. * @param frame defines the frame to move to
  14818. */
  14819. goToFrame(frame: number): void;
  14820. /**
  14821. * @hidden Internal use only
  14822. */
  14823. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14824. /**
  14825. * Execute the current animation
  14826. * @param delay defines the delay to add to the current frame
  14827. * @param from defines the lower bound of the animation range
  14828. * @param to defines the upper bound of the animation range
  14829. * @param loop defines if the current animation must loop
  14830. * @param speedRatio defines the current speed ratio
  14831. * @param weight defines the weight of the animation (default is -1 so no weight)
  14832. * @param onLoop optional callback called when animation loops
  14833. * @returns a boolean indicating if the animation is running
  14834. */
  14835. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14836. }
  14837. }
  14838. declare module "babylonjs/Animations/animatable" {
  14839. import { Animation } from "babylonjs/Animations/animation";
  14840. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14841. import { Nullable } from "babylonjs/types";
  14842. import { Observable } from "babylonjs/Misc/observable";
  14843. import { Scene } from "babylonjs/scene";
  14844. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14845. import { Node } from "babylonjs/node";
  14846. /**
  14847. * Class used to store an actual running animation
  14848. */
  14849. export class Animatable {
  14850. /** defines the target object */
  14851. target: any;
  14852. /** defines the starting frame number (default is 0) */
  14853. fromFrame: number;
  14854. /** defines the ending frame number (default is 100) */
  14855. toFrame: number;
  14856. /** defines if the animation must loop (default is false) */
  14857. loopAnimation: boolean;
  14858. /** defines a callback to call when animation ends if it is not looping */
  14859. onAnimationEnd?: (() => void) | null | undefined;
  14860. /** defines a callback to call when animation loops */
  14861. onAnimationLoop?: (() => void) | null | undefined;
  14862. private _localDelayOffset;
  14863. private _pausedDelay;
  14864. private _runtimeAnimations;
  14865. private _paused;
  14866. private _scene;
  14867. private _speedRatio;
  14868. private _weight;
  14869. private _syncRoot;
  14870. /**
  14871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14872. * This will only apply for non looping animation (default is true)
  14873. */
  14874. disposeOnEnd: boolean;
  14875. /**
  14876. * Gets a boolean indicating if the animation has started
  14877. */
  14878. animationStarted: boolean;
  14879. /**
  14880. * Observer raised when the animation ends
  14881. */
  14882. onAnimationEndObservable: Observable<Animatable>;
  14883. /**
  14884. * Observer raised when the animation loops
  14885. */
  14886. onAnimationLoopObservable: Observable<Animatable>;
  14887. /**
  14888. * Gets the root Animatable used to synchronize and normalize animations
  14889. */
  14890. get syncRoot(): Nullable<Animatable>;
  14891. /**
  14892. * Gets the current frame of the first RuntimeAnimation
  14893. * Used to synchronize Animatables
  14894. */
  14895. get masterFrame(): number;
  14896. /**
  14897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14898. */
  14899. get weight(): number;
  14900. set weight(value: number);
  14901. /**
  14902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14903. */
  14904. get speedRatio(): number;
  14905. set speedRatio(value: number);
  14906. /**
  14907. * Creates a new Animatable
  14908. * @param scene defines the hosting scene
  14909. * @param target defines the target object
  14910. * @param fromFrame defines the starting frame number (default is 0)
  14911. * @param toFrame defines the ending frame number (default is 100)
  14912. * @param loopAnimation defines if the animation must loop (default is false)
  14913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14915. * @param animations defines a group of animation to add to the new Animatable
  14916. * @param onAnimationLoop defines a callback to call when animation loops
  14917. */
  14918. constructor(scene: Scene,
  14919. /** defines the target object */
  14920. target: any,
  14921. /** defines the starting frame number (default is 0) */
  14922. fromFrame?: number,
  14923. /** defines the ending frame number (default is 100) */
  14924. toFrame?: number,
  14925. /** defines if the animation must loop (default is false) */
  14926. loopAnimation?: boolean, speedRatio?: number,
  14927. /** defines a callback to call when animation ends if it is not looping */
  14928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14929. /** defines a callback to call when animation loops */
  14930. onAnimationLoop?: (() => void) | null | undefined);
  14931. /**
  14932. * Synchronize and normalize current Animatable with a source Animatable
  14933. * This is useful when using animation weights and when animations are not of the same length
  14934. * @param root defines the root Animatable to synchronize with
  14935. * @returns the current Animatable
  14936. */
  14937. syncWith(root: Animatable): Animatable;
  14938. /**
  14939. * Gets the list of runtime animations
  14940. * @returns an array of RuntimeAnimation
  14941. */
  14942. getAnimations(): RuntimeAnimation[];
  14943. /**
  14944. * Adds more animations to the current animatable
  14945. * @param target defines the target of the animations
  14946. * @param animations defines the new animations to add
  14947. */
  14948. appendAnimations(target: any, animations: Animation[]): void;
  14949. /**
  14950. * Gets the source animation for a specific property
  14951. * @param property defines the propertyu to look for
  14952. * @returns null or the source animation for the given property
  14953. */
  14954. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14955. /**
  14956. * Gets the runtime animation for a specific property
  14957. * @param property defines the propertyu to look for
  14958. * @returns null or the runtime animation for the given property
  14959. */
  14960. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14961. /**
  14962. * Resets the animatable to its original state
  14963. */
  14964. reset(): void;
  14965. /**
  14966. * Allows the animatable to blend with current running animations
  14967. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14968. * @param blendingSpeed defines the blending speed to use
  14969. */
  14970. enableBlending(blendingSpeed: number): void;
  14971. /**
  14972. * Disable animation blending
  14973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14974. */
  14975. disableBlending(): void;
  14976. /**
  14977. * Jump directly to a given frame
  14978. * @param frame defines the frame to jump to
  14979. */
  14980. goToFrame(frame: number): void;
  14981. /**
  14982. * Pause the animation
  14983. */
  14984. pause(): void;
  14985. /**
  14986. * Restart the animation
  14987. */
  14988. restart(): void;
  14989. private _raiseOnAnimationEnd;
  14990. /**
  14991. * Stop and delete the current animation
  14992. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14993. * @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)
  14994. */
  14995. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14996. /**
  14997. * Wait asynchronously for the animation to end
  14998. * @returns a promise which will be fullfilled when the animation ends
  14999. */
  15000. waitAsync(): Promise<Animatable>;
  15001. /** @hidden */
  15002. _animate(delay: number): boolean;
  15003. }
  15004. module "babylonjs/scene" {
  15005. interface Scene {
  15006. /** @hidden */
  15007. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15008. /** @hidden */
  15009. _processLateAnimationBindingsForMatrices(holder: {
  15010. totalWeight: number;
  15011. animations: RuntimeAnimation[];
  15012. originalValue: Matrix;
  15013. }): any;
  15014. /** @hidden */
  15015. _processLateAnimationBindingsForQuaternions(holder: {
  15016. totalWeight: number;
  15017. animations: RuntimeAnimation[];
  15018. originalValue: Quaternion;
  15019. }, refQuaternion: Quaternion): Quaternion;
  15020. /** @hidden */
  15021. _processLateAnimationBindings(): void;
  15022. /**
  15023. * Will start the animation sequence of a given target
  15024. * @param target defines the target
  15025. * @param from defines from which frame should animation start
  15026. * @param to defines until which frame should animation run.
  15027. * @param weight defines the weight to apply to the animation (1.0 by default)
  15028. * @param loop defines if the animation loops
  15029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15030. * @param onAnimationEnd defines the function to be executed when the animation ends
  15031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15033. * @param onAnimationLoop defines the callback to call when an animation loops
  15034. * @returns the animatable object created for this animation
  15035. */
  15036. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15037. /**
  15038. * Will start the animation sequence of a given target
  15039. * @param target defines the target
  15040. * @param from defines from which frame should animation start
  15041. * @param to defines until which frame should animation run.
  15042. * @param loop defines if the animation loops
  15043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15044. * @param onAnimationEnd defines the function to be executed when the animation ends
  15045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15046. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15047. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15048. * @param onAnimationLoop defines the callback to call when an animation loops
  15049. * @returns the animatable object created for this animation
  15050. */
  15051. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15052. /**
  15053. * Will start the animation sequence of a given target and its hierarchy
  15054. * @param target defines the target
  15055. * @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.
  15056. * @param from defines from which frame should animation start
  15057. * @param to defines until which frame should animation run.
  15058. * @param loop defines if the animation loops
  15059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15060. * @param onAnimationEnd defines the function to be executed when the animation ends
  15061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15062. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15063. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15064. * @param onAnimationLoop defines the callback to call when an animation loops
  15065. * @returns the list of created animatables
  15066. */
  15067. 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[];
  15068. /**
  15069. * Begin a new animation on a given node
  15070. * @param target defines the target where the animation will take place
  15071. * @param animations defines the list of animations to start
  15072. * @param from defines the initial value
  15073. * @param to defines the final value
  15074. * @param loop defines if you want animation to loop (off by default)
  15075. * @param speedRatio defines the speed ratio to apply to all animations
  15076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15077. * @param onAnimationLoop defines the callback to call when an animation loops
  15078. * @returns the list of created animatables
  15079. */
  15080. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15081. /**
  15082. * Begin a new animation on a given node and its hierarchy
  15083. * @param target defines the root node where the animation will take place
  15084. * @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.
  15085. * @param animations defines the list of animations to start
  15086. * @param from defines the initial value
  15087. * @param to defines the final value
  15088. * @param loop defines if you want animation to loop (off by default)
  15089. * @param speedRatio defines the speed ratio to apply to all animations
  15090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15091. * @param onAnimationLoop defines the callback to call when an animation loops
  15092. * @returns the list of animatables created for all nodes
  15093. */
  15094. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15095. /**
  15096. * Gets the animatable associated with a specific target
  15097. * @param target defines the target of the animatable
  15098. * @returns the required animatable if found
  15099. */
  15100. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15101. /**
  15102. * Gets all animatables associated with a given target
  15103. * @param target defines the target to look animatables for
  15104. * @returns an array of Animatables
  15105. */
  15106. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15107. /**
  15108. * Stops and removes all animations that have been applied to the scene
  15109. */
  15110. stopAllAnimations(): void;
  15111. /**
  15112. * Gets the current delta time used by animation engine
  15113. */
  15114. deltaTime: number;
  15115. }
  15116. }
  15117. module "babylonjs/Bones/bone" {
  15118. interface Bone {
  15119. /**
  15120. * Copy an animation range from another bone
  15121. * @param source defines the source bone
  15122. * @param rangeName defines the range name to copy
  15123. * @param frameOffset defines the frame offset
  15124. * @param rescaleAsRequired defines if rescaling must be applied if required
  15125. * @param skelDimensionsRatio defines the scaling ratio
  15126. * @returns true if operation was successful
  15127. */
  15128. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15129. }
  15130. }
  15131. }
  15132. declare module "babylonjs/Bones/skeleton" {
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { Observable } from "babylonjs/Misc/observable";
  15135. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Nullable } from "babylonjs/types";
  15138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15139. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15140. import { Animatable } from "babylonjs/Animations/animatable";
  15141. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15142. import { Animation } from "babylonjs/Animations/animation";
  15143. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15144. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15146. /**
  15147. * Class used to handle skinning animations
  15148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15149. */
  15150. export class Skeleton implements IAnimatable {
  15151. /** defines the skeleton name */
  15152. name: string;
  15153. /** defines the skeleton Id */
  15154. id: string;
  15155. /**
  15156. * Defines the list of child bones
  15157. */
  15158. bones: Bone[];
  15159. /**
  15160. * Defines an estimate of the dimension of the skeleton at rest
  15161. */
  15162. dimensionsAtRest: Vector3;
  15163. /**
  15164. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15165. */
  15166. needInitialSkinMatrix: boolean;
  15167. /**
  15168. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15169. */
  15170. overrideMesh: Nullable<AbstractMesh>;
  15171. /**
  15172. * Gets the list of animations attached to this skeleton
  15173. */
  15174. animations: Array<Animation>;
  15175. private _scene;
  15176. private _isDirty;
  15177. private _transformMatrices;
  15178. private _transformMatrixTexture;
  15179. private _meshesWithPoseMatrix;
  15180. private _animatables;
  15181. private _identity;
  15182. private _synchronizedWithMesh;
  15183. private _ranges;
  15184. private _lastAbsoluteTransformsUpdateId;
  15185. private _canUseTextureForBones;
  15186. private _uniqueId;
  15187. /** @hidden */
  15188. _numBonesWithLinkedTransformNode: number;
  15189. /** @hidden */
  15190. _hasWaitingData: Nullable<boolean>;
  15191. /**
  15192. * Specifies if the skeleton should be serialized
  15193. */
  15194. doNotSerialize: boolean;
  15195. private _useTextureToStoreBoneMatrices;
  15196. /**
  15197. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15198. * Please note that this option is not available if the hardware does not support it
  15199. */
  15200. get useTextureToStoreBoneMatrices(): boolean;
  15201. set useTextureToStoreBoneMatrices(value: boolean);
  15202. private _animationPropertiesOverride;
  15203. /**
  15204. * Gets or sets the animation properties override
  15205. */
  15206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15208. /**
  15209. * List of inspectable custom properties (used by the Inspector)
  15210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15211. */
  15212. inspectableCustomProperties: IInspectable[];
  15213. /**
  15214. * An observable triggered before computing the skeleton's matrices
  15215. */
  15216. onBeforeComputeObservable: Observable<Skeleton>;
  15217. /**
  15218. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15219. */
  15220. get isUsingTextureForMatrices(): boolean;
  15221. /**
  15222. * Gets the unique ID of this skeleton
  15223. */
  15224. get uniqueId(): number;
  15225. /**
  15226. * Creates a new skeleton
  15227. * @param name defines the skeleton name
  15228. * @param id defines the skeleton Id
  15229. * @param scene defines the hosting scene
  15230. */
  15231. constructor(
  15232. /** defines the skeleton name */
  15233. name: string,
  15234. /** defines the skeleton Id */
  15235. id: string, scene: Scene);
  15236. /**
  15237. * Gets the current object class name.
  15238. * @return the class name
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Returns an array containing the root bones
  15243. * @returns an array containing the root bones
  15244. */
  15245. getChildren(): Array<Bone>;
  15246. /**
  15247. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15248. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15249. * @returns a Float32Array containing matrices data
  15250. */
  15251. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15252. /**
  15253. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15254. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15255. * @returns a raw texture containing the data
  15256. */
  15257. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15258. /**
  15259. * Gets the current hosting scene
  15260. * @returns a scene object
  15261. */
  15262. getScene(): Scene;
  15263. /**
  15264. * Gets a string representing the current skeleton data
  15265. * @param fullDetails defines a boolean indicating if we want a verbose version
  15266. * @returns a string representing the current skeleton data
  15267. */
  15268. toString(fullDetails?: boolean): string;
  15269. /**
  15270. * Get bone's index searching by name
  15271. * @param name defines bone's name to search for
  15272. * @return the indice of the bone. Returns -1 if not found
  15273. */
  15274. getBoneIndexByName(name: string): number;
  15275. /**
  15276. * Creater a new animation range
  15277. * @param name defines the name of the range
  15278. * @param from defines the start key
  15279. * @param to defines the end key
  15280. */
  15281. createAnimationRange(name: string, from: number, to: number): void;
  15282. /**
  15283. * Delete a specific animation range
  15284. * @param name defines the name of the range
  15285. * @param deleteFrames defines if frames must be removed as well
  15286. */
  15287. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15288. /**
  15289. * Gets a specific animation range
  15290. * @param name defines the name of the range to look for
  15291. * @returns the requested animation range or null if not found
  15292. */
  15293. getAnimationRange(name: string): Nullable<AnimationRange>;
  15294. /**
  15295. * Gets the list of all animation ranges defined on this skeleton
  15296. * @returns an array
  15297. */
  15298. getAnimationRanges(): Nullable<AnimationRange>[];
  15299. /**
  15300. * Copy animation range from a source skeleton.
  15301. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15302. * @param source defines the source skeleton
  15303. * @param name defines the name of the range to copy
  15304. * @param rescaleAsRequired defines if rescaling must be applied if required
  15305. * @returns true if operation was successful
  15306. */
  15307. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15308. /**
  15309. * Forces the skeleton to go to rest pose
  15310. */
  15311. returnToRest(): void;
  15312. private _getHighestAnimationFrame;
  15313. /**
  15314. * Begin a specific animation range
  15315. * @param name defines the name of the range to start
  15316. * @param loop defines if looping must be turned on (false by default)
  15317. * @param speedRatio defines the speed ratio to apply (1 by default)
  15318. * @param onAnimationEnd defines a callback which will be called when animation will end
  15319. * @returns a new animatable
  15320. */
  15321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15322. /** @hidden */
  15323. _markAsDirty(): void;
  15324. /** @hidden */
  15325. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15326. /** @hidden */
  15327. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15328. private _computeTransformMatrices;
  15329. /**
  15330. * Build all resources required to render a skeleton
  15331. */
  15332. prepare(): void;
  15333. /**
  15334. * Gets the list of animatables currently running for this skeleton
  15335. * @returns an array of animatables
  15336. */
  15337. getAnimatables(): IAnimatable[];
  15338. /**
  15339. * Clone the current skeleton
  15340. * @param name defines the name of the new skeleton
  15341. * @param id defines the id of the new skeleton
  15342. * @returns the new skeleton
  15343. */
  15344. clone(name: string, id?: string): Skeleton;
  15345. /**
  15346. * Enable animation blending for this skeleton
  15347. * @param blendingSpeed defines the blending speed to apply
  15348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15349. */
  15350. enableBlending(blendingSpeed?: number): void;
  15351. /**
  15352. * Releases all resources associated with the current skeleton
  15353. */
  15354. dispose(): void;
  15355. /**
  15356. * Serialize the skeleton in a JSON object
  15357. * @returns a JSON object
  15358. */
  15359. serialize(): any;
  15360. /**
  15361. * Creates a new skeleton from serialized data
  15362. * @param parsedSkeleton defines the serialized data
  15363. * @param scene defines the hosting scene
  15364. * @returns a new skeleton
  15365. */
  15366. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15367. /**
  15368. * Compute all node absolute transforms
  15369. * @param forceUpdate defines if computation must be done even if cache is up to date
  15370. */
  15371. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15372. /**
  15373. * Gets the root pose matrix
  15374. * @returns a matrix
  15375. */
  15376. getPoseMatrix(): Nullable<Matrix>;
  15377. /**
  15378. * Sorts bones per internal index
  15379. */
  15380. sortBones(): void;
  15381. private _sortBones;
  15382. }
  15383. }
  15384. declare module "babylonjs/Meshes/instancedMesh" {
  15385. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Camera } from "babylonjs/Cameras/camera";
  15388. import { Node } from "babylonjs/node";
  15389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15390. import { Mesh } from "babylonjs/Meshes/mesh";
  15391. import { Material } from "babylonjs/Materials/material";
  15392. import { Skeleton } from "babylonjs/Bones/skeleton";
  15393. import { Light } from "babylonjs/Lights/light";
  15394. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15395. /**
  15396. * Creates an instance based on a source mesh.
  15397. */
  15398. export class InstancedMesh extends AbstractMesh {
  15399. private _sourceMesh;
  15400. private _currentLOD;
  15401. /** @hidden */
  15402. _indexInSourceMeshInstanceArray: number;
  15403. constructor(name: string, source: Mesh);
  15404. /**
  15405. * Returns the string "InstancedMesh".
  15406. */
  15407. getClassName(): string;
  15408. /** Gets the list of lights affecting that mesh */
  15409. get lightSources(): Light[];
  15410. _resyncLightSources(): void;
  15411. _resyncLightSource(light: Light): void;
  15412. _removeLightSource(light: Light, dispose: boolean): void;
  15413. /**
  15414. * If the source mesh receives shadows
  15415. */
  15416. get receiveShadows(): boolean;
  15417. /**
  15418. * The material of the source mesh
  15419. */
  15420. get material(): Nullable<Material>;
  15421. /**
  15422. * Visibility of the source mesh
  15423. */
  15424. get visibility(): number;
  15425. /**
  15426. * Skeleton of the source mesh
  15427. */
  15428. get skeleton(): Nullable<Skeleton>;
  15429. /**
  15430. * Rendering ground id of the source mesh
  15431. */
  15432. get renderingGroupId(): number;
  15433. set renderingGroupId(value: number);
  15434. /**
  15435. * Returns the total number of vertices (integer).
  15436. */
  15437. getTotalVertices(): number;
  15438. /**
  15439. * Returns a positive integer : the total number of indices in this mesh geometry.
  15440. * @returns the numner of indices or zero if the mesh has no geometry.
  15441. */
  15442. getTotalIndices(): number;
  15443. /**
  15444. * The source mesh of the instance
  15445. */
  15446. get sourceMesh(): Mesh;
  15447. /**
  15448. * Is this node ready to be used/rendered
  15449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15450. * @return {boolean} is it ready
  15451. */
  15452. isReady(completeCheck?: boolean): boolean;
  15453. /**
  15454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15455. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15456. * @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.
  15457. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15458. */
  15459. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15460. /**
  15461. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15462. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15463. * The `data` are either a numeric array either a Float32Array.
  15464. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15465. * 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).
  15466. * Note that a new underlying VertexBuffer object is created each call.
  15467. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15468. *
  15469. * Possible `kind` values :
  15470. * - VertexBuffer.PositionKind
  15471. * - VertexBuffer.UVKind
  15472. * - VertexBuffer.UV2Kind
  15473. * - VertexBuffer.UV3Kind
  15474. * - VertexBuffer.UV4Kind
  15475. * - VertexBuffer.UV5Kind
  15476. * - VertexBuffer.UV6Kind
  15477. * - VertexBuffer.ColorKind
  15478. * - VertexBuffer.MatricesIndicesKind
  15479. * - VertexBuffer.MatricesIndicesExtraKind
  15480. * - VertexBuffer.MatricesWeightsKind
  15481. * - VertexBuffer.MatricesWeightsExtraKind
  15482. *
  15483. * Returns the Mesh.
  15484. */
  15485. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15486. /**
  15487. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15488. * If the mesh has no geometry, it is simply returned as it is.
  15489. * The `data` are either a numeric array either a Float32Array.
  15490. * No new underlying VertexBuffer object is created.
  15491. * 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.
  15492. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15493. *
  15494. * Possible `kind` values :
  15495. * - VertexBuffer.PositionKind
  15496. * - VertexBuffer.UVKind
  15497. * - VertexBuffer.UV2Kind
  15498. * - VertexBuffer.UV3Kind
  15499. * - VertexBuffer.UV4Kind
  15500. * - VertexBuffer.UV5Kind
  15501. * - VertexBuffer.UV6Kind
  15502. * - VertexBuffer.ColorKind
  15503. * - VertexBuffer.MatricesIndicesKind
  15504. * - VertexBuffer.MatricesIndicesExtraKind
  15505. * - VertexBuffer.MatricesWeightsKind
  15506. * - VertexBuffer.MatricesWeightsExtraKind
  15507. *
  15508. * Returns the Mesh.
  15509. */
  15510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15511. /**
  15512. * Sets the mesh indices.
  15513. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15515. * This method creates a new index buffer each call.
  15516. * Returns the Mesh.
  15517. */
  15518. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15519. /**
  15520. * Boolean : True if the mesh owns the requested kind of data.
  15521. */
  15522. isVerticesDataPresent(kind: string): boolean;
  15523. /**
  15524. * Returns an array of indices (IndicesArray).
  15525. */
  15526. getIndices(): Nullable<IndicesArray>;
  15527. get _positions(): Nullable<Vector3[]>;
  15528. /**
  15529. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15530. * This means the mesh underlying bounding box and sphere are recomputed.
  15531. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15532. * @returns the current mesh
  15533. */
  15534. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15535. /** @hidden */
  15536. _preActivate(): InstancedMesh;
  15537. /** @hidden */
  15538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15539. /** @hidden */
  15540. _postActivate(): void;
  15541. getWorldMatrix(): Matrix;
  15542. get isAnInstance(): boolean;
  15543. /**
  15544. * Returns the current associated LOD AbstractMesh.
  15545. */
  15546. getLOD(camera: Camera): AbstractMesh;
  15547. /** @hidden */
  15548. _syncSubMeshes(): InstancedMesh;
  15549. /** @hidden */
  15550. _generatePointsArray(): boolean;
  15551. /**
  15552. * Creates a new InstancedMesh from the current mesh.
  15553. * - name (string) : the cloned mesh name
  15554. * - newParent (optional Node) : the optional Node to parent the clone to.
  15555. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15556. *
  15557. * Returns the clone.
  15558. */
  15559. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15560. /**
  15561. * Disposes the InstancedMesh.
  15562. * Returns nothing.
  15563. */
  15564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15565. }
  15566. module "babylonjs/Meshes/mesh" {
  15567. interface Mesh {
  15568. /**
  15569. * Register a custom buffer that will be instanced
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15571. * @param kind defines the buffer kind
  15572. * @param stride defines the stride in floats
  15573. */
  15574. registerInstancedBuffer(kind: string, stride: number): void;
  15575. /** @hidden */
  15576. _userInstancedBuffersStorage: {
  15577. data: {
  15578. [key: string]: Float32Array;
  15579. };
  15580. sizes: {
  15581. [key: string]: number;
  15582. };
  15583. vertexBuffers: {
  15584. [key: string]: Nullable<VertexBuffer>;
  15585. };
  15586. strides: {
  15587. [key: string]: number;
  15588. };
  15589. };
  15590. }
  15591. }
  15592. module "babylonjs/Meshes/abstractMesh" {
  15593. interface AbstractMesh {
  15594. /**
  15595. * Object used to store instanced buffers defined by user
  15596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15597. */
  15598. instancedBuffers: {
  15599. [key: string]: any;
  15600. };
  15601. }
  15602. }
  15603. }
  15604. declare module "babylonjs/Materials/shaderMaterial" {
  15605. import { Scene } from "babylonjs/scene";
  15606. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15608. import { Mesh } from "babylonjs/Meshes/mesh";
  15609. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15611. import { Texture } from "babylonjs/Materials/Textures/texture";
  15612. import { Material } from "babylonjs/Materials/material";
  15613. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15614. /**
  15615. * Defines the options associated with the creation of a shader material.
  15616. */
  15617. export interface IShaderMaterialOptions {
  15618. /**
  15619. * Does the material work in alpha blend mode
  15620. */
  15621. needAlphaBlending: boolean;
  15622. /**
  15623. * Does the material work in alpha test mode
  15624. */
  15625. needAlphaTesting: boolean;
  15626. /**
  15627. * The list of attribute names used in the shader
  15628. */
  15629. attributes: string[];
  15630. /**
  15631. * The list of unifrom names used in the shader
  15632. */
  15633. uniforms: string[];
  15634. /**
  15635. * The list of UBO names used in the shader
  15636. */
  15637. uniformBuffers: string[];
  15638. /**
  15639. * The list of sampler names used in the shader
  15640. */
  15641. samplers: string[];
  15642. /**
  15643. * The list of defines used in the shader
  15644. */
  15645. defines: string[];
  15646. }
  15647. /**
  15648. * 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.
  15649. *
  15650. * This returned material effects how the mesh will look based on the code in the shaders.
  15651. *
  15652. * @see http://doc.babylonjs.com/how_to/shader_material
  15653. */
  15654. export class ShaderMaterial extends Material {
  15655. private _shaderPath;
  15656. private _options;
  15657. private _textures;
  15658. private _textureArrays;
  15659. private _floats;
  15660. private _ints;
  15661. private _floatsArrays;
  15662. private _colors3;
  15663. private _colors3Arrays;
  15664. private _colors4;
  15665. private _colors4Arrays;
  15666. private _vectors2;
  15667. private _vectors3;
  15668. private _vectors4;
  15669. private _matrices;
  15670. private _matrixArrays;
  15671. private _matrices3x3;
  15672. private _matrices2x2;
  15673. private _vectors2Arrays;
  15674. private _vectors3Arrays;
  15675. private _vectors4Arrays;
  15676. private _cachedWorldViewMatrix;
  15677. private _cachedWorldViewProjectionMatrix;
  15678. private _renderId;
  15679. private _multiview;
  15680. /**
  15681. * Instantiate a new shader material.
  15682. * 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.
  15683. * This returned material effects how the mesh will look based on the code in the shaders.
  15684. * @see http://doc.babylonjs.com/how_to/shader_material
  15685. * @param name Define the name of the material in the scene
  15686. * @param scene Define the scene the material belongs to
  15687. * @param shaderPath Defines the route to the shader code in one of three ways:
  15688. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15689. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15690. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15691. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15692. * @param options Define the options used to create the shader
  15693. */
  15694. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15695. /**
  15696. * Gets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. get shaderPath(): any;
  15700. /**
  15701. * Sets the shader path used to define the shader code
  15702. * It can be modified to trigger a new compilation
  15703. */
  15704. set shaderPath(shaderPath: any);
  15705. /**
  15706. * Gets the options used to compile the shader.
  15707. * They can be modified to trigger a new compilation
  15708. */
  15709. get options(): IShaderMaterialOptions;
  15710. /**
  15711. * Gets the current class name of the material e.g. "ShaderMaterial"
  15712. * Mainly use in serialization.
  15713. * @returns the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Specifies if the material will require alpha blending
  15718. * @returns a boolean specifying if alpha blending is needed
  15719. */
  15720. needAlphaBlending(): boolean;
  15721. /**
  15722. * Specifies if this material should be rendered in alpha test mode
  15723. * @returns a boolean specifying if an alpha test is needed.
  15724. */
  15725. needAlphaTesting(): boolean;
  15726. private _checkUniform;
  15727. /**
  15728. * Set a texture in the shader.
  15729. * @param name Define the name of the uniform samplers as defined in the shader
  15730. * @param texture Define the texture to bind to this sampler
  15731. * @return the material itself allowing "fluent" like uniform updates
  15732. */
  15733. setTexture(name: string, texture: Texture): ShaderMaterial;
  15734. /**
  15735. * Set a texture array in the shader.
  15736. * @param name Define the name of the uniform sampler array as defined in the shader
  15737. * @param textures Define the list of textures to bind to this sampler
  15738. * @return the material itself allowing "fluent" like uniform updates
  15739. */
  15740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15741. /**
  15742. * Set a float in the shader.
  15743. * @param name Define the name of the uniform as defined in the shader
  15744. * @param value Define the value to give to the uniform
  15745. * @return the material itself allowing "fluent" like uniform updates
  15746. */
  15747. setFloat(name: string, value: number): ShaderMaterial;
  15748. /**
  15749. * Set a int in the shader.
  15750. * @param name Define the name of the uniform as defined in the shader
  15751. * @param value Define the value to give to the uniform
  15752. * @return the material itself allowing "fluent" like uniform updates
  15753. */
  15754. setInt(name: string, value: number): ShaderMaterial;
  15755. /**
  15756. * Set an array of floats in the shader.
  15757. * @param name Define the name of the uniform as defined in the shader
  15758. * @param value Define the value to give to the uniform
  15759. * @return the material itself allowing "fluent" like uniform updates
  15760. */
  15761. setFloats(name: string, value: number[]): ShaderMaterial;
  15762. /**
  15763. * Set a vec3 in the shader from a Color3.
  15764. * @param name Define the name of the uniform as defined in the shader
  15765. * @param value Define the value to give to the uniform
  15766. * @return the material itself allowing "fluent" like uniform updates
  15767. */
  15768. setColor3(name: string, value: Color3): ShaderMaterial;
  15769. /**
  15770. * Set a vec3 array in the shader from a Color3 array.
  15771. * @param name Define the name of the uniform as defined in the shader
  15772. * @param value Define the value to give to the uniform
  15773. * @return the material itself allowing "fluent" like uniform updates
  15774. */
  15775. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15776. /**
  15777. * Set a vec4 in the shader from a Color4.
  15778. * @param name Define the name of the uniform as defined in the shader
  15779. * @param value Define the value to give to the uniform
  15780. * @return the material itself allowing "fluent" like uniform updates
  15781. */
  15782. setColor4(name: string, value: Color4): ShaderMaterial;
  15783. /**
  15784. * Set a vec4 array in the shader from a Color4 array.
  15785. * @param name Define the name of the uniform as defined in the shader
  15786. * @param value Define the value to give to the uniform
  15787. * @return the material itself allowing "fluent" like uniform updates
  15788. */
  15789. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15790. /**
  15791. * Set a vec2 in the shader from a Vector2.
  15792. * @param name Define the name of the uniform as defined in the shader
  15793. * @param value Define the value to give to the uniform
  15794. * @return the material itself allowing "fluent" like uniform updates
  15795. */
  15796. setVector2(name: string, value: Vector2): ShaderMaterial;
  15797. /**
  15798. * Set a vec3 in the shader from a Vector3.
  15799. * @param name Define the name of the uniform as defined in the shader
  15800. * @param value Define the value to give to the uniform
  15801. * @return the material itself allowing "fluent" like uniform updates
  15802. */
  15803. setVector3(name: string, value: Vector3): ShaderMaterial;
  15804. /**
  15805. * Set a vec4 in the shader from a Vector4.
  15806. * @param name Define the name of the uniform as defined in the shader
  15807. * @param value Define the value to give to the uniform
  15808. * @return the material itself allowing "fluent" like uniform updates
  15809. */
  15810. setVector4(name: string, value: Vector4): ShaderMaterial;
  15811. /**
  15812. * Set a mat4 in the shader from a Matrix.
  15813. * @param name Define the name of the uniform as defined in the shader
  15814. * @param value Define the value to give to the uniform
  15815. * @return the material itself allowing "fluent" like uniform updates
  15816. */
  15817. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15818. /**
  15819. * Set a float32Array in the shader from a matrix array.
  15820. * @param name Define the name of the uniform as defined in the shader
  15821. * @param value Define the value to give to the uniform
  15822. * @return the material itself allowing "fluent" like uniform updates
  15823. */
  15824. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15825. /**
  15826. * Set a mat3 in the shader from a Float32Array.
  15827. * @param name Define the name of the uniform as defined in the shader
  15828. * @param value Define the value to give to the uniform
  15829. * @return the material itself allowing "fluent" like uniform updates
  15830. */
  15831. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15832. /**
  15833. * Set a mat2 in the shader from a Float32Array.
  15834. * @param name Define the name of the uniform as defined in the shader
  15835. * @param value Define the value to give to the uniform
  15836. * @return the material itself allowing "fluent" like uniform updates
  15837. */
  15838. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15839. /**
  15840. * Set a vec2 array in the shader from a number array.
  15841. * @param name Define the name of the uniform as defined in the shader
  15842. * @param value Define the value to give to the uniform
  15843. * @return the material itself allowing "fluent" like uniform updates
  15844. */
  15845. setArray2(name: string, value: number[]): ShaderMaterial;
  15846. /**
  15847. * Set a vec3 array in the shader from a number array.
  15848. * @param name Define the name of the uniform as defined in the shader
  15849. * @param value Define the value to give to the uniform
  15850. * @return the material itself allowing "fluent" like uniform updates
  15851. */
  15852. setArray3(name: string, value: number[]): ShaderMaterial;
  15853. /**
  15854. * Set a vec4 array in the shader from a number array.
  15855. * @param name Define the name of the uniform as defined in the shader
  15856. * @param value Define the value to give to the uniform
  15857. * @return the material itself allowing "fluent" like uniform updates
  15858. */
  15859. setArray4(name: string, value: number[]): ShaderMaterial;
  15860. private _checkCache;
  15861. /**
  15862. * Specifies that the submesh is ready to be used
  15863. * @param mesh defines the mesh to check
  15864. * @param subMesh defines which submesh to check
  15865. * @param useInstances specifies that instances should be used
  15866. * @returns a boolean indicating that the submesh is ready or not
  15867. */
  15868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15869. /**
  15870. * Checks if the material is ready to render the requested mesh
  15871. * @param mesh Define the mesh to render
  15872. * @param useInstances Define whether or not the material is used with instances
  15873. * @returns true if ready, otherwise false
  15874. */
  15875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15876. /**
  15877. * Binds the world matrix to the material
  15878. * @param world defines the world transformation matrix
  15879. */
  15880. bindOnlyWorldMatrix(world: Matrix): void;
  15881. /**
  15882. * Binds the material to the mesh
  15883. * @param world defines the world transformation matrix
  15884. * @param mesh defines the mesh to bind the material to
  15885. */
  15886. bind(world: Matrix, mesh?: Mesh): void;
  15887. /**
  15888. * Gets the active textures from the material
  15889. * @returns an array of textures
  15890. */
  15891. getActiveTextures(): BaseTexture[];
  15892. /**
  15893. * Specifies if the material uses a texture
  15894. * @param texture defines the texture to check against the material
  15895. * @returns a boolean specifying if the material uses the texture
  15896. */
  15897. hasTexture(texture: BaseTexture): boolean;
  15898. /**
  15899. * Makes a duplicate of the material, and gives it a new name
  15900. * @param name defines the new name for the duplicated material
  15901. * @returns the cloned material
  15902. */
  15903. clone(name: string): ShaderMaterial;
  15904. /**
  15905. * Disposes the material
  15906. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15907. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15908. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15909. */
  15910. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15911. /**
  15912. * Serializes this material in a JSON representation
  15913. * @returns the serialized material object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Creates a shader material from parsed shader material data
  15918. * @param source defines the JSON represnetation of the material
  15919. * @param scene defines the hosting scene
  15920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15921. * @returns a new material
  15922. */
  15923. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15924. }
  15925. }
  15926. declare module "babylonjs/Shaders/color.fragment" {
  15927. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15929. /** @hidden */
  15930. export var colorPixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module "babylonjs/Shaders/color.vertex" {
  15936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15937. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15942. /** @hidden */
  15943. export var colorVertexShader: {
  15944. name: string;
  15945. shader: string;
  15946. };
  15947. }
  15948. declare module "babylonjs/Meshes/linesMesh" {
  15949. import { Nullable } from "babylonjs/types";
  15950. import { Scene } from "babylonjs/scene";
  15951. import { Color3 } from "babylonjs/Maths/math.color";
  15952. import { Node } from "babylonjs/node";
  15953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15954. import { Mesh } from "babylonjs/Meshes/mesh";
  15955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15956. import { Effect } from "babylonjs/Materials/effect";
  15957. import { Material } from "babylonjs/Materials/material";
  15958. import "babylonjs/Shaders/color.fragment";
  15959. import "babylonjs/Shaders/color.vertex";
  15960. /**
  15961. * Line mesh
  15962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15963. */
  15964. export class LinesMesh extends Mesh {
  15965. /**
  15966. * If vertex color should be applied to the mesh
  15967. */
  15968. readonly useVertexColor?: boolean | undefined;
  15969. /**
  15970. * If vertex alpha should be applied to the mesh
  15971. */
  15972. readonly useVertexAlpha?: boolean | undefined;
  15973. /**
  15974. * Color of the line (Default: White)
  15975. */
  15976. color: Color3;
  15977. /**
  15978. * Alpha of the line (Default: 1)
  15979. */
  15980. alpha: number;
  15981. /**
  15982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15983. * This margin is expressed in world space coordinates, so its value may vary.
  15984. * Default value is 0.1
  15985. */
  15986. intersectionThreshold: number;
  15987. private _colorShader;
  15988. private color4;
  15989. /**
  15990. * Creates a new LinesMesh
  15991. * @param name defines the name
  15992. * @param scene defines the hosting scene
  15993. * @param parent defines the parent mesh if any
  15994. * @param source defines the optional source LinesMesh used to clone data from
  15995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15996. * When false, achieved by calling a clone(), also passing False.
  15997. * This will make creation of children, recursive.
  15998. * @param useVertexColor defines if this LinesMesh supports vertex color
  15999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16000. */
  16001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16002. /**
  16003. * If vertex color should be applied to the mesh
  16004. */
  16005. useVertexColor?: boolean | undefined,
  16006. /**
  16007. * If vertex alpha should be applied to the mesh
  16008. */
  16009. useVertexAlpha?: boolean | undefined);
  16010. private _addClipPlaneDefine;
  16011. private _removeClipPlaneDefine;
  16012. isReady(): boolean;
  16013. /**
  16014. * Returns the string "LineMesh"
  16015. */
  16016. getClassName(): string;
  16017. /**
  16018. * @hidden
  16019. */
  16020. get material(): Material;
  16021. /**
  16022. * @hidden
  16023. */
  16024. set material(value: Material);
  16025. /**
  16026. * @hidden
  16027. */
  16028. get checkCollisions(): boolean;
  16029. /** @hidden */
  16030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16031. /** @hidden */
  16032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16033. /**
  16034. * Disposes of the line mesh
  16035. * @param doNotRecurse If children should be disposed
  16036. */
  16037. dispose(doNotRecurse?: boolean): void;
  16038. /**
  16039. * Returns a new LineMesh object cloned from the current one.
  16040. */
  16041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16042. /**
  16043. * Creates a new InstancedLinesMesh object from the mesh model.
  16044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16045. * @param name defines the name of the new instance
  16046. * @returns a new InstancedLinesMesh
  16047. */
  16048. createInstance(name: string): InstancedLinesMesh;
  16049. }
  16050. /**
  16051. * Creates an instance based on a source LinesMesh
  16052. */
  16053. export class InstancedLinesMesh extends InstancedMesh {
  16054. /**
  16055. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16056. * This margin is expressed in world space coordinates, so its value may vary.
  16057. * Initilized with the intersectionThreshold value of the source LinesMesh
  16058. */
  16059. intersectionThreshold: number;
  16060. constructor(name: string, source: LinesMesh);
  16061. /**
  16062. * Returns the string "InstancedLinesMesh".
  16063. */
  16064. getClassName(): string;
  16065. }
  16066. }
  16067. declare module "babylonjs/Shaders/line.fragment" {
  16068. /** @hidden */
  16069. export var linePixelShader: {
  16070. name: string;
  16071. shader: string;
  16072. };
  16073. }
  16074. declare module "babylonjs/Shaders/line.vertex" {
  16075. /** @hidden */
  16076. export var lineVertexShader: {
  16077. name: string;
  16078. shader: string;
  16079. };
  16080. }
  16081. declare module "babylonjs/Rendering/edgesRenderer" {
  16082. import { Nullable } from "babylonjs/types";
  16083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16085. import { Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { IDisposable } from "babylonjs/scene";
  16087. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16088. import "babylonjs/Shaders/line.fragment";
  16089. import "babylonjs/Shaders/line.vertex";
  16090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16091. module "babylonjs/Meshes/abstractMesh" {
  16092. interface AbstractMesh {
  16093. /**
  16094. * Gets the edgesRenderer associated with the mesh
  16095. */
  16096. edgesRenderer: Nullable<EdgesRenderer>;
  16097. }
  16098. }
  16099. module "babylonjs/Meshes/linesMesh" {
  16100. interface LinesMesh {
  16101. /**
  16102. * Enables the edge rendering mode on the mesh.
  16103. * This mode makes the mesh edges visible
  16104. * @param epsilon defines the maximal distance between two angles to detect a face
  16105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16106. * @returns the currentAbstractMesh
  16107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16108. */
  16109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16110. }
  16111. }
  16112. module "babylonjs/Meshes/linesMesh" {
  16113. interface InstancedLinesMesh {
  16114. /**
  16115. * Enables the edge rendering mode on the mesh.
  16116. * This mode makes the mesh edges visible
  16117. * @param epsilon defines the maximal distance between two angles to detect a face
  16118. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16119. * @returns the current InstancedLinesMesh
  16120. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16121. */
  16122. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16123. }
  16124. }
  16125. /**
  16126. * Defines the minimum contract an Edges renderer should follow.
  16127. */
  16128. export interface IEdgesRenderer extends IDisposable {
  16129. /**
  16130. * Gets or sets a boolean indicating if the edgesRenderer is active
  16131. */
  16132. isEnabled: boolean;
  16133. /**
  16134. * Renders the edges of the attached mesh,
  16135. */
  16136. render(): void;
  16137. /**
  16138. * Checks wether or not the edges renderer is ready to render.
  16139. * @return true if ready, otherwise false.
  16140. */
  16141. isReady(): boolean;
  16142. }
  16143. /**
  16144. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16145. */
  16146. export class EdgesRenderer implements IEdgesRenderer {
  16147. /**
  16148. * Define the size of the edges with an orthographic camera
  16149. */
  16150. edgesWidthScalerForOrthographic: number;
  16151. /**
  16152. * Define the size of the edges with a perspective camera
  16153. */
  16154. edgesWidthScalerForPerspective: number;
  16155. protected _source: AbstractMesh;
  16156. protected _linesPositions: number[];
  16157. protected _linesNormals: number[];
  16158. protected _linesIndices: number[];
  16159. protected _epsilon: number;
  16160. protected _indicesCount: number;
  16161. protected _lineShader: ShaderMaterial;
  16162. protected _ib: DataBuffer;
  16163. protected _buffers: {
  16164. [key: string]: Nullable<VertexBuffer>;
  16165. };
  16166. protected _checkVerticesInsteadOfIndices: boolean;
  16167. private _meshRebuildObserver;
  16168. private _meshDisposeObserver;
  16169. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16170. isEnabled: boolean;
  16171. /**
  16172. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16173. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16174. * @param source Mesh used to create edges
  16175. * @param epsilon sum of angles in adjacency to check for edge
  16176. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16177. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16178. */
  16179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16180. protected _prepareRessources(): void;
  16181. /** @hidden */
  16182. _rebuild(): void;
  16183. /**
  16184. * Releases the required resources for the edges renderer
  16185. */
  16186. dispose(): void;
  16187. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16188. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16189. /**
  16190. * Checks if the pair of p0 and p1 is en edge
  16191. * @param faceIndex
  16192. * @param edge
  16193. * @param faceNormals
  16194. * @param p0
  16195. * @param p1
  16196. * @private
  16197. */
  16198. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16199. /**
  16200. * push line into the position, normal and index buffer
  16201. * @protected
  16202. */
  16203. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16204. /**
  16205. * Generates lines edges from adjacencjes
  16206. * @private
  16207. */
  16208. _generateEdgesLines(): void;
  16209. /**
  16210. * Checks wether or not the edges renderer is ready to render.
  16211. * @return true if ready, otherwise false.
  16212. */
  16213. isReady(): boolean;
  16214. /**
  16215. * Renders the edges of the attached mesh,
  16216. */
  16217. render(): void;
  16218. }
  16219. /**
  16220. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16221. */
  16222. export class LineEdgesRenderer extends EdgesRenderer {
  16223. /**
  16224. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16225. * @param source LineMesh used to generate edges
  16226. * @param epsilon not important (specified angle for edge detection)
  16227. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16228. */
  16229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16230. /**
  16231. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16232. */
  16233. _generateEdgesLines(): void;
  16234. }
  16235. }
  16236. declare module "babylonjs/Rendering/renderingGroup" {
  16237. import { SmartArray } from "babylonjs/Misc/smartArray";
  16238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16240. import { Nullable } from "babylonjs/types";
  16241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16242. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16243. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16244. import { Material } from "babylonjs/Materials/material";
  16245. import { Scene } from "babylonjs/scene";
  16246. /**
  16247. * This represents the object necessary to create a rendering group.
  16248. * This is exclusively used and created by the rendering manager.
  16249. * To modify the behavior, you use the available helpers in your scene or meshes.
  16250. * @hidden
  16251. */
  16252. export class RenderingGroup {
  16253. index: number;
  16254. private static _zeroVector;
  16255. private _scene;
  16256. private _opaqueSubMeshes;
  16257. private _transparentSubMeshes;
  16258. private _alphaTestSubMeshes;
  16259. private _depthOnlySubMeshes;
  16260. private _particleSystems;
  16261. private _spriteManagers;
  16262. private _opaqueSortCompareFn;
  16263. private _alphaTestSortCompareFn;
  16264. private _transparentSortCompareFn;
  16265. private _renderOpaque;
  16266. private _renderAlphaTest;
  16267. private _renderTransparent;
  16268. /** @hidden */
  16269. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16270. onBeforeTransparentRendering: () => void;
  16271. /**
  16272. * Set the opaque sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the alpha test sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Set the transparent sort comparison function.
  16283. * If null the sub meshes will be render in the order they were created
  16284. */
  16285. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16286. /**
  16287. * Creates a new rendering group.
  16288. * @param index The rendering group index
  16289. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16290. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16291. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16292. */
  16293. 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>);
  16294. /**
  16295. * Render all the sub meshes contained in the group.
  16296. * @param customRenderFunction Used to override the default render behaviour of the group.
  16297. * @returns true if rendered some submeshes.
  16298. */
  16299. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderOpaqueSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderAlphaTestSorted;
  16310. /**
  16311. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16312. * @param subMeshes The submeshes to render
  16313. */
  16314. private renderTransparentSorted;
  16315. /**
  16316. * Renders the submeshes in a specified order.
  16317. * @param subMeshes The submeshes to sort before render
  16318. * @param sortCompareFn The comparison function use to sort
  16319. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16320. * @param transparent Specifies to activate blending if true
  16321. */
  16322. private static renderSorted;
  16323. /**
  16324. * Renders the submeshes in the order they were dispatched (no sort applied).
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private static renderUnsorted;
  16328. /**
  16329. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16330. * are rendered back to front if in the same alpha index.
  16331. *
  16332. * @param a The first submesh
  16333. * @param b The second submesh
  16334. * @returns The result of the comparison
  16335. */
  16336. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16337. /**
  16338. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16339. * are rendered back to front.
  16340. *
  16341. * @param a The first submesh
  16342. * @param b The second submesh
  16343. * @returns The result of the comparison
  16344. */
  16345. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16346. /**
  16347. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16348. * are rendered front to back (prevent overdraw).
  16349. *
  16350. * @param a The first submesh
  16351. * @param b The second submesh
  16352. * @returns The result of the comparison
  16353. */
  16354. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16355. /**
  16356. * Resets the different lists of submeshes to prepare a new frame.
  16357. */
  16358. prepare(): void;
  16359. dispose(): void;
  16360. /**
  16361. * Inserts the submesh in its correct queue depending on its material.
  16362. * @param subMesh The submesh to dispatch
  16363. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16364. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16365. */
  16366. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16367. dispatchSprites(spriteManager: ISpriteManager): void;
  16368. dispatchParticles(particleSystem: IParticleSystem): void;
  16369. private _renderParticles;
  16370. private _renderSprites;
  16371. }
  16372. }
  16373. declare module "babylonjs/Rendering/renderingManager" {
  16374. import { Nullable } from "babylonjs/types";
  16375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16377. import { SmartArray } from "babylonjs/Misc/smartArray";
  16378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16379. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16380. import { Material } from "babylonjs/Materials/material";
  16381. import { Scene } from "babylonjs/scene";
  16382. import { Camera } from "babylonjs/Cameras/camera";
  16383. /**
  16384. * Interface describing the different options available in the rendering manager
  16385. * regarding Auto Clear between groups.
  16386. */
  16387. export interface IRenderingManagerAutoClearSetup {
  16388. /**
  16389. * Defines whether or not autoclear is enable.
  16390. */
  16391. autoClear: boolean;
  16392. /**
  16393. * Defines whether or not to autoclear the depth buffer.
  16394. */
  16395. depth: boolean;
  16396. /**
  16397. * Defines whether or not to autoclear the stencil buffer.
  16398. */
  16399. stencil: boolean;
  16400. }
  16401. /**
  16402. * This class is used by the onRenderingGroupObservable
  16403. */
  16404. export class RenderingGroupInfo {
  16405. /**
  16406. * The Scene that being rendered
  16407. */
  16408. scene: Scene;
  16409. /**
  16410. * The camera currently used for the rendering pass
  16411. */
  16412. camera: Nullable<Camera>;
  16413. /**
  16414. * The ID of the renderingGroup being processed
  16415. */
  16416. renderingGroupId: number;
  16417. }
  16418. /**
  16419. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16420. * It is enable to manage the different groups as well as the different necessary sort functions.
  16421. * This should not be used directly aside of the few static configurations
  16422. */
  16423. export class RenderingManager {
  16424. /**
  16425. * The max id used for rendering groups (not included)
  16426. */
  16427. static MAX_RENDERINGGROUPS: number;
  16428. /**
  16429. * The min id used for rendering groups (included)
  16430. */
  16431. static MIN_RENDERINGGROUPS: number;
  16432. /**
  16433. * Used to globally prevent autoclearing scenes.
  16434. */
  16435. static AUTOCLEAR: boolean;
  16436. /**
  16437. * @hidden
  16438. */
  16439. _useSceneAutoClearSetup: boolean;
  16440. private _scene;
  16441. private _renderingGroups;
  16442. private _depthStencilBufferAlreadyCleaned;
  16443. private _autoClearDepthStencil;
  16444. private _customOpaqueSortCompareFn;
  16445. private _customAlphaTestSortCompareFn;
  16446. private _customTransparentSortCompareFn;
  16447. private _renderingGroupInfo;
  16448. /**
  16449. * Instantiates a new rendering group for a particular scene
  16450. * @param scene Defines the scene the groups belongs to
  16451. */
  16452. constructor(scene: Scene);
  16453. private _clearDepthStencilBuffer;
  16454. /**
  16455. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16456. * @hidden
  16457. */
  16458. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16459. /**
  16460. * Resets the different information of the group to prepare a new frame
  16461. * @hidden
  16462. */
  16463. reset(): void;
  16464. /**
  16465. * Dispose and release the group and its associated resources.
  16466. * @hidden
  16467. */
  16468. dispose(): void;
  16469. /**
  16470. * Clear the info related to rendering groups preventing retention points during dispose.
  16471. */
  16472. freeRenderingGroups(): void;
  16473. private _prepareRenderingGroup;
  16474. /**
  16475. * Add a sprite manager to the rendering manager in order to render it this frame.
  16476. * @param spriteManager Define the sprite manager to render
  16477. */
  16478. dispatchSprites(spriteManager: ISpriteManager): void;
  16479. /**
  16480. * Add a particle system to the rendering manager in order to render it this frame.
  16481. * @param particleSystem Define the particle system to render
  16482. */
  16483. dispatchParticles(particleSystem: IParticleSystem): void;
  16484. /**
  16485. * Add a submesh to the manager in order to render it this frame
  16486. * @param subMesh The submesh to dispatch
  16487. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16488. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16489. */
  16490. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16491. /**
  16492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16493. * This allowed control for front to back rendering or reversly depending of the special needs.
  16494. *
  16495. * @param renderingGroupId The rendering group id corresponding to its index
  16496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16499. */
  16500. 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;
  16501. /**
  16502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16503. *
  16504. * @param renderingGroupId The rendering group id corresponding to its index
  16505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16508. */
  16509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16510. /**
  16511. * Gets the current auto clear configuration for one rendering group of the rendering
  16512. * manager.
  16513. * @param index the rendering group index to get the information for
  16514. * @returns The auto clear setup for the requested rendering group
  16515. */
  16516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16517. }
  16518. }
  16519. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16520. import { SmartArray } from "babylonjs/Misc/smartArray";
  16521. import { Nullable } from "babylonjs/types";
  16522. import { Scene } from "babylonjs/scene";
  16523. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16526. import { Mesh } from "babylonjs/Meshes/mesh";
  16527. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16528. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16529. import { Effect } from "babylonjs/Materials/effect";
  16530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16532. import "babylonjs/Shaders/shadowMap.fragment";
  16533. import "babylonjs/Shaders/shadowMap.vertex";
  16534. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. /**
  16537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16538. */
  16539. export interface ICustomShaderOptions {
  16540. /**
  16541. * Gets or sets the custom shader name to use
  16542. */
  16543. shaderName: string;
  16544. /**
  16545. * The list of attribute names used in the shader
  16546. */
  16547. attributes?: string[];
  16548. /**
  16549. * The list of unifrom names used in the shader
  16550. */
  16551. uniforms?: string[];
  16552. /**
  16553. * The list of sampler names used in the shader
  16554. */
  16555. samplers?: string[];
  16556. /**
  16557. * The list of defines used in the shader
  16558. */
  16559. defines?: string[];
  16560. }
  16561. /**
  16562. * Interface to implement to create a shadow generator compatible with BJS.
  16563. */
  16564. export interface IShadowGenerator {
  16565. /**
  16566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16567. * @returns The render target texture if present otherwise, null
  16568. */
  16569. getShadowMap(): Nullable<RenderTargetTexture>;
  16570. /**
  16571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16572. * @param subMesh The submesh we want to render in the shadow map
  16573. * @param useInstances Defines wether will draw in the map using instances
  16574. * @returns true if ready otherwise, false
  16575. */
  16576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16577. /**
  16578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16579. * @param defines Defines of the material we want to update
  16580. * @param lightIndex Index of the light in the enabled light list of the material
  16581. */
  16582. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16583. /**
  16584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16585. * defined in the generator but impacting the effect).
  16586. * It implies the unifroms available on the materials are the standard BJS ones.
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. /**
  16603. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16604. * @param onCompiled Callback triggered at the and of the effects compilation
  16605. * @param options Sets of optional options forcing the compilation with different modes
  16606. */
  16607. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16608. useInstances: boolean;
  16609. }>): void;
  16610. /**
  16611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16612. * @param options Sets of optional options forcing the compilation with different modes
  16613. * @returns A promise that resolves when the compilation completes
  16614. */
  16615. forceCompilationAsync(options?: Partial<{
  16616. useInstances: boolean;
  16617. }>): Promise<void>;
  16618. /**
  16619. * Serializes the shadow generator setup to a json object.
  16620. * @returns The serialized JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Disposes the Shadow map and related Textures and effects.
  16625. */
  16626. dispose(): void;
  16627. }
  16628. /**
  16629. * Default implementation IShadowGenerator.
  16630. * This is the main object responsible of generating shadows in the framework.
  16631. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16632. */
  16633. export class ShadowGenerator implements IShadowGenerator {
  16634. /**
  16635. * Name of the shadow generator class
  16636. */
  16637. static CLASSNAME: string;
  16638. /**
  16639. * Shadow generator mode None: no filtering applied.
  16640. */
  16641. static readonly FILTER_NONE: number;
  16642. /**
  16643. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16645. */
  16646. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16647. /**
  16648. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16649. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16650. */
  16651. static readonly FILTER_POISSONSAMPLING: number;
  16652. /**
  16653. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16655. */
  16656. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16657. /**
  16658. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16659. * edge artifacts on steep falloff.
  16660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16661. */
  16662. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16663. /**
  16664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16665. * edge artifacts on steep falloff.
  16666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16667. */
  16668. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16669. /**
  16670. * Shadow generator mode PCF: Percentage Closer Filtering
  16671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16672. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16673. */
  16674. static readonly FILTER_PCF: number;
  16675. /**
  16676. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16677. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16678. * Contact Hardening
  16679. */
  16680. static readonly FILTER_PCSS: number;
  16681. /**
  16682. * Reserved for PCF and PCSS
  16683. * Highest Quality.
  16684. *
  16685. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16686. *
  16687. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16688. */
  16689. static readonly QUALITY_HIGH: number;
  16690. /**
  16691. * Reserved for PCF and PCSS
  16692. * Good tradeoff for quality/perf cross devices
  16693. *
  16694. * Execute PCF on a 3*3 kernel.
  16695. *
  16696. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16697. */
  16698. static readonly QUALITY_MEDIUM: number;
  16699. /**
  16700. * Reserved for PCF and PCSS
  16701. * The lowest quality but the fastest.
  16702. *
  16703. * Execute PCF on a 1*1 kernel.
  16704. *
  16705. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16706. */
  16707. static readonly QUALITY_LOW: number;
  16708. /** Gets or sets the custom shader name to use */
  16709. customShaderOptions: ICustomShaderOptions;
  16710. /**
  16711. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16712. */
  16713. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16714. /**
  16715. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16716. */
  16717. onAfterShadowMapRenderObservable: Observable<Effect>;
  16718. /**
  16719. * Observable triggered before a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16721. */
  16722. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. /**
  16724. * Observable triggered after a mesh is rendered in the shadow map.
  16725. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16726. */
  16727. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16728. protected _bias: number;
  16729. /**
  16730. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16731. */
  16732. get bias(): number;
  16733. /**
  16734. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16735. */
  16736. set bias(bias: number);
  16737. protected _normalBias: number;
  16738. /**
  16739. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16740. */
  16741. get normalBias(): number;
  16742. /**
  16743. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16744. */
  16745. set normalBias(normalBias: number);
  16746. protected _blurBoxOffset: number;
  16747. /**
  16748. * Gets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. get blurBoxOffset(): number;
  16752. /**
  16753. * Sets the blur box offset: offset applied during the blur pass.
  16754. * Only useful if useKernelBlur = false
  16755. */
  16756. set blurBoxOffset(value: number);
  16757. protected _blurScale: number;
  16758. /**
  16759. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. get blurScale(): number;
  16763. /**
  16764. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16765. * 2 means half of the size.
  16766. */
  16767. set blurScale(value: number);
  16768. protected _blurKernel: number;
  16769. /**
  16770. * Gets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. get blurKernel(): number;
  16774. /**
  16775. * Sets the blur kernel: kernel size of the blur pass.
  16776. * Only useful if useKernelBlur = true
  16777. */
  16778. set blurKernel(value: number);
  16779. protected _useKernelBlur: boolean;
  16780. /**
  16781. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. get useKernelBlur(): boolean;
  16785. /**
  16786. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16788. */
  16789. set useKernelBlur(value: boolean);
  16790. protected _depthScale: number;
  16791. /**
  16792. * Gets the depth scale used in ESM mode.
  16793. */
  16794. get depthScale(): number;
  16795. /**
  16796. * Sets the depth scale used in ESM mode.
  16797. * This can override the scale stored on the light.
  16798. */
  16799. set depthScale(value: number);
  16800. protected _validateFilter(filter: number): number;
  16801. protected _filter: number;
  16802. /**
  16803. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. get filter(): number;
  16807. /**
  16808. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16810. */
  16811. set filter(value: number);
  16812. /**
  16813. * Gets if the current filter is set to Poisson Sampling.
  16814. */
  16815. get usePoissonSampling(): boolean;
  16816. /**
  16817. * Sets the current filter to Poisson Sampling.
  16818. */
  16819. set usePoissonSampling(value: boolean);
  16820. /**
  16821. * Gets if the current filter is set to ESM.
  16822. */
  16823. get useExponentialShadowMap(): boolean;
  16824. /**
  16825. * Sets the current filter is to ESM.
  16826. */
  16827. set useExponentialShadowMap(value: boolean);
  16828. /**
  16829. * Gets if the current filter is set to filtered ESM.
  16830. */
  16831. get useBlurExponentialShadowMap(): boolean;
  16832. /**
  16833. * Gets if the current filter is set to filtered ESM.
  16834. */
  16835. set useBlurExponentialShadowMap(value: boolean);
  16836. /**
  16837. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. get useCloseExponentialShadowMap(): boolean;
  16841. /**
  16842. * Sets the current filter to "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. set useCloseExponentialShadowMap(value: boolean);
  16846. /**
  16847. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. get useBlurCloseExponentialShadowMap(): boolean;
  16851. /**
  16852. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16853. * exponential to prevent steep falloff artifacts).
  16854. */
  16855. set useBlurCloseExponentialShadowMap(value: boolean);
  16856. /**
  16857. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16858. */
  16859. get usePercentageCloserFiltering(): boolean;
  16860. /**
  16861. * Sets the current filter to "PCF" (percentage closer filtering).
  16862. */
  16863. set usePercentageCloserFiltering(value: boolean);
  16864. protected _filteringQuality: number;
  16865. /**
  16866. * Gets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. get filteringQuality(): number;
  16870. /**
  16871. * Sets the PCF or PCSS Quality.
  16872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16873. */
  16874. set filteringQuality(filteringQuality: number);
  16875. /**
  16876. * Gets if the current filter is set to "PCSS" (contact hardening).
  16877. */
  16878. get useContactHardeningShadow(): boolean;
  16879. /**
  16880. * Sets the current filter to "PCSS" (contact hardening).
  16881. */
  16882. set useContactHardeningShadow(value: boolean);
  16883. protected _contactHardeningLightSizeUVRatio: number;
  16884. /**
  16885. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16886. * Using a ratio helps keeping shape stability independently of the map size.
  16887. *
  16888. * It does not account for the light projection as it was having too much
  16889. * instability during the light setup or during light position changes.
  16890. *
  16891. * Only valid if useContactHardeningShadow is true.
  16892. */
  16893. get contactHardeningLightSizeUVRatio(): number;
  16894. /**
  16895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16896. * Using a ratio helps keeping shape stability independently of the map size.
  16897. *
  16898. * It does not account for the light projection as it was having too much
  16899. * instability during the light setup or during light position changes.
  16900. *
  16901. * Only valid if useContactHardeningShadow is true.
  16902. */
  16903. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16904. protected _darkness: number;
  16905. /** Gets or sets the actual darkness of a shadow */
  16906. get darkness(): number;
  16907. set darkness(value: number);
  16908. /**
  16909. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16910. * 0 means strongest and 1 would means no shadow.
  16911. * @returns the darkness.
  16912. */
  16913. getDarkness(): number;
  16914. /**
  16915. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16916. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16917. * @returns the shadow generator allowing fluent coding.
  16918. */
  16919. setDarkness(darkness: number): ShadowGenerator;
  16920. protected _transparencyShadow: boolean;
  16921. /** Gets or sets the ability to have transparent shadow */
  16922. get transparencyShadow(): boolean;
  16923. set transparencyShadow(value: boolean);
  16924. /**
  16925. * Sets the ability to have transparent shadow (boolean).
  16926. * @param transparent True if transparent else False
  16927. * @returns the shadow generator allowing fluent coding
  16928. */
  16929. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16930. protected _shadowMap: Nullable<RenderTargetTexture>;
  16931. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16934. * @returns The render target texture if present otherwise, null
  16935. */
  16936. getShadowMap(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16939. * @returns The render target texture if the shadow map is present otherwise, null
  16940. */
  16941. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16942. /**
  16943. * Gets the class name of that object
  16944. * @returns "ShadowGenerator"
  16945. */
  16946. getClassName(): string;
  16947. /**
  16948. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16949. * @param mesh Mesh to add
  16950. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16951. * @returns the Shadow Generator itself
  16952. */
  16953. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16954. /**
  16955. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16956. * @param mesh Mesh to remove
  16957. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16958. * @returns the Shadow Generator itself
  16959. */
  16960. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16961. /**
  16962. * Controls the extent to which the shadows fade out at the edge of the frustum
  16963. */
  16964. frustumEdgeFalloff: number;
  16965. protected _light: IShadowLight;
  16966. /**
  16967. * Returns the associated light object.
  16968. * @returns the light generating the shadow
  16969. */
  16970. getLight(): IShadowLight;
  16971. /**
  16972. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16973. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16974. * It might on the other hand introduce peter panning.
  16975. */
  16976. forceBackFacesOnly: boolean;
  16977. protected _scene: Scene;
  16978. protected _lightDirection: Vector3;
  16979. protected _effect: Effect;
  16980. protected _viewMatrix: Matrix;
  16981. protected _projectionMatrix: Matrix;
  16982. protected _transformMatrix: Matrix;
  16983. protected _cachedPosition: Vector3;
  16984. protected _cachedDirection: Vector3;
  16985. protected _cachedDefines: string;
  16986. protected _currentRenderID: number;
  16987. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16988. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16989. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16990. protected _blurPostProcesses: PostProcess[];
  16991. protected _mapSize: number;
  16992. protected _currentFaceIndex: number;
  16993. protected _currentFaceIndexCache: number;
  16994. protected _textureType: number;
  16995. protected _defaultTextureMatrix: Matrix;
  16996. protected _storedUniqueId: Nullable<number>;
  16997. /** @hidden */
  16998. static _SceneComponentInitialization: (scene: Scene) => void;
  16999. /**
  17000. * Creates a ShadowGenerator object.
  17001. * A ShadowGenerator is the required tool to use the shadows.
  17002. * Each light casting shadows needs to use its own ShadowGenerator.
  17003. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17004. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17005. * @param light The light object generating the shadows.
  17006. * @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.
  17007. */
  17008. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17009. protected _initializeGenerator(): void;
  17010. protected _createTargetRenderTexture(): void;
  17011. protected _initializeShadowMap(): void;
  17012. protected _initializeBlurRTTAndPostProcesses(): void;
  17013. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17014. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17015. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17016. protected _applyFilterValues(): void;
  17017. /**
  17018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17019. * @param onCompiled Callback triggered at the and of the effects compilation
  17020. * @param options Sets of optional options forcing the compilation with different modes
  17021. */
  17022. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17023. useInstances: boolean;
  17024. }>): void;
  17025. /**
  17026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17027. * @param options Sets of optional options forcing the compilation with different modes
  17028. * @returns A promise that resolves when the compilation completes
  17029. */
  17030. forceCompilationAsync(options?: Partial<{
  17031. useInstances: boolean;
  17032. }>): Promise<void>;
  17033. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17034. /**
  17035. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17036. * @param subMesh The submesh we want to render in the shadow map
  17037. * @param useInstances Defines wether will draw in the map using instances
  17038. * @returns true if ready otherwise, false
  17039. */
  17040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17041. /**
  17042. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17043. * @param defines Defines of the material we want to update
  17044. * @param lightIndex Index of the light in the enabled light list of the material
  17045. */
  17046. prepareDefines(defines: any, lightIndex: number): void;
  17047. /**
  17048. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17049. * defined in the generator but impacting the effect).
  17050. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17051. * @param effect The effect we are binfing the information for
  17052. */
  17053. bindShadowLight(lightIndex: string, effect: Effect): void;
  17054. /**
  17055. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17056. * (eq to shadow prjection matrix * light transform matrix)
  17057. * @returns The transform matrix used to create the shadow map
  17058. */
  17059. getTransformMatrix(): Matrix;
  17060. /**
  17061. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17062. * Cube and 2D textures for instance.
  17063. */
  17064. recreateShadowMap(): void;
  17065. protected _disposeBlurPostProcesses(): void;
  17066. protected _disposeRTTandPostProcesses(): void;
  17067. /**
  17068. * Disposes the ShadowGenerator.
  17069. * Returns nothing.
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Serializes the shadow generator setup to a json object.
  17074. * @returns The serialized JSON object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17079. * @param parsedShadowGenerator The JSON object to parse
  17080. * @param scene The scene to create the shadow map for
  17081. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17082. * @returns The parsed shadow generator
  17083. */
  17084. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17085. }
  17086. }
  17087. declare module "babylonjs/Lights/light" {
  17088. import { Nullable } from "babylonjs/types";
  17089. import { Scene } from "babylonjs/scene";
  17090. import { Vector3 } from "babylonjs/Maths/math.vector";
  17091. import { Color3 } from "babylonjs/Maths/math.color";
  17092. import { Node } from "babylonjs/node";
  17093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17094. import { Effect } from "babylonjs/Materials/effect";
  17095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17096. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17097. /**
  17098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17100. * 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.
  17101. */
  17102. export abstract class Light extends Node {
  17103. /**
  17104. * Falloff Default: light is falling off following the material specification:
  17105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17106. */
  17107. static readonly FALLOFF_DEFAULT: number;
  17108. /**
  17109. * Falloff Physical: light is falling off following the inverse squared distance law.
  17110. */
  17111. static readonly FALLOFF_PHYSICAL: number;
  17112. /**
  17113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17114. * to enhance interoperability with other engines.
  17115. */
  17116. static readonly FALLOFF_GLTF: number;
  17117. /**
  17118. * Falloff Standard: light is falling off like in the standard material
  17119. * to enhance interoperability with other materials.
  17120. */
  17121. static readonly FALLOFF_STANDARD: number;
  17122. /**
  17123. * If every light affecting the material is in this lightmapMode,
  17124. * material.lightmapTexture adds or multiplies
  17125. * (depends on material.useLightmapAsShadowmap)
  17126. * after every other light calculations.
  17127. */
  17128. static readonly LIGHTMAP_DEFAULT: number;
  17129. /**
  17130. * material.lightmapTexture as only diffuse lighting from this light
  17131. * adds only specular lighting from this light
  17132. * adds dynamic shadows
  17133. */
  17134. static readonly LIGHTMAP_SPECULAR: number;
  17135. /**
  17136. * material.lightmapTexture as only lighting
  17137. * no light calculation from this light
  17138. * only adds dynamic shadows from this light
  17139. */
  17140. static readonly LIGHTMAP_SHADOWSONLY: number;
  17141. /**
  17142. * Each light type uses the default quantity according to its type:
  17143. * point/spot lights use luminous intensity
  17144. * directional lights use illuminance
  17145. */
  17146. static readonly INTENSITYMODE_AUTOMATIC: number;
  17147. /**
  17148. * lumen (lm)
  17149. */
  17150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17151. /**
  17152. * candela (lm/sr)
  17153. */
  17154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17155. /**
  17156. * lux (lm/m^2)
  17157. */
  17158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17159. /**
  17160. * nit (cd/m^2)
  17161. */
  17162. static readonly INTENSITYMODE_LUMINANCE: number;
  17163. /**
  17164. * Light type const id of the point light.
  17165. */
  17166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17167. /**
  17168. * Light type const id of the directional light.
  17169. */
  17170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17171. /**
  17172. * Light type const id of the spot light.
  17173. */
  17174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17175. /**
  17176. * Light type const id of the hemispheric light.
  17177. */
  17178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17179. /**
  17180. * Diffuse gives the basic color to an object.
  17181. */
  17182. diffuse: Color3;
  17183. /**
  17184. * Specular produces a highlight color on an object.
  17185. * Note: This is note affecting PBR materials.
  17186. */
  17187. specular: Color3;
  17188. /**
  17189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17190. * falling off base on range or angle.
  17191. * This can be set to any values in Light.FALLOFF_x.
  17192. *
  17193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17194. * other types of materials.
  17195. */
  17196. falloffType: number;
  17197. /**
  17198. * Strength of the light.
  17199. * Note: By default it is define in the framework own unit.
  17200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17201. */
  17202. intensity: number;
  17203. private _range;
  17204. protected _inverseSquaredRange: number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. get range(): number;
  17210. /**
  17211. * Defines how far from the source the light is impacting in scene units.
  17212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17213. */
  17214. set range(value: number);
  17215. /**
  17216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17217. * of light.
  17218. */
  17219. private _photometricScale;
  17220. private _intensityMode;
  17221. /**
  17222. * Gets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. get intensityMode(): number;
  17226. /**
  17227. * Sets the photometric scale used to interpret the intensity.
  17228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17229. */
  17230. set intensityMode(value: number);
  17231. private _radius;
  17232. /**
  17233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17234. */
  17235. get radius(): number;
  17236. /**
  17237. * sets the light radius used by PBR Materials to simulate soft area lights.
  17238. */
  17239. set radius(value: number);
  17240. private _renderPriority;
  17241. /**
  17242. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17243. * exceeding the number allowed of the materials.
  17244. */
  17245. renderPriority: number;
  17246. private _shadowEnabled;
  17247. /**
  17248. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. get shadowEnabled(): boolean;
  17252. /**
  17253. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17254. * the current shadow generator.
  17255. */
  17256. set shadowEnabled(value: boolean);
  17257. private _includedOnlyMeshes;
  17258. /**
  17259. * Gets the only meshes impacted by this light.
  17260. */
  17261. get includedOnlyMeshes(): AbstractMesh[];
  17262. /**
  17263. * Sets the only meshes impacted by this light.
  17264. */
  17265. set includedOnlyMeshes(value: AbstractMesh[]);
  17266. private _excludedMeshes;
  17267. /**
  17268. * Gets the meshes not impacted by this light.
  17269. */
  17270. get excludedMeshes(): AbstractMesh[];
  17271. /**
  17272. * Sets the meshes not impacted by this light.
  17273. */
  17274. set excludedMeshes(value: AbstractMesh[]);
  17275. private _excludeWithLayerMask;
  17276. /**
  17277. * Gets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. get excludeWithLayerMask(): number;
  17281. /**
  17282. * Sets the layer id use to find what meshes are not impacted by the light.
  17283. * Inactive if 0
  17284. */
  17285. set excludeWithLayerMask(value: number);
  17286. private _includeOnlyWithLayerMask;
  17287. /**
  17288. * Gets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. get includeOnlyWithLayerMask(): number;
  17292. /**
  17293. * Sets the layer id use to find what meshes are impacted by the light.
  17294. * Inactive if 0
  17295. */
  17296. set includeOnlyWithLayerMask(value: number);
  17297. private _lightmapMode;
  17298. /**
  17299. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17300. */
  17301. get lightmapMode(): number;
  17302. /**
  17303. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17304. */
  17305. set lightmapMode(value: number);
  17306. /**
  17307. * Shadow generator associted to the light.
  17308. * @hidden Internal use only.
  17309. */
  17310. _shadowGenerator: Nullable<IShadowGenerator>;
  17311. /**
  17312. * @hidden Internal use only.
  17313. */
  17314. _excludedMeshesIds: string[];
  17315. /**
  17316. * @hidden Internal use only.
  17317. */
  17318. _includedOnlyMeshesIds: string[];
  17319. /**
  17320. * The current light unifom buffer.
  17321. * @hidden Internal use only.
  17322. */
  17323. _uniformBuffer: UniformBuffer;
  17324. /** @hidden */
  17325. _renderId: number;
  17326. /**
  17327. * Creates a Light object in the scene.
  17328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17329. * @param name The firendly name of the light
  17330. * @param scene The scene the light belongs too
  17331. */
  17332. constructor(name: string, scene: Scene);
  17333. protected abstract _buildUniformLayout(): void;
  17334. /**
  17335. * Sets the passed Effect "effect" with the Light information.
  17336. * @param effect The effect to update
  17337. * @param lightIndex The index of the light in the effect to update
  17338. * @returns The light
  17339. */
  17340. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17341. /**
  17342. * Sets the passed Effect "effect" with the Light textures.
  17343. * @param effect The effect to update
  17344. * @param lightIndex The index of the light in the effect to update
  17345. * @returns The light
  17346. */
  17347. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17348. /**
  17349. * Binds the lights information from the scene to the effect for the given mesh.
  17350. * @param lightIndex Light index
  17351. * @param scene The scene where the light belongs to
  17352. * @param effect The effect we are binding the data to
  17353. * @param useSpecular Defines if specular is supported
  17354. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17355. */
  17356. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17361. * @returns The light
  17362. */
  17363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17364. /**
  17365. * Returns the string "Light".
  17366. * @returns the class name
  17367. */
  17368. getClassName(): string;
  17369. /** @hidden */
  17370. readonly _isLight: boolean;
  17371. /**
  17372. * Converts the light information to a readable string for debug purpose.
  17373. * @param fullDetails Supports for multiple levels of logging within scene loading
  17374. * @returns the human readable light info
  17375. */
  17376. toString(fullDetails?: boolean): string;
  17377. /** @hidden */
  17378. protected _syncParentEnabledState(): void;
  17379. /**
  17380. * Set the enabled state of this node.
  17381. * @param value - the new enabled state
  17382. */
  17383. setEnabled(value: boolean): void;
  17384. /**
  17385. * Returns the Light associated shadow generator if any.
  17386. * @return the associated shadow generator.
  17387. */
  17388. getShadowGenerator(): Nullable<IShadowGenerator>;
  17389. /**
  17390. * Returns a Vector3, the absolute light position in the World.
  17391. * @returns the world space position of the light
  17392. */
  17393. getAbsolutePosition(): Vector3;
  17394. /**
  17395. * Specifies if the light will affect the passed mesh.
  17396. * @param mesh The mesh to test against the light
  17397. * @return true the mesh is affected otherwise, false.
  17398. */
  17399. canAffectMesh(mesh: AbstractMesh): boolean;
  17400. /**
  17401. * Sort function to order lights for rendering.
  17402. * @param a First Light object to compare to second.
  17403. * @param b Second Light object to compare first.
  17404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17405. */
  17406. static CompareLightsPriority(a: Light, b: Light): number;
  17407. /**
  17408. * Releases resources associated with this node.
  17409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17411. */
  17412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17413. /**
  17414. * Returns the light type ID (integer).
  17415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17416. */
  17417. getTypeID(): number;
  17418. /**
  17419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17420. * @returns the scaled intensity in intensity mode unit
  17421. */
  17422. getScaledIntensity(): number;
  17423. /**
  17424. * Returns a new Light object, named "name", from the current one.
  17425. * @param name The name of the cloned light
  17426. * @returns the new created light
  17427. */
  17428. clone(name: string): Nullable<Light>;
  17429. /**
  17430. * Serializes the current light into a Serialization object.
  17431. * @returns the serialized object.
  17432. */
  17433. serialize(): any;
  17434. /**
  17435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17436. * This new light is named "name" and added to the passed scene.
  17437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17438. * @param name The friendly name of the light
  17439. * @param scene The scene the new light will belong to
  17440. * @returns the constructor function
  17441. */
  17442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17443. /**
  17444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17445. * @param parsedLight The JSON representation of the light
  17446. * @param scene The scene to create the parsed light in
  17447. * @returns the created light after parsing
  17448. */
  17449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17450. private _hookArrayForExcluded;
  17451. private _hookArrayForIncludedOnly;
  17452. private _resyncMeshes;
  17453. /**
  17454. * Forces the meshes to update their light related information in their rendering used effects
  17455. * @hidden Internal Use Only
  17456. */
  17457. _markMeshesAsLightDirty(): void;
  17458. /**
  17459. * Recomputes the cached photometric scale if needed.
  17460. */
  17461. private _computePhotometricScale;
  17462. /**
  17463. * Returns the Photometric Scale according to the light type and intensity mode.
  17464. */
  17465. private _getPhotometricScale;
  17466. /**
  17467. * Reorder the light in the scene according to their defined priority.
  17468. * @hidden Internal Use Only
  17469. */
  17470. _reorderLightsInScene(): void;
  17471. /**
  17472. * Prepares the list of defines specific to the light type.
  17473. * @param defines the list of defines
  17474. * @param lightIndex defines the index of the light for the effect
  17475. */
  17476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17477. }
  17478. }
  17479. declare module "babylonjs/Actions/action" {
  17480. import { Observable } from "babylonjs/Misc/observable";
  17481. import { Condition } from "babylonjs/Actions/condition";
  17482. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17483. import { ActionManager } from "babylonjs/Actions/actionManager";
  17484. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17485. /**
  17486. * Interface used to define Action
  17487. */
  17488. export interface IAction {
  17489. /**
  17490. * Trigger for the action
  17491. */
  17492. trigger: number;
  17493. /** Options of the trigger */
  17494. triggerOptions: any;
  17495. /**
  17496. * Gets the trigger parameters
  17497. * @returns the trigger parameters
  17498. */
  17499. getTriggerParameter(): any;
  17500. /**
  17501. * Internal only - executes current action event
  17502. * @hidden
  17503. */
  17504. _executeCurrent(evt?: ActionEvent): void;
  17505. /**
  17506. * Serialize placeholder for child classes
  17507. * @param parent of child
  17508. * @returns the serialized object
  17509. */
  17510. serialize(parent: any): any;
  17511. /**
  17512. * Internal only
  17513. * @hidden
  17514. */
  17515. _prepare(): void;
  17516. /**
  17517. * Internal only - manager for action
  17518. * @hidden
  17519. */
  17520. _actionManager: AbstractActionManager;
  17521. /**
  17522. * Adds action to chain of actions, may be a DoNothingAction
  17523. * @param action defines the next action to execute
  17524. * @returns The action passed in
  17525. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17526. */
  17527. then(action: IAction): IAction;
  17528. }
  17529. /**
  17530. * The action to be carried out following a trigger
  17531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17532. */
  17533. export class Action implements IAction {
  17534. /** the trigger, with or without parameters, for the action */
  17535. triggerOptions: any;
  17536. /**
  17537. * Trigger for the action
  17538. */
  17539. trigger: number;
  17540. /**
  17541. * Internal only - manager for action
  17542. * @hidden
  17543. */
  17544. _actionManager: ActionManager;
  17545. private _nextActiveAction;
  17546. private _child;
  17547. private _condition?;
  17548. private _triggerParameter;
  17549. /**
  17550. * An event triggered prior to action being executed.
  17551. */
  17552. onBeforeExecuteObservable: Observable<Action>;
  17553. /**
  17554. * Creates a new Action
  17555. * @param triggerOptions the trigger, with or without parameters, for the action
  17556. * @param condition an optional determinant of action
  17557. */
  17558. constructor(
  17559. /** the trigger, with or without parameters, for the action */
  17560. triggerOptions: any, condition?: Condition);
  17561. /**
  17562. * Internal only
  17563. * @hidden
  17564. */
  17565. _prepare(): void;
  17566. /**
  17567. * Gets the trigger parameters
  17568. * @returns the trigger parameters
  17569. */
  17570. getTriggerParameter(): any;
  17571. /**
  17572. * Internal only - executes current action event
  17573. * @hidden
  17574. */
  17575. _executeCurrent(evt?: ActionEvent): void;
  17576. /**
  17577. * Execute placeholder for child classes
  17578. * @param evt optional action event
  17579. */
  17580. execute(evt?: ActionEvent): void;
  17581. /**
  17582. * Skips to next active action
  17583. */
  17584. skipToNextActiveAction(): void;
  17585. /**
  17586. * Adds action to chain of actions, may be a DoNothingAction
  17587. * @param action defines the next action to execute
  17588. * @returns The action passed in
  17589. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17590. */
  17591. then(action: Action): Action;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getProperty(propertyPath: string): string;
  17597. /**
  17598. * Internal only
  17599. * @hidden
  17600. */
  17601. _getEffectiveTarget(target: any, propertyPath: string): any;
  17602. /**
  17603. * Serialize placeholder for child classes
  17604. * @param parent of child
  17605. * @returns the serialized object
  17606. */
  17607. serialize(parent: any): any;
  17608. /**
  17609. * Internal only called by serialize
  17610. * @hidden
  17611. */
  17612. protected _serialize(serializedAction: any, parent?: any): any;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _SerializeValueAsString: (value: any) => string;
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17623. name: string;
  17624. targetType: string;
  17625. value: string;
  17626. };
  17627. }
  17628. }
  17629. declare module "babylonjs/Actions/condition" {
  17630. import { ActionManager } from "babylonjs/Actions/actionManager";
  17631. /**
  17632. * A Condition applied to an Action
  17633. */
  17634. export class Condition {
  17635. /**
  17636. * Internal only - manager for action
  17637. * @hidden
  17638. */
  17639. _actionManager: ActionManager;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _evaluationId: number;
  17645. /**
  17646. * Internal only
  17647. * @hidden
  17648. */
  17649. _currentResult: boolean;
  17650. /**
  17651. * Creates a new Condition
  17652. * @param actionManager the manager of the action the condition is applied to
  17653. */
  17654. constructor(actionManager: ActionManager);
  17655. /**
  17656. * Check if the current condition is valid
  17657. * @returns a boolean
  17658. */
  17659. isValid(): boolean;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getProperty(propertyPath: string): string;
  17665. /**
  17666. * Internal only
  17667. * @hidden
  17668. */
  17669. _getEffectiveTarget(target: any, propertyPath: string): any;
  17670. /**
  17671. * Serialize placeholder for child classes
  17672. * @returns the serialized object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Internal only
  17677. * @hidden
  17678. */
  17679. protected _serialize(serializedCondition: any): any;
  17680. }
  17681. /**
  17682. * Defines specific conditional operators as extensions of Condition
  17683. */
  17684. export class ValueCondition extends Condition {
  17685. /** path to specify the property of the target the conditional operator uses */
  17686. propertyPath: string;
  17687. /** the value compared by the conditional operator against the current value of the property */
  17688. value: any;
  17689. /** the conditional operator, default ValueCondition.IsEqual */
  17690. operator: number;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsEqual;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsDifferent;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsGreater;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. private static _IsLesser;
  17711. /**
  17712. * returns the number for IsEqual
  17713. */
  17714. static get IsEqual(): number;
  17715. /**
  17716. * Returns the number for IsDifferent
  17717. */
  17718. static get IsDifferent(): number;
  17719. /**
  17720. * Returns the number for IsGreater
  17721. */
  17722. static get IsGreater(): number;
  17723. /**
  17724. * Returns the number for IsLesser
  17725. */
  17726. static get IsLesser(): number;
  17727. /**
  17728. * Internal only The action manager for the condition
  17729. * @hidden
  17730. */
  17731. _actionManager: ActionManager;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _target;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _effectiveTarget;
  17742. /**
  17743. * Internal only
  17744. * @hidden
  17745. */
  17746. private _property;
  17747. /**
  17748. * Creates a new ValueCondition
  17749. * @param actionManager manager for the action the condition applies to
  17750. * @param target for the action
  17751. * @param propertyPath path to specify the property of the target the conditional operator uses
  17752. * @param value the value compared by the conditional operator against the current value of the property
  17753. * @param operator the conditional operator, default ValueCondition.IsEqual
  17754. */
  17755. constructor(actionManager: ActionManager, target: any,
  17756. /** path to specify the property of the target the conditional operator uses */
  17757. propertyPath: string,
  17758. /** the value compared by the conditional operator against the current value of the property */
  17759. value: any,
  17760. /** the conditional operator, default ValueCondition.IsEqual */
  17761. operator?: number);
  17762. /**
  17763. * Compares the given value with the property value for the specified conditional operator
  17764. * @returns the result of the comparison
  17765. */
  17766. isValid(): boolean;
  17767. /**
  17768. * Serialize the ValueCondition into a JSON compatible object
  17769. * @returns serialization object
  17770. */
  17771. serialize(): any;
  17772. /**
  17773. * Gets the name of the conditional operator for the ValueCondition
  17774. * @param operator the conditional operator
  17775. * @returns the name
  17776. */
  17777. static GetOperatorName(operator: number): string;
  17778. }
  17779. /**
  17780. * Defines a predicate condition as an extension of Condition
  17781. */
  17782. export class PredicateCondition extends Condition {
  17783. /** defines the predicate function used to validate the condition */
  17784. predicate: () => boolean;
  17785. /**
  17786. * Internal only - manager for action
  17787. * @hidden
  17788. */
  17789. _actionManager: ActionManager;
  17790. /**
  17791. * Creates a new PredicateCondition
  17792. * @param actionManager manager for the action the condition applies to
  17793. * @param predicate defines the predicate function used to validate the condition
  17794. */
  17795. constructor(actionManager: ActionManager,
  17796. /** defines the predicate function used to validate the condition */
  17797. predicate: () => boolean);
  17798. /**
  17799. * @returns the validity of the predicate condition
  17800. */
  17801. isValid(): boolean;
  17802. }
  17803. /**
  17804. * Defines a state condition as an extension of Condition
  17805. */
  17806. export class StateCondition extends Condition {
  17807. /** Value to compare with target state */
  17808. value: string;
  17809. /**
  17810. * Internal only - manager for action
  17811. * @hidden
  17812. */
  17813. _actionManager: ActionManager;
  17814. /**
  17815. * Internal only
  17816. * @hidden
  17817. */
  17818. private _target;
  17819. /**
  17820. * Creates a new StateCondition
  17821. * @param actionManager manager for the action the condition applies to
  17822. * @param target of the condition
  17823. * @param value to compare with target state
  17824. */
  17825. constructor(actionManager: ActionManager, target: any,
  17826. /** Value to compare with target state */
  17827. value: string);
  17828. /**
  17829. * Gets a boolean indicating if the current condition is met
  17830. * @returns the validity of the state
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the StateCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. }
  17839. }
  17840. declare module "babylonjs/Actions/directActions" {
  17841. import { Action } from "babylonjs/Actions/action";
  17842. import { Condition } from "babylonjs/Actions/condition";
  17843. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17844. /**
  17845. * This defines an action responsible to toggle a boolean once triggered.
  17846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17847. */
  17848. export class SwitchBooleanAction extends Action {
  17849. /**
  17850. * The path to the boolean property in the target object
  17851. */
  17852. propertyPath: string;
  17853. private _target;
  17854. private _effectiveTarget;
  17855. private _property;
  17856. /**
  17857. * Instantiate the action
  17858. * @param triggerOptions defines the trigger options
  17859. * @param target defines the object containing the boolean
  17860. * @param propertyPath defines the path to the boolean property in the target object
  17861. * @param condition defines the trigger related conditions
  17862. */
  17863. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17864. /** @hidden */
  17865. _prepare(): void;
  17866. /**
  17867. * Execute the action toggle the boolean value.
  17868. */
  17869. execute(): void;
  17870. /**
  17871. * Serializes the actions and its related information.
  17872. * @param parent defines the object to serialize in
  17873. * @returns the serialized object
  17874. */
  17875. serialize(parent: any): any;
  17876. }
  17877. /**
  17878. * This defines an action responsible to set a the state field of the target
  17879. * to a desired value once triggered.
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17881. */
  17882. export class SetStateAction extends Action {
  17883. /**
  17884. * The value to store in the state field.
  17885. */
  17886. value: string;
  17887. private _target;
  17888. /**
  17889. * Instantiate the action
  17890. * @param triggerOptions defines the trigger options
  17891. * @param target defines the object containing the state property
  17892. * @param value defines the value to store in the state field
  17893. * @param condition defines the trigger related conditions
  17894. */
  17895. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17896. /**
  17897. * Execute the action and store the value on the target state property.
  17898. */
  17899. execute(): void;
  17900. /**
  17901. * Serializes the actions and its related information.
  17902. * @param parent defines the object to serialize in
  17903. * @returns the serialized object
  17904. */
  17905. serialize(parent: any): any;
  17906. }
  17907. /**
  17908. * This defines an action responsible to set a property of the target
  17909. * to a desired value once triggered.
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. export class SetValueAction extends Action {
  17913. /**
  17914. * The path of the property to set in the target.
  17915. */
  17916. propertyPath: string;
  17917. /**
  17918. * The value to set in the property
  17919. */
  17920. value: any;
  17921. private _target;
  17922. private _effectiveTarget;
  17923. private _property;
  17924. /**
  17925. * Instantiate the action
  17926. * @param triggerOptions defines the trigger options
  17927. * @param target defines the object containing the property
  17928. * @param propertyPath defines the path of the property to set in the target
  17929. * @param value defines the value to set in the property
  17930. * @param condition defines the trigger related conditions
  17931. */
  17932. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17933. /** @hidden */
  17934. _prepare(): void;
  17935. /**
  17936. * Execute the action and set the targetted property to the desired value.
  17937. */
  17938. execute(): void;
  17939. /**
  17940. * Serializes the actions and its related information.
  17941. * @param parent defines the object to serialize in
  17942. * @returns the serialized object
  17943. */
  17944. serialize(parent: any): any;
  17945. }
  17946. /**
  17947. * This defines an action responsible to increment the target value
  17948. * to a desired value once triggered.
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17950. */
  17951. export class IncrementValueAction extends Action {
  17952. /**
  17953. * The path of the property to increment in the target.
  17954. */
  17955. propertyPath: string;
  17956. /**
  17957. * The value we should increment the property by.
  17958. */
  17959. value: any;
  17960. private _target;
  17961. private _effectiveTarget;
  17962. private _property;
  17963. /**
  17964. * Instantiate the action
  17965. * @param triggerOptions defines the trigger options
  17966. * @param target defines the object containing the property
  17967. * @param propertyPath defines the path of the property to increment in the target
  17968. * @param value defines the value value we should increment the property by
  17969. * @param condition defines the trigger related conditions
  17970. */
  17971. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17972. /** @hidden */
  17973. _prepare(): void;
  17974. /**
  17975. * Execute the action and increment the target of the value amount.
  17976. */
  17977. execute(): void;
  17978. /**
  17979. * Serializes the actions and its related information.
  17980. * @param parent defines the object to serialize in
  17981. * @returns the serialized object
  17982. */
  17983. serialize(parent: any): any;
  17984. }
  17985. /**
  17986. * This defines an action responsible to start an animation once triggered.
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17988. */
  17989. export class PlayAnimationAction extends Action {
  17990. /**
  17991. * Where the animation should start (animation frame)
  17992. */
  17993. from: number;
  17994. /**
  17995. * Where the animation should stop (animation frame)
  17996. */
  17997. to: number;
  17998. /**
  17999. * Define if the animation should loop or stop after the first play.
  18000. */
  18001. loop?: boolean;
  18002. private _target;
  18003. /**
  18004. * Instantiate the action
  18005. * @param triggerOptions defines the trigger options
  18006. * @param target defines the target animation or animation name
  18007. * @param from defines from where the animation should start (animation frame)
  18008. * @param end defines where the animation should stop (animation frame)
  18009. * @param loop defines if the animation should loop or stop after the first play
  18010. * @param condition defines the trigger related conditions
  18011. */
  18012. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18013. /** @hidden */
  18014. _prepare(): void;
  18015. /**
  18016. * Execute the action and play the animation.
  18017. */
  18018. execute(): void;
  18019. /**
  18020. * Serializes the actions and its related information.
  18021. * @param parent defines the object to serialize in
  18022. * @returns the serialized object
  18023. */
  18024. serialize(parent: any): any;
  18025. }
  18026. /**
  18027. * This defines an action responsible to stop an animation once triggered.
  18028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18029. */
  18030. export class StopAnimationAction extends Action {
  18031. private _target;
  18032. /**
  18033. * Instantiate the action
  18034. * @param triggerOptions defines the trigger options
  18035. * @param target defines the target animation or animation name
  18036. * @param condition defines the trigger related conditions
  18037. */
  18038. constructor(triggerOptions: any, target: any, condition?: Condition);
  18039. /** @hidden */
  18040. _prepare(): void;
  18041. /**
  18042. * Execute the action and stop the animation.
  18043. */
  18044. execute(): void;
  18045. /**
  18046. * Serializes the actions and its related information.
  18047. * @param parent defines the object to serialize in
  18048. * @returns the serialized object
  18049. */
  18050. serialize(parent: any): any;
  18051. }
  18052. /**
  18053. * This defines an action responsible that does nothing once triggered.
  18054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18055. */
  18056. export class DoNothingAction extends Action {
  18057. /**
  18058. * Instantiate the action
  18059. * @param triggerOptions defines the trigger options
  18060. * @param condition defines the trigger related conditions
  18061. */
  18062. constructor(triggerOptions?: any, condition?: Condition);
  18063. /**
  18064. * Execute the action and do nothing.
  18065. */
  18066. execute(): void;
  18067. /**
  18068. * Serializes the actions and its related information.
  18069. * @param parent defines the object to serialize in
  18070. * @returns the serialized object
  18071. */
  18072. serialize(parent: any): any;
  18073. }
  18074. /**
  18075. * This defines an action responsible to trigger several actions once triggered.
  18076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18077. */
  18078. export class CombineAction extends Action {
  18079. /**
  18080. * The list of aggregated animations to run.
  18081. */
  18082. children: Action[];
  18083. /**
  18084. * Instantiate the action
  18085. * @param triggerOptions defines the trigger options
  18086. * @param children defines the list of aggregated animations to run
  18087. * @param condition defines the trigger related conditions
  18088. */
  18089. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18090. /** @hidden */
  18091. _prepare(): void;
  18092. /**
  18093. * Execute the action and executes all the aggregated actions.
  18094. */
  18095. execute(evt: ActionEvent): void;
  18096. /**
  18097. * Serializes the actions and its related information.
  18098. * @param parent defines the object to serialize in
  18099. * @returns the serialized object
  18100. */
  18101. serialize(parent: any): any;
  18102. }
  18103. /**
  18104. * This defines an action responsible to run code (external event) once triggered.
  18105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18106. */
  18107. export class ExecuteCodeAction extends Action {
  18108. /**
  18109. * The callback function to run.
  18110. */
  18111. func: (evt: ActionEvent) => void;
  18112. /**
  18113. * Instantiate the action
  18114. * @param triggerOptions defines the trigger options
  18115. * @param func defines the callback function to run
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18119. /**
  18120. * Execute the action and run the attached code.
  18121. */
  18122. execute(evt: ActionEvent): void;
  18123. }
  18124. /**
  18125. * This defines an action responsible to set the parent property of the target once triggered.
  18126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18127. */
  18128. export class SetParentAction extends Action {
  18129. private _parent;
  18130. private _target;
  18131. /**
  18132. * Instantiate the action
  18133. * @param triggerOptions defines the trigger options
  18134. * @param target defines the target containing the parent property
  18135. * @param parent defines from where the animation should start (animation frame)
  18136. * @param condition defines the trigger related conditions
  18137. */
  18138. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18139. /** @hidden */
  18140. _prepare(): void;
  18141. /**
  18142. * Execute the action and set the parent property.
  18143. */
  18144. execute(): void;
  18145. /**
  18146. * Serializes the actions and its related information.
  18147. * @param parent defines the object to serialize in
  18148. * @returns the serialized object
  18149. */
  18150. serialize(parent: any): any;
  18151. }
  18152. }
  18153. declare module "babylonjs/Actions/actionManager" {
  18154. import { Nullable } from "babylonjs/types";
  18155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18156. import { Scene } from "babylonjs/scene";
  18157. import { IAction } from "babylonjs/Actions/action";
  18158. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18160. /**
  18161. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18162. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18164. */
  18165. export class ActionManager extends AbstractActionManager {
  18166. /**
  18167. * Nothing
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly NothingTrigger: number;
  18171. /**
  18172. * On pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnPickTrigger: number;
  18176. /**
  18177. * On left pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnLeftPickTrigger: number;
  18181. /**
  18182. * On right pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnRightPickTrigger: number;
  18186. /**
  18187. * On center pick
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnCenterPickTrigger: number;
  18191. /**
  18192. * On pick down
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnPickDownTrigger: number;
  18196. /**
  18197. * On double pick
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnDoublePickTrigger: number;
  18201. /**
  18202. * On pick up
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18204. */
  18205. static readonly OnPickUpTrigger: number;
  18206. /**
  18207. * On pick out.
  18208. * This trigger will only be raised if you also declared a OnPickDown
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnPickOutTrigger: number;
  18212. /**
  18213. * On long press
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnLongPressTrigger: number;
  18217. /**
  18218. * On pointer over
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOverTrigger: number;
  18222. /**
  18223. * On pointer out
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnPointerOutTrigger: number;
  18227. /**
  18228. * On every frame
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnEveryFrameTrigger: number;
  18232. /**
  18233. * On intersection enter
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionEnterTrigger: number;
  18237. /**
  18238. * On intersection exit
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnIntersectionExitTrigger: number;
  18242. /**
  18243. * On key down
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyDownTrigger: number;
  18247. /**
  18248. * On key up
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnKeyUpTrigger: number;
  18252. private _scene;
  18253. /**
  18254. * Creates a new action manager
  18255. * @param scene defines the hosting scene
  18256. */
  18257. constructor(scene: Scene);
  18258. /**
  18259. * Releases all associated resources
  18260. */
  18261. dispose(): void;
  18262. /**
  18263. * Gets hosting scene
  18264. * @returns the hosting scene
  18265. */
  18266. getScene(): Scene;
  18267. /**
  18268. * Does this action manager handles actions of any of the given triggers
  18269. * @param triggers defines the triggers to be tested
  18270. * @return a boolean indicating whether one (or more) of the triggers is handled
  18271. */
  18272. hasSpecificTriggers(triggers: number[]): boolean;
  18273. /**
  18274. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18275. * speed.
  18276. * @param triggerA defines the trigger to be tested
  18277. * @param triggerB defines the trigger to be tested
  18278. * @return a boolean indicating whether one (or more) of the triggers is handled
  18279. */
  18280. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18281. /**
  18282. * Does this action manager handles actions of a given trigger
  18283. * @param trigger defines the trigger to be tested
  18284. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18285. * @return whether the trigger is handled
  18286. */
  18287. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18288. /**
  18289. * Does this action manager has pointer triggers
  18290. */
  18291. get hasPointerTriggers(): boolean;
  18292. /**
  18293. * Does this action manager has pick triggers
  18294. */
  18295. get hasPickTriggers(): boolean;
  18296. /**
  18297. * Registers an action to this action manager
  18298. * @param action defines the action to be registered
  18299. * @return the action amended (prepared) after registration
  18300. */
  18301. registerAction(action: IAction): Nullable<IAction>;
  18302. /**
  18303. * Unregisters an action to this action manager
  18304. * @param action defines the action to be unregistered
  18305. * @return a boolean indicating whether the action has been unregistered
  18306. */
  18307. unregisterAction(action: IAction): Boolean;
  18308. /**
  18309. * Process a specific trigger
  18310. * @param trigger defines the trigger to process
  18311. * @param evt defines the event details to be processed
  18312. */
  18313. processTrigger(trigger: number, evt?: IActionEvent): void;
  18314. /** @hidden */
  18315. _getEffectiveTarget(target: any, propertyPath: string): any;
  18316. /** @hidden */
  18317. _getProperty(propertyPath: string): string;
  18318. /**
  18319. * Serialize this manager to a JSON object
  18320. * @param name defines the property name to store this manager
  18321. * @returns a JSON representation of this manager
  18322. */
  18323. serialize(name: string): any;
  18324. /**
  18325. * Creates a new ActionManager from a JSON data
  18326. * @param parsedActions defines the JSON data to read from
  18327. * @param object defines the hosting mesh
  18328. * @param scene defines the hosting scene
  18329. */
  18330. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18331. /**
  18332. * Get a trigger name by index
  18333. * @param trigger defines the trigger index
  18334. * @returns a trigger name
  18335. */
  18336. static GetTriggerName(trigger: number): string;
  18337. }
  18338. }
  18339. declare module "babylonjs/Sprites/sprite" {
  18340. import { Vector3 } from "babylonjs/Maths/math.vector";
  18341. import { Nullable } from "babylonjs/types";
  18342. import { ActionManager } from "babylonjs/Actions/actionManager";
  18343. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18344. import { Color4 } from "babylonjs/Maths/math.color";
  18345. /**
  18346. * Class used to represent a sprite
  18347. * @see http://doc.babylonjs.com/babylon101/sprites
  18348. */
  18349. export class Sprite {
  18350. /** defines the name */
  18351. name: string;
  18352. /** Gets or sets the current world position */
  18353. position: Vector3;
  18354. /** Gets or sets the main color */
  18355. color: Color4;
  18356. /** Gets or sets the width */
  18357. width: number;
  18358. /** Gets or sets the height */
  18359. height: number;
  18360. /** Gets or sets rotation angle */
  18361. angle: number;
  18362. /** Gets or sets the cell index in the sprite sheet */
  18363. cellIndex: number;
  18364. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18365. cellRef: string;
  18366. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18367. invertU: number;
  18368. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18369. invertV: number;
  18370. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18371. disposeWhenFinishedAnimating: boolean;
  18372. /** Gets the list of attached animations */
  18373. animations: Animation[];
  18374. /** Gets or sets a boolean indicating if the sprite can be picked */
  18375. isPickable: boolean;
  18376. /**
  18377. * Gets or sets the associated action manager
  18378. */
  18379. actionManager: Nullable<ActionManager>;
  18380. private _animationStarted;
  18381. private _loopAnimation;
  18382. private _fromIndex;
  18383. private _toIndex;
  18384. private _delay;
  18385. private _direction;
  18386. private _manager;
  18387. private _time;
  18388. private _onAnimationEnd;
  18389. /**
  18390. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18391. */
  18392. isVisible: boolean;
  18393. /**
  18394. * Gets or sets the sprite size
  18395. */
  18396. get size(): number;
  18397. set size(value: number);
  18398. /**
  18399. * Creates a new Sprite
  18400. * @param name defines the name
  18401. * @param manager defines the manager
  18402. */
  18403. constructor(
  18404. /** defines the name */
  18405. name: string, manager: ISpriteManager);
  18406. /**
  18407. * Starts an animation
  18408. * @param from defines the initial key
  18409. * @param to defines the end key
  18410. * @param loop defines if the animation must loop
  18411. * @param delay defines the start delay (in ms)
  18412. * @param onAnimationEnd defines a callback to call when animation ends
  18413. */
  18414. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18415. /** Stops current animation (if any) */
  18416. stopAnimation(): void;
  18417. /** @hidden */
  18418. _animate(deltaTime: number): void;
  18419. /** Release associated resources */
  18420. dispose(): void;
  18421. }
  18422. }
  18423. declare module "babylonjs/Collisions/pickingInfo" {
  18424. import { Nullable } from "babylonjs/types";
  18425. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18427. import { Sprite } from "babylonjs/Sprites/sprite";
  18428. import { Ray } from "babylonjs/Culling/ray";
  18429. /**
  18430. * Information about the result of picking within a scene
  18431. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18432. */
  18433. export class PickingInfo {
  18434. /** @hidden */
  18435. _pickingUnavailable: boolean;
  18436. /**
  18437. * If the pick collided with an object
  18438. */
  18439. hit: boolean;
  18440. /**
  18441. * Distance away where the pick collided
  18442. */
  18443. distance: number;
  18444. /**
  18445. * The location of pick collision
  18446. */
  18447. pickedPoint: Nullable<Vector3>;
  18448. /**
  18449. * The mesh corresponding the the pick collision
  18450. */
  18451. pickedMesh: Nullable<AbstractMesh>;
  18452. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18453. bu: number;
  18454. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18455. bv: number;
  18456. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18457. faceId: number;
  18458. /** Id of the the submesh that was picked */
  18459. subMeshId: number;
  18460. /** If a sprite was picked, this will be the sprite the pick collided with */
  18461. pickedSprite: Nullable<Sprite>;
  18462. /**
  18463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18464. */
  18465. originMesh: Nullable<AbstractMesh>;
  18466. /**
  18467. * The ray that was used to perform the picking.
  18468. */
  18469. ray: Nullable<Ray>;
  18470. /**
  18471. * Gets the normal correspodning to the face the pick collided with
  18472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18474. * @returns The normal correspodning to the face the pick collided with
  18475. */
  18476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18477. /**
  18478. * Gets the texture coordinates of where the pick occured
  18479. * @returns the vector containing the coordnates of the texture
  18480. */
  18481. getTextureCoordinates(): Nullable<Vector2>;
  18482. }
  18483. }
  18484. declare module "babylonjs/Events/pointerEvents" {
  18485. import { Nullable } from "babylonjs/types";
  18486. import { Vector2 } from "babylonjs/Maths/math.vector";
  18487. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18488. import { Ray } from "babylonjs/Culling/ray";
  18489. /**
  18490. * Gather the list of pointer event types as constants.
  18491. */
  18492. export class PointerEventTypes {
  18493. /**
  18494. * 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.
  18495. */
  18496. static readonly POINTERDOWN: number;
  18497. /**
  18498. * The pointerup event is fired when a pointer is no longer active.
  18499. */
  18500. static readonly POINTERUP: number;
  18501. /**
  18502. * The pointermove event is fired when a pointer changes coordinates.
  18503. */
  18504. static readonly POINTERMOVE: number;
  18505. /**
  18506. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18507. */
  18508. static readonly POINTERWHEEL: number;
  18509. /**
  18510. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18511. */
  18512. static readonly POINTERPICK: number;
  18513. /**
  18514. * The pointertap event is fired when a the object has been touched and released without drag.
  18515. */
  18516. static readonly POINTERTAP: number;
  18517. /**
  18518. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18519. */
  18520. static readonly POINTERDOUBLETAP: number;
  18521. }
  18522. /**
  18523. * Base class of pointer info types.
  18524. */
  18525. export class PointerInfoBase {
  18526. /**
  18527. * Defines the type of event (PointerEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: PointerEvent | MouseWheelEvent;
  18534. /**
  18535. * Instantiates the base class of pointers info.
  18536. * @param type Defines the type of event (PointerEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (PointerEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: PointerEvent | MouseWheelEvent);
  18548. }
  18549. /**
  18550. * This class is used to store pointer related info for the onPrePointerObservable event.
  18551. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18552. */
  18553. export class PointerInfoPre extends PointerInfoBase {
  18554. /**
  18555. * Ray from a pointer if availible (eg. 6dof controller)
  18556. */
  18557. ray: Nullable<Ray>;
  18558. /**
  18559. * Defines the local position of the pointer on the canvas.
  18560. */
  18561. localPosition: Vector2;
  18562. /**
  18563. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18568. * @param type Defines the type of event (PointerEventTypes)
  18569. * @param event Defines the related dom event
  18570. * @param localX Defines the local x coordinates of the pointer when the event occured
  18571. * @param localY Defines the local y coordinates of the pointer when the event occured
  18572. */
  18573. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18574. }
  18575. /**
  18576. * This type contains all the data related to a pointer event in Babylon.js.
  18577. * 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.
  18578. */
  18579. export class PointerInfo extends PointerInfoBase {
  18580. /**
  18581. * Defines the picking info associated to the info (if any)\
  18582. */
  18583. pickInfo: Nullable<PickingInfo>;
  18584. /**
  18585. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18586. * @param type Defines the type of event (PointerEventTypes)
  18587. * @param event Defines the related dom event
  18588. * @param pickInfo Defines the picking info associated to the info (if any)\
  18589. */
  18590. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18591. /**
  18592. * Defines the picking info associated to the info (if any)\
  18593. */
  18594. pickInfo: Nullable<PickingInfo>);
  18595. }
  18596. /**
  18597. * Data relating to a touch event on the screen.
  18598. */
  18599. export interface PointerTouch {
  18600. /**
  18601. * X coordinate of touch.
  18602. */
  18603. x: number;
  18604. /**
  18605. * Y coordinate of touch.
  18606. */
  18607. y: number;
  18608. /**
  18609. * Id of touch. Unique for each finger.
  18610. */
  18611. pointerId: number;
  18612. /**
  18613. * Event type passed from DOM.
  18614. */
  18615. type: any;
  18616. }
  18617. }
  18618. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18619. import { Observable } from "babylonjs/Misc/observable";
  18620. import { Nullable } from "babylonjs/types";
  18621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. */
  18627. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18628. /**
  18629. * Define if touch is enabled in the mouse input
  18630. */
  18631. touchEnabled: boolean;
  18632. /**
  18633. * Defines the camera the input is attached to.
  18634. */
  18635. camera: FreeCamera;
  18636. /**
  18637. * Defines the buttons associated with the input to handle camera move.
  18638. */
  18639. buttons: number[];
  18640. /**
  18641. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18642. */
  18643. angularSensibility: number;
  18644. private _pointerInput;
  18645. private _onMouseMove;
  18646. private _observer;
  18647. private previousPosition;
  18648. /**
  18649. * Observable for when a pointer move event occurs containing the move offset
  18650. */
  18651. onPointerMovedObservable: Observable<{
  18652. offsetX: number;
  18653. offsetY: number;
  18654. }>;
  18655. /**
  18656. * @hidden
  18657. * If the camera should be rotated automatically based on pointer movement
  18658. */
  18659. _allowCameraRotation: boolean;
  18660. /**
  18661. * Manage the mouse inputs to control the movement of a free camera.
  18662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18663. * @param touchEnabled Defines if touch is enabled or not
  18664. */
  18665. constructor(
  18666. /**
  18667. * Define if touch is enabled in the mouse input
  18668. */
  18669. touchEnabled?: boolean);
  18670. /**
  18671. * Attach the input controls to a specific dom element to get the input from.
  18672. * @param element Defines the element the controls should be listened from
  18673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18674. */
  18675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18676. /**
  18677. * Called on JS contextmenu event.
  18678. * Override this method to provide functionality.
  18679. */
  18680. protected onContextMenu(evt: PointerEvent): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Gets the class name of the current intput.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Get the friendly name associated with the input class.
  18693. * @returns the input friendly name
  18694. */
  18695. getSimpleName(): string;
  18696. }
  18697. }
  18698. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18699. import { Nullable } from "babylonjs/types";
  18700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18702. /**
  18703. * Manage the touch inputs to control the movement of a free camera.
  18704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18705. */
  18706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18707. /**
  18708. * Defines the camera the input is attached to.
  18709. */
  18710. camera: FreeCamera;
  18711. /**
  18712. * Defines the touch sensibility for rotation.
  18713. * The higher the faster.
  18714. */
  18715. touchAngularSensibility: number;
  18716. /**
  18717. * Defines the touch sensibility for move.
  18718. * The higher the faster.
  18719. */
  18720. touchMoveSensibility: number;
  18721. private _offsetX;
  18722. private _offsetY;
  18723. private _pointerPressed;
  18724. private _pointerInput;
  18725. private _observer;
  18726. private _onLostFocus;
  18727. /**
  18728. * Attach the input controls to a specific dom element to get the input from.
  18729. * @param element Defines the element the controls should be listened from
  18730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18731. */
  18732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18733. /**
  18734. * Detach the current controls from the specified dom element.
  18735. * @param element Defines the element to stop listening the inputs from
  18736. */
  18737. detachControl(element: Nullable<HTMLElement>): void;
  18738. /**
  18739. * Update the current camera state depending on the inputs that have been used this frame.
  18740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18741. */
  18742. checkInputs(): void;
  18743. /**
  18744. * Gets the class name of the current intput.
  18745. * @returns the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Get the friendly name associated with the input class.
  18750. * @returns the input friendly name
  18751. */
  18752. getSimpleName(): string;
  18753. }
  18754. }
  18755. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18758. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18759. import { Nullable } from "babylonjs/types";
  18760. /**
  18761. * Default Inputs manager for the FreeCamera.
  18762. * It groups all the default supported inputs for ease of use.
  18763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18764. */
  18765. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18766. /**
  18767. * @hidden
  18768. */
  18769. _mouseInput: Nullable<FreeCameraMouseInput>;
  18770. /**
  18771. * Instantiates a new FreeCameraInputsManager.
  18772. * @param camera Defines the camera the inputs belong to
  18773. */
  18774. constructor(camera: FreeCamera);
  18775. /**
  18776. * Add keyboard input support to the input manager.
  18777. * @returns the current input manager
  18778. */
  18779. addKeyboard(): FreeCameraInputsManager;
  18780. /**
  18781. * Add mouse input support to the input manager.
  18782. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18783. * @returns the current input manager
  18784. */
  18785. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18786. /**
  18787. * Removes the mouse input support from the manager
  18788. * @returns the current input manager
  18789. */
  18790. removeMouse(): FreeCameraInputsManager;
  18791. /**
  18792. * Add touch input support to the input manager.
  18793. * @returns the current input manager
  18794. */
  18795. addTouch(): FreeCameraInputsManager;
  18796. /**
  18797. * Remove all attached input methods from a camera
  18798. */
  18799. clear(): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Cameras/freeCamera" {
  18803. import { Vector3 } from "babylonjs/Maths/math.vector";
  18804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18805. import { Scene } from "babylonjs/scene";
  18806. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18807. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18808. /**
  18809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18810. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18812. */
  18813. export class FreeCamera extends TargetCamera {
  18814. /**
  18815. * Define the collision ellipsoid of the camera.
  18816. * This is helpful to simulate a camera body like the player body around the camera
  18817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18818. */
  18819. ellipsoid: Vector3;
  18820. /**
  18821. * Define an offset for the position of the ellipsoid around the camera.
  18822. * This can be helpful to determine the center of the body near the gravity center of the body
  18823. * instead of its head.
  18824. */
  18825. ellipsoidOffset: Vector3;
  18826. /**
  18827. * Enable or disable collisions of the camera with the rest of the scene objects.
  18828. */
  18829. checkCollisions: boolean;
  18830. /**
  18831. * Enable or disable gravity on the camera.
  18832. */
  18833. applyGravity: boolean;
  18834. /**
  18835. * Define the input manager associated to the camera.
  18836. */
  18837. inputs: FreeCameraInputsManager;
  18838. /**
  18839. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. get angularSensibility(): number;
  18843. /**
  18844. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. set angularSensibility(value: number);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18850. */
  18851. get keysUp(): number[];
  18852. set keysUp(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18855. */
  18856. get keysDown(): number[];
  18857. set keysDown(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18860. */
  18861. get keysLeft(): number[];
  18862. set keysLeft(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18865. */
  18866. get keysRight(): number[];
  18867. set keysRight(value: number[]);
  18868. /**
  18869. * Event raised when the camera collide with a mesh in the scene.
  18870. */
  18871. onCollide: (collidedMesh: AbstractMesh) => void;
  18872. private _collider;
  18873. private _needMoveForGravity;
  18874. private _oldPosition;
  18875. private _diffPosition;
  18876. private _newPosition;
  18877. /** @hidden */
  18878. _localDirection: Vector3;
  18879. /** @hidden */
  18880. _transformedDirection: Vector3;
  18881. /**
  18882. * Instantiates a Free Camera.
  18883. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18884. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18886. * @param name Define the name of the camera in the scene
  18887. * @param position Define the start position of the camera in the scene
  18888. * @param scene Define the scene the camera belongs to
  18889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18890. */
  18891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18892. /**
  18893. * Attached controls to the current camera.
  18894. * @param element Defines the element the controls should be listened from
  18895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18896. */
  18897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18898. /**
  18899. * Detach the current controls from the camera.
  18900. * The camera will stop reacting to inputs.
  18901. * @param element Defines the element to stop listening the inputs from
  18902. */
  18903. detachControl(element: HTMLElement): void;
  18904. private _collisionMask;
  18905. /**
  18906. * Define a collision mask to limit the list of object the camera can collide with
  18907. */
  18908. get collisionMask(): number;
  18909. set collisionMask(mask: number);
  18910. /** @hidden */
  18911. _collideWithWorld(displacement: Vector3): void;
  18912. private _onCollisionPositionChange;
  18913. /** @hidden */
  18914. _checkInputs(): void;
  18915. /** @hidden */
  18916. _decideIfNeedsToMove(): boolean;
  18917. /** @hidden */
  18918. _updatePosition(): void;
  18919. /**
  18920. * Destroy the camera and release the current resources hold by it.
  18921. */
  18922. dispose(): void;
  18923. /**
  18924. * Gets the current object class name.
  18925. * @return the class name
  18926. */
  18927. getClassName(): string;
  18928. }
  18929. }
  18930. declare module "babylonjs/Gamepads/gamepad" {
  18931. import { Observable } from "babylonjs/Misc/observable";
  18932. /**
  18933. * Represents a gamepad control stick position
  18934. */
  18935. export class StickValues {
  18936. /**
  18937. * The x component of the control stick
  18938. */
  18939. x: number;
  18940. /**
  18941. * The y component of the control stick
  18942. */
  18943. y: number;
  18944. /**
  18945. * Initializes the gamepad x and y control stick values
  18946. * @param x The x component of the gamepad control stick value
  18947. * @param y The y component of the gamepad control stick value
  18948. */
  18949. constructor(
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number,
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number);
  18958. }
  18959. /**
  18960. * An interface which manages callbacks for gamepad button changes
  18961. */
  18962. export interface GamepadButtonChanges {
  18963. /**
  18964. * Called when a gamepad has been changed
  18965. */
  18966. changed: boolean;
  18967. /**
  18968. * Called when a gamepad press event has been triggered
  18969. */
  18970. pressChanged: boolean;
  18971. /**
  18972. * Called when a touch event has been triggered
  18973. */
  18974. touchChanged: boolean;
  18975. /**
  18976. * Called when a value has changed
  18977. */
  18978. valueChanged: boolean;
  18979. }
  18980. /**
  18981. * Represents a gamepad
  18982. */
  18983. export class Gamepad {
  18984. /**
  18985. * The id of the gamepad
  18986. */
  18987. id: string;
  18988. /**
  18989. * The index of the gamepad
  18990. */
  18991. index: number;
  18992. /**
  18993. * The browser gamepad
  18994. */
  18995. browserGamepad: any;
  18996. /**
  18997. * Specifies what type of gamepad this represents
  18998. */
  18999. type: number;
  19000. private _leftStick;
  19001. private _rightStick;
  19002. /** @hidden */
  19003. _isConnected: boolean;
  19004. private _leftStickAxisX;
  19005. private _leftStickAxisY;
  19006. private _rightStickAxisX;
  19007. private _rightStickAxisY;
  19008. /**
  19009. * Triggered when the left control stick has been changed
  19010. */
  19011. private _onleftstickchanged;
  19012. /**
  19013. * Triggered when the right control stick has been changed
  19014. */
  19015. private _onrightstickchanged;
  19016. /**
  19017. * Represents a gamepad controller
  19018. */
  19019. static GAMEPAD: number;
  19020. /**
  19021. * Represents a generic controller
  19022. */
  19023. static GENERIC: number;
  19024. /**
  19025. * Represents an XBox controller
  19026. */
  19027. static XBOX: number;
  19028. /**
  19029. * Represents a pose-enabled controller
  19030. */
  19031. static POSE_ENABLED: number;
  19032. /**
  19033. * Represents an Dual Shock controller
  19034. */
  19035. static DUALSHOCK: number;
  19036. /**
  19037. * Specifies whether the left control stick should be Y-inverted
  19038. */
  19039. protected _invertLeftStickY: boolean;
  19040. /**
  19041. * Specifies if the gamepad has been connected
  19042. */
  19043. get isConnected(): boolean;
  19044. /**
  19045. * Initializes the gamepad
  19046. * @param id The id of the gamepad
  19047. * @param index The index of the gamepad
  19048. * @param browserGamepad The browser gamepad
  19049. * @param leftStickX The x component of the left joystick
  19050. * @param leftStickY The y component of the left joystick
  19051. * @param rightStickX The x component of the right joystick
  19052. * @param rightStickY The y component of the right joystick
  19053. */
  19054. constructor(
  19055. /**
  19056. * The id of the gamepad
  19057. */
  19058. id: string,
  19059. /**
  19060. * The index of the gamepad
  19061. */
  19062. index: number,
  19063. /**
  19064. * The browser gamepad
  19065. */
  19066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19067. /**
  19068. * Callback triggered when the left joystick has changed
  19069. * @param callback
  19070. */
  19071. onleftstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Callback triggered when the right joystick has changed
  19074. * @param callback
  19075. */
  19076. onrightstickchanged(callback: (values: StickValues) => void): void;
  19077. /**
  19078. * Gets the left joystick
  19079. */
  19080. get leftStick(): StickValues;
  19081. /**
  19082. * Sets the left joystick values
  19083. */
  19084. set leftStick(newValues: StickValues);
  19085. /**
  19086. * Gets the right joystick
  19087. */
  19088. get rightStick(): StickValues;
  19089. /**
  19090. * Sets the right joystick value
  19091. */
  19092. set rightStick(newValues: StickValues);
  19093. /**
  19094. * Updates the gamepad joystick positions
  19095. */
  19096. update(): void;
  19097. /**
  19098. * Disposes the gamepad
  19099. */
  19100. dispose(): void;
  19101. }
  19102. /**
  19103. * Represents a generic gamepad
  19104. */
  19105. export class GenericPad extends Gamepad {
  19106. private _buttons;
  19107. private _onbuttondown;
  19108. private _onbuttonup;
  19109. /**
  19110. * Observable triggered when a button has been pressed
  19111. */
  19112. onButtonDownObservable: Observable<number>;
  19113. /**
  19114. * Observable triggered when a button has been released
  19115. */
  19116. onButtonUpObservable: Observable<number>;
  19117. /**
  19118. * Callback triggered when a button has been pressed
  19119. * @param callback Called when a button has been pressed
  19120. */
  19121. onbuttondown(callback: (buttonPressed: number) => void): void;
  19122. /**
  19123. * Callback triggered when a button has been released
  19124. * @param callback Called when a button has been released
  19125. */
  19126. onbuttonup(callback: (buttonReleased: number) => void): void;
  19127. /**
  19128. * Initializes the generic gamepad
  19129. * @param id The id of the generic gamepad
  19130. * @param index The index of the generic gamepad
  19131. * @param browserGamepad The browser gamepad
  19132. */
  19133. constructor(id: string, index: number, browserGamepad: any);
  19134. private _setButtonValue;
  19135. /**
  19136. * Updates the generic gamepad
  19137. */
  19138. update(): void;
  19139. /**
  19140. * Disposes the generic gamepad
  19141. */
  19142. dispose(): void;
  19143. }
  19144. }
  19145. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19146. import { Observable } from "babylonjs/Misc/observable";
  19147. import { Nullable } from "babylonjs/types";
  19148. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19151. import { Ray } from "babylonjs/Culling/ray";
  19152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19153. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19154. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19155. /**
  19156. * Defines the types of pose enabled controllers that are supported
  19157. */
  19158. export enum PoseEnabledControllerType {
  19159. /**
  19160. * HTC Vive
  19161. */
  19162. VIVE = 0,
  19163. /**
  19164. * Oculus Rift
  19165. */
  19166. OCULUS = 1,
  19167. /**
  19168. * Windows mixed reality
  19169. */
  19170. WINDOWS = 2,
  19171. /**
  19172. * Samsung gear VR
  19173. */
  19174. GEAR_VR = 3,
  19175. /**
  19176. * Google Daydream
  19177. */
  19178. DAYDREAM = 4,
  19179. /**
  19180. * Generic
  19181. */
  19182. GENERIC = 5
  19183. }
  19184. /**
  19185. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19186. */
  19187. export interface MutableGamepadButton {
  19188. /**
  19189. * Value of the button/trigger
  19190. */
  19191. value: number;
  19192. /**
  19193. * If the button/trigger is currently touched
  19194. */
  19195. touched: boolean;
  19196. /**
  19197. * If the button/trigger is currently pressed
  19198. */
  19199. pressed: boolean;
  19200. }
  19201. /**
  19202. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19203. * @hidden
  19204. */
  19205. export interface ExtendedGamepadButton extends GamepadButton {
  19206. /**
  19207. * If the button/trigger is currently pressed
  19208. */
  19209. readonly pressed: boolean;
  19210. /**
  19211. * If the button/trigger is currently touched
  19212. */
  19213. readonly touched: boolean;
  19214. /**
  19215. * Value of the button/trigger
  19216. */
  19217. readonly value: number;
  19218. }
  19219. /** @hidden */
  19220. export interface _GamePadFactory {
  19221. /**
  19222. * Returns whether or not the current gamepad can be created for this type of controller.
  19223. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19224. * @returns true if it can be created, otherwise false
  19225. */
  19226. canCreate(gamepadInfo: any): boolean;
  19227. /**
  19228. * Creates a new instance of the Gamepad.
  19229. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19230. * @returns the new gamepad instance
  19231. */
  19232. create(gamepadInfo: any): Gamepad;
  19233. }
  19234. /**
  19235. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19236. */
  19237. export class PoseEnabledControllerHelper {
  19238. /** @hidden */
  19239. static _ControllerFactories: _GamePadFactory[];
  19240. /** @hidden */
  19241. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19242. /**
  19243. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19244. * @param vrGamepad the gamepad to initialized
  19245. * @returns a vr controller of the type the gamepad identified as
  19246. */
  19247. static InitiateController(vrGamepad: any): Gamepad;
  19248. }
  19249. /**
  19250. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19251. */
  19252. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19253. /**
  19254. * If the controller is used in a webXR session
  19255. */
  19256. isXR: boolean;
  19257. private _deviceRoomPosition;
  19258. private _deviceRoomRotationQuaternion;
  19259. /**
  19260. * The device position in babylon space
  19261. */
  19262. devicePosition: Vector3;
  19263. /**
  19264. * The device rotation in babylon space
  19265. */
  19266. deviceRotationQuaternion: Quaternion;
  19267. /**
  19268. * The scale factor of the device in babylon space
  19269. */
  19270. deviceScaleFactor: number;
  19271. /**
  19272. * (Likely devicePosition should be used instead) The device position in its room space
  19273. */
  19274. position: Vector3;
  19275. /**
  19276. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19277. */
  19278. rotationQuaternion: Quaternion;
  19279. /**
  19280. * The type of controller (Eg. Windows mixed reality)
  19281. */
  19282. controllerType: PoseEnabledControllerType;
  19283. protected _calculatedPosition: Vector3;
  19284. private _calculatedRotation;
  19285. /**
  19286. * The raw pose from the device
  19287. */
  19288. rawPose: DevicePose;
  19289. private _trackPosition;
  19290. private _maxRotationDistFromHeadset;
  19291. private _draggedRoomRotation;
  19292. /**
  19293. * @hidden
  19294. */
  19295. _disableTrackPosition(fixedPosition: Vector3): void;
  19296. /**
  19297. * Internal, the mesh attached to the controller
  19298. * @hidden
  19299. */
  19300. _mesh: Nullable<AbstractMesh>;
  19301. private _poseControlledCamera;
  19302. private _leftHandSystemQuaternion;
  19303. /**
  19304. * Internal, matrix used to convert room space to babylon space
  19305. * @hidden
  19306. */
  19307. _deviceToWorld: Matrix;
  19308. /**
  19309. * Node to be used when casting a ray from the controller
  19310. * @hidden
  19311. */
  19312. _pointingPoseNode: Nullable<TransformNode>;
  19313. /**
  19314. * Name of the child mesh that can be used to cast a ray from the controller
  19315. */
  19316. static readonly POINTING_POSE: string;
  19317. /**
  19318. * Creates a new PoseEnabledController from a gamepad
  19319. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19320. */
  19321. constructor(browserGamepad: any);
  19322. private _workingMatrix;
  19323. /**
  19324. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19325. */
  19326. update(): void;
  19327. /**
  19328. * Updates only the pose device and mesh without doing any button event checking
  19329. */
  19330. protected _updatePoseAndMesh(): void;
  19331. /**
  19332. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19333. * @param poseData raw pose fromthe device
  19334. */
  19335. updateFromDevice(poseData: DevicePose): void;
  19336. /**
  19337. * @hidden
  19338. */
  19339. _meshAttachedObservable: Observable<AbstractMesh>;
  19340. /**
  19341. * Attaches a mesh to the controller
  19342. * @param mesh the mesh to be attached
  19343. */
  19344. attachToMesh(mesh: AbstractMesh): void;
  19345. /**
  19346. * Attaches the controllers mesh to a camera
  19347. * @param camera the camera the mesh should be attached to
  19348. */
  19349. attachToPoseControlledCamera(camera: TargetCamera): void;
  19350. /**
  19351. * Disposes of the controller
  19352. */
  19353. dispose(): void;
  19354. /**
  19355. * The mesh that is attached to the controller
  19356. */
  19357. get mesh(): Nullable<AbstractMesh>;
  19358. /**
  19359. * Gets the ray of the controller in the direction the controller is pointing
  19360. * @param length the length the resulting ray should be
  19361. * @returns a ray in the direction the controller is pointing
  19362. */
  19363. getForwardRay(length?: number): Ray;
  19364. }
  19365. }
  19366. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19367. import { Observable } from "babylonjs/Misc/observable";
  19368. import { Scene } from "babylonjs/scene";
  19369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19370. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19371. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19372. import { Nullable } from "babylonjs/types";
  19373. /**
  19374. * Defines the WebVRController object that represents controllers tracked in 3D space
  19375. */
  19376. export abstract class WebVRController extends PoseEnabledController {
  19377. /**
  19378. * Internal, the default controller model for the controller
  19379. */
  19380. protected _defaultModel: Nullable<AbstractMesh>;
  19381. /**
  19382. * Fired when the trigger state has changed
  19383. */
  19384. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19385. /**
  19386. * Fired when the main button state has changed
  19387. */
  19388. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19389. /**
  19390. * Fired when the secondary button state has changed
  19391. */
  19392. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19393. /**
  19394. * Fired when the pad state has changed
  19395. */
  19396. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19397. /**
  19398. * Fired when controllers stick values have changed
  19399. */
  19400. onPadValuesChangedObservable: Observable<StickValues>;
  19401. /**
  19402. * Array of button availible on the controller
  19403. */
  19404. protected _buttons: Array<MutableGamepadButton>;
  19405. private _onButtonStateChange;
  19406. /**
  19407. * Fired when a controller button's state has changed
  19408. * @param callback the callback containing the button that was modified
  19409. */
  19410. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19411. /**
  19412. * X and Y axis corresponding to the controllers joystick
  19413. */
  19414. pad: StickValues;
  19415. /**
  19416. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19417. */
  19418. hand: string;
  19419. /**
  19420. * The default controller model for the controller
  19421. */
  19422. get defaultModel(): Nullable<AbstractMesh>;
  19423. /**
  19424. * Creates a new WebVRController from a gamepad
  19425. * @param vrGamepad the gamepad that the WebVRController should be created from
  19426. */
  19427. constructor(vrGamepad: any);
  19428. /**
  19429. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19430. */
  19431. update(): void;
  19432. /**
  19433. * Function to be called when a button is modified
  19434. */
  19435. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19436. /**
  19437. * Loads a mesh and attaches it to the controller
  19438. * @param scene the scene the mesh should be added to
  19439. * @param meshLoaded callback for when the mesh has been loaded
  19440. */
  19441. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19442. private _setButtonValue;
  19443. private _changes;
  19444. private _checkChanges;
  19445. /**
  19446. * Disposes of th webVRCOntroller
  19447. */
  19448. dispose(): void;
  19449. }
  19450. }
  19451. declare module "babylonjs/Lights/hemisphericLight" {
  19452. import { Nullable } from "babylonjs/types";
  19453. import { Scene } from "babylonjs/scene";
  19454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19455. import { Color3 } from "babylonjs/Maths/math.color";
  19456. import { Effect } from "babylonjs/Materials/effect";
  19457. import { Light } from "babylonjs/Lights/light";
  19458. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19459. /**
  19460. * The HemisphericLight simulates the ambient environment light,
  19461. * so the passed direction is the light reflection direction, not the incoming direction.
  19462. */
  19463. export class HemisphericLight extends Light {
  19464. /**
  19465. * The groundColor is the light in the opposite direction to the one specified during creation.
  19466. * 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.
  19467. */
  19468. groundColor: Color3;
  19469. /**
  19470. * The light reflection direction, not the incoming direction.
  19471. */
  19472. direction: Vector3;
  19473. /**
  19474. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19475. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19476. * The HemisphericLight can't cast shadows.
  19477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19478. * @param name The friendly name of the light
  19479. * @param direction The direction of the light reflection
  19480. * @param scene The scene the light belongs to
  19481. */
  19482. constructor(name: string, direction: Vector3, scene: Scene);
  19483. protected _buildUniformLayout(): void;
  19484. /**
  19485. * Returns the string "HemisphericLight".
  19486. * @return The class name
  19487. */
  19488. getClassName(): string;
  19489. /**
  19490. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19491. * Returns the updated direction.
  19492. * @param target The target the direction should point to
  19493. * @return The computed direction
  19494. */
  19495. setDirectionToTarget(target: Vector3): Vector3;
  19496. /**
  19497. * Returns the shadow generator associated to the light.
  19498. * @returns Always null for hemispheric lights because it does not support shadows.
  19499. */
  19500. getShadowGenerator(): Nullable<IShadowGenerator>;
  19501. /**
  19502. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19503. * @param effect The effect to update
  19504. * @param lightIndex The index of the light in the effect to update
  19505. * @returns The hemispheric light
  19506. */
  19507. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19508. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19509. /**
  19510. * Computes the world matrix of the node
  19511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19512. * @param useWasUpdatedFlag defines a reserved property
  19513. * @returns the world matrix
  19514. */
  19515. computeWorldMatrix(): Matrix;
  19516. /**
  19517. * Returns the integer 3.
  19518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19519. */
  19520. getTypeID(): number;
  19521. /**
  19522. * Prepares the list of defines specific to the light type.
  19523. * @param defines the list of defines
  19524. * @param lightIndex defines the index of the light for the effect
  19525. */
  19526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19527. }
  19528. }
  19529. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19530. /** @hidden */
  19531. export var vrMultiviewToSingleviewPixelShader: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19538. import { Scene } from "babylonjs/scene";
  19539. /**
  19540. * Renders to multiple views with a single draw call
  19541. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19542. */
  19543. export class MultiviewRenderTarget extends RenderTargetTexture {
  19544. /**
  19545. * Creates a multiview render target
  19546. * @param scene scene used with the render target
  19547. * @param size the size of the render target (used for each view)
  19548. */
  19549. constructor(scene: Scene, size?: number | {
  19550. width: number;
  19551. height: number;
  19552. } | {
  19553. ratio: number;
  19554. });
  19555. /**
  19556. * @hidden
  19557. * @param faceIndex the face index, if its a cube texture
  19558. */
  19559. _bindFrameBuffer(faceIndex?: number): void;
  19560. /**
  19561. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19562. * @returns the view count
  19563. */
  19564. getViewCount(): number;
  19565. }
  19566. }
  19567. declare module "babylonjs/Maths/math.frustum" {
  19568. import { Matrix } from "babylonjs/Maths/math.vector";
  19569. import { DeepImmutable } from "babylonjs/types";
  19570. import { Plane } from "babylonjs/Maths/math.plane";
  19571. /**
  19572. * Represents a camera frustum
  19573. */
  19574. export class Frustum {
  19575. /**
  19576. * Gets the planes representing the frustum
  19577. * @param transform matrix to be applied to the returned planes
  19578. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19579. */
  19580. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19581. /**
  19582. * Gets the near frustum plane transformed by the transform matrix
  19583. * @param transform transformation matrix to be applied to the resulting frustum plane
  19584. * @param frustumPlane the resuling frustum plane
  19585. */
  19586. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19587. /**
  19588. * Gets the far frustum plane transformed by the transform matrix
  19589. * @param transform transformation matrix to be applied to the resulting frustum plane
  19590. * @param frustumPlane the resuling frustum plane
  19591. */
  19592. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19593. /**
  19594. * Gets the left frustum plane transformed by the transform matrix
  19595. * @param transform transformation matrix to be applied to the resulting frustum plane
  19596. * @param frustumPlane the resuling frustum plane
  19597. */
  19598. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19599. /**
  19600. * Gets the right frustum plane transformed by the transform matrix
  19601. * @param transform transformation matrix to be applied to the resulting frustum plane
  19602. * @param frustumPlane the resuling frustum plane
  19603. */
  19604. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19605. /**
  19606. * Gets the top frustum plane transformed by the transform matrix
  19607. * @param transform transformation matrix to be applied to the resulting frustum plane
  19608. * @param frustumPlane the resuling frustum plane
  19609. */
  19610. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19611. /**
  19612. * Gets the bottom frustum plane transformed by the transform matrix
  19613. * @param transform transformation matrix to be applied to the resulting frustum plane
  19614. * @param frustumPlane the resuling frustum plane
  19615. */
  19616. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19617. /**
  19618. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19619. * @param transform transformation matrix to be applied to the resulting frustum planes
  19620. * @param frustumPlanes the resuling frustum planes
  19621. */
  19622. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19623. }
  19624. }
  19625. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19626. import { Camera } from "babylonjs/Cameras/camera";
  19627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19628. import { Nullable } from "babylonjs/types";
  19629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19630. import { Matrix } from "babylonjs/Maths/math.vector";
  19631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19632. module "babylonjs/Engines/engine" {
  19633. interface Engine {
  19634. /**
  19635. * Creates a new multiview render target
  19636. * @param width defines the width of the texture
  19637. * @param height defines the height of the texture
  19638. * @returns the created multiview texture
  19639. */
  19640. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19641. /**
  19642. * Binds a multiview framebuffer to be drawn to
  19643. * @param multiviewTexture texture to bind
  19644. */
  19645. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19646. }
  19647. }
  19648. module "babylonjs/Cameras/camera" {
  19649. interface Camera {
  19650. /**
  19651. * @hidden
  19652. * 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)
  19653. */
  19654. _useMultiviewToSingleView: boolean;
  19655. /**
  19656. * @hidden
  19657. * 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)
  19658. */
  19659. _multiviewTexture: Nullable<RenderTargetTexture>;
  19660. /**
  19661. * @hidden
  19662. * ensures the multiview texture of the camera exists and has the specified width/height
  19663. * @param width height to set on the multiview texture
  19664. * @param height width to set on the multiview texture
  19665. */
  19666. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19667. }
  19668. }
  19669. module "babylonjs/scene" {
  19670. interface Scene {
  19671. /** @hidden */
  19672. _transformMatrixR: Matrix;
  19673. /** @hidden */
  19674. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19675. /** @hidden */
  19676. _createMultiviewUbo(): void;
  19677. /** @hidden */
  19678. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19679. /** @hidden */
  19680. _renderMultiviewToSingleView(camera: Camera): void;
  19681. }
  19682. }
  19683. }
  19684. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19685. import { Camera } from "babylonjs/Cameras/camera";
  19686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19687. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19688. import "babylonjs/Engines/Extensions/engine.multiview";
  19689. /**
  19690. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19691. * This will not be used for webXR as it supports displaying texture arrays directly
  19692. */
  19693. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19694. /**
  19695. * Initializes a VRMultiviewToSingleview
  19696. * @param name name of the post process
  19697. * @param camera camera to be applied to
  19698. * @param scaleFactor scaling factor to the size of the output texture
  19699. */
  19700. constructor(name: string, camera: Camera, scaleFactor: number);
  19701. }
  19702. }
  19703. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19704. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19705. import { Nullable } from "babylonjs/types";
  19706. import { Size } from "babylonjs/Maths/math.size";
  19707. import { Observable } from "babylonjs/Misc/observable";
  19708. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19709. /**
  19710. * Interface used to define additional presentation attributes
  19711. */
  19712. export interface IVRPresentationAttributes {
  19713. /**
  19714. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19715. */
  19716. highRefreshRate: boolean;
  19717. /**
  19718. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19719. */
  19720. foveationLevel: number;
  19721. }
  19722. module "babylonjs/Engines/engine" {
  19723. interface Engine {
  19724. /** @hidden */
  19725. _vrDisplay: any;
  19726. /** @hidden */
  19727. _vrSupported: boolean;
  19728. /** @hidden */
  19729. _oldSize: Size;
  19730. /** @hidden */
  19731. _oldHardwareScaleFactor: number;
  19732. /** @hidden */
  19733. _vrExclusivePointerMode: boolean;
  19734. /** @hidden */
  19735. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19736. /** @hidden */
  19737. _onVRDisplayPointerRestricted: () => void;
  19738. /** @hidden */
  19739. _onVRDisplayPointerUnrestricted: () => void;
  19740. /** @hidden */
  19741. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19742. /** @hidden */
  19743. _onVrDisplayDisconnect: Nullable<() => void>;
  19744. /** @hidden */
  19745. _onVrDisplayPresentChange: Nullable<() => void>;
  19746. /**
  19747. * Observable signaled when VR display mode changes
  19748. */
  19749. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19750. /**
  19751. * Observable signaled when VR request present is complete
  19752. */
  19753. onVRRequestPresentComplete: Observable<boolean>;
  19754. /**
  19755. * Observable signaled when VR request present starts
  19756. */
  19757. onVRRequestPresentStart: Observable<Engine>;
  19758. /**
  19759. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19760. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19761. */
  19762. isInVRExclusivePointerMode: boolean;
  19763. /**
  19764. * Gets a boolean indicating if a webVR device was detected
  19765. * @returns true if a webVR device was detected
  19766. */
  19767. isVRDevicePresent(): boolean;
  19768. /**
  19769. * Gets the current webVR device
  19770. * @returns the current webVR device (or null)
  19771. */
  19772. getVRDevice(): any;
  19773. /**
  19774. * Initializes a webVR display and starts listening to display change events
  19775. * The onVRDisplayChangedObservable will be notified upon these changes
  19776. * @returns A promise containing a VRDisplay and if vr is supported
  19777. */
  19778. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19779. /** @hidden */
  19780. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19781. /**
  19782. * Gets or sets the presentation attributes used to configure VR rendering
  19783. */
  19784. vrPresentationAttributes?: IVRPresentationAttributes;
  19785. /**
  19786. * Call this function to switch to webVR mode
  19787. * Will do nothing if webVR is not supported or if there is no webVR device
  19788. * @param options the webvr options provided to the camera. mainly used for multiview
  19789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19790. */
  19791. enableVR(options: WebVROptions): void;
  19792. /** @hidden */
  19793. _onVRFullScreenTriggered(): void;
  19794. }
  19795. }
  19796. }
  19797. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19798. import { Nullable } from "babylonjs/types";
  19799. import { Observable } from "babylonjs/Misc/observable";
  19800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19801. import { Scene } from "babylonjs/scene";
  19802. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19804. import { Node } from "babylonjs/node";
  19805. import { Ray } from "babylonjs/Culling/ray";
  19806. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19807. import "babylonjs/Engines/Extensions/engine.webVR";
  19808. /**
  19809. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19810. * IMPORTANT!! The data is right-hand data.
  19811. * @export
  19812. * @interface DevicePose
  19813. */
  19814. export interface DevicePose {
  19815. /**
  19816. * The position of the device, values in array are [x,y,z].
  19817. */
  19818. readonly position: Nullable<Float32Array>;
  19819. /**
  19820. * The linearVelocity of the device, values in array are [x,y,z].
  19821. */
  19822. readonly linearVelocity: Nullable<Float32Array>;
  19823. /**
  19824. * The linearAcceleration of the device, values in array are [x,y,z].
  19825. */
  19826. readonly linearAcceleration: Nullable<Float32Array>;
  19827. /**
  19828. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19829. */
  19830. readonly orientation: Nullable<Float32Array>;
  19831. /**
  19832. * The angularVelocity of the device, values in array are [x,y,z].
  19833. */
  19834. readonly angularVelocity: Nullable<Float32Array>;
  19835. /**
  19836. * The angularAcceleration of the device, values in array are [x,y,z].
  19837. */
  19838. readonly angularAcceleration: Nullable<Float32Array>;
  19839. }
  19840. /**
  19841. * Interface representing a pose controlled object in Babylon.
  19842. * A pose controlled object has both regular pose values as well as pose values
  19843. * from an external device such as a VR head mounted display
  19844. */
  19845. export interface PoseControlled {
  19846. /**
  19847. * The position of the object in babylon space.
  19848. */
  19849. position: Vector3;
  19850. /**
  19851. * The rotation quaternion of the object in babylon space.
  19852. */
  19853. rotationQuaternion: Quaternion;
  19854. /**
  19855. * The position of the device in babylon space.
  19856. */
  19857. devicePosition?: Vector3;
  19858. /**
  19859. * The rotation quaternion of the device in babylon space.
  19860. */
  19861. deviceRotationQuaternion: Quaternion;
  19862. /**
  19863. * The raw pose coming from the device.
  19864. */
  19865. rawPose: Nullable<DevicePose>;
  19866. /**
  19867. * The scale of the device to be used when translating from device space to babylon space.
  19868. */
  19869. deviceScaleFactor: number;
  19870. /**
  19871. * Updates the poseControlled values based on the input device pose.
  19872. * @param poseData the pose data to update the object with
  19873. */
  19874. updateFromDevice(poseData: DevicePose): void;
  19875. }
  19876. /**
  19877. * Set of options to customize the webVRCamera
  19878. */
  19879. export interface WebVROptions {
  19880. /**
  19881. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19882. */
  19883. trackPosition?: boolean;
  19884. /**
  19885. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19886. */
  19887. positionScale?: number;
  19888. /**
  19889. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19890. */
  19891. displayName?: string;
  19892. /**
  19893. * Should the native controller meshes be initialized. (default: true)
  19894. */
  19895. controllerMeshes?: boolean;
  19896. /**
  19897. * Creating a default HemiLight only on controllers. (default: true)
  19898. */
  19899. defaultLightingOnControllers?: boolean;
  19900. /**
  19901. * If you don't want to use the default VR button of the helper. (default: false)
  19902. */
  19903. useCustomVRButton?: boolean;
  19904. /**
  19905. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19906. */
  19907. customVRButton?: HTMLButtonElement;
  19908. /**
  19909. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19910. */
  19911. rayLength?: number;
  19912. /**
  19913. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19914. */
  19915. defaultHeight?: number;
  19916. /**
  19917. * If multiview should be used if availible (default: false)
  19918. */
  19919. useMultiview?: boolean;
  19920. }
  19921. /**
  19922. * This represents a WebVR camera.
  19923. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19924. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19925. */
  19926. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19927. private webVROptions;
  19928. /**
  19929. * @hidden
  19930. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19931. */
  19932. _vrDevice: any;
  19933. /**
  19934. * The rawPose of the vrDevice.
  19935. */
  19936. rawPose: Nullable<DevicePose>;
  19937. private _onVREnabled;
  19938. private _specsVersion;
  19939. private _attached;
  19940. private _frameData;
  19941. protected _descendants: Array<Node>;
  19942. private _deviceRoomPosition;
  19943. /** @hidden */
  19944. _deviceRoomRotationQuaternion: Quaternion;
  19945. private _standingMatrix;
  19946. /**
  19947. * Represents device position in babylon space.
  19948. */
  19949. devicePosition: Vector3;
  19950. /**
  19951. * Represents device rotation in babylon space.
  19952. */
  19953. deviceRotationQuaternion: Quaternion;
  19954. /**
  19955. * The scale of the device to be used when translating from device space to babylon space.
  19956. */
  19957. deviceScaleFactor: number;
  19958. private _deviceToWorld;
  19959. private _worldToDevice;
  19960. /**
  19961. * References to the webVR controllers for the vrDevice.
  19962. */
  19963. controllers: Array<WebVRController>;
  19964. /**
  19965. * Emits an event when a controller is attached.
  19966. */
  19967. onControllersAttachedObservable: Observable<WebVRController[]>;
  19968. /**
  19969. * Emits an event when a controller's mesh has been loaded;
  19970. */
  19971. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19972. /**
  19973. * Emits an event when the HMD's pose has been updated.
  19974. */
  19975. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19976. private _poseSet;
  19977. /**
  19978. * If the rig cameras be used as parent instead of this camera.
  19979. */
  19980. rigParenting: boolean;
  19981. private _lightOnControllers;
  19982. private _defaultHeight?;
  19983. /**
  19984. * Instantiates a WebVRFreeCamera.
  19985. * @param name The name of the WebVRFreeCamera
  19986. * @param position The starting anchor position for the camera
  19987. * @param scene The scene the camera belongs to
  19988. * @param webVROptions a set of customizable options for the webVRCamera
  19989. */
  19990. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19991. /**
  19992. * Gets the device distance from the ground in meters.
  19993. * @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.
  19994. */
  19995. deviceDistanceToRoomGround(): number;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19999. */
  20000. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20001. /**
  20002. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20003. * @returns A promise with a boolean set to if the standing matrix is supported.
  20004. */
  20005. useStandingMatrixAsync(): Promise<boolean>;
  20006. /**
  20007. * Disposes the camera
  20008. */
  20009. dispose(): void;
  20010. /**
  20011. * Gets a vrController by name.
  20012. * @param name The name of the controller to retreive
  20013. * @returns the controller matching the name specified or null if not found
  20014. */
  20015. getControllerByName(name: string): Nullable<WebVRController>;
  20016. private _leftController;
  20017. /**
  20018. * The controller corresponding to the users left hand.
  20019. */
  20020. get leftController(): Nullable<WebVRController>;
  20021. private _rightController;
  20022. /**
  20023. * The controller corresponding to the users right hand.
  20024. */
  20025. get rightController(): Nullable<WebVRController>;
  20026. /**
  20027. * Casts a ray forward from the vrCamera's gaze.
  20028. * @param length Length of the ray (default: 100)
  20029. * @returns the ray corresponding to the gaze
  20030. */
  20031. getForwardRay(length?: number): Ray;
  20032. /**
  20033. * @hidden
  20034. * Updates the camera based on device's frame data
  20035. */
  20036. _checkInputs(): void;
  20037. /**
  20038. * Updates the poseControlled values based on the input device pose.
  20039. * @param poseData Pose coming from the device
  20040. */
  20041. updateFromDevice(poseData: DevicePose): void;
  20042. private _htmlElementAttached;
  20043. private _detachIfAttached;
  20044. /**
  20045. * WebVR's attach control will start broadcasting frames to the device.
  20046. * Note that in certain browsers (chrome for example) this function must be called
  20047. * within a user-interaction callback. Example:
  20048. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20049. *
  20050. * @param element html element to attach the vrDevice to
  20051. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20052. */
  20053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20054. /**
  20055. * Detaches the camera from the html element and disables VR
  20056. *
  20057. * @param element html element to detach from
  20058. */
  20059. detachControl(element: HTMLElement): void;
  20060. /**
  20061. * @returns the name of this class
  20062. */
  20063. getClassName(): string;
  20064. /**
  20065. * Calls resetPose on the vrDisplay
  20066. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20067. */
  20068. resetToCurrentRotation(): void;
  20069. /**
  20070. * @hidden
  20071. * Updates the rig cameras (left and right eye)
  20072. */
  20073. _updateRigCameras(): void;
  20074. private _workingVector;
  20075. private _oneVector;
  20076. private _workingMatrix;
  20077. private updateCacheCalled;
  20078. private _correctPositionIfNotTrackPosition;
  20079. /**
  20080. * @hidden
  20081. * Updates the cached values of the camera
  20082. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20083. */
  20084. _updateCache(ignoreParentClass?: boolean): void;
  20085. /**
  20086. * @hidden
  20087. * Get current device position in babylon world
  20088. */
  20089. _computeDevicePosition(): void;
  20090. /**
  20091. * Updates the current device position and rotation in the babylon world
  20092. */
  20093. update(): void;
  20094. /**
  20095. * @hidden
  20096. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20097. * @returns an identity matrix
  20098. */
  20099. _getViewMatrix(): Matrix;
  20100. private _tmpMatrix;
  20101. /**
  20102. * This function is called by the two RIG cameras.
  20103. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20104. * @hidden
  20105. */
  20106. _getWebVRViewMatrix(): Matrix;
  20107. /** @hidden */
  20108. _getWebVRProjectionMatrix(): Matrix;
  20109. private _onGamepadConnectedObserver;
  20110. private _onGamepadDisconnectedObserver;
  20111. private _updateCacheWhenTrackingDisabledObserver;
  20112. /**
  20113. * Initializes the controllers and their meshes
  20114. */
  20115. initControllers(): void;
  20116. }
  20117. }
  20118. declare module "babylonjs/PostProcesses/postProcess" {
  20119. import { Nullable } from "babylonjs/types";
  20120. import { SmartArray } from "babylonjs/Misc/smartArray";
  20121. import { Observable } from "babylonjs/Misc/observable";
  20122. import { Vector2 } from "babylonjs/Maths/math.vector";
  20123. import { Camera } from "babylonjs/Cameras/camera";
  20124. import { Effect } from "babylonjs/Materials/effect";
  20125. import "babylonjs/Shaders/postprocess.vertex";
  20126. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20127. import { Engine } from "babylonjs/Engines/engine";
  20128. import { Color4 } from "babylonjs/Maths/math.color";
  20129. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20131. /**
  20132. * Size options for a post process
  20133. */
  20134. export type PostProcessOptions = {
  20135. width: number;
  20136. height: number;
  20137. };
  20138. /**
  20139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20141. */
  20142. export class PostProcess {
  20143. /** Name of the PostProcess. */
  20144. name: string;
  20145. /**
  20146. * Gets or sets the unique id of the post process
  20147. */
  20148. uniqueId: number;
  20149. /**
  20150. * Width of the texture to apply the post process on
  20151. */
  20152. width: number;
  20153. /**
  20154. * Height of the texture to apply the post process on
  20155. */
  20156. height: number;
  20157. /**
  20158. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20159. * @hidden
  20160. */
  20161. _outputTexture: Nullable<InternalTexture>;
  20162. /**
  20163. * Sampling mode used by the shader
  20164. * See https://doc.babylonjs.com/classes/3.1/texture
  20165. */
  20166. renderTargetSamplingMode: number;
  20167. /**
  20168. * Clear color to use when screen clearing
  20169. */
  20170. clearColor: Color4;
  20171. /**
  20172. * If the buffer needs to be cleared before applying the post process. (default: true)
  20173. * Should be set to false if shader will overwrite all previous pixels.
  20174. */
  20175. autoClear: boolean;
  20176. /**
  20177. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20178. */
  20179. alphaMode: number;
  20180. /**
  20181. * Sets the setAlphaBlendConstants of the babylon engine
  20182. */
  20183. alphaConstants: Color4;
  20184. /**
  20185. * Animations to be used for the post processing
  20186. */
  20187. animations: import("babylonjs/Animations/animation").Animation[];
  20188. /**
  20189. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20190. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20191. */
  20192. enablePixelPerfectMode: boolean;
  20193. /**
  20194. * Force the postprocess to be applied without taking in account viewport
  20195. */
  20196. forceFullscreenViewport: boolean;
  20197. /**
  20198. * List of inspectable custom properties (used by the Inspector)
  20199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20200. */
  20201. inspectableCustomProperties: IInspectable[];
  20202. /**
  20203. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20204. *
  20205. * | Value | Type | Description |
  20206. * | ----- | ----------------------------------- | ----------- |
  20207. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20208. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20209. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20210. *
  20211. */
  20212. scaleMode: number;
  20213. /**
  20214. * Force textures to be a power of two (default: false)
  20215. */
  20216. alwaysForcePOT: boolean;
  20217. private _samples;
  20218. /**
  20219. * Number of sample textures (default: 1)
  20220. */
  20221. get samples(): number;
  20222. set samples(n: number);
  20223. /**
  20224. * Modify the scale of the post process to be the same as the viewport (default: false)
  20225. */
  20226. adaptScaleToCurrentViewport: boolean;
  20227. private _camera;
  20228. private _scene;
  20229. private _engine;
  20230. private _options;
  20231. private _reusable;
  20232. private _textureType;
  20233. private _textureFormat;
  20234. /**
  20235. * Smart array of input and output textures for the post process.
  20236. * @hidden
  20237. */
  20238. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20239. /**
  20240. * The index in _textures that corresponds to the output texture.
  20241. * @hidden
  20242. */
  20243. _currentRenderTextureInd: number;
  20244. private _effect;
  20245. private _samplers;
  20246. private _fragmentUrl;
  20247. private _vertexUrl;
  20248. private _parameters;
  20249. private _scaleRatio;
  20250. protected _indexParameters: any;
  20251. private _shareOutputWithPostProcess;
  20252. private _texelSize;
  20253. private _forcedOutputTexture;
  20254. /**
  20255. * Returns the fragment url or shader name used in the post process.
  20256. * @returns the fragment url or name in the shader store.
  20257. */
  20258. getEffectName(): string;
  20259. /**
  20260. * An event triggered when the postprocess is activated.
  20261. */
  20262. onActivateObservable: Observable<Camera>;
  20263. private _onActivateObserver;
  20264. /**
  20265. * A function that is added to the onActivateObservable
  20266. */
  20267. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20268. /**
  20269. * An event triggered when the postprocess changes its size.
  20270. */
  20271. onSizeChangedObservable: Observable<PostProcess>;
  20272. private _onSizeChangedObserver;
  20273. /**
  20274. * A function that is added to the onSizeChangedObservable
  20275. */
  20276. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20277. /**
  20278. * An event triggered when the postprocess applies its effect.
  20279. */
  20280. onApplyObservable: Observable<Effect>;
  20281. private _onApplyObserver;
  20282. /**
  20283. * A function that is added to the onApplyObservable
  20284. */
  20285. set onApply(callback: (effect: Effect) => void);
  20286. /**
  20287. * An event triggered before rendering the postprocess
  20288. */
  20289. onBeforeRenderObservable: Observable<Effect>;
  20290. private _onBeforeRenderObserver;
  20291. /**
  20292. * A function that is added to the onBeforeRenderObservable
  20293. */
  20294. set onBeforeRender(callback: (effect: Effect) => void);
  20295. /**
  20296. * An event triggered after rendering the postprocess
  20297. */
  20298. onAfterRenderObservable: Observable<Effect>;
  20299. private _onAfterRenderObserver;
  20300. /**
  20301. * A function that is added to the onAfterRenderObservable
  20302. */
  20303. set onAfterRender(callback: (efect: Effect) => void);
  20304. /**
  20305. * 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
  20306. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20307. */
  20308. get inputTexture(): InternalTexture;
  20309. set inputTexture(value: InternalTexture);
  20310. /**
  20311. * Gets the camera which post process is applied to.
  20312. * @returns The camera the post process is applied to.
  20313. */
  20314. getCamera(): Camera;
  20315. /**
  20316. * Gets the texel size of the postprocess.
  20317. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20318. */
  20319. get texelSize(): Vector2;
  20320. /**
  20321. * Creates a new instance PostProcess
  20322. * @param name The name of the PostProcess.
  20323. * @param fragmentUrl The url of the fragment shader to be used.
  20324. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20325. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20326. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20327. * @param camera The camera to apply the render pass to.
  20328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20329. * @param engine The engine which the post process will be applied. (default: current engine)
  20330. * @param reusable If the post process can be reused on the same frame. (default: false)
  20331. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20332. * @param textureType Type of textures used when performing the post process. (default: 0)
  20333. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20334. * @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
  20335. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20336. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20337. */
  20338. constructor(
  20339. /** Name of the PostProcess. */
  20340. 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, textureFormat?: number);
  20341. /**
  20342. * Gets a string idenfifying the name of the class
  20343. * @returns "PostProcess" string
  20344. */
  20345. getClassName(): string;
  20346. /**
  20347. * Gets the engine which this post process belongs to.
  20348. * @returns The engine the post process was enabled with.
  20349. */
  20350. getEngine(): Engine;
  20351. /**
  20352. * The effect that is created when initializing the post process.
  20353. * @returns The created effect corresponding the the postprocess.
  20354. */
  20355. getEffect(): Effect;
  20356. /**
  20357. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20358. * @param postProcess The post process to share the output with.
  20359. * @returns This post process.
  20360. */
  20361. shareOutputWith(postProcess: PostProcess): PostProcess;
  20362. /**
  20363. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20364. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20365. */
  20366. useOwnOutput(): void;
  20367. /**
  20368. * Updates the effect with the current post process compile time values and recompiles the shader.
  20369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20372. * @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
  20373. * @param onCompiled Called when the shader has been compiled.
  20374. * @param onError Called if there is an error when compiling a shader.
  20375. */
  20376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20377. /**
  20378. * The post process is reusable if it can be used multiple times within one frame.
  20379. * @returns If the post process is reusable
  20380. */
  20381. isReusable(): boolean;
  20382. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20383. markTextureDirty(): void;
  20384. /**
  20385. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20386. * 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.
  20387. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20388. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20389. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20390. * @returns The target texture that was bound to be written to.
  20391. */
  20392. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20393. /**
  20394. * If the post process is supported.
  20395. */
  20396. get isSupported(): boolean;
  20397. /**
  20398. * The aspect ratio of the output texture.
  20399. */
  20400. get aspectRatio(): number;
  20401. /**
  20402. * Get a value indicating if the post-process is ready to be used
  20403. * @returns true if the post-process is ready (shader is compiled)
  20404. */
  20405. isReady(): boolean;
  20406. /**
  20407. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20408. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20409. */
  20410. apply(): Nullable<Effect>;
  20411. private _disposeTextures;
  20412. /**
  20413. * Disposes the post process.
  20414. * @param camera The camera to dispose the post process on.
  20415. */
  20416. dispose(camera?: Camera): void;
  20417. }
  20418. }
  20419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20420. /** @hidden */
  20421. export var kernelBlurVaryingDeclaration: {
  20422. name: string;
  20423. shader: string;
  20424. };
  20425. }
  20426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20427. /** @hidden */
  20428. export var kernelBlurFragment: {
  20429. name: string;
  20430. shader: string;
  20431. };
  20432. }
  20433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20434. /** @hidden */
  20435. export var kernelBlurFragment2: {
  20436. name: string;
  20437. shader: string;
  20438. };
  20439. }
  20440. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20442. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20443. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20444. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20445. /** @hidden */
  20446. export var kernelBlurPixelShader: {
  20447. name: string;
  20448. shader: string;
  20449. };
  20450. }
  20451. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20452. /** @hidden */
  20453. export var kernelBlurVertex: {
  20454. name: string;
  20455. shader: string;
  20456. };
  20457. }
  20458. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20459. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20460. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20461. /** @hidden */
  20462. export var kernelBlurVertexShader: {
  20463. name: string;
  20464. shader: string;
  20465. };
  20466. }
  20467. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20468. import { Vector2 } from "babylonjs/Maths/math.vector";
  20469. import { Nullable } from "babylonjs/types";
  20470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { Effect } from "babylonjs/Materials/effect";
  20473. import { Engine } from "babylonjs/Engines/engine";
  20474. import "babylonjs/Shaders/kernelBlur.fragment";
  20475. import "babylonjs/Shaders/kernelBlur.vertex";
  20476. /**
  20477. * The Blur Post Process which blurs an image based on a kernel and direction.
  20478. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20479. */
  20480. export class BlurPostProcess extends PostProcess {
  20481. /** The direction in which to blur the image. */
  20482. direction: Vector2;
  20483. private blockCompilation;
  20484. protected _kernel: number;
  20485. protected _idealKernel: number;
  20486. protected _packedFloat: boolean;
  20487. private _staticDefines;
  20488. /**
  20489. * Sets the length in pixels of the blur sample region
  20490. */
  20491. set kernel(v: number);
  20492. /**
  20493. * Gets the length in pixels of the blur sample region
  20494. */
  20495. get kernel(): number;
  20496. /**
  20497. * Sets wether or not the blur needs to unpack/repack floats
  20498. */
  20499. set packedFloat(v: boolean);
  20500. /**
  20501. * Gets wether or not the blur is unpacking/repacking floats
  20502. */
  20503. get packedFloat(): boolean;
  20504. /**
  20505. * Creates a new instance BlurPostProcess
  20506. * @param name The name of the effect.
  20507. * @param direction The direction in which to blur the image.
  20508. * @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.
  20509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20510. * @param camera The camera to apply the render pass to.
  20511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20512. * @param engine The engine which the post process will be applied. (default: current engine)
  20513. * @param reusable If the post process can be reused on the same frame. (default: false)
  20514. * @param textureType Type of textures used when performing the post process. (default: 0)
  20515. * @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)
  20516. */
  20517. constructor(name: string,
  20518. /** The direction in which to blur the image. */
  20519. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20520. /**
  20521. * Updates the effect with the current post process compile time values and recompiles the shader.
  20522. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20523. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20524. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20525. * @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
  20526. * @param onCompiled Called when the shader has been compiled.
  20527. * @param onError Called if there is an error when compiling a shader.
  20528. */
  20529. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20530. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20531. /**
  20532. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20533. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20534. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20535. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20536. * The gaps between physical kernels are compensated for in the weighting of the samples
  20537. * @param idealKernel Ideal blur kernel.
  20538. * @return Nearest best kernel.
  20539. */
  20540. protected _nearestBestKernel(idealKernel: number): number;
  20541. /**
  20542. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20543. * @param x The point on the Gaussian distribution to sample.
  20544. * @return the value of the Gaussian function at x.
  20545. */
  20546. protected _gaussianWeight(x: number): number;
  20547. /**
  20548. * Generates a string that can be used as a floating point number in GLSL.
  20549. * @param x Value to print.
  20550. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20551. * @return GLSL float string.
  20552. */
  20553. protected _glslFloat(x: number, decimalFigures?: number): string;
  20554. }
  20555. }
  20556. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20557. import { Scene } from "babylonjs/scene";
  20558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20559. import { Plane } from "babylonjs/Maths/math.plane";
  20560. /**
  20561. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20562. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20563. * You can then easily use it as a reflectionTexture on a flat surface.
  20564. * In case the surface is not a plane, please consider relying on reflection probes.
  20565. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20566. */
  20567. export class MirrorTexture extends RenderTargetTexture {
  20568. private scene;
  20569. /**
  20570. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20571. * 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.
  20572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20573. */
  20574. mirrorPlane: Plane;
  20575. /**
  20576. * Define the blur ratio used to blur the reflection if needed.
  20577. */
  20578. set blurRatio(value: number);
  20579. get blurRatio(): number;
  20580. /**
  20581. * Define the adaptive blur kernel used to blur the reflection if needed.
  20582. * This will autocompute the closest best match for the `blurKernel`
  20583. */
  20584. set adaptiveBlurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernel(value: number);
  20590. /**
  20591. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20593. */
  20594. set blurKernelX(value: number);
  20595. get blurKernelX(): number;
  20596. /**
  20597. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20599. */
  20600. set blurKernelY(value: number);
  20601. get blurKernelY(): number;
  20602. private _autoComputeBlurKernel;
  20603. protected _onRatioRescale(): void;
  20604. private _updateGammaSpace;
  20605. private _imageProcessingConfigChangeObserver;
  20606. private _transformMatrix;
  20607. private _mirrorMatrix;
  20608. private _savedViewMatrix;
  20609. private _blurX;
  20610. private _blurY;
  20611. private _adaptiveBlurKernel;
  20612. private _blurKernelX;
  20613. private _blurKernelY;
  20614. private _blurRatio;
  20615. /**
  20616. * Instantiates a Mirror Texture.
  20617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20619. * You can then easily use it as a reflectionTexture on a flat surface.
  20620. * In case the surface is not a plane, please consider relying on reflection probes.
  20621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20622. * @param name
  20623. * @param size
  20624. * @param scene
  20625. * @param generateMipMaps
  20626. * @param type
  20627. * @param samplingMode
  20628. * @param generateDepthBuffer
  20629. */
  20630. constructor(name: string, size: number | {
  20631. width: number;
  20632. height: number;
  20633. } | {
  20634. ratio: number;
  20635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20636. private _preparePostProcesses;
  20637. /**
  20638. * Clone the mirror texture.
  20639. * @returns the cloned texture
  20640. */
  20641. clone(): MirrorTexture;
  20642. /**
  20643. * Serialize the texture to a JSON representation you could use in Parse later on
  20644. * @returns the serialized JSON representation
  20645. */
  20646. serialize(): any;
  20647. /**
  20648. * Dispose the texture and release its associated resources.
  20649. */
  20650. dispose(): void;
  20651. }
  20652. }
  20653. declare module "babylonjs/Materials/Textures/texture" {
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { Nullable } from "babylonjs/types";
  20656. import { Matrix } from "babylonjs/Maths/math.vector";
  20657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20659. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20660. import { Scene } from "babylonjs/scene";
  20661. /**
  20662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20664. */
  20665. export class Texture extends BaseTexture {
  20666. /**
  20667. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20668. */
  20669. static SerializeBuffers: boolean;
  20670. /** @hidden */
  20671. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20672. /** @hidden */
  20673. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20674. /** @hidden */
  20675. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20676. /** nearest is mag = nearest and min = nearest and mip = linear */
  20677. static readonly NEAREST_SAMPLINGMODE: number;
  20678. /** nearest is mag = nearest and min = nearest and mip = linear */
  20679. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20681. static readonly BILINEAR_SAMPLINGMODE: number;
  20682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20683. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20684. /** Trilinear is mag = linear and min = linear and mip = linear */
  20685. static readonly TRILINEAR_SAMPLINGMODE: number;
  20686. /** Trilinear is mag = linear and min = linear and mip = linear */
  20687. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20688. /** mag = nearest and min = nearest and mip = nearest */
  20689. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20690. /** mag = nearest and min = linear and mip = nearest */
  20691. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20692. /** mag = nearest and min = linear and mip = linear */
  20693. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20694. /** mag = nearest and min = linear and mip = none */
  20695. static readonly NEAREST_LINEAR: number;
  20696. /** mag = nearest and min = nearest and mip = none */
  20697. static readonly NEAREST_NEAREST: number;
  20698. /** mag = linear and min = nearest and mip = nearest */
  20699. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20700. /** mag = linear and min = nearest and mip = linear */
  20701. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20702. /** mag = linear and min = linear and mip = none */
  20703. static readonly LINEAR_LINEAR: number;
  20704. /** mag = linear and min = nearest and mip = none */
  20705. static readonly LINEAR_NEAREST: number;
  20706. /** Explicit coordinates mode */
  20707. static readonly EXPLICIT_MODE: number;
  20708. /** Spherical coordinates mode */
  20709. static readonly SPHERICAL_MODE: number;
  20710. /** Planar coordinates mode */
  20711. static readonly PLANAR_MODE: number;
  20712. /** Cubic coordinates mode */
  20713. static readonly CUBIC_MODE: number;
  20714. /** Projection coordinates mode */
  20715. static readonly PROJECTION_MODE: number;
  20716. /** Inverse Cubic coordinates mode */
  20717. static readonly SKYBOX_MODE: number;
  20718. /** Inverse Cubic coordinates mode */
  20719. static readonly INVCUBIC_MODE: number;
  20720. /** Equirectangular coordinates mode */
  20721. static readonly EQUIRECTANGULAR_MODE: number;
  20722. /** Equirectangular Fixed coordinates mode */
  20723. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20724. /** Equirectangular Fixed Mirrored coordinates mode */
  20725. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20726. /** Texture is not repeating outside of 0..1 UVs */
  20727. static readonly CLAMP_ADDRESSMODE: number;
  20728. /** Texture is repeating outside of 0..1 UVs */
  20729. static readonly WRAP_ADDRESSMODE: number;
  20730. /** Texture is repeating and mirrored */
  20731. static readonly MIRROR_ADDRESSMODE: number;
  20732. /**
  20733. * 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
  20734. */
  20735. static UseSerializedUrlIfAny: boolean;
  20736. /**
  20737. * Define the url of the texture.
  20738. */
  20739. url: Nullable<string>;
  20740. /**
  20741. * Define an offset on the texture to offset the u coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. uOffset: number;
  20745. /**
  20746. * Define an offset on the texture to offset the v coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20748. */
  20749. vOffset: number;
  20750. /**
  20751. * Define an offset on the texture to scale the u coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. uScale: number;
  20755. /**
  20756. * Define an offset on the texture to scale the v coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20758. */
  20759. vScale: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. uAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. vAng: number;
  20770. /**
  20771. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20772. * @see http://doc.babylonjs.com/how_to/more_materials
  20773. */
  20774. wAng: number;
  20775. /**
  20776. * Defines the center of rotation (U)
  20777. */
  20778. uRotationCenter: number;
  20779. /**
  20780. * Defines the center of rotation (V)
  20781. */
  20782. vRotationCenter: number;
  20783. /**
  20784. * Defines the center of rotation (W)
  20785. */
  20786. wRotationCenter: number;
  20787. /**
  20788. * Are mip maps generated for this texture or not.
  20789. */
  20790. get noMipmap(): boolean;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: Nullable<IInspectable[]>;
  20796. private _noMipmap;
  20797. /** @hidden */
  20798. _invertY: boolean;
  20799. private _rowGenerationMatrix;
  20800. private _cachedTextureMatrix;
  20801. private _projectionModeMatrix;
  20802. private _t0;
  20803. private _t1;
  20804. private _t2;
  20805. private _cachedUOffset;
  20806. private _cachedVOffset;
  20807. private _cachedUScale;
  20808. private _cachedVScale;
  20809. private _cachedUAng;
  20810. private _cachedVAng;
  20811. private _cachedWAng;
  20812. private _cachedProjectionMatrixId;
  20813. private _cachedCoordinatesMode;
  20814. /** @hidden */
  20815. protected _initialSamplingMode: number;
  20816. /** @hidden */
  20817. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20818. private _deleteBuffer;
  20819. protected _format: Nullable<number>;
  20820. private _delayedOnLoad;
  20821. private _delayedOnError;
  20822. private _mimeType?;
  20823. /**
  20824. * Observable triggered once the texture has been loaded.
  20825. */
  20826. onLoadObservable: Observable<Texture>;
  20827. protected _isBlocking: boolean;
  20828. /**
  20829. * Is the texture preventing material to render while loading.
  20830. * If false, a default texture will be used instead of the loading one during the preparation step.
  20831. */
  20832. set isBlocking(value: boolean);
  20833. get isBlocking(): boolean;
  20834. /**
  20835. * Get the current sampling mode associated with the texture.
  20836. */
  20837. get samplingMode(): number;
  20838. /**
  20839. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20840. */
  20841. get invertY(): boolean;
  20842. /**
  20843. * Instantiates a new texture.
  20844. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20845. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20846. * @param url defines the url of the picture to load as a texture
  20847. * @param scene defines the scene or engine the texture will belong to
  20848. * @param noMipmap defines if the texture will require mip maps or not
  20849. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20850. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20851. * @param onLoad defines a callback triggered when the texture has been loaded
  20852. * @param onError defines a callback triggered when an error occurred during the loading session
  20853. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20854. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20855. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20856. * @param mimeType defines an optional mime type information
  20857. */
  20858. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20859. /**
  20860. * Update the url (and optional buffer) of this texture if url was null during construction.
  20861. * @param url the url of the texture
  20862. * @param buffer the buffer of the texture (defaults to null)
  20863. * @param onLoad callback called when the texture is loaded (defaults to null)
  20864. */
  20865. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20866. /**
  20867. * Finish the loading sequence of a texture flagged as delayed load.
  20868. * @hidden
  20869. */
  20870. delayLoad(): void;
  20871. private _prepareRowForTextureGeneration;
  20872. /**
  20873. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20874. * @returns the transform matrix of the texture.
  20875. */
  20876. getTextureMatrix(uBase?: number): Matrix;
  20877. /**
  20878. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20879. * @returns The reflection texture transform
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Clones the texture.
  20884. * @returns the cloned texture
  20885. */
  20886. clone(): Texture;
  20887. /**
  20888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20889. * @returns The JSON representation of the texture
  20890. */
  20891. serialize(): any;
  20892. /**
  20893. * Get the current class name of the texture useful for serialization or dynamic coding.
  20894. * @returns "Texture"
  20895. */
  20896. getClassName(): string;
  20897. /**
  20898. * Dispose the texture and release its associated resources.
  20899. */
  20900. dispose(): void;
  20901. /**
  20902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20903. * @param parsedTexture Define the JSON representation of the texture
  20904. * @param scene Define the scene the parsed texture should be instantiated in
  20905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20906. * @returns The parsed texture if successful
  20907. */
  20908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20909. /**
  20910. * Creates a texture from its base 64 representation.
  20911. * @param data Define the base64 payload without the data: prefix
  20912. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20913. * @param scene Define the scene the texture should belong to
  20914. * @param noMipmap Forces the texture to not create mip map information if true
  20915. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20916. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20917. * @param onLoad define a callback triggered when the texture has been loaded
  20918. * @param onError define a callback triggered when an error occurred during the loading session
  20919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20920. * @returns the created texture
  20921. */
  20922. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20923. /**
  20924. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20925. * @param data Define the base64 payload without the data: prefix
  20926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20928. * @param scene Define the scene the texture should belong to
  20929. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20930. * @param noMipmap Forces the texture to not create mip map information if true
  20931. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20932. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20933. * @param onLoad define a callback triggered when the texture has been loaded
  20934. * @param onError define a callback triggered when an error occurred during the loading session
  20935. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20936. * @returns the created texture
  20937. */
  20938. 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;
  20939. }
  20940. }
  20941. declare module "babylonjs/PostProcesses/postProcessManager" {
  20942. import { Nullable } from "babylonjs/types";
  20943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20945. import { Scene } from "babylonjs/scene";
  20946. /**
  20947. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20948. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20949. */
  20950. export class PostProcessManager {
  20951. private _scene;
  20952. private _indexBuffer;
  20953. private _vertexBuffers;
  20954. /**
  20955. * Creates a new instance PostProcess
  20956. * @param scene The scene that the post process is associated with.
  20957. */
  20958. constructor(scene: Scene);
  20959. private _prepareBuffers;
  20960. private _buildIndexBuffer;
  20961. /**
  20962. * Rebuilds the vertex buffers of the manager.
  20963. * @hidden
  20964. */
  20965. _rebuild(): void;
  20966. /**
  20967. * Prepares a frame to be run through a post process.
  20968. * @param sourceTexture The input texture to the post procesess. (default: null)
  20969. * @param postProcesses An array of post processes to be run. (default: null)
  20970. * @returns True if the post processes were able to be run.
  20971. * @hidden
  20972. */
  20973. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20974. /**
  20975. * Manually render a set of post processes to a texture.
  20976. * @param postProcesses An array of post processes to be run.
  20977. * @param targetTexture The target texture to render to.
  20978. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20979. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20980. * @param lodLevel defines which lod of the texture to render to
  20981. */
  20982. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20983. /**
  20984. * Finalize the result of the output of the postprocesses.
  20985. * @param doNotPresent If true the result will not be displayed to the screen.
  20986. * @param targetTexture The target texture to render to.
  20987. * @param faceIndex The index of the face to bind the target texture to.
  20988. * @param postProcesses The array of post processes to render.
  20989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20990. * @hidden
  20991. */
  20992. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20993. /**
  20994. * Disposes of the post process manager.
  20995. */
  20996. dispose(): void;
  20997. }
  20998. }
  20999. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { SmartArray } from "babylonjs/Misc/smartArray";
  21002. import { Nullable, Immutable } from "babylonjs/types";
  21003. import { Camera } from "babylonjs/Cameras/camera";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21006. import { Color4 } from "babylonjs/Maths/math.color";
  21007. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21011. import { Texture } from "babylonjs/Materials/Textures/texture";
  21012. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21013. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21014. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21015. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21016. import { Engine } from "babylonjs/Engines/engine";
  21017. /**
  21018. * This Helps creating a texture that will be created from a camera in your scene.
  21019. * It is basically a dynamic texture that could be used to create special effects for instance.
  21020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21021. */
  21022. export class RenderTargetTexture extends Texture {
  21023. isCube: boolean;
  21024. /**
  21025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21026. */
  21027. static readonly REFRESHRATE_RENDER_ONCE: number;
  21028. /**
  21029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21032. /**
  21033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21034. * the central point of your effect and can save a lot of performances.
  21035. */
  21036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21037. /**
  21038. * Use this predicate to dynamically define the list of mesh you want to render.
  21039. * If set, the renderList property will be overwritten.
  21040. */
  21041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21042. private _renderList;
  21043. /**
  21044. * Use this list to define the list of mesh you want to render.
  21045. */
  21046. get renderList(): Nullable<Array<AbstractMesh>>;
  21047. set renderList(value: Nullable<Array<AbstractMesh>>);
  21048. /**
  21049. * Use this function to overload the renderList array at rendering time.
  21050. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21051. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21052. * the cube (if the RTT is a cube, else layerOrFace=0).
  21053. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21054. */
  21055. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21056. private _hookArray;
  21057. /**
  21058. * Define if particles should be rendered in your texture.
  21059. */
  21060. renderParticles: boolean;
  21061. /**
  21062. * Define if sprites should be rendered in your texture.
  21063. */
  21064. renderSprites: boolean;
  21065. /**
  21066. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21067. */
  21068. coordinatesMode: number;
  21069. /**
  21070. * Define the camera used to render the texture.
  21071. */
  21072. activeCamera: Nullable<Camera>;
  21073. /**
  21074. * Override the render function of the texture with your own one.
  21075. */
  21076. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21077. /**
  21078. * Define if camera post processes should be use while rendering the texture.
  21079. */
  21080. useCameraPostProcesses: boolean;
  21081. /**
  21082. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21083. */
  21084. ignoreCameraViewport: boolean;
  21085. private _postProcessManager;
  21086. private _postProcesses;
  21087. private _resizeObserver;
  21088. /**
  21089. * An event triggered when the texture is unbind.
  21090. */
  21091. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21092. /**
  21093. * An event triggered when the texture is unbind.
  21094. */
  21095. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21096. private _onAfterUnbindObserver;
  21097. /**
  21098. * Set a after unbind callback in the texture.
  21099. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21100. */
  21101. set onAfterUnbind(callback: () => void);
  21102. /**
  21103. * An event triggered before rendering the texture
  21104. */
  21105. onBeforeRenderObservable: Observable<number>;
  21106. private _onBeforeRenderObserver;
  21107. /**
  21108. * Set a before render callback in the texture.
  21109. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21110. */
  21111. set onBeforeRender(callback: (faceIndex: number) => void);
  21112. /**
  21113. * An event triggered after rendering the texture
  21114. */
  21115. onAfterRenderObservable: Observable<number>;
  21116. private _onAfterRenderObserver;
  21117. /**
  21118. * Set a after render callback in the texture.
  21119. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21120. */
  21121. set onAfterRender(callback: (faceIndex: number) => void);
  21122. /**
  21123. * An event triggered after the texture clear
  21124. */
  21125. onClearObservable: Observable<Engine>;
  21126. private _onClearObserver;
  21127. /**
  21128. * Set a clear callback in the texture.
  21129. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21130. */
  21131. set onClear(callback: (Engine: Engine) => void);
  21132. /**
  21133. * An event triggered when the texture is resized.
  21134. */
  21135. onResizeObservable: Observable<RenderTargetTexture>;
  21136. /**
  21137. * Define the clear color of the Render Target if it should be different from the scene.
  21138. */
  21139. clearColor: Color4;
  21140. protected _size: number | {
  21141. width: number;
  21142. height: number;
  21143. layers?: number;
  21144. };
  21145. protected _initialSizeParameter: number | {
  21146. width: number;
  21147. height: number;
  21148. } | {
  21149. ratio: number;
  21150. };
  21151. protected _sizeRatio: Nullable<number>;
  21152. /** @hidden */
  21153. _generateMipMaps: boolean;
  21154. protected _renderingManager: RenderingManager;
  21155. /** @hidden */
  21156. _waitingRenderList: string[];
  21157. protected _doNotChangeAspectRatio: boolean;
  21158. protected _currentRefreshId: number;
  21159. protected _refreshRate: number;
  21160. protected _textureMatrix: Matrix;
  21161. protected _samples: number;
  21162. protected _renderTargetOptions: RenderTargetCreationOptions;
  21163. /**
  21164. * Gets render target creation options that were used.
  21165. */
  21166. get renderTargetOptions(): RenderTargetCreationOptions;
  21167. protected _engine: Engine;
  21168. protected _onRatioRescale(): void;
  21169. /**
  21170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21171. * It must define where the camera used to render the texture is set
  21172. */
  21173. boundingBoxPosition: Vector3;
  21174. private _boundingBoxSize;
  21175. /**
  21176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21177. * When defined, the cubemap will switch to local mode
  21178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21179. * @example https://www.babylonjs-playground.com/#RNASML
  21180. */
  21181. set boundingBoxSize(value: Vector3);
  21182. get boundingBoxSize(): Vector3;
  21183. /**
  21184. * In case the RTT has been created with a depth texture, get the associated
  21185. * depth texture.
  21186. * Otherwise, return null.
  21187. */
  21188. get depthStencilTexture(): Nullable<InternalTexture>;
  21189. /**
  21190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21191. * or used a shadow, depth texture...
  21192. * @param name The friendly name of the texture
  21193. * @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)
  21194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21195. * @param generateMipMaps True if mip maps need to be generated after render.
  21196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21197. * @param type The type of the buffer in the RTT (int, half float, float...)
  21198. * @param isCube True if a cube texture needs to be created
  21199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21200. * @param generateDepthBuffer True to generate a depth buffer
  21201. * @param generateStencilBuffer True to generate a stencil buffer
  21202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21205. */
  21206. constructor(name: string, size: number | {
  21207. width: number;
  21208. height: number;
  21209. layers?: number;
  21210. } | {
  21211. ratio: number;
  21212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21213. /**
  21214. * Creates a depth stencil texture.
  21215. * This is only available in WebGL 2 or with the depth texture extension available.
  21216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21219. */
  21220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21221. private _processSizeParameter;
  21222. /**
  21223. * Define the number of samples to use in case of MSAA.
  21224. * It defaults to one meaning no MSAA has been enabled.
  21225. */
  21226. get samples(): number;
  21227. set samples(value: number);
  21228. /**
  21229. * Resets the refresh counter of the texture and start bak from scratch.
  21230. * Could be useful to regenerate the texture if it is setup to render only once.
  21231. */
  21232. resetRefreshCounter(): void;
  21233. /**
  21234. * Define the refresh rate of the texture or the rendering frequency.
  21235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21236. */
  21237. get refreshRate(): number;
  21238. set refreshRate(value: number);
  21239. /**
  21240. * Adds a post process to the render target rendering passes.
  21241. * @param postProcess define the post process to add
  21242. */
  21243. addPostProcess(postProcess: PostProcess): void;
  21244. /**
  21245. * Clear all the post processes attached to the render target
  21246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21247. */
  21248. clearPostProcesses(dispose?: boolean): void;
  21249. /**
  21250. * Remove one of the post process from the list of attached post processes to the texture
  21251. * @param postProcess define the post process to remove from the list
  21252. */
  21253. removePostProcess(postProcess: PostProcess): void;
  21254. /** @hidden */
  21255. _shouldRender(): boolean;
  21256. /**
  21257. * Gets the actual render size of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderSize(): number;
  21261. /**
  21262. * Gets the actual render width of the texture.
  21263. * @returns the width of the render size
  21264. */
  21265. getRenderWidth(): number;
  21266. /**
  21267. * Gets the actual render height of the texture.
  21268. * @returns the height of the render size
  21269. */
  21270. getRenderHeight(): number;
  21271. /**
  21272. * Gets the actual number of layers of the texture.
  21273. * @returns the number of layers
  21274. */
  21275. getRenderLayers(): number;
  21276. /**
  21277. * Get if the texture can be rescaled or not.
  21278. */
  21279. get canRescale(): boolean;
  21280. /**
  21281. * Resize the texture using a ratio.
  21282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21283. */
  21284. scale(ratio: number): void;
  21285. /**
  21286. * Get the texture reflection matrix used to rotate/transform the reflection.
  21287. * @returns the reflection matrix
  21288. */
  21289. getReflectionTextureMatrix(): Matrix;
  21290. /**
  21291. * Resize the texture to a new desired size.
  21292. * Be carrefull as it will recreate all the data in the new texture.
  21293. * @param size Define the new size. It can be:
  21294. * - a number for squared texture,
  21295. * - an object containing { width: number, height: number }
  21296. * - or an object containing a ratio { ratio: number }
  21297. */
  21298. resize(size: number | {
  21299. width: number;
  21300. height: number;
  21301. } | {
  21302. ratio: number;
  21303. }): void;
  21304. private _defaultRenderListPrepared;
  21305. /**
  21306. * Renders all the objects from the render list into the texture.
  21307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21309. */
  21310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21311. private _bestReflectionRenderTargetDimension;
  21312. private _prepareRenderingManager;
  21313. /**
  21314. * @hidden
  21315. * @param faceIndex face index to bind to if this is a cubetexture
  21316. * @param layer defines the index of the texture to bind in the array
  21317. */
  21318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21320. private renderToTarget;
  21321. /**
  21322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21323. * This allowed control for front to back rendering or reversly depending of the special needs.
  21324. *
  21325. * @param renderingGroupId The rendering group id corresponding to its index
  21326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21329. */
  21330. 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;
  21331. /**
  21332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21333. *
  21334. * @param renderingGroupId The rendering group id corresponding to its index
  21335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21336. */
  21337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21338. /**
  21339. * Clones the texture.
  21340. * @returns the cloned texture
  21341. */
  21342. clone(): RenderTargetTexture;
  21343. /**
  21344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21345. * @returns The JSON representation of the texture
  21346. */
  21347. serialize(): any;
  21348. /**
  21349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21350. */
  21351. disposeFramebufferObjects(): void;
  21352. /**
  21353. * Dispose the texture and release its associated resources.
  21354. */
  21355. dispose(): void;
  21356. /** @hidden */
  21357. _rebuild(): void;
  21358. /**
  21359. * Clear the info related to rendering groups preventing retention point in material dispose.
  21360. */
  21361. freeRenderingGroups(): void;
  21362. /**
  21363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21364. * @returns the view count
  21365. */
  21366. getViewCount(): number;
  21367. }
  21368. }
  21369. declare module "babylonjs/Materials/material" {
  21370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21371. import { SmartArray } from "babylonjs/Misc/smartArray";
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import { Matrix } from "babylonjs/Maths/math.vector";
  21376. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21379. import { Effect } from "babylonjs/Materials/effect";
  21380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21382. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21383. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21384. import { Mesh } from "babylonjs/Meshes/mesh";
  21385. import { Animation } from "babylonjs/Animations/animation";
  21386. /**
  21387. * Options for compiling materials.
  21388. */
  21389. export interface IMaterialCompilationOptions {
  21390. /**
  21391. * Defines whether clip planes are enabled.
  21392. */
  21393. clipPlane: boolean;
  21394. /**
  21395. * Defines whether instances are enabled.
  21396. */
  21397. useInstances: boolean;
  21398. }
  21399. /**
  21400. * Base class for the main features of a material in Babylon.js
  21401. */
  21402. export class Material implements IAnimatable {
  21403. /**
  21404. * Returns the triangle fill mode
  21405. */
  21406. static readonly TriangleFillMode: number;
  21407. /**
  21408. * Returns the wireframe mode
  21409. */
  21410. static readonly WireFrameFillMode: number;
  21411. /**
  21412. * Returns the point fill mode
  21413. */
  21414. static readonly PointFillMode: number;
  21415. /**
  21416. * Returns the point list draw mode
  21417. */
  21418. static readonly PointListDrawMode: number;
  21419. /**
  21420. * Returns the line list draw mode
  21421. */
  21422. static readonly LineListDrawMode: number;
  21423. /**
  21424. * Returns the line loop draw mode
  21425. */
  21426. static readonly LineLoopDrawMode: number;
  21427. /**
  21428. * Returns the line strip draw mode
  21429. */
  21430. static readonly LineStripDrawMode: number;
  21431. /**
  21432. * Returns the triangle strip draw mode
  21433. */
  21434. static readonly TriangleStripDrawMode: number;
  21435. /**
  21436. * Returns the triangle fan draw mode
  21437. */
  21438. static readonly TriangleFanDrawMode: number;
  21439. /**
  21440. * Stores the clock-wise side orientation
  21441. */
  21442. static readonly ClockWiseSideOrientation: number;
  21443. /**
  21444. * Stores the counter clock-wise side orientation
  21445. */
  21446. static readonly CounterClockWiseSideOrientation: number;
  21447. /**
  21448. * The dirty texture flag value
  21449. */
  21450. static readonly TextureDirtyFlag: number;
  21451. /**
  21452. * The dirty light flag value
  21453. */
  21454. static readonly LightDirtyFlag: number;
  21455. /**
  21456. * The dirty fresnel flag value
  21457. */
  21458. static readonly FresnelDirtyFlag: number;
  21459. /**
  21460. * The dirty attribute flag value
  21461. */
  21462. static readonly AttributesDirtyFlag: number;
  21463. /**
  21464. * The dirty misc flag value
  21465. */
  21466. static readonly MiscDirtyFlag: number;
  21467. /**
  21468. * The all dirty flag value
  21469. */
  21470. static readonly AllDirtyFlag: number;
  21471. /**
  21472. * The ID of the material
  21473. */
  21474. id: string;
  21475. /**
  21476. * Gets or sets the unique id of the material
  21477. */
  21478. uniqueId: number;
  21479. /**
  21480. * The name of the material
  21481. */
  21482. name: string;
  21483. /**
  21484. * Gets or sets user defined metadata
  21485. */
  21486. metadata: any;
  21487. /**
  21488. * For internal use only. Please do not use.
  21489. */
  21490. reservedDataStore: any;
  21491. /**
  21492. * Specifies if the ready state should be checked on each call
  21493. */
  21494. checkReadyOnEveryCall: boolean;
  21495. /**
  21496. * Specifies if the ready state should be checked once
  21497. */
  21498. checkReadyOnlyOnce: boolean;
  21499. /**
  21500. * The state of the material
  21501. */
  21502. state: string;
  21503. /**
  21504. * The alpha value of the material
  21505. */
  21506. protected _alpha: number;
  21507. /**
  21508. * List of inspectable custom properties (used by the Inspector)
  21509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21510. */
  21511. inspectableCustomProperties: IInspectable[];
  21512. /**
  21513. * Sets the alpha value of the material
  21514. */
  21515. set alpha(value: number);
  21516. /**
  21517. * Gets the alpha value of the material
  21518. */
  21519. get alpha(): number;
  21520. /**
  21521. * Specifies if back face culling is enabled
  21522. */
  21523. protected _backFaceCulling: boolean;
  21524. /**
  21525. * Sets the back-face culling state
  21526. */
  21527. set backFaceCulling(value: boolean);
  21528. /**
  21529. * Gets the back-face culling state
  21530. */
  21531. get backFaceCulling(): boolean;
  21532. /**
  21533. * Stores the value for side orientation
  21534. */
  21535. sideOrientation: number;
  21536. /**
  21537. * Callback triggered when the material is compiled
  21538. */
  21539. onCompiled: Nullable<(effect: Effect) => void>;
  21540. /**
  21541. * Callback triggered when an error occurs
  21542. */
  21543. onError: Nullable<(effect: Effect, errors: string) => void>;
  21544. /**
  21545. * Callback triggered to get the render target textures
  21546. */
  21547. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21548. /**
  21549. * Gets a boolean indicating that current material needs to register RTT
  21550. */
  21551. get hasRenderTargetTextures(): boolean;
  21552. /**
  21553. * Specifies if the material should be serialized
  21554. */
  21555. doNotSerialize: boolean;
  21556. /**
  21557. * @hidden
  21558. */
  21559. _storeEffectOnSubMeshes: boolean;
  21560. /**
  21561. * Stores the animations for the material
  21562. */
  21563. animations: Nullable<Array<Animation>>;
  21564. /**
  21565. * An event triggered when the material is disposed
  21566. */
  21567. onDisposeObservable: Observable<Material>;
  21568. /**
  21569. * An observer which watches for dispose events
  21570. */
  21571. private _onDisposeObserver;
  21572. private _onUnBindObservable;
  21573. /**
  21574. * Called during a dispose event
  21575. */
  21576. set onDispose(callback: () => void);
  21577. private _onBindObservable;
  21578. /**
  21579. * An event triggered when the material is bound
  21580. */
  21581. get onBindObservable(): Observable<AbstractMesh>;
  21582. /**
  21583. * An observer which watches for bind events
  21584. */
  21585. private _onBindObserver;
  21586. /**
  21587. * Called during a bind event
  21588. */
  21589. set onBind(callback: (Mesh: AbstractMesh) => void);
  21590. /**
  21591. * An event triggered when the material is unbound
  21592. */
  21593. get onUnBindObservable(): Observable<Material>;
  21594. /**
  21595. * Stores the value of the alpha mode
  21596. */
  21597. private _alphaMode;
  21598. /**
  21599. * Sets the value of the alpha mode.
  21600. *
  21601. * | Value | Type | Description |
  21602. * | --- | --- | --- |
  21603. * | 0 | ALPHA_DISABLE | |
  21604. * | 1 | ALPHA_ADD | |
  21605. * | 2 | ALPHA_COMBINE | |
  21606. * | 3 | ALPHA_SUBTRACT | |
  21607. * | 4 | ALPHA_MULTIPLY | |
  21608. * | 5 | ALPHA_MAXIMIZED | |
  21609. * | 6 | ALPHA_ONEONE | |
  21610. * | 7 | ALPHA_PREMULTIPLIED | |
  21611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21612. * | 9 | ALPHA_INTERPOLATE | |
  21613. * | 10 | ALPHA_SCREENMODE | |
  21614. *
  21615. */
  21616. set alphaMode(value: number);
  21617. /**
  21618. * Gets the value of the alpha mode
  21619. */
  21620. get alphaMode(): number;
  21621. /**
  21622. * Stores the state of the need depth pre-pass value
  21623. */
  21624. private _needDepthPrePass;
  21625. /**
  21626. * Sets the need depth pre-pass value
  21627. */
  21628. set needDepthPrePass(value: boolean);
  21629. /**
  21630. * Gets the depth pre-pass value
  21631. */
  21632. get needDepthPrePass(): boolean;
  21633. /**
  21634. * Specifies if depth writing should be disabled
  21635. */
  21636. disableDepthWrite: boolean;
  21637. /**
  21638. * Specifies if depth writing should be forced
  21639. */
  21640. forceDepthWrite: boolean;
  21641. /**
  21642. * Specifies the depth function that should be used. 0 means the default engine function
  21643. */
  21644. depthFunction: number;
  21645. /**
  21646. * Specifies if there should be a separate pass for culling
  21647. */
  21648. separateCullingPass: boolean;
  21649. /**
  21650. * Stores the state specifing if fog should be enabled
  21651. */
  21652. private _fogEnabled;
  21653. /**
  21654. * Sets the state for enabling fog
  21655. */
  21656. set fogEnabled(value: boolean);
  21657. /**
  21658. * Gets the value of the fog enabled state
  21659. */
  21660. get fogEnabled(): boolean;
  21661. /**
  21662. * Stores the size of points
  21663. */
  21664. pointSize: number;
  21665. /**
  21666. * Stores the z offset value
  21667. */
  21668. zOffset: number;
  21669. /**
  21670. * Gets a value specifying if wireframe mode is enabled
  21671. */
  21672. get wireframe(): boolean;
  21673. /**
  21674. * Sets the state of wireframe mode
  21675. */
  21676. set wireframe(value: boolean);
  21677. /**
  21678. * Gets the value specifying if point clouds are enabled
  21679. */
  21680. get pointsCloud(): boolean;
  21681. /**
  21682. * Sets the state of point cloud mode
  21683. */
  21684. set pointsCloud(value: boolean);
  21685. /**
  21686. * Gets the material fill mode
  21687. */
  21688. get fillMode(): number;
  21689. /**
  21690. * Sets the material fill mode
  21691. */
  21692. set fillMode(value: number);
  21693. /**
  21694. * @hidden
  21695. * Stores the effects for the material
  21696. */
  21697. _effect: Nullable<Effect>;
  21698. /**
  21699. * Specifies if uniform buffers should be used
  21700. */
  21701. private _useUBO;
  21702. /**
  21703. * Stores a reference to the scene
  21704. */
  21705. private _scene;
  21706. /**
  21707. * Stores the fill mode state
  21708. */
  21709. private _fillMode;
  21710. /**
  21711. * Specifies if the depth write state should be cached
  21712. */
  21713. private _cachedDepthWriteState;
  21714. /**
  21715. * Specifies if the depth function state should be cached
  21716. */
  21717. private _cachedDepthFunctionState;
  21718. /**
  21719. * Stores the uniform buffer
  21720. */
  21721. protected _uniformBuffer: UniformBuffer;
  21722. /** @hidden */
  21723. _indexInSceneMaterialArray: number;
  21724. /** @hidden */
  21725. meshMap: Nullable<{
  21726. [id: string]: AbstractMesh | undefined;
  21727. }>;
  21728. /**
  21729. * Creates a material instance
  21730. * @param name defines the name of the material
  21731. * @param scene defines the scene to reference
  21732. * @param doNotAdd specifies if the material should be added to the scene
  21733. */
  21734. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21735. /**
  21736. * Returns a string representation of the current material
  21737. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21738. * @returns a string with material information
  21739. */
  21740. toString(fullDetails?: boolean): string;
  21741. /**
  21742. * Gets the class name of the material
  21743. * @returns a string with the class name of the material
  21744. */
  21745. getClassName(): string;
  21746. /**
  21747. * Specifies if updates for the material been locked
  21748. */
  21749. get isFrozen(): boolean;
  21750. /**
  21751. * Locks updates for the material
  21752. */
  21753. freeze(): void;
  21754. /**
  21755. * Unlocks updates for the material
  21756. */
  21757. unfreeze(): void;
  21758. /**
  21759. * Specifies if the material is ready to be used
  21760. * @param mesh defines the mesh to check
  21761. * @param useInstances specifies if instances should be used
  21762. * @returns a boolean indicating if the material is ready to be used
  21763. */
  21764. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21765. /**
  21766. * Specifies that the submesh is ready to be used
  21767. * @param mesh defines the mesh to check
  21768. * @param subMesh defines which submesh to check
  21769. * @param useInstances specifies that instances should be used
  21770. * @returns a boolean indicating that the submesh is ready or not
  21771. */
  21772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21773. /**
  21774. * Returns the material effect
  21775. * @returns the effect associated with the material
  21776. */
  21777. getEffect(): Nullable<Effect>;
  21778. /**
  21779. * Returns the current scene
  21780. * @returns a Scene
  21781. */
  21782. getScene(): Scene;
  21783. /**
  21784. * Specifies if the material will require alpha blending
  21785. * @returns a boolean specifying if alpha blending is needed
  21786. */
  21787. needAlphaBlending(): boolean;
  21788. /**
  21789. * Specifies if the mesh will require alpha blending
  21790. * @param mesh defines the mesh to check
  21791. * @returns a boolean specifying if alpha blending is needed for the mesh
  21792. */
  21793. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21794. /**
  21795. * Specifies if this material should be rendered in alpha test mode
  21796. * @returns a boolean specifying if an alpha test is needed.
  21797. */
  21798. needAlphaTesting(): boolean;
  21799. /**
  21800. * Gets the texture used for the alpha test
  21801. * @returns the texture to use for alpha testing
  21802. */
  21803. getAlphaTestTexture(): Nullable<BaseTexture>;
  21804. /**
  21805. * Marks the material to indicate that it needs to be re-calculated
  21806. */
  21807. markDirty(): void;
  21808. /** @hidden */
  21809. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21810. /**
  21811. * Binds the material to the mesh
  21812. * @param world defines the world transformation matrix
  21813. * @param mesh defines the mesh to bind the material to
  21814. */
  21815. bind(world: Matrix, mesh?: Mesh): void;
  21816. /**
  21817. * Binds the submesh to the material
  21818. * @param world defines the world transformation matrix
  21819. * @param mesh defines the mesh containing the submesh
  21820. * @param subMesh defines the submesh to bind the material to
  21821. */
  21822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21823. /**
  21824. * Binds the world matrix to the material
  21825. * @param world defines the world transformation matrix
  21826. */
  21827. bindOnlyWorldMatrix(world: Matrix): void;
  21828. /**
  21829. * Binds the scene's uniform buffer to the effect.
  21830. * @param effect defines the effect to bind to the scene uniform buffer
  21831. * @param sceneUbo defines the uniform buffer storing scene data
  21832. */
  21833. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21834. /**
  21835. * Binds the view matrix to the effect
  21836. * @param effect defines the effect to bind the view matrix to
  21837. */
  21838. bindView(effect: Effect): void;
  21839. /**
  21840. * Binds the view projection matrix to the effect
  21841. * @param effect defines the effect to bind the view projection matrix to
  21842. */
  21843. bindViewProjection(effect: Effect): void;
  21844. /**
  21845. * Specifies if material alpha testing should be turned on for the mesh
  21846. * @param mesh defines the mesh to check
  21847. */
  21848. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21849. /**
  21850. * Processes to execute after binding the material to a mesh
  21851. * @param mesh defines the rendered mesh
  21852. */
  21853. protected _afterBind(mesh?: Mesh): void;
  21854. /**
  21855. * Unbinds the material from the mesh
  21856. */
  21857. unbind(): void;
  21858. /**
  21859. * Gets the active textures from the material
  21860. * @returns an array of textures
  21861. */
  21862. getActiveTextures(): BaseTexture[];
  21863. /**
  21864. * Specifies if the material uses a texture
  21865. * @param texture defines the texture to check against the material
  21866. * @returns a boolean specifying if the material uses the texture
  21867. */
  21868. hasTexture(texture: BaseTexture): boolean;
  21869. /**
  21870. * Makes a duplicate of the material, and gives it a new name
  21871. * @param name defines the new name for the duplicated material
  21872. * @returns the cloned material
  21873. */
  21874. clone(name: string): Nullable<Material>;
  21875. /**
  21876. * Gets the meshes bound to the material
  21877. * @returns an array of meshes bound to the material
  21878. */
  21879. getBindedMeshes(): AbstractMesh[];
  21880. /**
  21881. * Force shader compilation
  21882. * @param mesh defines the mesh associated with this material
  21883. * @param onCompiled defines a function to execute once the material is compiled
  21884. * @param options defines the options to configure the compilation
  21885. * @param onError defines a function to execute if the material fails compiling
  21886. */
  21887. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21888. /**
  21889. * Force shader compilation
  21890. * @param mesh defines the mesh that will use this material
  21891. * @param options defines additional options for compiling the shaders
  21892. * @returns a promise that resolves when the compilation completes
  21893. */
  21894. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21895. private static readonly _AllDirtyCallBack;
  21896. private static readonly _ImageProcessingDirtyCallBack;
  21897. private static readonly _TextureDirtyCallBack;
  21898. private static readonly _FresnelDirtyCallBack;
  21899. private static readonly _MiscDirtyCallBack;
  21900. private static readonly _LightsDirtyCallBack;
  21901. private static readonly _AttributeDirtyCallBack;
  21902. private static _FresnelAndMiscDirtyCallBack;
  21903. private static _TextureAndMiscDirtyCallBack;
  21904. private static readonly _DirtyCallbackArray;
  21905. private static readonly _RunDirtyCallBacks;
  21906. /**
  21907. * Marks a define in the material to indicate that it needs to be re-computed
  21908. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21909. */
  21910. markAsDirty(flag: number): void;
  21911. /**
  21912. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21913. * @param func defines a function which checks material defines against the submeshes
  21914. */
  21915. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21916. /**
  21917. * Indicates that we need to re-calculated for all submeshes
  21918. */
  21919. protected _markAllSubMeshesAsAllDirty(): void;
  21920. /**
  21921. * Indicates that image processing needs to be re-calculated for all submeshes
  21922. */
  21923. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21924. /**
  21925. * Indicates that textures need to be re-calculated for all submeshes
  21926. */
  21927. protected _markAllSubMeshesAsTexturesDirty(): void;
  21928. /**
  21929. * Indicates that fresnel needs to be re-calculated for all submeshes
  21930. */
  21931. protected _markAllSubMeshesAsFresnelDirty(): void;
  21932. /**
  21933. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21934. */
  21935. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21936. /**
  21937. * Indicates that lights need to be re-calculated for all submeshes
  21938. */
  21939. protected _markAllSubMeshesAsLightsDirty(): void;
  21940. /**
  21941. * Indicates that attributes need to be re-calculated for all submeshes
  21942. */
  21943. protected _markAllSubMeshesAsAttributesDirty(): void;
  21944. /**
  21945. * Indicates that misc needs to be re-calculated for all submeshes
  21946. */
  21947. protected _markAllSubMeshesAsMiscDirty(): void;
  21948. /**
  21949. * Indicates that textures and misc need to be re-calculated for all submeshes
  21950. */
  21951. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21952. /**
  21953. * Disposes the material
  21954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21957. */
  21958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21959. /** @hidden */
  21960. private releaseVertexArrayObject;
  21961. /**
  21962. * Serializes this material
  21963. * @returns the serialized material object
  21964. */
  21965. serialize(): any;
  21966. /**
  21967. * Creates a material from parsed material data
  21968. * @param parsedMaterial defines parsed material data
  21969. * @param scene defines the hosting scene
  21970. * @param rootUrl defines the root URL to use to load textures
  21971. * @returns a new material
  21972. */
  21973. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21974. }
  21975. }
  21976. declare module "babylonjs/Materials/multiMaterial" {
  21977. import { Nullable } from "babylonjs/types";
  21978. import { Scene } from "babylonjs/scene";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Material } from "babylonjs/Materials/material";
  21983. /**
  21984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21985. * separate meshes. This can be use to improve performances.
  21986. * @see http://doc.babylonjs.com/how_to/multi_materials
  21987. */
  21988. export class MultiMaterial extends Material {
  21989. private _subMaterials;
  21990. /**
  21991. * Gets or Sets the list of Materials used within the multi material.
  21992. * They need to be ordered according to the submeshes order in the associated mesh
  21993. */
  21994. get subMaterials(): Nullable<Material>[];
  21995. set subMaterials(value: Nullable<Material>[]);
  21996. /**
  21997. * Function used to align with Node.getChildren()
  21998. * @returns the list of Materials used within the multi material
  21999. */
  22000. getChildren(): Nullable<Material>[];
  22001. /**
  22002. * Instantiates a new Multi Material
  22003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22004. * separate meshes. This can be use to improve performances.
  22005. * @see http://doc.babylonjs.com/how_to/multi_materials
  22006. * @param name Define the name in the scene
  22007. * @param scene Define the scene the material belongs to
  22008. */
  22009. constructor(name: string, scene: Scene);
  22010. private _hookArray;
  22011. /**
  22012. * Get one of the submaterial by its index in the submaterials array
  22013. * @param index The index to look the sub material at
  22014. * @returns The Material if the index has been defined
  22015. */
  22016. getSubMaterial(index: number): Nullable<Material>;
  22017. /**
  22018. * Get the list of active textures for the whole sub materials list.
  22019. * @returns All the textures that will be used during the rendering
  22020. */
  22021. getActiveTextures(): BaseTexture[];
  22022. /**
  22023. * Gets the current class name of the material e.g. "MultiMaterial"
  22024. * Mainly use in serialization.
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Checks if the material is ready to render the requested sub mesh
  22030. * @param mesh Define the mesh the submesh belongs to
  22031. * @param subMesh Define the sub mesh to look readyness for
  22032. * @param useInstances Define whether or not the material is used with instances
  22033. * @returns true if ready, otherwise false
  22034. */
  22035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22036. /**
  22037. * Clones the current material and its related sub materials
  22038. * @param name Define the name of the newly cloned material
  22039. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22040. * @returns the cloned material
  22041. */
  22042. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22043. /**
  22044. * Serializes the materials into a JSON representation.
  22045. * @returns the JSON representation
  22046. */
  22047. serialize(): any;
  22048. /**
  22049. * Dispose the material and release its associated resources
  22050. * @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)
  22051. * @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)
  22052. * @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)
  22053. */
  22054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22055. /**
  22056. * Creates a MultiMaterial from parsed MultiMaterial data.
  22057. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22058. * @param scene defines the hosting scene
  22059. * @returns a new MultiMaterial
  22060. */
  22061. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22062. }
  22063. }
  22064. declare module "babylonjs/Meshes/subMesh" {
  22065. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22067. import { Engine } from "babylonjs/Engines/engine";
  22068. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22069. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22072. import { Plane } from "babylonjs/Maths/math.plane";
  22073. import { Collider } from "babylonjs/Collisions/collider";
  22074. import { Material } from "babylonjs/Materials/material";
  22075. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22077. import { Mesh } from "babylonjs/Meshes/mesh";
  22078. import { Ray } from "babylonjs/Culling/ray";
  22079. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22080. /**
  22081. * Base class for submeshes
  22082. */
  22083. export class BaseSubMesh {
  22084. /** @hidden */
  22085. _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */
  22087. _materialEffect: Nullable<Effect>;
  22088. /**
  22089. * Gets material defines used by the effect associated to the sub mesh
  22090. */
  22091. get materialDefines(): Nullable<MaterialDefines>;
  22092. /**
  22093. * Sets material defines used by the effect associated to the sub mesh
  22094. */
  22095. set materialDefines(defines: Nullable<MaterialDefines>);
  22096. /**
  22097. * Gets associated effect
  22098. */
  22099. get effect(): Nullable<Effect>;
  22100. /**
  22101. * Sets associated effect (effect used to render this submesh)
  22102. * @param effect defines the effect to associate with
  22103. * @param defines defines the set of defines used to compile this effect
  22104. */
  22105. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22106. }
  22107. /**
  22108. * Defines a subdivision inside a mesh
  22109. */
  22110. export class SubMesh extends BaseSubMesh implements ICullable {
  22111. /** the material index to use */
  22112. materialIndex: number;
  22113. /** vertex index start */
  22114. verticesStart: number;
  22115. /** vertices count */
  22116. verticesCount: number;
  22117. /** index start */
  22118. indexStart: number;
  22119. /** indices count */
  22120. indexCount: number;
  22121. /** @hidden */
  22122. _linesIndexCount: number;
  22123. private _mesh;
  22124. private _renderingMesh;
  22125. private _boundingInfo;
  22126. private _linesIndexBuffer;
  22127. /** @hidden */
  22128. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22129. /** @hidden */
  22130. _trianglePlanes: Plane[];
  22131. /** @hidden */
  22132. _lastColliderTransformMatrix: Nullable<Matrix>;
  22133. /** @hidden */
  22134. _renderId: number;
  22135. /** @hidden */
  22136. _alphaIndex: number;
  22137. /** @hidden */
  22138. _distanceToCamera: number;
  22139. /** @hidden */
  22140. _id: number;
  22141. private _currentMaterial;
  22142. /**
  22143. * Add a new submesh to a mesh
  22144. * @param materialIndex defines the material index to use
  22145. * @param verticesStart defines vertex index start
  22146. * @param verticesCount defines vertices count
  22147. * @param indexStart defines index start
  22148. * @param indexCount defines indices count
  22149. * @param mesh defines the parent mesh
  22150. * @param renderingMesh defines an optional rendering mesh
  22151. * @param createBoundingBox defines if bounding box should be created for this submesh
  22152. * @returns the new submesh
  22153. */
  22154. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22155. /**
  22156. * Creates a new submesh
  22157. * @param materialIndex defines the material index to use
  22158. * @param verticesStart defines vertex index start
  22159. * @param verticesCount defines vertices count
  22160. * @param indexStart defines index start
  22161. * @param indexCount defines indices count
  22162. * @param mesh defines the parent mesh
  22163. * @param renderingMesh defines an optional rendering mesh
  22164. * @param createBoundingBox defines if bounding box should be created for this submesh
  22165. */
  22166. constructor(
  22167. /** the material index to use */
  22168. materialIndex: number,
  22169. /** vertex index start */
  22170. verticesStart: number,
  22171. /** vertices count */
  22172. verticesCount: number,
  22173. /** index start */
  22174. indexStart: number,
  22175. /** indices count */
  22176. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22177. /**
  22178. * Returns true if this submesh covers the entire parent mesh
  22179. * @ignorenaming
  22180. */
  22181. get IsGlobal(): boolean;
  22182. /**
  22183. * Returns the submesh BoudingInfo object
  22184. * @returns current bounding info (or mesh's one if the submesh is global)
  22185. */
  22186. getBoundingInfo(): BoundingInfo;
  22187. /**
  22188. * Sets the submesh BoundingInfo
  22189. * @param boundingInfo defines the new bounding info to use
  22190. * @returns the SubMesh
  22191. */
  22192. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22193. /**
  22194. * Returns the mesh of the current submesh
  22195. * @return the parent mesh
  22196. */
  22197. getMesh(): AbstractMesh;
  22198. /**
  22199. * Returns the rendering mesh of the submesh
  22200. * @returns the rendering mesh (could be different from parent mesh)
  22201. */
  22202. getRenderingMesh(): Mesh;
  22203. /**
  22204. * Returns the submesh material
  22205. * @returns null or the current material
  22206. */
  22207. getMaterial(): Nullable<Material>;
  22208. /**
  22209. * Sets a new updated BoundingInfo object to the submesh
  22210. * @param data defines an optional position array to use to determine the bounding info
  22211. * @returns the SubMesh
  22212. */
  22213. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22214. /** @hidden */
  22215. _checkCollision(collider: Collider): boolean;
  22216. /**
  22217. * Updates the submesh BoundingInfo
  22218. * @param world defines the world matrix to use to update the bounding info
  22219. * @returns the submesh
  22220. */
  22221. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22222. /**
  22223. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22224. * @param frustumPlanes defines the frustum planes
  22225. * @returns true if the submesh is intersecting with the frustum
  22226. */
  22227. isInFrustum(frustumPlanes: Plane[]): boolean;
  22228. /**
  22229. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22230. * @param frustumPlanes defines the frustum planes
  22231. * @returns true if the submesh is inside the frustum
  22232. */
  22233. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22234. /**
  22235. * Renders the submesh
  22236. * @param enableAlphaMode defines if alpha needs to be used
  22237. * @returns the submesh
  22238. */
  22239. render(enableAlphaMode: boolean): SubMesh;
  22240. /**
  22241. * @hidden
  22242. */
  22243. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22244. /**
  22245. * Checks if the submesh intersects with a ray
  22246. * @param ray defines the ray to test
  22247. * @returns true is the passed ray intersects the submesh bounding box
  22248. */
  22249. canIntersects(ray: Ray): boolean;
  22250. /**
  22251. * Intersects current submesh with a ray
  22252. * @param ray defines the ray to test
  22253. * @param positions defines mesh's positions array
  22254. * @param indices defines mesh's indices array
  22255. * @param fastCheck defines if only bounding info should be used
  22256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22257. * @returns intersection info or null if no intersection
  22258. */
  22259. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22260. /** @hidden */
  22261. private _intersectLines;
  22262. /** @hidden */
  22263. private _intersectUnIndexedLines;
  22264. /** @hidden */
  22265. private _intersectTriangles;
  22266. /** @hidden */
  22267. private _intersectUnIndexedTriangles;
  22268. /** @hidden */
  22269. _rebuild(): void;
  22270. /**
  22271. * Creates a new submesh from the passed mesh
  22272. * @param newMesh defines the new hosting mesh
  22273. * @param newRenderingMesh defines an optional rendering mesh
  22274. * @returns the new submesh
  22275. */
  22276. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22277. /**
  22278. * Release associated resources
  22279. */
  22280. dispose(): void;
  22281. /**
  22282. * Gets the class name
  22283. * @returns the string "SubMesh".
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Creates a new submesh from indices data
  22288. * @param materialIndex the index of the main mesh material
  22289. * @param startIndex the index where to start the copy in the mesh indices array
  22290. * @param indexCount the number of indices to copy then from the startIndex
  22291. * @param mesh the main mesh to create the submesh from
  22292. * @param renderingMesh the optional rendering mesh
  22293. * @returns a new submesh
  22294. */
  22295. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22296. }
  22297. }
  22298. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22299. /**
  22300. * Class used to represent data loading progression
  22301. */
  22302. export class SceneLoaderFlags {
  22303. private static _ForceFullSceneLoadingForIncremental;
  22304. private static _ShowLoadingScreen;
  22305. private static _CleanBoneMatrixWeights;
  22306. private static _loggingLevel;
  22307. /**
  22308. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22309. */
  22310. static get ForceFullSceneLoadingForIncremental(): boolean;
  22311. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22312. /**
  22313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22314. */
  22315. static get ShowLoadingScreen(): boolean;
  22316. static set ShowLoadingScreen(value: boolean);
  22317. /**
  22318. * Defines the current logging level (while loading the scene)
  22319. * @ignorenaming
  22320. */
  22321. static get loggingLevel(): number;
  22322. static set loggingLevel(value: number);
  22323. /**
  22324. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22325. */
  22326. static get CleanBoneMatrixWeights(): boolean;
  22327. static set CleanBoneMatrixWeights(value: boolean);
  22328. }
  22329. }
  22330. declare module "babylonjs/Meshes/geometry" {
  22331. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22334. import { Engine } from "babylonjs/Engines/engine";
  22335. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22336. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22337. import { Effect } from "babylonjs/Materials/effect";
  22338. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22340. import { Mesh } from "babylonjs/Meshes/mesh";
  22341. /**
  22342. * Class used to store geometry data (vertex buffers + index buffer)
  22343. */
  22344. export class Geometry implements IGetSetVerticesData {
  22345. /**
  22346. * Gets or sets the ID of the geometry
  22347. */
  22348. id: string;
  22349. /**
  22350. * Gets or sets the unique ID of the geometry
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22355. */
  22356. delayLoadState: number;
  22357. /**
  22358. * Gets the file containing the data to load when running in delay load state
  22359. */
  22360. delayLoadingFile: Nullable<string>;
  22361. /**
  22362. * Callback called when the geometry is updated
  22363. */
  22364. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22365. private _scene;
  22366. private _engine;
  22367. private _meshes;
  22368. private _totalVertices;
  22369. /** @hidden */
  22370. _indices: IndicesArray;
  22371. /** @hidden */
  22372. _vertexBuffers: {
  22373. [key: string]: VertexBuffer;
  22374. };
  22375. private _isDisposed;
  22376. private _extend;
  22377. private _boundingBias;
  22378. /** @hidden */
  22379. _delayInfo: Array<string>;
  22380. private _indexBuffer;
  22381. private _indexBufferIsUpdatable;
  22382. /** @hidden */
  22383. _boundingInfo: Nullable<BoundingInfo>;
  22384. /** @hidden */
  22385. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22386. /** @hidden */
  22387. _softwareSkinningFrameId: number;
  22388. private _vertexArrayObjects;
  22389. private _updatable;
  22390. /** @hidden */
  22391. _positions: Nullable<Vector3[]>;
  22392. /**
  22393. * 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
  22394. */
  22395. get boundingBias(): Vector2;
  22396. /**
  22397. * 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
  22398. */
  22399. set boundingBias(value: Vector2);
  22400. /**
  22401. * Static function used to attach a new empty geometry to a mesh
  22402. * @param mesh defines the mesh to attach the geometry to
  22403. * @returns the new Geometry
  22404. */
  22405. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22406. /**
  22407. * Creates a new geometry
  22408. * @param id defines the unique ID
  22409. * @param scene defines the hosting scene
  22410. * @param vertexData defines the VertexData used to get geometry data
  22411. * @param updatable defines if geometry must be updatable (false by default)
  22412. * @param mesh defines the mesh that will be associated with the geometry
  22413. */
  22414. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22415. /**
  22416. * Gets the current extend of the geometry
  22417. */
  22418. get extend(): {
  22419. minimum: Vector3;
  22420. maximum: Vector3;
  22421. };
  22422. /**
  22423. * Gets the hosting scene
  22424. * @returns the hosting Scene
  22425. */
  22426. getScene(): Scene;
  22427. /**
  22428. * Gets the hosting engine
  22429. * @returns the hosting Engine
  22430. */
  22431. getEngine(): Engine;
  22432. /**
  22433. * Defines if the geometry is ready to use
  22434. * @returns true if the geometry is ready to be used
  22435. */
  22436. isReady(): boolean;
  22437. /**
  22438. * Gets a value indicating that the geometry should not be serialized
  22439. */
  22440. get doNotSerialize(): boolean;
  22441. /** @hidden */
  22442. _rebuild(): void;
  22443. /**
  22444. * Affects all geometry data in one call
  22445. * @param vertexData defines the geometry data
  22446. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22447. */
  22448. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22449. /**
  22450. * Set specific vertex data
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @param data defines the vertex data to use
  22453. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22454. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22455. */
  22456. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22457. /**
  22458. * Removes a specific vertex data
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. */
  22461. removeVerticesData(kind: string): void;
  22462. /**
  22463. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22464. * @param buffer defines the vertex buffer to use
  22465. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22466. */
  22467. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22468. /**
  22469. * Update a specific vertex buffer
  22470. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22471. * It will do nothing if the buffer is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param offset defines the offset in the target buffer where to store the data
  22475. * @param useBytes set to true if the offset is in bytes
  22476. */
  22477. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22478. /**
  22479. * Update a specific vertex buffer
  22480. * This function will create a new buffer if the current one is not updatable
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @param data defines the data to use
  22483. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22484. */
  22485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22486. private _updateBoundingInfo;
  22487. /** @hidden */
  22488. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22489. /**
  22490. * Gets total number of vertices
  22491. * @returns the total number of vertices
  22492. */
  22493. getTotalVertices(): number;
  22494. /**
  22495. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22496. * @param kind defines the data kind (Position, normal, etc...)
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns a float array containing vertex data
  22500. */
  22501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22502. /**
  22503. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if the vertex buffer with the specified kind is updatable
  22506. */
  22507. isVertexBufferUpdatable(kind: string): boolean;
  22508. /**
  22509. * Gets a specific vertex buffer
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @returns a VertexBuffer
  22512. */
  22513. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22514. /**
  22515. * Returns all vertex buffers
  22516. * @return an object holding all vertex buffers indexed by kind
  22517. */
  22518. getVertexBuffers(): Nullable<{
  22519. [key: string]: VertexBuffer;
  22520. }>;
  22521. /**
  22522. * Gets a boolean indicating if specific vertex buffer is present
  22523. * @param kind defines the data kind (Position, normal, etc...)
  22524. * @returns true if data is present
  22525. */
  22526. isVerticesDataPresent(kind: string): boolean;
  22527. /**
  22528. * Gets a list of all attached data kinds (Position, normal, etc...)
  22529. * @returns a list of string containing all kinds
  22530. */
  22531. getVerticesDataKinds(): string[];
  22532. /**
  22533. * Update index buffer
  22534. * @param indices defines the indices to store in the index buffer
  22535. * @param offset defines the offset in the target buffer where to store the data
  22536. * @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)
  22537. */
  22538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22539. /**
  22540. * Creates a new index buffer
  22541. * @param indices defines the indices to store in the index buffer
  22542. * @param totalVertices defines the total number of vertices (could be null)
  22543. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22546. /**
  22547. * Return the total number of indices
  22548. * @returns the total number of indices
  22549. */
  22550. getTotalIndices(): number;
  22551. /**
  22552. * Gets the index buffer array
  22553. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22555. * @returns the index buffer array
  22556. */
  22557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22558. /**
  22559. * Gets the index buffer
  22560. * @return the index buffer
  22561. */
  22562. getIndexBuffer(): Nullable<DataBuffer>;
  22563. /** @hidden */
  22564. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22565. /**
  22566. * Release the associated resources for a specific mesh
  22567. * @param mesh defines the source mesh
  22568. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22569. */
  22570. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22571. /**
  22572. * Apply current geometry to a given mesh
  22573. * @param mesh defines the mesh to apply geometry to
  22574. */
  22575. applyToMesh(mesh: Mesh): void;
  22576. private _updateExtend;
  22577. private _applyToMesh;
  22578. private notifyUpdate;
  22579. /**
  22580. * Load the geometry if it was flagged as delay loaded
  22581. * @param scene defines the hosting scene
  22582. * @param onLoaded defines a callback called when the geometry is loaded
  22583. */
  22584. load(scene: Scene, onLoaded?: () => void): void;
  22585. private _queueLoad;
  22586. /**
  22587. * Invert the geometry to move from a right handed system to a left handed one.
  22588. */
  22589. toLeftHanded(): void;
  22590. /** @hidden */
  22591. _resetPointsArrayCache(): void;
  22592. /** @hidden */
  22593. _generatePointsArray(): boolean;
  22594. /**
  22595. * Gets a value indicating if the geometry is disposed
  22596. * @returns true if the geometry was disposed
  22597. */
  22598. isDisposed(): boolean;
  22599. private _disposeVertexArrayObjects;
  22600. /**
  22601. * Free all associated resources
  22602. */
  22603. dispose(): void;
  22604. /**
  22605. * Clone the current geometry into a new geometry
  22606. * @param id defines the unique ID of the new geometry
  22607. * @returns a new geometry object
  22608. */
  22609. copy(id: string): Geometry;
  22610. /**
  22611. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22612. * @return a JSON representation of the current geometry data (without the vertices data)
  22613. */
  22614. serialize(): any;
  22615. private toNumberArray;
  22616. /**
  22617. * Serialize all vertices data into a JSON oject
  22618. * @returns a JSON representation of the current geometry data
  22619. */
  22620. serializeVerticeData(): any;
  22621. /**
  22622. * Extracts a clone of a mesh geometry
  22623. * @param mesh defines the source mesh
  22624. * @param id defines the unique ID of the new geometry object
  22625. * @returns the new geometry object
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22628. /**
  22629. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22630. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22631. * Be aware Math.random() could cause collisions, but:
  22632. * "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"
  22633. * @returns a string containing a new GUID
  22634. */
  22635. static RandomId(): string;
  22636. /** @hidden */
  22637. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22638. private static _CleanMatricesWeights;
  22639. /**
  22640. * Create a new geometry from persisted data (Using .babylon file format)
  22641. * @param parsedVertexData defines the persisted data
  22642. * @param scene defines the hosting scene
  22643. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22644. * @returns the new geometry object
  22645. */
  22646. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22647. }
  22648. }
  22649. declare module "babylonjs/Meshes/mesh.vertexData" {
  22650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22651. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22652. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22653. import { Geometry } from "babylonjs/Meshes/geometry";
  22654. import { Mesh } from "babylonjs/Meshes/mesh";
  22655. /**
  22656. * Define an interface for all classes that will get and set the data on vertices
  22657. */
  22658. export interface IGetSetVerticesData {
  22659. /**
  22660. * Gets a boolean indicating if specific vertex data is present
  22661. * @param kind defines the vertex data kind to use
  22662. * @returns true is data kind is present
  22663. */
  22664. isVerticesDataPresent(kind: string): boolean;
  22665. /**
  22666. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22667. * @param kind defines the data kind (Position, normal, etc...)
  22668. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22670. * @returns a float array containing vertex data
  22671. */
  22672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22673. /**
  22674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22675. * @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.
  22676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22677. * @returns the indices array or an empty array if the mesh has no geometry
  22678. */
  22679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22680. /**
  22681. * Set specific vertex data
  22682. * @param kind defines the data kind (Position, normal, etc...)
  22683. * @param data defines the vertex data to use
  22684. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22685. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22686. */
  22687. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22688. /**
  22689. * Update a specific associated vertex buffer
  22690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22691. * - VertexBuffer.PositionKind
  22692. * - VertexBuffer.UVKind
  22693. * - VertexBuffer.UV2Kind
  22694. * - VertexBuffer.UV3Kind
  22695. * - VertexBuffer.UV4Kind
  22696. * - VertexBuffer.UV5Kind
  22697. * - VertexBuffer.UV6Kind
  22698. * - VertexBuffer.ColorKind
  22699. * - VertexBuffer.MatricesIndicesKind
  22700. * - VertexBuffer.MatricesIndicesExtraKind
  22701. * - VertexBuffer.MatricesWeightsKind
  22702. * - VertexBuffer.MatricesWeightsExtraKind
  22703. * @param data defines the data source
  22704. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22705. * @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)
  22706. */
  22707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22708. /**
  22709. * Creates a new index buffer
  22710. * @param indices defines the indices to store in the index buffer
  22711. * @param totalVertices defines the total number of vertices (could be null)
  22712. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22713. */
  22714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22715. }
  22716. /**
  22717. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22718. */
  22719. export class VertexData {
  22720. /**
  22721. * Mesh side orientation : usually the external or front surface
  22722. */
  22723. static readonly FRONTSIDE: number;
  22724. /**
  22725. * Mesh side orientation : usually the internal or back surface
  22726. */
  22727. static readonly BACKSIDE: number;
  22728. /**
  22729. * Mesh side orientation : both internal and external or front and back surfaces
  22730. */
  22731. static readonly DOUBLESIDE: number;
  22732. /**
  22733. * Mesh side orientation : by default, `FRONTSIDE`
  22734. */
  22735. static readonly DEFAULTSIDE: number;
  22736. /**
  22737. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22738. */
  22739. positions: Nullable<FloatArray>;
  22740. /**
  22741. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22742. */
  22743. normals: Nullable<FloatArray>;
  22744. /**
  22745. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22746. */
  22747. tangents: Nullable<FloatArray>;
  22748. /**
  22749. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22750. */
  22751. uvs: Nullable<FloatArray>;
  22752. /**
  22753. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22754. */
  22755. uvs2: Nullable<FloatArray>;
  22756. /**
  22757. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22758. */
  22759. uvs3: Nullable<FloatArray>;
  22760. /**
  22761. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22762. */
  22763. uvs4: Nullable<FloatArray>;
  22764. /**
  22765. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs5: Nullable<FloatArray>;
  22768. /**
  22769. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs6: Nullable<FloatArray>;
  22772. /**
  22773. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22774. */
  22775. colors: Nullable<FloatArray>;
  22776. /**
  22777. * 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).
  22778. */
  22779. matricesIndices: Nullable<FloatArray>;
  22780. /**
  22781. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22782. */
  22783. matricesWeights: Nullable<FloatArray>;
  22784. /**
  22785. * An array extending the number of possible indices
  22786. */
  22787. matricesIndicesExtra: Nullable<FloatArray>;
  22788. /**
  22789. * An array extending the number of possible weights when the number of indices is extended
  22790. */
  22791. matricesWeightsExtra: Nullable<FloatArray>;
  22792. /**
  22793. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22794. */
  22795. indices: Nullable<IndicesArray>;
  22796. /**
  22797. * Uses the passed data array to set the set the values for the specified kind of data
  22798. * @param data a linear array of floating numbers
  22799. * @param kind the type of data that is being set, eg positions, colors etc
  22800. */
  22801. set(data: FloatArray, kind: string): void;
  22802. /**
  22803. * Associates the vertexData to the passed Mesh.
  22804. * Sets it as updatable or not (default `false`)
  22805. * @param mesh the mesh the vertexData is applied to
  22806. * @param updatable when used and having the value true allows new data to update the vertexData
  22807. * @returns the VertexData
  22808. */
  22809. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22810. /**
  22811. * Associates the vertexData to the passed Geometry.
  22812. * Sets it as updatable or not (default `false`)
  22813. * @param geometry the geometry the vertexData is applied to
  22814. * @param updatable when used and having the value true allows new data to update the vertexData
  22815. * @returns VertexData
  22816. */
  22817. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22818. /**
  22819. * Updates the associated mesh
  22820. * @param mesh the mesh to be updated
  22821. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22822. * @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
  22823. * @returns VertexData
  22824. */
  22825. updateMesh(mesh: Mesh): VertexData;
  22826. /**
  22827. * Updates the associated geometry
  22828. * @param geometry the geometry to be updated
  22829. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22830. * @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
  22831. * @returns VertexData.
  22832. */
  22833. updateGeometry(geometry: Geometry): VertexData;
  22834. private _applyTo;
  22835. private _update;
  22836. /**
  22837. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22838. * @param matrix the transforming matrix
  22839. * @returns the VertexData
  22840. */
  22841. transform(matrix: Matrix): VertexData;
  22842. /**
  22843. * Merges the passed VertexData into the current one
  22844. * @param other the VertexData to be merged into the current one
  22845. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22846. * @returns the modified VertexData
  22847. */
  22848. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22849. private _mergeElement;
  22850. private _validate;
  22851. /**
  22852. * Serializes the VertexData
  22853. * @returns a serialized object
  22854. */
  22855. serialize(): any;
  22856. /**
  22857. * Extracts the vertexData from a mesh
  22858. * @param mesh the mesh from which to extract the VertexData
  22859. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22861. * @returns the object VertexData associated to the passed mesh
  22862. */
  22863. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22864. /**
  22865. * Extracts the vertexData from the geometry
  22866. * @param geometry the geometry from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22868. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22869. * @returns the object VertexData associated to the passed mesh
  22870. */
  22871. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. private static _ExtractFrom;
  22873. /**
  22874. * Creates the VertexData for a Ribbon
  22875. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22876. * * pathArray array of paths, each of which an array of successive Vector3
  22877. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22878. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22879. * * 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
  22880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22881. * * 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)
  22882. * * 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)
  22883. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22884. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22885. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22886. * @returns the VertexData of the ribbon
  22887. */
  22888. static CreateRibbon(options: {
  22889. pathArray: Vector3[][];
  22890. closeArray?: boolean;
  22891. closePath?: boolean;
  22892. offset?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. invertUV?: boolean;
  22897. uvs?: Vector2[];
  22898. colors?: Color4[];
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a box
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22906. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22907. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22908. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the box
  22913. */
  22914. static CreateBox(options: {
  22915. size?: number;
  22916. width?: number;
  22917. height?: number;
  22918. depth?: number;
  22919. faceUV?: Vector4[];
  22920. faceColors?: Color4[];
  22921. sideOrientation?: number;
  22922. frontUVs?: Vector4;
  22923. backUVs?: Vector4;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a tiled box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22929. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22930. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22932. * @returns the VertexData of the box
  22933. */
  22934. static CreateTiledBox(options: {
  22935. pattern?: number;
  22936. width?: number;
  22937. height?: number;
  22938. depth?: number;
  22939. tileSize?: number;
  22940. tileWidth?: number;
  22941. tileHeight?: number;
  22942. alignHorizontal?: number;
  22943. alignVertical?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. }): VertexData;
  22948. /**
  22949. * Creates the VertexData for a tiled plane
  22950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22951. * * pattern a limited pattern arrangement depending on the number
  22952. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22953. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22954. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22956. * * 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)
  22957. * * 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)
  22958. * @returns the VertexData of the tiled plane
  22959. */
  22960. static CreateTiledPlane(options: {
  22961. pattern?: number;
  22962. tileSize?: number;
  22963. tileWidth?: number;
  22964. tileHeight?: number;
  22965. size?: number;
  22966. width?: number;
  22967. height?: number;
  22968. alignHorizontal?: number;
  22969. alignVertical?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22977. * * segments sets the number of horizontal strips optional, default 32
  22978. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22979. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22980. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22981. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22982. * * 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
  22983. * * 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
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * 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)
  22986. * * 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)
  22987. * @returns the VertexData of the ellipsoid
  22988. */
  22989. static CreateSphere(options: {
  22990. segments?: number;
  22991. diameter?: number;
  22992. diameterX?: number;
  22993. diameterY?: number;
  22994. diameterZ?: number;
  22995. arc?: number;
  22996. slice?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a cylinder, cone or prism
  23003. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23004. * * height sets the height (y direction) of the cylinder, optional, default 2
  23005. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23006. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23007. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23008. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23009. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23010. * * 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
  23011. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23012. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23013. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23014. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23016. * * 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)
  23017. * * 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)
  23018. * @returns the VertexData of the cylinder, cone or prism
  23019. */
  23020. static CreateCylinder(options: {
  23021. height?: number;
  23022. diameterTop?: number;
  23023. diameterBottom?: number;
  23024. diameter?: number;
  23025. tessellation?: number;
  23026. subdivisions?: number;
  23027. arc?: number;
  23028. faceColors?: Color4[];
  23029. faceUV?: Vector4[];
  23030. hasRings?: boolean;
  23031. enclose?: boolean;
  23032. sideOrientation?: number;
  23033. frontUVs?: Vector4;
  23034. backUVs?: Vector4;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a torus
  23038. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23039. * * diameter the diameter of the torus, optional default 1
  23040. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23041. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * 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)
  23044. * * 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)
  23045. * @returns the VertexData of the torus
  23046. */
  23047. static CreateTorus(options: {
  23048. diameter?: number;
  23049. thickness?: number;
  23050. tessellation?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData of the LineSystem
  23057. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23058. * - lines an array of lines, each line being an array of successive Vector3
  23059. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23060. * @returns the VertexData of the LineSystem
  23061. */
  23062. static CreateLineSystem(options: {
  23063. lines: Vector3[][];
  23064. colors?: Nullable<Color4[][]>;
  23065. }): VertexData;
  23066. /**
  23067. * Create the VertexData for a DashedLines
  23068. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23069. * - points an array successive Vector3
  23070. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23071. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23072. * - dashNb the intended total number of dashes, optional, default 200
  23073. * @returns the VertexData for the DashedLines
  23074. */
  23075. static CreateDashedLines(options: {
  23076. points: Vector3[];
  23077. dashSize?: number;
  23078. gapSize?: number;
  23079. dashNb?: number;
  23080. }): VertexData;
  23081. /**
  23082. * Creates the VertexData for a Ground
  23083. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23084. * - width the width (x direction) of the ground, optional, default 1
  23085. * - height the height (z direction) of the ground, optional, default 1
  23086. * - subdivisions the number of subdivisions per side, optional, default 1
  23087. * @returns the VertexData of the Ground
  23088. */
  23089. static CreateGround(options: {
  23090. width?: number;
  23091. height?: number;
  23092. subdivisions?: number;
  23093. subdivisionsX?: number;
  23094. subdivisionsY?: number;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23098. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23099. * * xmin the ground minimum X coordinate, optional, default -1
  23100. * * zmin the ground minimum Z coordinate, optional, default -1
  23101. * * xmax the ground maximum X coordinate, optional, default 1
  23102. * * zmax the ground maximum Z coordinate, optional, default 1
  23103. * * 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}
  23104. * * 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}
  23105. * @returns the VertexData of the TiledGround
  23106. */
  23107. static CreateTiledGround(options: {
  23108. xmin: number;
  23109. zmin: number;
  23110. xmax: number;
  23111. zmax: number;
  23112. subdivisions?: {
  23113. w: number;
  23114. h: number;
  23115. };
  23116. precision?: {
  23117. w: number;
  23118. h: number;
  23119. };
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData of the Ground designed from a heightmap
  23123. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23124. * * width the width (x direction) of the ground
  23125. * * height the height (z direction) of the ground
  23126. * * subdivisions the number of subdivisions per side
  23127. * * minHeight the minimum altitude on the ground, optional, default 0
  23128. * * maxHeight the maximum altitude on the ground, optional default 1
  23129. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23130. * * buffer the array holding the image color data
  23131. * * bufferWidth the width of image
  23132. * * bufferHeight the height of image
  23133. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23134. * @returns the VertexData of the Ground designed from a heightmap
  23135. */
  23136. static CreateGroundFromHeightMap(options: {
  23137. width: number;
  23138. height: number;
  23139. subdivisions: number;
  23140. minHeight: number;
  23141. maxHeight: number;
  23142. colorFilter: Color3;
  23143. buffer: Uint8Array;
  23144. bufferWidth: number;
  23145. bufferHeight: number;
  23146. alphaFilter: number;
  23147. }): VertexData;
  23148. /**
  23149. * Creates the VertexData for a Plane
  23150. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23151. * * size sets the width and height of the plane to the value of size, optional default 1
  23152. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23153. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23155. * * 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)
  23156. * * 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)
  23157. * @returns the VertexData of the box
  23158. */
  23159. static CreatePlane(options: {
  23160. size?: number;
  23161. width?: number;
  23162. height?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData of the Disc or regular Polygon
  23169. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23170. * * radius the radius of the disc, optional default 0.5
  23171. * * tessellation the number of polygon sides, optional, default 64
  23172. * * 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
  23173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23174. * * 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)
  23175. * * 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)
  23176. * @returns the VertexData of the box
  23177. */
  23178. static CreateDisc(options: {
  23179. radius?: number;
  23180. tessellation?: number;
  23181. arc?: number;
  23182. sideOrientation?: number;
  23183. frontUVs?: Vector4;
  23184. backUVs?: Vector4;
  23185. }): VertexData;
  23186. /**
  23187. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23188. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23189. * @param polygon a mesh built from polygonTriangulation.build()
  23190. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23191. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23192. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23193. * @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)
  23194. * @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)
  23195. * @returns the VertexData of the Polygon
  23196. */
  23197. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23198. /**
  23199. * Creates the VertexData of the IcoSphere
  23200. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23201. * * radius the radius of the IcoSphere, optional default 1
  23202. * * radiusX allows stretching in the x direction, optional, default radius
  23203. * * radiusY allows stretching in the y direction, optional, default radius
  23204. * * radiusZ allows stretching in the z direction, optional, default radius
  23205. * * flat when true creates a flat shaded mesh, optional, default true
  23206. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * 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)
  23209. * * 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)
  23210. * @returns the VertexData of the IcoSphere
  23211. */
  23212. static CreateIcoSphere(options: {
  23213. radius?: number;
  23214. radiusX?: number;
  23215. radiusY?: number;
  23216. radiusZ?: number;
  23217. flat?: boolean;
  23218. subdivisions?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a Polyhedron
  23225. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23226. * * type provided types are:
  23227. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23228. * * 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)
  23229. * * size the size of the IcoSphere, optional default 1
  23230. * * sizeX allows stretching in the x direction, optional, default size
  23231. * * sizeY allows stretching in the y direction, optional, default size
  23232. * * sizeZ allows stretching in the z direction, optional, default size
  23233. * * 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
  23234. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23235. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23236. * * flat when true creates a flat shaded mesh, optional, default true
  23237. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * @returns the VertexData of the Polyhedron
  23242. */
  23243. static CreatePolyhedron(options: {
  23244. type?: number;
  23245. size?: number;
  23246. sizeX?: number;
  23247. sizeY?: number;
  23248. sizeZ?: number;
  23249. custom?: any;
  23250. faceUV?: Vector4[];
  23251. faceColors?: Color4[];
  23252. flat?: boolean;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. }): VertexData;
  23257. /**
  23258. * Creates the VertexData for a TorusKnot
  23259. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23260. * * radius the radius of the torus knot, optional, default 2
  23261. * * tube the thickness of the tube, optional, default 0.5
  23262. * * radialSegments the number of sides on each tube segments, optional, default 32
  23263. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23264. * * p the number of windings around the z axis, optional, default 2
  23265. * * q the number of windings around the x axis, optional, default 3
  23266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23267. * * 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)
  23268. * * 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)
  23269. * @returns the VertexData of the Torus Knot
  23270. */
  23271. static CreateTorusKnot(options: {
  23272. radius?: number;
  23273. tube?: number;
  23274. radialSegments?: number;
  23275. tubularSegments?: number;
  23276. p?: number;
  23277. q?: number;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Compute normals for given positions and indices
  23284. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23285. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23286. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23287. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23288. * * facetNormals : optional array of facet normals (vector3)
  23289. * * facetPositions : optional array of facet positions (vector3)
  23290. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23291. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23292. * * bInfo : optional bounding info, required for facetPartitioning computation
  23293. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23294. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23295. * * useRightHandedSystem: optional boolean to for right handed system computation
  23296. * * depthSort : optional boolean to enable the facet depth sort computation
  23297. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23298. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23299. */
  23300. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23301. facetNormals?: any;
  23302. facetPositions?: any;
  23303. facetPartitioning?: any;
  23304. ratio?: number;
  23305. bInfo?: any;
  23306. bbSize?: Vector3;
  23307. subDiv?: any;
  23308. useRightHandedSystem?: boolean;
  23309. depthSort?: boolean;
  23310. distanceTo?: Vector3;
  23311. depthSortedFacets?: any;
  23312. }): void;
  23313. /** @hidden */
  23314. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23315. /**
  23316. * Applies VertexData created from the imported parameters to the geometry
  23317. * @param parsedVertexData the parsed data from an imported file
  23318. * @param geometry the geometry to apply the VertexData to
  23319. */
  23320. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23321. }
  23322. }
  23323. declare module "babylonjs/Morph/morphTarget" {
  23324. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23325. import { Observable } from "babylonjs/Misc/observable";
  23326. import { Nullable, FloatArray } from "babylonjs/types";
  23327. import { Scene } from "babylonjs/scene";
  23328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23329. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23330. /**
  23331. * Defines a target to use with MorphTargetManager
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23333. */
  23334. export class MorphTarget implements IAnimatable {
  23335. /** defines the name of the target */
  23336. name: string;
  23337. /**
  23338. * Gets or sets the list of animations
  23339. */
  23340. animations: import("babylonjs/Animations/animation").Animation[];
  23341. private _scene;
  23342. private _positions;
  23343. private _normals;
  23344. private _tangents;
  23345. private _uvs;
  23346. private _influence;
  23347. private _uniqueId;
  23348. /**
  23349. * Observable raised when the influence changes
  23350. */
  23351. onInfluenceChanged: Observable<boolean>;
  23352. /** @hidden */
  23353. _onDataLayoutChanged: Observable<void>;
  23354. /**
  23355. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23356. */
  23357. get influence(): number;
  23358. set influence(influence: number);
  23359. /**
  23360. * Gets or sets the id of the morph Target
  23361. */
  23362. id: string;
  23363. private _animationPropertiesOverride;
  23364. /**
  23365. * Gets or sets the animation properties override
  23366. */
  23367. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23368. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23369. /**
  23370. * Creates a new MorphTarget
  23371. * @param name defines the name of the target
  23372. * @param influence defines the influence to use
  23373. * @param scene defines the scene the morphtarget belongs to
  23374. */
  23375. constructor(
  23376. /** defines the name of the target */
  23377. name: string, influence?: number, scene?: Nullable<Scene>);
  23378. /**
  23379. * Gets the unique ID of this manager
  23380. */
  23381. get uniqueId(): number;
  23382. /**
  23383. * Gets a boolean defining if the target contains position data
  23384. */
  23385. get hasPositions(): boolean;
  23386. /**
  23387. * Gets a boolean defining if the target contains normal data
  23388. */
  23389. get hasNormals(): boolean;
  23390. /**
  23391. * Gets a boolean defining if the target contains tangent data
  23392. */
  23393. get hasTangents(): boolean;
  23394. /**
  23395. * Gets a boolean defining if the target contains texture coordinates data
  23396. */
  23397. get hasUVs(): boolean;
  23398. /**
  23399. * Affects position data to this target
  23400. * @param data defines the position data to use
  23401. */
  23402. setPositions(data: Nullable<FloatArray>): void;
  23403. /**
  23404. * Gets the position data stored in this target
  23405. * @returns a FloatArray containing the position data (or null if not present)
  23406. */
  23407. getPositions(): Nullable<FloatArray>;
  23408. /**
  23409. * Affects normal data to this target
  23410. * @param data defines the normal data to use
  23411. */
  23412. setNormals(data: Nullable<FloatArray>): void;
  23413. /**
  23414. * Gets the normal data stored in this target
  23415. * @returns a FloatArray containing the normal data (or null if not present)
  23416. */
  23417. getNormals(): Nullable<FloatArray>;
  23418. /**
  23419. * Affects tangent data to this target
  23420. * @param data defines the tangent data to use
  23421. */
  23422. setTangents(data: Nullable<FloatArray>): void;
  23423. /**
  23424. * Gets the tangent data stored in this target
  23425. * @returns a FloatArray containing the tangent data (or null if not present)
  23426. */
  23427. getTangents(): Nullable<FloatArray>;
  23428. /**
  23429. * Affects texture coordinates data to this target
  23430. * @param data defines the texture coordinates data to use
  23431. */
  23432. setUVs(data: Nullable<FloatArray>): void;
  23433. /**
  23434. * Gets the texture coordinates data stored in this target
  23435. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23436. */
  23437. getUVs(): Nullable<FloatArray>;
  23438. /**
  23439. * Clone the current target
  23440. * @returns a new MorphTarget
  23441. */
  23442. clone(): MorphTarget;
  23443. /**
  23444. * Serializes the current target into a Serialization object
  23445. * @returns the serialized object
  23446. */
  23447. serialize(): any;
  23448. /**
  23449. * Returns the string "MorphTarget"
  23450. * @returns "MorphTarget"
  23451. */
  23452. getClassName(): string;
  23453. /**
  23454. * Creates a new target from serialized data
  23455. * @param serializationObject defines the serialized data to use
  23456. * @returns a new MorphTarget
  23457. */
  23458. static Parse(serializationObject: any): MorphTarget;
  23459. /**
  23460. * Creates a MorphTarget from mesh data
  23461. * @param mesh defines the source mesh
  23462. * @param name defines the name to use for the new target
  23463. * @param influence defines the influence to attach to the target
  23464. * @returns a new MorphTarget
  23465. */
  23466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23467. }
  23468. }
  23469. declare module "babylonjs/Morph/morphTargetManager" {
  23470. import { Nullable } from "babylonjs/types";
  23471. import { Scene } from "babylonjs/scene";
  23472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23473. /**
  23474. * This class is used to deform meshes using morphing between different targets
  23475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23476. */
  23477. export class MorphTargetManager {
  23478. private _targets;
  23479. private _targetInfluenceChangedObservers;
  23480. private _targetDataLayoutChangedObservers;
  23481. private _activeTargets;
  23482. private _scene;
  23483. private _influences;
  23484. private _supportsNormals;
  23485. private _supportsTangents;
  23486. private _supportsUVs;
  23487. private _vertexCount;
  23488. private _uniqueId;
  23489. private _tempInfluences;
  23490. /**
  23491. * Gets or sets a boolean indicating if normals must be morphed
  23492. */
  23493. enableNormalMorphing: boolean;
  23494. /**
  23495. * Gets or sets a boolean indicating if tangents must be morphed
  23496. */
  23497. enableTangentMorphing: boolean;
  23498. /**
  23499. * Gets or sets a boolean indicating if UV must be morphed
  23500. */
  23501. enableUVMorphing: boolean;
  23502. /**
  23503. * Creates a new MorphTargetManager
  23504. * @param scene defines the current scene
  23505. */
  23506. constructor(scene?: Nullable<Scene>);
  23507. /**
  23508. * Gets the unique ID of this manager
  23509. */
  23510. get uniqueId(): number;
  23511. /**
  23512. * Gets the number of vertices handled by this manager
  23513. */
  23514. get vertexCount(): number;
  23515. /**
  23516. * Gets a boolean indicating if this manager supports morphing of normals
  23517. */
  23518. get supportsNormals(): boolean;
  23519. /**
  23520. * Gets a boolean indicating if this manager supports morphing of tangents
  23521. */
  23522. get supportsTangents(): boolean;
  23523. /**
  23524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23525. */
  23526. get supportsUVs(): boolean;
  23527. /**
  23528. * Gets the number of targets stored in this manager
  23529. */
  23530. get numTargets(): number;
  23531. /**
  23532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23533. */
  23534. get numInfluencers(): number;
  23535. /**
  23536. * Gets the list of influences (one per target)
  23537. */
  23538. get influences(): Float32Array;
  23539. /**
  23540. * Gets the active target at specified index. An active target is a target with an influence > 0
  23541. * @param index defines the index to check
  23542. * @returns the requested target
  23543. */
  23544. getActiveTarget(index: number): MorphTarget;
  23545. /**
  23546. * Gets the target at specified index
  23547. * @param index defines the index to check
  23548. * @returns the requested target
  23549. */
  23550. getTarget(index: number): MorphTarget;
  23551. /**
  23552. * Add a new target to this manager
  23553. * @param target defines the target to add
  23554. */
  23555. addTarget(target: MorphTarget): void;
  23556. /**
  23557. * Removes a target from the manager
  23558. * @param target defines the target to remove
  23559. */
  23560. removeTarget(target: MorphTarget): void;
  23561. /**
  23562. * Clone the current manager
  23563. * @returns a new MorphTargetManager
  23564. */
  23565. clone(): MorphTargetManager;
  23566. /**
  23567. * Serializes the current manager into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. private _syncActiveTargets;
  23572. /**
  23573. * Syncrhonize the targets with all the meshes using this morph target manager
  23574. */
  23575. synchronize(): void;
  23576. /**
  23577. * Creates a new MorphTargetManager from serialized data
  23578. * @param serializationObject defines the serialized data
  23579. * @param scene defines the hosting scene
  23580. * @returns the new MorphTargetManager
  23581. */
  23582. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23583. }
  23584. }
  23585. declare module "babylonjs/Meshes/meshLODLevel" {
  23586. import { Mesh } from "babylonjs/Meshes/mesh";
  23587. import { Nullable } from "babylonjs/types";
  23588. /**
  23589. * Class used to represent a specific level of detail of a mesh
  23590. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23591. */
  23592. export class MeshLODLevel {
  23593. /** Defines the distance where this level should start being displayed */
  23594. distance: number;
  23595. /** Defines the mesh to use to render this level */
  23596. mesh: Nullable<Mesh>;
  23597. /**
  23598. * Creates a new LOD level
  23599. * @param distance defines the distance where this level should star being displayed
  23600. * @param mesh defines the mesh to use to render this level
  23601. */
  23602. constructor(
  23603. /** Defines the distance where this level should start being displayed */
  23604. distance: number,
  23605. /** Defines the mesh to use to render this level */
  23606. mesh: Nullable<Mesh>);
  23607. }
  23608. }
  23609. declare module "babylonjs/Meshes/groundMesh" {
  23610. import { Scene } from "babylonjs/scene";
  23611. import { Vector3 } from "babylonjs/Maths/math.vector";
  23612. import { Mesh } from "babylonjs/Meshes/mesh";
  23613. /**
  23614. * Mesh representing the gorund
  23615. */
  23616. export class GroundMesh extends Mesh {
  23617. /** If octree should be generated */
  23618. generateOctree: boolean;
  23619. private _heightQuads;
  23620. /** @hidden */
  23621. _subdivisionsX: number;
  23622. /** @hidden */
  23623. _subdivisionsY: number;
  23624. /** @hidden */
  23625. _width: number;
  23626. /** @hidden */
  23627. _height: number;
  23628. /** @hidden */
  23629. _minX: number;
  23630. /** @hidden */
  23631. _maxX: number;
  23632. /** @hidden */
  23633. _minZ: number;
  23634. /** @hidden */
  23635. _maxZ: number;
  23636. constructor(name: string, scene: Scene);
  23637. /**
  23638. * "GroundMesh"
  23639. * @returns "GroundMesh"
  23640. */
  23641. getClassName(): string;
  23642. /**
  23643. * The minimum of x and y subdivisions
  23644. */
  23645. get subdivisions(): number;
  23646. /**
  23647. * X subdivisions
  23648. */
  23649. get subdivisionsX(): number;
  23650. /**
  23651. * Y subdivisions
  23652. */
  23653. get subdivisionsY(): number;
  23654. /**
  23655. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23656. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23657. * @param chunksCount the number of subdivisions for x and y
  23658. * @param octreeBlocksSize (Default: 32)
  23659. */
  23660. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23661. /**
  23662. * Returns a height (y) value in the Worl system :
  23663. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23664. * @param x x coordinate
  23665. * @param z z coordinate
  23666. * @returns the ground y position if (x, z) are outside the ground surface.
  23667. */
  23668. getHeightAtCoordinates(x: number, z: number): number;
  23669. /**
  23670. * Returns a normalized vector (Vector3) orthogonal to the ground
  23671. * at the ground coordinates (x, z) expressed in the World system.
  23672. * @param x x coordinate
  23673. * @param z z coordinate
  23674. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23675. */
  23676. getNormalAtCoordinates(x: number, z: number): Vector3;
  23677. /**
  23678. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23679. * at the ground coordinates (x, z) expressed in the World system.
  23680. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23681. * @param x x coordinate
  23682. * @param z z coordinate
  23683. * @param ref vector to store the result
  23684. * @returns the GroundMesh.
  23685. */
  23686. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23687. /**
  23688. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23689. * if the ground has been updated.
  23690. * This can be used in the render loop.
  23691. * @returns the GroundMesh.
  23692. */
  23693. updateCoordinateHeights(): GroundMesh;
  23694. private _getFacetAt;
  23695. private _initHeightQuads;
  23696. private _computeHeightQuads;
  23697. /**
  23698. * Serializes this ground mesh
  23699. * @param serializationObject object to write serialization to
  23700. */
  23701. serialize(serializationObject: any): void;
  23702. /**
  23703. * Parses a serialized ground mesh
  23704. * @param parsedMesh the serialized mesh
  23705. * @param scene the scene to create the ground mesh in
  23706. * @returns the created ground mesh
  23707. */
  23708. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23709. }
  23710. }
  23711. declare module "babylonjs/Physics/physicsJoint" {
  23712. import { Vector3 } from "babylonjs/Maths/math.vector";
  23713. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23714. /**
  23715. * Interface for Physics-Joint data
  23716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23717. */
  23718. export interface PhysicsJointData {
  23719. /**
  23720. * The main pivot of the joint
  23721. */
  23722. mainPivot?: Vector3;
  23723. /**
  23724. * The connected pivot of the joint
  23725. */
  23726. connectedPivot?: Vector3;
  23727. /**
  23728. * The main axis of the joint
  23729. */
  23730. mainAxis?: Vector3;
  23731. /**
  23732. * The connected axis of the joint
  23733. */
  23734. connectedAxis?: Vector3;
  23735. /**
  23736. * The collision of the joint
  23737. */
  23738. collision?: boolean;
  23739. /**
  23740. * Native Oimo/Cannon/Energy data
  23741. */
  23742. nativeParams?: any;
  23743. }
  23744. /**
  23745. * This is a holder class for the physics joint created by the physics plugin
  23746. * It holds a set of functions to control the underlying joint
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export class PhysicsJoint {
  23750. /**
  23751. * The type of the physics joint
  23752. */
  23753. type: number;
  23754. /**
  23755. * The data for the physics joint
  23756. */
  23757. jointData: PhysicsJointData;
  23758. private _physicsJoint;
  23759. protected _physicsPlugin: IPhysicsEnginePlugin;
  23760. /**
  23761. * Initializes the physics joint
  23762. * @param type The type of the physics joint
  23763. * @param jointData The data for the physics joint
  23764. */
  23765. constructor(
  23766. /**
  23767. * The type of the physics joint
  23768. */
  23769. type: number,
  23770. /**
  23771. * The data for the physics joint
  23772. */
  23773. jointData: PhysicsJointData);
  23774. /**
  23775. * Gets the physics joint
  23776. */
  23777. get physicsJoint(): any;
  23778. /**
  23779. * Sets the physics joint
  23780. */
  23781. set physicsJoint(newJoint: any);
  23782. /**
  23783. * Sets the physics plugin
  23784. */
  23785. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23786. /**
  23787. * Execute a function that is physics-plugin specific.
  23788. * @param {Function} func the function that will be executed.
  23789. * It accepts two parameters: the physics world and the physics joint
  23790. */
  23791. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23792. /**
  23793. * Distance-Joint type
  23794. */
  23795. static DistanceJoint: number;
  23796. /**
  23797. * Hinge-Joint type
  23798. */
  23799. static HingeJoint: number;
  23800. /**
  23801. * Ball-and-Socket joint type
  23802. */
  23803. static BallAndSocketJoint: number;
  23804. /**
  23805. * Wheel-Joint type
  23806. */
  23807. static WheelJoint: number;
  23808. /**
  23809. * Slider-Joint type
  23810. */
  23811. static SliderJoint: number;
  23812. /**
  23813. * Prismatic-Joint type
  23814. */
  23815. static PrismaticJoint: number;
  23816. /**
  23817. * Universal-Joint type
  23818. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23819. */
  23820. static UniversalJoint: number;
  23821. /**
  23822. * Hinge-Joint 2 type
  23823. */
  23824. static Hinge2Joint: number;
  23825. /**
  23826. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23827. */
  23828. static PointToPointJoint: number;
  23829. /**
  23830. * Spring-Joint type
  23831. */
  23832. static SpringJoint: number;
  23833. /**
  23834. * Lock-Joint type
  23835. */
  23836. static LockJoint: number;
  23837. }
  23838. /**
  23839. * A class representing a physics distance joint
  23840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23841. */
  23842. export class DistanceJoint extends PhysicsJoint {
  23843. /**
  23844. *
  23845. * @param jointData The data for the Distance-Joint
  23846. */
  23847. constructor(jointData: DistanceJointData);
  23848. /**
  23849. * Update the predefined distance.
  23850. * @param maxDistance The maximum preferred distance
  23851. * @param minDistance The minimum preferred distance
  23852. */
  23853. updateDistance(maxDistance: number, minDistance?: number): void;
  23854. }
  23855. /**
  23856. * Represents a Motor-Enabled Joint
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23860. /**
  23861. * Initializes the Motor-Enabled Joint
  23862. * @param type The type of the joint
  23863. * @param jointData The physica joint data for the joint
  23864. */
  23865. constructor(type: number, jointData: PhysicsJointData);
  23866. /**
  23867. * Set the motor values.
  23868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23869. * @param force the force to apply
  23870. * @param maxForce max force for this motor.
  23871. */
  23872. setMotor(force?: number, maxForce?: number): void;
  23873. /**
  23874. * Set the motor's limits.
  23875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23876. * @param upperLimit The upper limit of the motor
  23877. * @param lowerLimit The lower limit of the motor
  23878. */
  23879. setLimit(upperLimit: number, lowerLimit?: number): void;
  23880. }
  23881. /**
  23882. * This class represents a single physics Hinge-Joint
  23883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23884. */
  23885. export class HingeJoint extends MotorEnabledJoint {
  23886. /**
  23887. * Initializes the Hinge-Joint
  23888. * @param jointData The joint data for the Hinge-Joint
  23889. */
  23890. constructor(jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param {number} force the force to apply
  23895. * @param {number} maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a dual hinge physics joint (same as wheel joint)
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class Hinge2Joint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge2-Joint
  23913. * @param jointData The joint data for the Hinge2-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} targetSpeed the speed the motor is to reach
  23920. * @param {number} maxForce max force for this motor.
  23921. * @param {motorIndex} the motor's index, 0 or 1.
  23922. */
  23923. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23924. /**
  23925. * Set the motor limits.
  23926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23927. * @param {number} upperLimit the upper limit
  23928. * @param {number} lowerLimit lower limit
  23929. * @param {motorIndex} the motor's index, 0 or 1.
  23930. */
  23931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23932. }
  23933. /**
  23934. * Interface for a motor enabled joint
  23935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23936. */
  23937. export interface IMotorEnabledJoint {
  23938. /**
  23939. * Physics joint
  23940. */
  23941. physicsJoint: any;
  23942. /**
  23943. * Sets the motor of the motor-enabled joint
  23944. * @param force The force of the motor
  23945. * @param maxForce The maximum force of the motor
  23946. * @param motorIndex The index of the motor
  23947. */
  23948. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Sets the limit of the motor
  23951. * @param upperLimit The upper limit of the motor
  23952. * @param lowerLimit The lower limit of the motor
  23953. * @param motorIndex The index of the motor
  23954. */
  23955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23956. }
  23957. /**
  23958. * Joint data for a Distance-Joint
  23959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23960. */
  23961. export interface DistanceJointData extends PhysicsJointData {
  23962. /**
  23963. * Max distance the 2 joint objects can be apart
  23964. */
  23965. maxDistance: number;
  23966. }
  23967. /**
  23968. * Joint data from a spring joint
  23969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23970. */
  23971. export interface SpringJointData extends PhysicsJointData {
  23972. /**
  23973. * Length of the spring
  23974. */
  23975. length: number;
  23976. /**
  23977. * Stiffness of the spring
  23978. */
  23979. stiffness: number;
  23980. /**
  23981. * Damping of the spring
  23982. */
  23983. damping: number;
  23984. /** this callback will be called when applying the force to the impostors. */
  23985. forceApplicationCallback: () => void;
  23986. }
  23987. }
  23988. declare module "babylonjs/Physics/physicsRaycastResult" {
  23989. import { Vector3 } from "babylonjs/Maths/math.vector";
  23990. /**
  23991. * Holds the data for the raycast result
  23992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23993. */
  23994. export class PhysicsRaycastResult {
  23995. private _hasHit;
  23996. private _hitDistance;
  23997. private _hitNormalWorld;
  23998. private _hitPointWorld;
  23999. private _rayFromWorld;
  24000. private _rayToWorld;
  24001. /**
  24002. * Gets if there was a hit
  24003. */
  24004. get hasHit(): boolean;
  24005. /**
  24006. * Gets the distance from the hit
  24007. */
  24008. get hitDistance(): number;
  24009. /**
  24010. * Gets the hit normal/direction in the world
  24011. */
  24012. get hitNormalWorld(): Vector3;
  24013. /**
  24014. * Gets the hit point in the world
  24015. */
  24016. get hitPointWorld(): Vector3;
  24017. /**
  24018. * Gets the ray "start point" of the ray in the world
  24019. */
  24020. get rayFromWorld(): Vector3;
  24021. /**
  24022. * Gets the ray "end point" of the ray in the world
  24023. */
  24024. get rayToWorld(): Vector3;
  24025. /**
  24026. * Sets the hit data (normal & point in world space)
  24027. * @param hitNormalWorld defines the normal in world space
  24028. * @param hitPointWorld defines the point in world space
  24029. */
  24030. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24031. /**
  24032. * Sets the distance from the start point to the hit point
  24033. * @param distance
  24034. */
  24035. setHitDistance(distance: number): void;
  24036. /**
  24037. * Calculates the distance manually
  24038. */
  24039. calculateHitDistance(): void;
  24040. /**
  24041. * Resets all the values to default
  24042. * @param from The from point on world space
  24043. * @param to The to point on world space
  24044. */
  24045. reset(from?: Vector3, to?: Vector3): void;
  24046. }
  24047. /**
  24048. * Interface for the size containing width and height
  24049. */
  24050. interface IXYZ {
  24051. /**
  24052. * X
  24053. */
  24054. x: number;
  24055. /**
  24056. * Y
  24057. */
  24058. y: number;
  24059. /**
  24060. * Z
  24061. */
  24062. z: number;
  24063. }
  24064. }
  24065. declare module "babylonjs/Physics/IPhysicsEngine" {
  24066. import { Nullable } from "babylonjs/types";
  24067. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24069. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24070. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24071. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24072. /**
  24073. * Interface used to describe a physics joint
  24074. */
  24075. export interface PhysicsImpostorJoint {
  24076. /** Defines the main impostor to which the joint is linked */
  24077. mainImpostor: PhysicsImpostor;
  24078. /** Defines the impostor that is connected to the main impostor using this joint */
  24079. connectedImpostor: PhysicsImpostor;
  24080. /** Defines the joint itself */
  24081. joint: PhysicsJoint;
  24082. }
  24083. /** @hidden */
  24084. export interface IPhysicsEnginePlugin {
  24085. world: any;
  24086. name: string;
  24087. setGravity(gravity: Vector3): void;
  24088. setTimeStep(timeStep: number): void;
  24089. getTimeStep(): number;
  24090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24094. removePhysicsBody(impostor: PhysicsImpostor): void;
  24095. generateJoint(joint: PhysicsImpostorJoint): void;
  24096. removeJoint(joint: PhysicsImpostorJoint): void;
  24097. isSupported(): boolean;
  24098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24105. getBodyMass(impostor: PhysicsImpostor): number;
  24106. getBodyFriction(impostor: PhysicsImpostor): number;
  24107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24108. getBodyRestitution(impostor: PhysicsImpostor): number;
  24109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24110. getBodyPressure?(impostor: PhysicsImpostor): number;
  24111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24120. sleepBody(impostor: PhysicsImpostor): void;
  24121. wakeUpBody(impostor: PhysicsImpostor): void;
  24122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24126. getRadius(impostor: PhysicsImpostor): number;
  24127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24129. dispose(): void;
  24130. }
  24131. /**
  24132. * Interface used to define a physics engine
  24133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24134. */
  24135. export interface IPhysicsEngine {
  24136. /**
  24137. * Gets the gravity vector used by the simulation
  24138. */
  24139. gravity: Vector3;
  24140. /**
  24141. * Sets the gravity vector used by the simulation
  24142. * @param gravity defines the gravity vector to use
  24143. */
  24144. setGravity(gravity: Vector3): void;
  24145. /**
  24146. * Set the time step of the physics engine.
  24147. * Default is 1/60.
  24148. * To slow it down, enter 1/600 for example.
  24149. * To speed it up, 1/30
  24150. * @param newTimeStep the new timestep to apply to this world.
  24151. */
  24152. setTimeStep(newTimeStep: number): void;
  24153. /**
  24154. * Get the time step of the physics engine.
  24155. * @returns the current time step
  24156. */
  24157. getTimeStep(): number;
  24158. /**
  24159. * Set the sub time step of the physics engine.
  24160. * Default is 0 meaning there is no sub steps
  24161. * To increase physics resolution precision, set a small value (like 1 ms)
  24162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24163. */
  24164. setSubTimeStep(subTimeStep: number): void;
  24165. /**
  24166. * Get the sub time step of the physics engine.
  24167. * @returns the current sub time step
  24168. */
  24169. getSubTimeStep(): number;
  24170. /**
  24171. * Release all resources
  24172. */
  24173. dispose(): void;
  24174. /**
  24175. * Gets the name of the current physics plugin
  24176. * @returns the name of the plugin
  24177. */
  24178. getPhysicsPluginName(): string;
  24179. /**
  24180. * Adding a new impostor for the impostor tracking.
  24181. * This will be done by the impostor itself.
  24182. * @param impostor the impostor to add
  24183. */
  24184. addImpostor(impostor: PhysicsImpostor): void;
  24185. /**
  24186. * Remove an impostor from the engine.
  24187. * This impostor and its mesh will not longer be updated by the physics engine.
  24188. * @param impostor the impostor to remove
  24189. */
  24190. removeImpostor(impostor: PhysicsImpostor): void;
  24191. /**
  24192. * Add a joint to the physics engine
  24193. * @param mainImpostor defines the main impostor to which the joint is added.
  24194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24195. * @param joint defines the joint that will connect both impostors.
  24196. */
  24197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24198. /**
  24199. * Removes a joint from the simulation
  24200. * @param mainImpostor defines the impostor used with the joint
  24201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24202. * @param joint defines the joint to remove
  24203. */
  24204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24205. /**
  24206. * Gets the current plugin used to run the simulation
  24207. * @returns current plugin
  24208. */
  24209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24210. /**
  24211. * Gets the list of physic impostors
  24212. * @returns an array of PhysicsImpostor
  24213. */
  24214. getImpostors(): Array<PhysicsImpostor>;
  24215. /**
  24216. * Gets the impostor for a physics enabled object
  24217. * @param object defines the object impersonated by the impostor
  24218. * @returns the PhysicsImpostor or null if not found
  24219. */
  24220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24221. /**
  24222. * Gets the impostor for a physics body object
  24223. * @param body defines physics body used by the impostor
  24224. * @returns the PhysicsImpostor or null if not found
  24225. */
  24226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24227. /**
  24228. * Does a raycast in the physics world
  24229. * @param from when should the ray start?
  24230. * @param to when should the ray end?
  24231. * @returns PhysicsRaycastResult
  24232. */
  24233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24234. /**
  24235. * Called by the scene. No need to call it.
  24236. * @param delta defines the timespam between frames
  24237. */
  24238. _step(delta: number): void;
  24239. }
  24240. }
  24241. declare module "babylonjs/Physics/physicsImpostor" {
  24242. import { Nullable, IndicesArray } from "babylonjs/types";
  24243. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24246. import { Scene } from "babylonjs/scene";
  24247. import { Bone } from "babylonjs/Bones/bone";
  24248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24249. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24250. import { Space } from "babylonjs/Maths/math.axis";
  24251. /**
  24252. * The interface for the physics imposter parameters
  24253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24254. */
  24255. export interface PhysicsImpostorParameters {
  24256. /**
  24257. * The mass of the physics imposter
  24258. */
  24259. mass: number;
  24260. /**
  24261. * The friction of the physics imposter
  24262. */
  24263. friction?: number;
  24264. /**
  24265. * The coefficient of restitution of the physics imposter
  24266. */
  24267. restitution?: number;
  24268. /**
  24269. * The native options of the physics imposter
  24270. */
  24271. nativeOptions?: any;
  24272. /**
  24273. * Specifies if the parent should be ignored
  24274. */
  24275. ignoreParent?: boolean;
  24276. /**
  24277. * Specifies if bi-directional transformations should be disabled
  24278. */
  24279. disableBidirectionalTransformation?: boolean;
  24280. /**
  24281. * The pressure inside the physics imposter, soft object only
  24282. */
  24283. pressure?: number;
  24284. /**
  24285. * The stiffness the physics imposter, soft object only
  24286. */
  24287. stiffness?: number;
  24288. /**
  24289. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24290. */
  24291. velocityIterations?: number;
  24292. /**
  24293. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24294. */
  24295. positionIterations?: number;
  24296. /**
  24297. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24298. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24299. * Add to fix multiple points
  24300. */
  24301. fixedPoints?: number;
  24302. /**
  24303. * The collision margin around a soft object
  24304. */
  24305. margin?: number;
  24306. /**
  24307. * The collision margin around a soft object
  24308. */
  24309. damping?: number;
  24310. /**
  24311. * The path for a rope based on an extrusion
  24312. */
  24313. path?: any;
  24314. /**
  24315. * The shape of an extrusion used for a rope based on an extrusion
  24316. */
  24317. shape?: any;
  24318. }
  24319. /**
  24320. * Interface for a physics-enabled object
  24321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24322. */
  24323. export interface IPhysicsEnabledObject {
  24324. /**
  24325. * The position of the physics-enabled object
  24326. */
  24327. position: Vector3;
  24328. /**
  24329. * The rotation of the physics-enabled object
  24330. */
  24331. rotationQuaternion: Nullable<Quaternion>;
  24332. /**
  24333. * The scale of the physics-enabled object
  24334. */
  24335. scaling: Vector3;
  24336. /**
  24337. * The rotation of the physics-enabled object
  24338. */
  24339. rotation?: Vector3;
  24340. /**
  24341. * The parent of the physics-enabled object
  24342. */
  24343. parent?: any;
  24344. /**
  24345. * The bounding info of the physics-enabled object
  24346. * @returns The bounding info of the physics-enabled object
  24347. */
  24348. getBoundingInfo(): BoundingInfo;
  24349. /**
  24350. * Computes the world matrix
  24351. * @param force Specifies if the world matrix should be computed by force
  24352. * @returns A world matrix
  24353. */
  24354. computeWorldMatrix(force: boolean): Matrix;
  24355. /**
  24356. * Gets the world matrix
  24357. * @returns A world matrix
  24358. */
  24359. getWorldMatrix?(): Matrix;
  24360. /**
  24361. * Gets the child meshes
  24362. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24363. * @returns An array of abstract meshes
  24364. */
  24365. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24366. /**
  24367. * Gets the vertex data
  24368. * @param kind The type of vertex data
  24369. * @returns A nullable array of numbers, or a float32 array
  24370. */
  24371. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24372. /**
  24373. * Gets the indices from the mesh
  24374. * @returns A nullable array of index arrays
  24375. */
  24376. getIndices?(): Nullable<IndicesArray>;
  24377. /**
  24378. * Gets the scene from the mesh
  24379. * @returns the indices array or null
  24380. */
  24381. getScene?(): Scene;
  24382. /**
  24383. * Gets the absolute position from the mesh
  24384. * @returns the absolute position
  24385. */
  24386. getAbsolutePosition(): Vector3;
  24387. /**
  24388. * Gets the absolute pivot point from the mesh
  24389. * @returns the absolute pivot point
  24390. */
  24391. getAbsolutePivotPoint(): Vector3;
  24392. /**
  24393. * Rotates the mesh
  24394. * @param axis The axis of rotation
  24395. * @param amount The amount of rotation
  24396. * @param space The space of the rotation
  24397. * @returns The rotation transform node
  24398. */
  24399. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24400. /**
  24401. * Translates the mesh
  24402. * @param axis The axis of translation
  24403. * @param distance The distance of translation
  24404. * @param space The space of the translation
  24405. * @returns The transform node
  24406. */
  24407. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24408. /**
  24409. * Sets the absolute position of the mesh
  24410. * @param absolutePosition The absolute position of the mesh
  24411. * @returns The transform node
  24412. */
  24413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24414. /**
  24415. * Gets the class name of the mesh
  24416. * @returns The class name
  24417. */
  24418. getClassName(): string;
  24419. }
  24420. /**
  24421. * Represents a physics imposter
  24422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24423. */
  24424. export class PhysicsImpostor {
  24425. /**
  24426. * The physics-enabled object used as the physics imposter
  24427. */
  24428. object: IPhysicsEnabledObject;
  24429. /**
  24430. * The type of the physics imposter
  24431. */
  24432. type: number;
  24433. private _options;
  24434. private _scene?;
  24435. /**
  24436. * The default object size of the imposter
  24437. */
  24438. static DEFAULT_OBJECT_SIZE: Vector3;
  24439. /**
  24440. * The identity quaternion of the imposter
  24441. */
  24442. static IDENTITY_QUATERNION: Quaternion;
  24443. /** @hidden */
  24444. _pluginData: any;
  24445. private _physicsEngine;
  24446. private _physicsBody;
  24447. private _bodyUpdateRequired;
  24448. private _onBeforePhysicsStepCallbacks;
  24449. private _onAfterPhysicsStepCallbacks;
  24450. /** @hidden */
  24451. _onPhysicsCollideCallbacks: Array<{
  24452. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24453. otherImpostors: Array<PhysicsImpostor>;
  24454. }>;
  24455. private _deltaPosition;
  24456. private _deltaRotation;
  24457. private _deltaRotationConjugated;
  24458. /** @hidden */
  24459. _isFromLine: boolean;
  24460. private _parent;
  24461. private _isDisposed;
  24462. private static _tmpVecs;
  24463. private static _tmpQuat;
  24464. /**
  24465. * Specifies if the physics imposter is disposed
  24466. */
  24467. get isDisposed(): boolean;
  24468. /**
  24469. * Gets the mass of the physics imposter
  24470. */
  24471. get mass(): number;
  24472. set mass(value: number);
  24473. /**
  24474. * Gets the coefficient of friction
  24475. */
  24476. get friction(): number;
  24477. /**
  24478. * Sets the coefficient of friction
  24479. */
  24480. set friction(value: number);
  24481. /**
  24482. * Gets the coefficient of restitution
  24483. */
  24484. get restitution(): number;
  24485. /**
  24486. * Sets the coefficient of restitution
  24487. */
  24488. set restitution(value: number);
  24489. /**
  24490. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24491. */
  24492. get pressure(): number;
  24493. /**
  24494. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24495. */
  24496. set pressure(value: number);
  24497. /**
  24498. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24499. */
  24500. get stiffness(): number;
  24501. /**
  24502. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24503. */
  24504. set stiffness(value: number);
  24505. /**
  24506. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24507. */
  24508. get velocityIterations(): number;
  24509. /**
  24510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24511. */
  24512. set velocityIterations(value: number);
  24513. /**
  24514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24515. */
  24516. get positionIterations(): number;
  24517. /**
  24518. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24519. */
  24520. set positionIterations(value: number);
  24521. /**
  24522. * The unique id of the physics imposter
  24523. * set by the physics engine when adding this impostor to the array
  24524. */
  24525. uniqueId: number;
  24526. /**
  24527. * @hidden
  24528. */
  24529. soft: boolean;
  24530. /**
  24531. * @hidden
  24532. */
  24533. segments: number;
  24534. private _joints;
  24535. /**
  24536. * Initializes the physics imposter
  24537. * @param object The physics-enabled object used as the physics imposter
  24538. * @param type The type of the physics imposter
  24539. * @param _options The options for the physics imposter
  24540. * @param _scene The Babylon scene
  24541. */
  24542. constructor(
  24543. /**
  24544. * The physics-enabled object used as the physics imposter
  24545. */
  24546. object: IPhysicsEnabledObject,
  24547. /**
  24548. * The type of the physics imposter
  24549. */
  24550. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24551. /**
  24552. * This function will completly initialize this impostor.
  24553. * It will create a new body - but only if this mesh has no parent.
  24554. * If it has, this impostor will not be used other than to define the impostor
  24555. * of the child mesh.
  24556. * @hidden
  24557. */
  24558. _init(): void;
  24559. private _getPhysicsParent;
  24560. /**
  24561. * Should a new body be generated.
  24562. * @returns boolean specifying if body initialization is required
  24563. */
  24564. isBodyInitRequired(): boolean;
  24565. /**
  24566. * Sets the updated scaling
  24567. * @param updated Specifies if the scaling is updated
  24568. */
  24569. setScalingUpdated(): void;
  24570. /**
  24571. * Force a regeneration of this or the parent's impostor's body.
  24572. * Use under cautious - This will remove all joints already implemented.
  24573. */
  24574. forceUpdate(): void;
  24575. /**
  24576. * Gets the body that holds this impostor. Either its own, or its parent.
  24577. */
  24578. get physicsBody(): any;
  24579. /**
  24580. * Get the parent of the physics imposter
  24581. * @returns Physics imposter or null
  24582. */
  24583. get parent(): Nullable<PhysicsImpostor>;
  24584. /**
  24585. * Sets the parent of the physics imposter
  24586. */
  24587. set parent(value: Nullable<PhysicsImpostor>);
  24588. /**
  24589. * Set the physics body. Used mainly by the physics engine/plugin
  24590. */
  24591. set physicsBody(physicsBody: any);
  24592. /**
  24593. * Resets the update flags
  24594. */
  24595. resetUpdateFlags(): void;
  24596. /**
  24597. * Gets the object extend size
  24598. * @returns the object extend size
  24599. */
  24600. getObjectExtendSize(): Vector3;
  24601. /**
  24602. * Gets the object center
  24603. * @returns The object center
  24604. */
  24605. getObjectCenter(): Vector3;
  24606. /**
  24607. * Get a specific parameter from the options parameters
  24608. * @param paramName The object parameter name
  24609. * @returns The object parameter
  24610. */
  24611. getParam(paramName: string): any;
  24612. /**
  24613. * Sets a specific parameter in the options given to the physics plugin
  24614. * @param paramName The parameter name
  24615. * @param value The value of the parameter
  24616. */
  24617. setParam(paramName: string, value: number): void;
  24618. /**
  24619. * Specifically change the body's mass option. Won't recreate the physics body object
  24620. * @param mass The mass of the physics imposter
  24621. */
  24622. setMass(mass: number): void;
  24623. /**
  24624. * Gets the linear velocity
  24625. * @returns linear velocity or null
  24626. */
  24627. getLinearVelocity(): Nullable<Vector3>;
  24628. /**
  24629. * Sets the linear velocity
  24630. * @param velocity linear velocity or null
  24631. */
  24632. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24633. /**
  24634. * Gets the angular velocity
  24635. * @returns angular velocity or null
  24636. */
  24637. getAngularVelocity(): Nullable<Vector3>;
  24638. /**
  24639. * Sets the angular velocity
  24640. * @param velocity The velocity or null
  24641. */
  24642. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24643. /**
  24644. * Execute a function with the physics plugin native code
  24645. * Provide a function the will have two variables - the world object and the physics body object
  24646. * @param func The function to execute with the physics plugin native code
  24647. */
  24648. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24649. /**
  24650. * Register a function that will be executed before the physics world is stepping forward
  24651. * @param func The function to execute before the physics world is stepped forward
  24652. */
  24653. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Unregister a function that will be executed before the physics world is stepping forward
  24656. * @param func The function to execute before the physics world is stepped forward
  24657. */
  24658. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Register a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * Unregisters a function that will be executed after the physics step
  24666. * @param func The function to execute after physics step
  24667. */
  24668. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24669. /**
  24670. * register a function that will be executed when this impostor collides against a different body
  24671. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24672. * @param func Callback that is executed on collision
  24673. */
  24674. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24675. /**
  24676. * Unregisters the physics imposter on contact
  24677. * @param collideAgainst The physics object to collide against
  24678. * @param func Callback to execute on collision
  24679. */
  24680. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24681. private _tmpQuat;
  24682. private _tmpQuat2;
  24683. /**
  24684. * Get the parent rotation
  24685. * @returns The parent rotation
  24686. */
  24687. getParentsRotation(): Quaternion;
  24688. /**
  24689. * this function is executed by the physics engine.
  24690. */
  24691. beforeStep: () => void;
  24692. /**
  24693. * this function is executed by the physics engine
  24694. */
  24695. afterStep: () => void;
  24696. /**
  24697. * Legacy collision detection event support
  24698. */
  24699. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24700. /**
  24701. * event and body object due to cannon's event-based architecture.
  24702. */
  24703. onCollide: (e: {
  24704. body: any;
  24705. }) => void;
  24706. /**
  24707. * Apply a force
  24708. * @param force The force to apply
  24709. * @param contactPoint The contact point for the force
  24710. * @returns The physics imposter
  24711. */
  24712. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24713. /**
  24714. * Apply an impulse
  24715. * @param force The impulse force
  24716. * @param contactPoint The contact point for the impulse force
  24717. * @returns The physics imposter
  24718. */
  24719. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24720. /**
  24721. * A help function to create a joint
  24722. * @param otherImpostor A physics imposter used to create a joint
  24723. * @param jointType The type of joint
  24724. * @param jointData The data for the joint
  24725. * @returns The physics imposter
  24726. */
  24727. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24728. /**
  24729. * Add a joint to this impostor with a different impostor
  24730. * @param otherImpostor A physics imposter used to add a joint
  24731. * @param joint The joint to add
  24732. * @returns The physics imposter
  24733. */
  24734. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24735. /**
  24736. * Add an anchor to a cloth impostor
  24737. * @param otherImpostor rigid impostor to anchor to
  24738. * @param width ratio across width from 0 to 1
  24739. * @param height ratio up height from 0 to 1
  24740. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24741. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24742. * @returns impostor the soft imposter
  24743. */
  24744. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24745. /**
  24746. * Add a hook to a rope impostor
  24747. * @param otherImpostor rigid impostor to anchor to
  24748. * @param length ratio across rope from 0 to 1
  24749. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24750. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24751. * @returns impostor the rope imposter
  24752. */
  24753. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24754. /**
  24755. * Will keep this body still, in a sleep mode.
  24756. * @returns the physics imposter
  24757. */
  24758. sleep(): PhysicsImpostor;
  24759. /**
  24760. * Wake the body up.
  24761. * @returns The physics imposter
  24762. */
  24763. wakeUp(): PhysicsImpostor;
  24764. /**
  24765. * Clones the physics imposter
  24766. * @param newObject The physics imposter clones to this physics-enabled object
  24767. * @returns A nullable physics imposter
  24768. */
  24769. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24770. /**
  24771. * Disposes the physics imposter
  24772. */
  24773. dispose(): void;
  24774. /**
  24775. * Sets the delta position
  24776. * @param position The delta position amount
  24777. */
  24778. setDeltaPosition(position: Vector3): void;
  24779. /**
  24780. * Sets the delta rotation
  24781. * @param rotation The delta rotation amount
  24782. */
  24783. setDeltaRotation(rotation: Quaternion): void;
  24784. /**
  24785. * Gets the box size of the physics imposter and stores the result in the input parameter
  24786. * @param result Stores the box size
  24787. * @returns The physics imposter
  24788. */
  24789. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24790. /**
  24791. * Gets the radius of the physics imposter
  24792. * @returns Radius of the physics imposter
  24793. */
  24794. getRadius(): number;
  24795. /**
  24796. * Sync a bone with this impostor
  24797. * @param bone The bone to sync to the impostor.
  24798. * @param boneMesh The mesh that the bone is influencing.
  24799. * @param jointPivot The pivot of the joint / bone in local space.
  24800. * @param distToJoint Optional distance from the impostor to the joint.
  24801. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24802. */
  24803. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24804. /**
  24805. * Sync impostor to a bone
  24806. * @param bone The bone that the impostor will be synced to.
  24807. * @param boneMesh The mesh that the bone is influencing.
  24808. * @param jointPivot The pivot of the joint / bone in local space.
  24809. * @param distToJoint Optional distance from the impostor to the joint.
  24810. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24811. * @param boneAxis Optional vector3 axis the bone is aligned with
  24812. */
  24813. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24814. /**
  24815. * No-Imposter type
  24816. */
  24817. static NoImpostor: number;
  24818. /**
  24819. * Sphere-Imposter type
  24820. */
  24821. static SphereImpostor: number;
  24822. /**
  24823. * Box-Imposter type
  24824. */
  24825. static BoxImpostor: number;
  24826. /**
  24827. * Plane-Imposter type
  24828. */
  24829. static PlaneImpostor: number;
  24830. /**
  24831. * Mesh-imposter type
  24832. */
  24833. static MeshImpostor: number;
  24834. /**
  24835. * Capsule-Impostor type (Ammo.js plugin only)
  24836. */
  24837. static CapsuleImpostor: number;
  24838. /**
  24839. * Cylinder-Imposter type
  24840. */
  24841. static CylinderImpostor: number;
  24842. /**
  24843. * Particle-Imposter type
  24844. */
  24845. static ParticleImpostor: number;
  24846. /**
  24847. * Heightmap-Imposter type
  24848. */
  24849. static HeightmapImpostor: number;
  24850. /**
  24851. * ConvexHull-Impostor type (Ammo.js plugin only)
  24852. */
  24853. static ConvexHullImpostor: number;
  24854. /**
  24855. * Custom-Imposter type (Ammo.js plugin only)
  24856. */
  24857. static CustomImpostor: number;
  24858. /**
  24859. * Rope-Imposter type
  24860. */
  24861. static RopeImpostor: number;
  24862. /**
  24863. * Cloth-Imposter type
  24864. */
  24865. static ClothImpostor: number;
  24866. /**
  24867. * Softbody-Imposter type
  24868. */
  24869. static SoftbodyImpostor: number;
  24870. }
  24871. }
  24872. declare module "babylonjs/Meshes/mesh" {
  24873. import { Observable } from "babylonjs/Misc/observable";
  24874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24876. import { Camera } from "babylonjs/Cameras/camera";
  24877. import { Scene } from "babylonjs/scene";
  24878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24879. import { Color4 } from "babylonjs/Maths/math.color";
  24880. import { Engine } from "babylonjs/Engines/engine";
  24881. import { Node } from "babylonjs/node";
  24882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24883. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24884. import { Buffer } from "babylonjs/Meshes/buffer";
  24885. import { Geometry } from "babylonjs/Meshes/geometry";
  24886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24888. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24889. import { Effect } from "babylonjs/Materials/effect";
  24890. import { Material } from "babylonjs/Materials/material";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24893. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24894. import { Path3D } from "babylonjs/Maths/math.path";
  24895. import { Plane } from "babylonjs/Maths/math.plane";
  24896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24897. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24898. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24899. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24900. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24902. /**
  24903. * @hidden
  24904. **/
  24905. export class _CreationDataStorage {
  24906. closePath?: boolean;
  24907. closeArray?: boolean;
  24908. idx: number[];
  24909. dashSize: number;
  24910. gapSize: number;
  24911. path3D: Path3D;
  24912. pathArray: Vector3[][];
  24913. arc: number;
  24914. radius: number;
  24915. cap: number;
  24916. tessellation: number;
  24917. }
  24918. /**
  24919. * @hidden
  24920. **/
  24921. class _InstanceDataStorage {
  24922. visibleInstances: any;
  24923. batchCache: _InstancesBatch;
  24924. instancesBufferSize: number;
  24925. instancesBuffer: Nullable<Buffer>;
  24926. instancesData: Float32Array;
  24927. overridenInstanceCount: number;
  24928. isFrozen: boolean;
  24929. previousBatch: Nullable<_InstancesBatch>;
  24930. hardwareInstancedRendering: boolean;
  24931. sideOrientation: number;
  24932. manualUpdate: boolean;
  24933. }
  24934. /**
  24935. * @hidden
  24936. **/
  24937. export class _InstancesBatch {
  24938. mustReturn: boolean;
  24939. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24940. renderSelf: boolean[];
  24941. hardwareInstancedRendering: boolean[];
  24942. }
  24943. /**
  24944. * Class used to represent renderable models
  24945. */
  24946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24947. /**
  24948. * Mesh side orientation : usually the external or front surface
  24949. */
  24950. static readonly FRONTSIDE: number;
  24951. /**
  24952. * Mesh side orientation : usually the internal or back surface
  24953. */
  24954. static readonly BACKSIDE: number;
  24955. /**
  24956. * Mesh side orientation : both internal and external or front and back surfaces
  24957. */
  24958. static readonly DOUBLESIDE: number;
  24959. /**
  24960. * Mesh side orientation : by default, `FRONTSIDE`
  24961. */
  24962. static readonly DEFAULTSIDE: number;
  24963. /**
  24964. * Mesh cap setting : no cap
  24965. */
  24966. static readonly NO_CAP: number;
  24967. /**
  24968. * Mesh cap setting : one cap at the beginning of the mesh
  24969. */
  24970. static readonly CAP_START: number;
  24971. /**
  24972. * Mesh cap setting : one cap at the end of the mesh
  24973. */
  24974. static readonly CAP_END: number;
  24975. /**
  24976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24977. */
  24978. static readonly CAP_ALL: number;
  24979. /**
  24980. * Mesh pattern setting : no flip or rotate
  24981. */
  24982. static readonly NO_FLIP: number;
  24983. /**
  24984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24985. */
  24986. static readonly FLIP_TILE: number;
  24987. /**
  24988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24989. */
  24990. static readonly ROTATE_TILE: number;
  24991. /**
  24992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24993. */
  24994. static readonly FLIP_ROW: number;
  24995. /**
  24996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24997. */
  24998. static readonly ROTATE_ROW: number;
  24999. /**
  25000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25001. */
  25002. static readonly FLIP_N_ROTATE_TILE: number;
  25003. /**
  25004. * Mesh pattern setting : rotate pattern and rotate
  25005. */
  25006. static readonly FLIP_N_ROTATE_ROW: number;
  25007. /**
  25008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25009. */
  25010. static readonly CENTER: number;
  25011. /**
  25012. * Mesh tile positioning : part tiles on left
  25013. */
  25014. static readonly LEFT: number;
  25015. /**
  25016. * Mesh tile positioning : part tiles on right
  25017. */
  25018. static readonly RIGHT: number;
  25019. /**
  25020. * Mesh tile positioning : part tiles on top
  25021. */
  25022. static readonly TOP: number;
  25023. /**
  25024. * Mesh tile positioning : part tiles on bottom
  25025. */
  25026. static readonly BOTTOM: number;
  25027. /**
  25028. * Gets the default side orientation.
  25029. * @param orientation the orientation to value to attempt to get
  25030. * @returns the default orientation
  25031. * @hidden
  25032. */
  25033. static _GetDefaultSideOrientation(orientation?: number): number;
  25034. private _internalMeshDataInfo;
  25035. /**
  25036. * An event triggered before rendering the mesh
  25037. */
  25038. get onBeforeRenderObservable(): Observable<Mesh>;
  25039. /**
  25040. * An event triggered before binding the mesh
  25041. */
  25042. get onBeforeBindObservable(): Observable<Mesh>;
  25043. /**
  25044. * An event triggered after rendering the mesh
  25045. */
  25046. get onAfterRenderObservable(): Observable<Mesh>;
  25047. /**
  25048. * An event triggered before drawing the mesh
  25049. */
  25050. get onBeforeDrawObservable(): Observable<Mesh>;
  25051. private _onBeforeDrawObserver;
  25052. /**
  25053. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25054. */
  25055. set onBeforeDraw(callback: () => void);
  25056. get hasInstances(): boolean;
  25057. /**
  25058. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25059. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25060. */
  25061. delayLoadState: number;
  25062. /**
  25063. * Gets the list of instances created from this mesh
  25064. * it is not supposed to be modified manually.
  25065. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25067. */
  25068. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25069. /**
  25070. * Gets the file containing delay loading data for this mesh
  25071. */
  25072. delayLoadingFile: string;
  25073. /** @hidden */
  25074. _binaryInfo: any;
  25075. /**
  25076. * User defined function used to change how LOD level selection is done
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25078. */
  25079. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25080. /**
  25081. * Gets or sets the morph target manager
  25082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25083. */
  25084. get morphTargetManager(): Nullable<MorphTargetManager>;
  25085. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25086. /** @hidden */
  25087. _creationDataStorage: Nullable<_CreationDataStorage>;
  25088. /** @hidden */
  25089. _geometry: Nullable<Geometry>;
  25090. /** @hidden */
  25091. _delayInfo: Array<string>;
  25092. /** @hidden */
  25093. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25094. /** @hidden */
  25095. _instanceDataStorage: _InstanceDataStorage;
  25096. private _effectiveMaterial;
  25097. /** @hidden */
  25098. _shouldGenerateFlatShading: boolean;
  25099. /** @hidden */
  25100. _originalBuilderSideOrientation: number;
  25101. /**
  25102. * Use this property to change the original side orientation defined at construction time
  25103. */
  25104. overrideMaterialSideOrientation: Nullable<number>;
  25105. /**
  25106. * Gets the source mesh (the one used to clone this one from)
  25107. */
  25108. get source(): Nullable<Mesh>;
  25109. /**
  25110. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25111. */
  25112. get isUnIndexed(): boolean;
  25113. set isUnIndexed(value: boolean);
  25114. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25115. get worldMatrixInstancedBuffer(): Float32Array;
  25116. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25117. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25118. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25119. /**
  25120. * @constructor
  25121. * @param name The value used by scene.getMeshByName() to do a lookup.
  25122. * @param scene The scene to add this mesh to.
  25123. * @param parent The parent of this mesh, if it has one
  25124. * @param source An optional Mesh from which geometry is shared, cloned.
  25125. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25126. * When false, achieved by calling a clone(), also passing False.
  25127. * This will make creation of children, recursive.
  25128. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25129. */
  25130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25131. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25132. doNotInstantiate: boolean;
  25133. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25134. /**
  25135. * Gets the class name
  25136. * @returns the string "Mesh".
  25137. */
  25138. getClassName(): string;
  25139. /** @hidden */
  25140. get _isMesh(): boolean;
  25141. /**
  25142. * Returns a description of this mesh
  25143. * @param fullDetails define if full details about this mesh must be used
  25144. * @returns a descriptive string representing this mesh
  25145. */
  25146. toString(fullDetails?: boolean): string;
  25147. /** @hidden */
  25148. _unBindEffect(): void;
  25149. /**
  25150. * Gets a boolean indicating if this mesh has LOD
  25151. */
  25152. get hasLODLevels(): boolean;
  25153. /**
  25154. * Gets the list of MeshLODLevel associated with the current mesh
  25155. * @returns an array of MeshLODLevel
  25156. */
  25157. getLODLevels(): MeshLODLevel[];
  25158. private _sortLODLevels;
  25159. /**
  25160. * Add a mesh as LOD level triggered at the given distance.
  25161. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25162. * @param distance The distance from the center of the object to show this level
  25163. * @param mesh The mesh to be added as LOD level (can be null)
  25164. * @return This mesh (for chaining)
  25165. */
  25166. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25167. /**
  25168. * Returns the LOD level mesh at the passed distance or null if not found.
  25169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25170. * @param distance The distance from the center of the object to show this level
  25171. * @returns a Mesh or `null`
  25172. */
  25173. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25174. /**
  25175. * Remove a mesh from the LOD array
  25176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25177. * @param mesh defines the mesh to be removed
  25178. * @return This mesh (for chaining)
  25179. */
  25180. removeLODLevel(mesh: Mesh): Mesh;
  25181. /**
  25182. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25184. * @param camera defines the camera to use to compute distance
  25185. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25186. * @return This mesh (for chaining)
  25187. */
  25188. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25189. /**
  25190. * Gets the mesh internal Geometry object
  25191. */
  25192. get geometry(): Nullable<Geometry>;
  25193. /**
  25194. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25195. * @returns the total number of vertices
  25196. */
  25197. getTotalVertices(): number;
  25198. /**
  25199. * Returns the content of an associated vertex buffer
  25200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @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
  25214. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25215. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25216. */
  25217. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25218. /**
  25219. * Returns the mesh VertexBuffer object from the requested `kind`
  25220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25221. * - VertexBuffer.PositionKind
  25222. * - VertexBuffer.NormalKind
  25223. * - VertexBuffer.UVKind
  25224. * - VertexBuffer.UV2Kind
  25225. * - VertexBuffer.UV3Kind
  25226. * - VertexBuffer.UV4Kind
  25227. * - VertexBuffer.UV5Kind
  25228. * - VertexBuffer.UV6Kind
  25229. * - VertexBuffer.ColorKind
  25230. * - VertexBuffer.MatricesIndicesKind
  25231. * - VertexBuffer.MatricesIndicesExtraKind
  25232. * - VertexBuffer.MatricesWeightsKind
  25233. * - VertexBuffer.MatricesWeightsExtraKind
  25234. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25235. */
  25236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25237. /**
  25238. * Tests if a specific vertex buffer is associated with this mesh
  25239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25240. * - VertexBuffer.PositionKind
  25241. * - VertexBuffer.NormalKind
  25242. * - VertexBuffer.UVKind
  25243. * - VertexBuffer.UV2Kind
  25244. * - VertexBuffer.UV3Kind
  25245. * - VertexBuffer.UV4Kind
  25246. * - VertexBuffer.UV5Kind
  25247. * - VertexBuffer.UV6Kind
  25248. * - VertexBuffer.ColorKind
  25249. * - VertexBuffer.MatricesIndicesKind
  25250. * - VertexBuffer.MatricesIndicesExtraKind
  25251. * - VertexBuffer.MatricesWeightsKind
  25252. * - VertexBuffer.MatricesWeightsExtraKind
  25253. * @returns a boolean
  25254. */
  25255. isVerticesDataPresent(kind: string): boolean;
  25256. /**
  25257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25259. * - VertexBuffer.PositionKind
  25260. * - VertexBuffer.UVKind
  25261. * - VertexBuffer.UV2Kind
  25262. * - VertexBuffer.UV3Kind
  25263. * - VertexBuffer.UV4Kind
  25264. * - VertexBuffer.UV5Kind
  25265. * - VertexBuffer.UV6Kind
  25266. * - VertexBuffer.ColorKind
  25267. * - VertexBuffer.MatricesIndicesKind
  25268. * - VertexBuffer.MatricesIndicesExtraKind
  25269. * - VertexBuffer.MatricesWeightsKind
  25270. * - VertexBuffer.MatricesWeightsExtraKind
  25271. * @returns a boolean
  25272. */
  25273. isVertexBufferUpdatable(kind: string): boolean;
  25274. /**
  25275. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25277. * - VertexBuffer.PositionKind
  25278. * - VertexBuffer.NormalKind
  25279. * - VertexBuffer.UVKind
  25280. * - VertexBuffer.UV2Kind
  25281. * - VertexBuffer.UV3Kind
  25282. * - VertexBuffer.UV4Kind
  25283. * - VertexBuffer.UV5Kind
  25284. * - VertexBuffer.UV6Kind
  25285. * - VertexBuffer.ColorKind
  25286. * - VertexBuffer.MatricesIndicesKind
  25287. * - VertexBuffer.MatricesIndicesExtraKind
  25288. * - VertexBuffer.MatricesWeightsKind
  25289. * - VertexBuffer.MatricesWeightsExtraKind
  25290. * @returns an array of strings
  25291. */
  25292. getVerticesDataKinds(): string[];
  25293. /**
  25294. * Returns a positive integer : the total number of indices in this mesh geometry.
  25295. * @returns the numner of indices or zero if the mesh has no geometry.
  25296. */
  25297. getTotalIndices(): number;
  25298. /**
  25299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25300. * @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.
  25301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25302. * @returns the indices array or an empty array if the mesh has no geometry
  25303. */
  25304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25305. get isBlocked(): boolean;
  25306. /**
  25307. * Determine if the current mesh is ready to be rendered
  25308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25310. * @returns true if all associated assets are ready (material, textures, shaders)
  25311. */
  25312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25313. /**
  25314. * 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.
  25315. */
  25316. get areNormalsFrozen(): boolean;
  25317. /**
  25318. * 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.
  25319. * @returns the current mesh
  25320. */
  25321. freezeNormals(): Mesh;
  25322. /**
  25323. * 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
  25324. * @returns the current mesh
  25325. */
  25326. unfreezeNormals(): Mesh;
  25327. /**
  25328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25329. */
  25330. set overridenInstanceCount(count: number);
  25331. /** @hidden */
  25332. _preActivate(): Mesh;
  25333. /** @hidden */
  25334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25335. /** @hidden */
  25336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25337. /**
  25338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25339. * This means the mesh underlying bounding box and sphere are recomputed.
  25340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25341. * @returns the current mesh
  25342. */
  25343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25344. /** @hidden */
  25345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25346. /**
  25347. * This function will subdivide the mesh into multiple submeshes
  25348. * @param count defines the expected number of submeshes
  25349. */
  25350. subdivide(count: number): void;
  25351. /**
  25352. * Copy a FloatArray into a specific associated vertex buffer
  25353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25354. * - VertexBuffer.PositionKind
  25355. * - VertexBuffer.UVKind
  25356. * - VertexBuffer.UV2Kind
  25357. * - VertexBuffer.UV3Kind
  25358. * - VertexBuffer.UV4Kind
  25359. * - VertexBuffer.UV5Kind
  25360. * - VertexBuffer.UV6Kind
  25361. * - VertexBuffer.ColorKind
  25362. * - VertexBuffer.MatricesIndicesKind
  25363. * - VertexBuffer.MatricesIndicesExtraKind
  25364. * - VertexBuffer.MatricesWeightsKind
  25365. * - VertexBuffer.MatricesWeightsExtraKind
  25366. * @param data defines the data source
  25367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25368. * @param stride defines the data stride size (can be null)
  25369. * @returns the current mesh
  25370. */
  25371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25372. /**
  25373. * Delete a vertex buffer associated with this mesh
  25374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25375. * - VertexBuffer.PositionKind
  25376. * - VertexBuffer.UVKind
  25377. * - VertexBuffer.UV2Kind
  25378. * - VertexBuffer.UV3Kind
  25379. * - VertexBuffer.UV4Kind
  25380. * - VertexBuffer.UV5Kind
  25381. * - VertexBuffer.UV6Kind
  25382. * - VertexBuffer.ColorKind
  25383. * - VertexBuffer.MatricesIndicesKind
  25384. * - VertexBuffer.MatricesIndicesExtraKind
  25385. * - VertexBuffer.MatricesWeightsKind
  25386. * - VertexBuffer.MatricesWeightsExtraKind
  25387. */
  25388. removeVerticesData(kind: string): void;
  25389. /**
  25390. * Flags an associated vertex buffer as updatable
  25391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25392. * - VertexBuffer.PositionKind
  25393. * - VertexBuffer.UVKind
  25394. * - VertexBuffer.UV2Kind
  25395. * - VertexBuffer.UV3Kind
  25396. * - VertexBuffer.UV4Kind
  25397. * - VertexBuffer.UV5Kind
  25398. * - VertexBuffer.UV6Kind
  25399. * - VertexBuffer.ColorKind
  25400. * - VertexBuffer.MatricesIndicesKind
  25401. * - VertexBuffer.MatricesIndicesExtraKind
  25402. * - VertexBuffer.MatricesWeightsKind
  25403. * - VertexBuffer.MatricesWeightsExtraKind
  25404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25405. */
  25406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25407. /**
  25408. * Sets the mesh global Vertex Buffer
  25409. * @param buffer defines the buffer to use
  25410. * @returns the current mesh
  25411. */
  25412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25413. /**
  25414. * Update a specific associated vertex buffer
  25415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25416. * - VertexBuffer.PositionKind
  25417. * - VertexBuffer.UVKind
  25418. * - VertexBuffer.UV2Kind
  25419. * - VertexBuffer.UV3Kind
  25420. * - VertexBuffer.UV4Kind
  25421. * - VertexBuffer.UV5Kind
  25422. * - VertexBuffer.UV6Kind
  25423. * - VertexBuffer.ColorKind
  25424. * - VertexBuffer.MatricesIndicesKind
  25425. * - VertexBuffer.MatricesIndicesExtraKind
  25426. * - VertexBuffer.MatricesWeightsKind
  25427. * - VertexBuffer.MatricesWeightsExtraKind
  25428. * @param data defines the data source
  25429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25430. * @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)
  25431. * @returns the current mesh
  25432. */
  25433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25434. /**
  25435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25439. * @returns the current mesh
  25440. */
  25441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25442. /**
  25443. * Creates a un-shared specific occurence of the geometry for the mesh.
  25444. * @returns the current mesh
  25445. */
  25446. makeGeometryUnique(): Mesh;
  25447. /**
  25448. * Set the index buffer of this mesh
  25449. * @param indices defines the source data
  25450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25452. * @returns the current mesh
  25453. */
  25454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25455. /**
  25456. * Update the current index buffer
  25457. * @param indices defines the source data
  25458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25459. * @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)
  25460. * @returns the current mesh
  25461. */
  25462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25463. /**
  25464. * Invert the geometry to move from a right handed system to a left handed one.
  25465. * @returns the current mesh
  25466. */
  25467. toLeftHanded(): Mesh;
  25468. /** @hidden */
  25469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25470. /** @hidden */
  25471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25472. /**
  25473. * Registers for this mesh a javascript function called just before the rendering process
  25474. * @param func defines the function to call before rendering this mesh
  25475. * @returns the current mesh
  25476. */
  25477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25478. /**
  25479. * Disposes a previously registered javascript function called before the rendering
  25480. * @param func defines the function to remove
  25481. * @returns the current mesh
  25482. */
  25483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25484. /**
  25485. * Registers for this mesh a javascript function called just after the rendering is complete
  25486. * @param func defines the function to call after rendering this mesh
  25487. * @returns the current mesh
  25488. */
  25489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25490. /**
  25491. * Disposes a previously registered javascript function called after the rendering.
  25492. * @param func defines the function to remove
  25493. * @returns the current mesh
  25494. */
  25495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25496. /** @hidden */
  25497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25498. /** @hidden */
  25499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25500. /** @hidden */
  25501. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25502. /** @hidden */
  25503. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25504. /** @hidden */
  25505. _rebuild(): void;
  25506. /** @hidden */
  25507. _freeze(): void;
  25508. /** @hidden */
  25509. _unFreeze(): void;
  25510. /**
  25511. * 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
  25512. * @param subMesh defines the subMesh to render
  25513. * @param enableAlphaMode defines if alpha mode can be changed
  25514. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25515. * @returns the current mesh
  25516. */
  25517. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25518. private _onBeforeDraw;
  25519. /**
  25520. * Renormalize the mesh and patch it up if there are no weights
  25521. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25522. * However in the case of zero weights then we set just a single influence to 1.
  25523. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25524. */
  25525. cleanMatrixWeights(): void;
  25526. private normalizeSkinFourWeights;
  25527. private normalizeSkinWeightsAndExtra;
  25528. /**
  25529. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25530. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25531. * the user know there was an issue with importing the mesh
  25532. * @returns a validation object with skinned, valid and report string
  25533. */
  25534. validateSkinning(): {
  25535. skinned: boolean;
  25536. valid: boolean;
  25537. report: string;
  25538. };
  25539. /** @hidden */
  25540. _checkDelayState(): Mesh;
  25541. private _queueLoad;
  25542. /**
  25543. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25544. * A mesh is in the frustum if its bounding box intersects the frustum
  25545. * @param frustumPlanes defines the frustum to test
  25546. * @returns true if the mesh is in the frustum planes
  25547. */
  25548. isInFrustum(frustumPlanes: Plane[]): boolean;
  25549. /**
  25550. * Sets the mesh material by the material or multiMaterial `id` property
  25551. * @param id is a string identifying the material or the multiMaterial
  25552. * @returns the current mesh
  25553. */
  25554. setMaterialByID(id: string): Mesh;
  25555. /**
  25556. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25557. * @returns an array of IAnimatable
  25558. */
  25559. getAnimatables(): IAnimatable[];
  25560. /**
  25561. * Modifies the mesh geometry according to the passed transformation matrix.
  25562. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25563. * The mesh normals are modified using the same transformation.
  25564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25565. * @param transform defines the transform matrix to use
  25566. * @see http://doc.babylonjs.com/resources/baking_transformations
  25567. * @returns the current mesh
  25568. */
  25569. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25570. /**
  25571. * Modifies the mesh geometry according to its own current World Matrix.
  25572. * The mesh World Matrix is then reset.
  25573. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25575. * @see http://doc.babylonjs.com/resources/baking_transformations
  25576. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25577. * @returns the current mesh
  25578. */
  25579. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25580. /** @hidden */
  25581. get _positions(): Nullable<Vector3[]>;
  25582. /** @hidden */
  25583. _resetPointsArrayCache(): Mesh;
  25584. /** @hidden */
  25585. _generatePointsArray(): boolean;
  25586. /**
  25587. * Returns a new Mesh object generated from the current mesh properties.
  25588. * This method must not get confused with createInstance()
  25589. * @param name is a string, the name given to the new mesh
  25590. * @param newParent can be any Node object (default `null`)
  25591. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25592. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25593. * @returns a new mesh
  25594. */
  25595. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25596. /**
  25597. * Releases resources associated with this mesh.
  25598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25600. */
  25601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25602. /** @hidden */
  25603. _disposeInstanceSpecificData(): void;
  25604. /**
  25605. * Modifies the mesh geometry according to a displacement map.
  25606. * 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.
  25607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25608. * @param url is a string, the URL from the image file is to be downloaded.
  25609. * @param minHeight is the lower limit of the displacement.
  25610. * @param maxHeight is the upper limit of the displacement.
  25611. * @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.
  25612. * @param uvOffset is an optional vector2 used to offset UV.
  25613. * @param uvScale is an optional vector2 used to scale UV.
  25614. * @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.
  25615. * @returns the Mesh.
  25616. */
  25617. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25618. /**
  25619. * Modifies the mesh geometry according to a displacementMap buffer.
  25620. * 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.
  25621. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25622. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25623. * @param heightMapWidth is the width of the buffer image.
  25624. * @param heightMapHeight is the height of the buffer image.
  25625. * @param minHeight is the lower limit of the displacement.
  25626. * @param maxHeight is the upper limit of the displacement.
  25627. * @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.
  25628. * @param uvOffset is an optional vector2 used to offset UV.
  25629. * @param uvScale is an optional vector2 used to scale UV.
  25630. * @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.
  25631. * @returns the Mesh.
  25632. */
  25633. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25634. /**
  25635. * Modify the mesh to get a flat shading rendering.
  25636. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25637. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25638. * @returns current mesh
  25639. */
  25640. convertToFlatShadedMesh(): Mesh;
  25641. /**
  25642. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25643. * In other words, more vertices, no more indices and a single bigger VBO.
  25644. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25645. * @returns current mesh
  25646. */
  25647. convertToUnIndexedMesh(): Mesh;
  25648. /**
  25649. * Inverses facet orientations.
  25650. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25651. * @param flipNormals will also inverts the normals
  25652. * @returns current mesh
  25653. */
  25654. flipFaces(flipNormals?: boolean): Mesh;
  25655. /**
  25656. * Increase the number of facets and hence vertices in a mesh
  25657. * Vertex normals are interpolated from existing vertex normals
  25658. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25659. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25660. */
  25661. increaseVertices(numberPerEdge: number): void;
  25662. /**
  25663. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25664. * This will undo any application of covertToFlatShadedMesh
  25665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25666. */
  25667. forceSharedVertices(): void;
  25668. /** @hidden */
  25669. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25670. /** @hidden */
  25671. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25672. /**
  25673. * Creates a new InstancedMesh object from the mesh model.
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25675. * @param name defines the name of the new instance
  25676. * @returns a new InstancedMesh
  25677. */
  25678. createInstance(name: string): InstancedMesh;
  25679. /**
  25680. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25681. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25682. * @returns the current mesh
  25683. */
  25684. synchronizeInstances(): Mesh;
  25685. /**
  25686. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25687. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25688. * This should be used together with the simplification to avoid disappearing triangles.
  25689. * @param successCallback an optional success callback to be called after the optimization finished.
  25690. * @returns the current mesh
  25691. */
  25692. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25693. /**
  25694. * Serialize current mesh
  25695. * @param serializationObject defines the object which will receive the serialization data
  25696. */
  25697. serialize(serializationObject: any): void;
  25698. /** @hidden */
  25699. _syncGeometryWithMorphTargetManager(): void;
  25700. /** @hidden */
  25701. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25702. /**
  25703. * Returns a new Mesh object parsed from the source provided.
  25704. * @param parsedMesh is the source
  25705. * @param scene defines the hosting scene
  25706. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25707. * @returns a new Mesh
  25708. */
  25709. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25710. /**
  25711. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25713. * @param name defines the name of the mesh to create
  25714. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25715. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25716. * @param closePath creates a seam between the first and the last points of each path of the path array
  25717. * @param offset is taken in account only if the `pathArray` is containing a single path
  25718. * @param scene defines the hosting scene
  25719. * @param updatable defines if the mesh must be flagged as updatable
  25720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25721. * @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)
  25722. * @returns a new Mesh
  25723. */
  25724. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25725. /**
  25726. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25727. * @param name defines the name of the mesh to create
  25728. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25729. * @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
  25730. * @param scene defines the hosting scene
  25731. * @param updatable defines if the mesh must be flagged as updatable
  25732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25736. /**
  25737. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25738. * @param name defines the name of the mesh to create
  25739. * @param size sets the size (float) of each box side (default 1)
  25740. * @param scene defines the hosting scene
  25741. * @param updatable defines if the mesh must be flagged as updatable
  25742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25743. * @returns a new Mesh
  25744. */
  25745. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25746. /**
  25747. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25748. * @param name defines the name of the mesh to create
  25749. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25750. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25757. /**
  25758. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25759. * @param name defines the name of the mesh to create
  25760. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25761. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25762. * @param scene defines the hosting scene
  25763. * @returns a new Mesh
  25764. */
  25765. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25766. /**
  25767. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25768. * @param name defines the name of the mesh to create
  25769. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25770. * @param diameterTop set the top cap diameter (floats, default 1)
  25771. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25772. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25773. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25774. * @param scene defines the hosting scene
  25775. * @param updatable defines if the mesh must be flagged as updatable
  25776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25777. * @returns a new Mesh
  25778. */
  25779. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25780. /**
  25781. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25782. * @param name defines the name of the mesh to create
  25783. * @param diameter sets the diameter size (float) of the torus (default 1)
  25784. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25785. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25786. * @param scene defines the hosting scene
  25787. * @param updatable defines if the mesh must be flagged as updatable
  25788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25789. * @returns a new Mesh
  25790. */
  25791. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25792. /**
  25793. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25794. * @param name defines the name of the mesh to create
  25795. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25796. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25797. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25798. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25799. * @param p the number of windings on X axis (positive integers, default 2)
  25800. * @param q the number of windings on Y axis (positive integers, default 3)
  25801. * @param scene defines the hosting scene
  25802. * @param updatable defines if the mesh must be flagged as updatable
  25803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25804. * @returns a new Mesh
  25805. */
  25806. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25807. /**
  25808. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25809. * @param name defines the name of the mesh to create
  25810. * @param points is an array successive Vector3
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @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).
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25817. /**
  25818. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param points is an array successive Vector3
  25821. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25822. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25823. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25824. * @param scene defines the hosting scene
  25825. * @param updatable defines if the mesh must be flagged as updatable
  25826. * @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)
  25827. * @returns a new Mesh
  25828. */
  25829. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25830. /**
  25831. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25832. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25833. * 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.
  25834. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25835. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25836. * Remember you can only change the shape positions, not their number when updating a polygon.
  25837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25838. * @param name defines the name of the mesh to create
  25839. * @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
  25840. * @param scene defines the hosting scene
  25841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @param earcutInjection can be used to inject your own earcut reference
  25845. * @returns a new Mesh
  25846. */
  25847. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25848. /**
  25849. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25850. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25851. * @param name defines the name of the mesh to create
  25852. * @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
  25853. * @param depth defines the height of extrusion
  25854. * @param scene defines the hosting scene
  25855. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25856. * @param updatable defines if the mesh must be flagged as updatable
  25857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25858. * @param earcutInjection can be used to inject your own earcut reference
  25859. * @returns a new Mesh
  25860. */
  25861. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25862. /**
  25863. * Creates an extruded shape mesh.
  25864. * 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
  25865. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25866. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25867. * @param name defines the name of the mesh to create
  25868. * @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
  25869. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25870. * @param scale is the value to scale the shape
  25871. * @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
  25872. * @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
  25873. * @param scene defines the hosting scene
  25874. * @param updatable defines if the mesh must be flagged as updatable
  25875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25876. * @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)
  25877. * @returns a new Mesh
  25878. */
  25879. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25880. /**
  25881. * Creates an custom extruded shape mesh.
  25882. * The custom extrusion is a parametric shape.
  25883. * It has no predefined shape. Its final shape will depend on the input parameters.
  25884. * Please consider using the same method from the MeshBuilder class instead
  25885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25886. * @param name defines the name of the mesh to create
  25887. * @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
  25888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25889. * @param scaleFunction is a custom Javascript function called on each path point
  25890. * @param rotationFunction is a custom Javascript function called on each path point
  25891. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25892. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25893. * @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
  25894. * @param scene defines the hosting scene
  25895. * @param updatable defines if the mesh must be flagged as updatable
  25896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25897. * @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)
  25898. * @returns a new Mesh
  25899. */
  25900. 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;
  25901. /**
  25902. * Creates lathe mesh.
  25903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25904. * Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @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
  25907. * @param radius is the radius value of the lathe
  25908. * @param tessellation is the side number of the lathe.
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @returns a new Mesh
  25923. */
  25924. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25925. /**
  25926. * Creates a ground mesh.
  25927. * Please consider using the same method from the MeshBuilder class instead
  25928. * @param name defines the name of the mesh to create
  25929. * @param width set the width of the ground
  25930. * @param height set the height of the ground
  25931. * @param subdivisions sets the number of subdivisions per side
  25932. * @param scene defines the hosting scene
  25933. * @param updatable defines if the mesh must be flagged as updatable
  25934. * @returns a new Mesh
  25935. */
  25936. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25937. /**
  25938. * Creates a tiled ground mesh.
  25939. * Please consider using the same method from the MeshBuilder class instead
  25940. * @param name defines the name of the mesh to create
  25941. * @param xmin set the ground minimum X coordinate
  25942. * @param zmin set the ground minimum Y coordinate
  25943. * @param xmax set the ground maximum X coordinate
  25944. * @param zmax set the ground maximum Z coordinate
  25945. * @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
  25946. * @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
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @returns a new Mesh
  25950. */
  25951. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25952. w: number;
  25953. h: number;
  25954. }, precision: {
  25955. w: number;
  25956. h: number;
  25957. }, scene: Scene, updatable?: boolean): Mesh;
  25958. /**
  25959. * Creates a ground mesh from a height map.
  25960. * Please consider using the same method from the MeshBuilder class instead
  25961. * @see http://doc.babylonjs.com/babylon101/height_map
  25962. * @param name defines the name of the mesh to create
  25963. * @param url sets the URL of the height map image resource
  25964. * @param width set the ground width size
  25965. * @param height set the ground height size
  25966. * @param subdivisions sets the number of subdivision per side
  25967. * @param minHeight is the minimum altitude on the ground
  25968. * @param maxHeight is the maximum altitude on the ground
  25969. * @param scene defines the hosting scene
  25970. * @param updatable defines if the mesh must be flagged as updatable
  25971. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25972. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25973. * @returns a new Mesh
  25974. */
  25975. 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;
  25976. /**
  25977. * Creates a tube mesh.
  25978. * The tube is a parametric shape.
  25979. * It has no predefined shape. Its final shape will depend on the input parameters.
  25980. * Please consider using the same method from the MeshBuilder class instead
  25981. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25982. * @param name defines the name of the mesh to create
  25983. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25984. * @param radius sets the tube radius size
  25985. * @param tessellation is the number of sides on the tubular surface
  25986. * @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
  25987. * @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
  25988. * @param scene defines the hosting scene
  25989. * @param updatable defines if the mesh must be flagged as updatable
  25990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25991. * @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)
  25992. * @returns a new Mesh
  25993. */
  25994. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25995. (i: number, distance: number): number;
  25996. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25997. /**
  25998. * Creates a polyhedron mesh.
  25999. * Please consider using the same method from the MeshBuilder class instead.
  26000. * * 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
  26001. * * The parameter `size` (positive float, default 1) sets the polygon size
  26002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26003. * * 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`
  26004. * * 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
  26005. * * 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)`)
  26006. * * 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
  26007. * * 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
  26008. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26009. * * If you create a double-sided mesh, you can choose what parts of 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
  26010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26011. * @param name defines the name of the mesh to create
  26012. * @param options defines the options used to create the mesh
  26013. * @param scene defines the hosting scene
  26014. * @returns a new Mesh
  26015. */
  26016. static CreatePolyhedron(name: string, options: {
  26017. type?: number;
  26018. size?: number;
  26019. sizeX?: number;
  26020. sizeY?: number;
  26021. sizeZ?: number;
  26022. custom?: any;
  26023. faceUV?: Vector4[];
  26024. faceColors?: Color4[];
  26025. updatable?: boolean;
  26026. sideOrientation?: number;
  26027. }, scene: Scene): Mesh;
  26028. /**
  26029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26031. * * 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`)
  26032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26033. * * 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
  26034. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26035. * * If you create a double-sided mesh, you can choose what parts of 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
  26036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26037. * @param name defines the name of the mesh
  26038. * @param options defines the options used to create the mesh
  26039. * @param scene defines the hosting scene
  26040. * @returns a new Mesh
  26041. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26042. */
  26043. static CreateIcoSphere(name: string, options: {
  26044. radius?: number;
  26045. flat?: boolean;
  26046. subdivisions?: number;
  26047. sideOrientation?: number;
  26048. updatable?: boolean;
  26049. }, scene: Scene): Mesh;
  26050. /**
  26051. * Creates a decal mesh.
  26052. * Please consider using the same method from the MeshBuilder class instead.
  26053. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26054. * @param name defines the name of the mesh
  26055. * @param sourceMesh defines the mesh receiving the decal
  26056. * @param position sets the position of the decal in world coordinates
  26057. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26058. * @param size sets the decal scaling
  26059. * @param angle sets the angle to rotate the decal
  26060. * @returns a new Mesh
  26061. */
  26062. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26063. /**
  26064. * Prepare internal position array for software CPU skinning
  26065. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26066. */
  26067. setPositionsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Prepare internal normal array for software CPU skinning
  26070. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26071. */
  26072. setNormalsForCPUSkinning(): Float32Array;
  26073. /**
  26074. * Updates the vertex buffer by applying transformation from the bones
  26075. * @param skeleton defines the skeleton to apply to current mesh
  26076. * @returns the current mesh
  26077. */
  26078. applySkeleton(skeleton: Skeleton): Mesh;
  26079. /**
  26080. * 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
  26081. * @param meshes defines the list of meshes to scan
  26082. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26083. */
  26084. static MinMax(meshes: AbstractMesh[]): {
  26085. min: Vector3;
  26086. max: Vector3;
  26087. };
  26088. /**
  26089. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26090. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26091. * @returns a vector3
  26092. */
  26093. static Center(meshesOrMinMaxVector: {
  26094. min: Vector3;
  26095. max: Vector3;
  26096. } | AbstractMesh[]): Vector3;
  26097. /**
  26098. * Merge the array of meshes into a single mesh for performance reasons.
  26099. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26100. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26101. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26102. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26103. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26104. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26105. * @returns a new mesh
  26106. */
  26107. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26108. /** @hidden */
  26109. addInstance(instance: InstancedMesh): void;
  26110. /** @hidden */
  26111. removeInstance(instance: InstancedMesh): void;
  26112. }
  26113. }
  26114. declare module "babylonjs/Cameras/camera" {
  26115. import { SmartArray } from "babylonjs/Misc/smartArray";
  26116. import { Observable } from "babylonjs/Misc/observable";
  26117. import { Nullable } from "babylonjs/types";
  26118. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26119. import { Scene } from "babylonjs/scene";
  26120. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26121. import { Node } from "babylonjs/node";
  26122. import { Mesh } from "babylonjs/Meshes/mesh";
  26123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26124. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26125. import { Viewport } from "babylonjs/Maths/math.viewport";
  26126. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26129. import { Ray } from "babylonjs/Culling/ray";
  26130. /**
  26131. * This is the base class of all the camera used in the application.
  26132. * @see http://doc.babylonjs.com/features/cameras
  26133. */
  26134. export class Camera extends Node {
  26135. /** @hidden */
  26136. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26137. /**
  26138. * This is the default projection mode used by the cameras.
  26139. * It helps recreating a feeling of perspective and better appreciate depth.
  26140. * This is the best way to simulate real life cameras.
  26141. */
  26142. static readonly PERSPECTIVE_CAMERA: number;
  26143. /**
  26144. * This helps creating camera with an orthographic mode.
  26145. * 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.
  26146. */
  26147. static readonly ORTHOGRAPHIC_CAMERA: number;
  26148. /**
  26149. * This is the default FOV mode for perspective cameras.
  26150. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26151. */
  26152. static readonly FOVMODE_VERTICAL_FIXED: number;
  26153. /**
  26154. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26155. */
  26156. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26157. /**
  26158. * This specifies ther is no need for a camera rig.
  26159. * Basically only one eye is rendered corresponding to the camera.
  26160. */
  26161. static readonly RIG_MODE_NONE: number;
  26162. /**
  26163. * Simulates a camera Rig with one blue eye and one red eye.
  26164. * This can be use with 3d blue and red glasses.
  26165. */
  26166. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26167. /**
  26168. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26169. */
  26170. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26171. /**
  26172. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26173. */
  26174. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26175. /**
  26176. * Defines that both eyes of the camera will be rendered over under each other.
  26177. */
  26178. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26179. /**
  26180. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26181. */
  26182. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26183. /**
  26184. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26185. */
  26186. static readonly RIG_MODE_VR: number;
  26187. /**
  26188. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26189. */
  26190. static readonly RIG_MODE_WEBVR: number;
  26191. /**
  26192. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26193. */
  26194. static readonly RIG_MODE_CUSTOM: number;
  26195. /**
  26196. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26197. */
  26198. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26199. /**
  26200. * Define the input manager associated with the camera.
  26201. */
  26202. inputs: CameraInputsManager<Camera>;
  26203. /** @hidden */
  26204. _position: Vector3;
  26205. /**
  26206. * Define the current local position of the camera in the scene
  26207. */
  26208. get position(): Vector3;
  26209. set position(newPosition: Vector3);
  26210. /**
  26211. * The vector the camera should consider as up.
  26212. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26213. */
  26214. upVector: Vector3;
  26215. /**
  26216. * Define the current limit on the left side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoLeft: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the right side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoRight: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the bottom side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoBottom: Nullable<number>;
  26230. /**
  26231. * Define the current limit on the top side for an orthographic camera
  26232. * In scene unit
  26233. */
  26234. orthoTop: Nullable<number>;
  26235. /**
  26236. * Field Of View is set in Radians. (default is 0.8)
  26237. */
  26238. fov: number;
  26239. /**
  26240. * Define the minimum distance the camera can see from.
  26241. * This is important to note that the depth buffer are not infinite and the closer it starts
  26242. * the more your scene might encounter depth fighting issue.
  26243. */
  26244. minZ: number;
  26245. /**
  26246. * Define the maximum distance the camera can see to.
  26247. * This is important to note that the depth buffer are not infinite and the further it end
  26248. * the more your scene might encounter depth fighting issue.
  26249. */
  26250. maxZ: number;
  26251. /**
  26252. * Define the default inertia of the camera.
  26253. * This helps giving a smooth feeling to the camera movement.
  26254. */
  26255. inertia: number;
  26256. /**
  26257. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26258. */
  26259. mode: number;
  26260. /**
  26261. * Define whether the camera is intermediate.
  26262. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26263. */
  26264. isIntermediate: boolean;
  26265. /**
  26266. * Define the viewport of the camera.
  26267. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26268. */
  26269. viewport: Viewport;
  26270. /**
  26271. * Restricts the camera to viewing objects with the same layerMask.
  26272. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26273. */
  26274. layerMask: number;
  26275. /**
  26276. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26277. */
  26278. fovMode: number;
  26279. /**
  26280. * Rig mode of the camera.
  26281. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26282. * This is normally controlled byt the camera themselves as internal use.
  26283. */
  26284. cameraRigMode: number;
  26285. /**
  26286. * Defines the distance between both "eyes" in case of a RIG
  26287. */
  26288. interaxialDistance: number;
  26289. /**
  26290. * Defines if stereoscopic rendering is done side by side or over under.
  26291. */
  26292. isStereoscopicSideBySide: boolean;
  26293. /**
  26294. * 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
  26295. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26296. * else in the scene. (Eg. security camera)
  26297. *
  26298. * 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)
  26299. */
  26300. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26301. /**
  26302. * When set, the camera will render to this render target instead of the default canvas
  26303. *
  26304. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26305. */
  26306. outputRenderTarget: Nullable<RenderTargetTexture>;
  26307. /**
  26308. * Observable triggered when the camera view matrix has changed.
  26309. */
  26310. onViewMatrixChangedObservable: Observable<Camera>;
  26311. /**
  26312. * Observable triggered when the camera Projection matrix has changed.
  26313. */
  26314. onProjectionMatrixChangedObservable: Observable<Camera>;
  26315. /**
  26316. * Observable triggered when the inputs have been processed.
  26317. */
  26318. onAfterCheckInputsObservable: Observable<Camera>;
  26319. /**
  26320. * Observable triggered when reset has been called and applied to the camera.
  26321. */
  26322. onRestoreStateObservable: Observable<Camera>;
  26323. /**
  26324. * Is this camera a part of a rig system?
  26325. */
  26326. isRigCamera: boolean;
  26327. /**
  26328. * If isRigCamera set to true this will be set with the parent camera.
  26329. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26330. */
  26331. rigParent?: Camera;
  26332. /** @hidden */
  26333. _cameraRigParams: any;
  26334. /** @hidden */
  26335. _rigCameras: Camera[];
  26336. /** @hidden */
  26337. _rigPostProcess: Nullable<PostProcess>;
  26338. protected _webvrViewMatrix: Matrix;
  26339. /** @hidden */
  26340. _skipRendering: boolean;
  26341. /** @hidden */
  26342. _projectionMatrix: Matrix;
  26343. /** @hidden */
  26344. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26345. /** @hidden */
  26346. _activeMeshes: SmartArray<AbstractMesh>;
  26347. protected _globalPosition: Vector3;
  26348. /** @hidden */
  26349. _computedViewMatrix: Matrix;
  26350. private _doNotComputeProjectionMatrix;
  26351. private _transformMatrix;
  26352. private _frustumPlanes;
  26353. private _refreshFrustumPlanes;
  26354. private _storedFov;
  26355. private _stateStored;
  26356. /**
  26357. * Instantiates a new camera object.
  26358. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26359. * @see http://doc.babylonjs.com/features/cameras
  26360. * @param name Defines the name of the camera in the scene
  26361. * @param position Defines the position of the camera
  26362. * @param scene Defines the scene the camera belongs too
  26363. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26364. */
  26365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26366. /**
  26367. * Store current camera state (fov, position, etc..)
  26368. * @returns the camera
  26369. */
  26370. storeState(): Camera;
  26371. /**
  26372. * Restores the camera state values if it has been stored. You must call storeState() first
  26373. */
  26374. protected _restoreStateValues(): boolean;
  26375. /**
  26376. * Restored camera state. You must call storeState() first.
  26377. * @returns true if restored and false otherwise
  26378. */
  26379. restoreState(): boolean;
  26380. /**
  26381. * Gets the class name of the camera.
  26382. * @returns the class name
  26383. */
  26384. getClassName(): string;
  26385. /** @hidden */
  26386. readonly _isCamera: boolean;
  26387. /**
  26388. * Gets a string representation of the camera useful for debug purpose.
  26389. * @param fullDetails Defines that a more verboe level of logging is required
  26390. * @returns the string representation
  26391. */
  26392. toString(fullDetails?: boolean): string;
  26393. /**
  26394. * Gets the current world space position of the camera.
  26395. */
  26396. get globalPosition(): Vector3;
  26397. /**
  26398. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26399. * @returns the active meshe list
  26400. */
  26401. getActiveMeshes(): SmartArray<AbstractMesh>;
  26402. /**
  26403. * Check whether a mesh is part of the current active mesh list of the camera
  26404. * @param mesh Defines the mesh to check
  26405. * @returns true if active, false otherwise
  26406. */
  26407. isActiveMesh(mesh: Mesh): boolean;
  26408. /**
  26409. * Is this camera ready to be used/rendered
  26410. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26411. * @return true if the camera is ready
  26412. */
  26413. isReady(completeCheck?: boolean): boolean;
  26414. /** @hidden */
  26415. _initCache(): void;
  26416. /** @hidden */
  26417. _updateCache(ignoreParentClass?: boolean): void;
  26418. /** @hidden */
  26419. _isSynchronized(): boolean;
  26420. /** @hidden */
  26421. _isSynchronizedViewMatrix(): boolean;
  26422. /** @hidden */
  26423. _isSynchronizedProjectionMatrix(): boolean;
  26424. /**
  26425. * Attach the input controls to a specific dom element to get the input from.
  26426. * @param element Defines the element the controls should be listened from
  26427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26428. */
  26429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26430. /**
  26431. * Detach the current controls from the specified dom element.
  26432. * @param element Defines the element to stop listening the inputs from
  26433. */
  26434. detachControl(element: HTMLElement): void;
  26435. /**
  26436. * Update the camera state according to the different inputs gathered during the frame.
  26437. */
  26438. update(): void;
  26439. /** @hidden */
  26440. _checkInputs(): void;
  26441. /** @hidden */
  26442. get rigCameras(): Camera[];
  26443. /**
  26444. * Gets the post process used by the rig cameras
  26445. */
  26446. get rigPostProcess(): Nullable<PostProcess>;
  26447. /**
  26448. * Internal, gets the first post proces.
  26449. * @returns the first post process to be run on this camera.
  26450. */
  26451. _getFirstPostProcess(): Nullable<PostProcess>;
  26452. private _cascadePostProcessesToRigCams;
  26453. /**
  26454. * Attach a post process to the camera.
  26455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26456. * @param postProcess The post process to attach to the camera
  26457. * @param insertAt The position of the post process in case several of them are in use in the scene
  26458. * @returns the position the post process has been inserted at
  26459. */
  26460. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26461. /**
  26462. * Detach a post process to the camera.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26464. * @param postProcess The post process to detach from the camera
  26465. */
  26466. detachPostProcess(postProcess: PostProcess): void;
  26467. /**
  26468. * Gets the current world matrix of the camera
  26469. */
  26470. getWorldMatrix(): Matrix;
  26471. /** @hidden */
  26472. _getViewMatrix(): Matrix;
  26473. /**
  26474. * Gets the current view matrix of the camera.
  26475. * @param force forces the camera to recompute the matrix without looking at the cached state
  26476. * @returns the view matrix
  26477. */
  26478. getViewMatrix(force?: boolean): Matrix;
  26479. /**
  26480. * Freeze the projection matrix.
  26481. * It will prevent the cache check of the camera projection compute and can speed up perf
  26482. * if no parameter of the camera are meant to change
  26483. * @param projection Defines manually a projection if necessary
  26484. */
  26485. freezeProjectionMatrix(projection?: Matrix): void;
  26486. /**
  26487. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26488. */
  26489. unfreezeProjectionMatrix(): void;
  26490. /**
  26491. * Gets the current projection matrix of the camera.
  26492. * @param force forces the camera to recompute the matrix without looking at the cached state
  26493. * @returns the projection matrix
  26494. */
  26495. getProjectionMatrix(force?: boolean): Matrix;
  26496. /**
  26497. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26498. * @returns a Matrix
  26499. */
  26500. getTransformationMatrix(): Matrix;
  26501. private _updateFrustumPlanes;
  26502. /**
  26503. * Checks if a cullable object (mesh...) is in the camera frustum
  26504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26505. * @param target The object to check
  26506. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26507. * @returns true if the object is in frustum otherwise false
  26508. */
  26509. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26510. /**
  26511. * Checks if a cullable object (mesh...) is in the camera frustum
  26512. * Unlike isInFrustum this cheks the full bounding box
  26513. * @param target The object to check
  26514. * @returns true if the object is in frustum otherwise false
  26515. */
  26516. isCompletelyInFrustum(target: ICullable): boolean;
  26517. /**
  26518. * Gets a ray in the forward direction from the camera.
  26519. * @param length Defines the length of the ray to create
  26520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26521. * @param origin Defines the start point of the ray which defaults to the camera position
  26522. * @returns the forward ray
  26523. */
  26524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26525. /**
  26526. * Releases resources associated with this node.
  26527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26529. */
  26530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26531. /** @hidden */
  26532. _isLeftCamera: boolean;
  26533. /**
  26534. * Gets the left camera of a rig setup in case of Rigged Camera
  26535. */
  26536. get isLeftCamera(): boolean;
  26537. /** @hidden */
  26538. _isRightCamera: boolean;
  26539. /**
  26540. * Gets the right camera of a rig setup in case of Rigged Camera
  26541. */
  26542. get isRightCamera(): boolean;
  26543. /**
  26544. * Gets the left camera of a rig setup in case of Rigged Camera
  26545. */
  26546. get leftCamera(): Nullable<FreeCamera>;
  26547. /**
  26548. * Gets the right camera of a rig setup in case of Rigged Camera
  26549. */
  26550. get rightCamera(): Nullable<FreeCamera>;
  26551. /**
  26552. * Gets the left camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getLeftTarget(): Nullable<Vector3>;
  26556. /**
  26557. * Gets the right camera target of a rig setup in case of Rigged Camera
  26558. * @returns the target position
  26559. */
  26560. getRightTarget(): Nullable<Vector3>;
  26561. /**
  26562. * @hidden
  26563. */
  26564. setCameraRigMode(mode: number, rigParams: any): void;
  26565. /** @hidden */
  26566. static _setStereoscopicRigMode(camera: Camera): void;
  26567. /** @hidden */
  26568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26569. /** @hidden */
  26570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26571. /** @hidden */
  26572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26573. /** @hidden */
  26574. _getVRProjectionMatrix(): Matrix;
  26575. protected _updateCameraRotationMatrix(): void;
  26576. protected _updateWebVRCameraRotationMatrix(): void;
  26577. /**
  26578. * This function MUST be overwritten by the different WebVR cameras available.
  26579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26580. * @hidden
  26581. */
  26582. _getWebVRProjectionMatrix(): Matrix;
  26583. /**
  26584. * This function MUST be overwritten by the different WebVR cameras available.
  26585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26586. * @hidden
  26587. */
  26588. _getWebVRViewMatrix(): Matrix;
  26589. /** @hidden */
  26590. setCameraRigParameter(name: string, value: any): void;
  26591. /**
  26592. * needs to be overridden by children so sub has required properties to be copied
  26593. * @hidden
  26594. */
  26595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26596. /**
  26597. * May need to be overridden by children
  26598. * @hidden
  26599. */
  26600. _updateRigCameras(): void;
  26601. /** @hidden */
  26602. _setupInputs(): void;
  26603. /**
  26604. * Serialiaze the camera setup to a json represention
  26605. * @returns the JSON representation
  26606. */
  26607. serialize(): any;
  26608. /**
  26609. * Clones the current camera.
  26610. * @param name The cloned camera name
  26611. * @returns the cloned camera
  26612. */
  26613. clone(name: string): Camera;
  26614. /**
  26615. * Gets the direction of the camera relative to a given local axis.
  26616. * @param localAxis Defines the reference axis to provide a relative direction.
  26617. * @return the direction
  26618. */
  26619. getDirection(localAxis: Vector3): Vector3;
  26620. /**
  26621. * Returns the current camera absolute rotation
  26622. */
  26623. get absoluteRotation(): Quaternion;
  26624. /**
  26625. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26626. * @param localAxis Defines the reference axis to provide a relative direction.
  26627. * @param result Defines the vector to store the result in
  26628. */
  26629. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26630. /**
  26631. * Gets a camera constructor for a given camera type
  26632. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26633. * @param name The name of the camera the result will be able to instantiate
  26634. * @param scene The scene the result will construct the camera in
  26635. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26636. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26637. * @returns a factory method to construc the camera
  26638. */
  26639. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26640. /**
  26641. * Compute the world matrix of the camera.
  26642. * @returns the camera world matrix
  26643. */
  26644. computeWorldMatrix(): Matrix;
  26645. /**
  26646. * Parse a JSON and creates the camera from the parsed information
  26647. * @param parsedCamera The JSON to parse
  26648. * @param scene The scene to instantiate the camera in
  26649. * @returns the newly constructed camera
  26650. */
  26651. static Parse(parsedCamera: any, scene: Scene): Camera;
  26652. }
  26653. }
  26654. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26655. import { Nullable } from "babylonjs/types";
  26656. import { Scene } from "babylonjs/scene";
  26657. import { Vector4 } from "babylonjs/Maths/math.vector";
  26658. import { Mesh } from "babylonjs/Meshes/mesh";
  26659. /**
  26660. * Class containing static functions to help procedurally build meshes
  26661. */
  26662. export class DiscBuilder {
  26663. /**
  26664. * Creates a plane polygonal mesh. By default, this is a disc
  26665. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26666. * * 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
  26667. * * 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
  26668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26671. * @param name defines the name of the mesh
  26672. * @param options defines the options used to create the mesh
  26673. * @param scene defines the hosting scene
  26674. * @returns the plane polygonal mesh
  26675. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26676. */
  26677. static CreateDisc(name: string, options: {
  26678. radius?: number;
  26679. tessellation?: number;
  26680. arc?: number;
  26681. updatable?: boolean;
  26682. sideOrientation?: number;
  26683. frontUVs?: Vector4;
  26684. backUVs?: Vector4;
  26685. }, scene?: Nullable<Scene>): Mesh;
  26686. }
  26687. }
  26688. declare module "babylonjs/Materials/fresnelParameters" {
  26689. import { Color3 } from "babylonjs/Maths/math.color";
  26690. /**
  26691. * This represents all the required information to add a fresnel effect on a material:
  26692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26693. */
  26694. export class FresnelParameters {
  26695. private _isEnabled;
  26696. /**
  26697. * Define if the fresnel effect is enable or not.
  26698. */
  26699. get isEnabled(): boolean;
  26700. set isEnabled(value: boolean);
  26701. /**
  26702. * Define the color used on edges (grazing angle)
  26703. */
  26704. leftColor: Color3;
  26705. /**
  26706. * Define the color used on center
  26707. */
  26708. rightColor: Color3;
  26709. /**
  26710. * Define bias applied to computed fresnel term
  26711. */
  26712. bias: number;
  26713. /**
  26714. * Defined the power exponent applied to fresnel term
  26715. */
  26716. power: number;
  26717. /**
  26718. * Clones the current fresnel and its valuues
  26719. * @returns a clone fresnel configuration
  26720. */
  26721. clone(): FresnelParameters;
  26722. /**
  26723. * Serializes the current fresnel parameters to a JSON representation.
  26724. * @return the JSON serialization
  26725. */
  26726. serialize(): any;
  26727. /**
  26728. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26729. * @param parsedFresnelParameters Define the JSON representation
  26730. * @returns the parsed parameters
  26731. */
  26732. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26733. }
  26734. }
  26735. declare module "babylonjs/Materials/pushMaterial" {
  26736. import { Nullable } from "babylonjs/types";
  26737. import { Scene } from "babylonjs/scene";
  26738. import { Matrix } from "babylonjs/Maths/math.vector";
  26739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26740. import { Mesh } from "babylonjs/Meshes/mesh";
  26741. import { Material } from "babylonjs/Materials/material";
  26742. import { Effect } from "babylonjs/Materials/effect";
  26743. /**
  26744. * Base class of materials working in push mode in babylon JS
  26745. * @hidden
  26746. */
  26747. export class PushMaterial extends Material {
  26748. protected _activeEffect: Effect;
  26749. protected _normalMatrix: Matrix;
  26750. /**
  26751. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26752. * This means that the material can keep using a previous shader while a new one is being compiled.
  26753. * This is mostly used when shader parallel compilation is supported (true by default)
  26754. */
  26755. allowShaderHotSwapping: boolean;
  26756. constructor(name: string, scene: Scene);
  26757. getEffect(): Effect;
  26758. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26759. /**
  26760. * Binds the given world matrix to the active effect
  26761. *
  26762. * @param world the matrix to bind
  26763. */
  26764. bindOnlyWorldMatrix(world: Matrix): void;
  26765. /**
  26766. * Binds the given normal matrix to the active effect
  26767. *
  26768. * @param normalMatrix the matrix to bind
  26769. */
  26770. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26771. bind(world: Matrix, mesh?: Mesh): void;
  26772. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26773. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26774. }
  26775. }
  26776. declare module "babylonjs/Materials/materialFlags" {
  26777. /**
  26778. * This groups all the flags used to control the materials channel.
  26779. */
  26780. export class MaterialFlags {
  26781. private static _DiffuseTextureEnabled;
  26782. /**
  26783. * Are diffuse textures enabled in the application.
  26784. */
  26785. static get DiffuseTextureEnabled(): boolean;
  26786. static set DiffuseTextureEnabled(value: boolean);
  26787. private static _AmbientTextureEnabled;
  26788. /**
  26789. * Are ambient textures enabled in the application.
  26790. */
  26791. static get AmbientTextureEnabled(): boolean;
  26792. static set AmbientTextureEnabled(value: boolean);
  26793. private static _OpacityTextureEnabled;
  26794. /**
  26795. * Are opacity textures enabled in the application.
  26796. */
  26797. static get OpacityTextureEnabled(): boolean;
  26798. static set OpacityTextureEnabled(value: boolean);
  26799. private static _ReflectionTextureEnabled;
  26800. /**
  26801. * Are reflection textures enabled in the application.
  26802. */
  26803. static get ReflectionTextureEnabled(): boolean;
  26804. static set ReflectionTextureEnabled(value: boolean);
  26805. private static _EmissiveTextureEnabled;
  26806. /**
  26807. * Are emissive textures enabled in the application.
  26808. */
  26809. static get EmissiveTextureEnabled(): boolean;
  26810. static set EmissiveTextureEnabled(value: boolean);
  26811. private static _SpecularTextureEnabled;
  26812. /**
  26813. * Are specular textures enabled in the application.
  26814. */
  26815. static get SpecularTextureEnabled(): boolean;
  26816. static set SpecularTextureEnabled(value: boolean);
  26817. private static _BumpTextureEnabled;
  26818. /**
  26819. * Are bump textures enabled in the application.
  26820. */
  26821. static get BumpTextureEnabled(): boolean;
  26822. static set BumpTextureEnabled(value: boolean);
  26823. private static _LightmapTextureEnabled;
  26824. /**
  26825. * Are lightmap textures enabled in the application.
  26826. */
  26827. static get LightmapTextureEnabled(): boolean;
  26828. static set LightmapTextureEnabled(value: boolean);
  26829. private static _RefractionTextureEnabled;
  26830. /**
  26831. * Are refraction textures enabled in the application.
  26832. */
  26833. static get RefractionTextureEnabled(): boolean;
  26834. static set RefractionTextureEnabled(value: boolean);
  26835. private static _ColorGradingTextureEnabled;
  26836. /**
  26837. * Are color grading textures enabled in the application.
  26838. */
  26839. static get ColorGradingTextureEnabled(): boolean;
  26840. static set ColorGradingTextureEnabled(value: boolean);
  26841. private static _FresnelEnabled;
  26842. /**
  26843. * Are fresnels enabled in the application.
  26844. */
  26845. static get FresnelEnabled(): boolean;
  26846. static set FresnelEnabled(value: boolean);
  26847. private static _ClearCoatTextureEnabled;
  26848. /**
  26849. * Are clear coat textures enabled in the application.
  26850. */
  26851. static get ClearCoatTextureEnabled(): boolean;
  26852. static set ClearCoatTextureEnabled(value: boolean);
  26853. private static _ClearCoatBumpTextureEnabled;
  26854. /**
  26855. * Are clear coat bump textures enabled in the application.
  26856. */
  26857. static get ClearCoatBumpTextureEnabled(): boolean;
  26858. static set ClearCoatBumpTextureEnabled(value: boolean);
  26859. private static _ClearCoatTintTextureEnabled;
  26860. /**
  26861. * Are clear coat tint textures enabled in the application.
  26862. */
  26863. static get ClearCoatTintTextureEnabled(): boolean;
  26864. static set ClearCoatTintTextureEnabled(value: boolean);
  26865. private static _SheenTextureEnabled;
  26866. /**
  26867. * Are sheen textures enabled in the application.
  26868. */
  26869. static get SheenTextureEnabled(): boolean;
  26870. static set SheenTextureEnabled(value: boolean);
  26871. private static _AnisotropicTextureEnabled;
  26872. /**
  26873. * Are anisotropic textures enabled in the application.
  26874. */
  26875. static get AnisotropicTextureEnabled(): boolean;
  26876. static set AnisotropicTextureEnabled(value: boolean);
  26877. private static _ThicknessTextureEnabled;
  26878. /**
  26879. * Are thickness textures enabled in the application.
  26880. */
  26881. static get ThicknessTextureEnabled(): boolean;
  26882. static set ThicknessTextureEnabled(value: boolean);
  26883. }
  26884. }
  26885. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26886. /** @hidden */
  26887. export var defaultFragmentDeclaration: {
  26888. name: string;
  26889. shader: string;
  26890. };
  26891. }
  26892. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26893. /** @hidden */
  26894. export var defaultUboDeclaration: {
  26895. name: string;
  26896. shader: string;
  26897. };
  26898. }
  26899. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26900. /** @hidden */
  26901. export var lightFragmentDeclaration: {
  26902. name: string;
  26903. shader: string;
  26904. };
  26905. }
  26906. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26907. /** @hidden */
  26908. export var lightUboDeclaration: {
  26909. name: string;
  26910. shader: string;
  26911. };
  26912. }
  26913. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26914. /** @hidden */
  26915. export var lightsFragmentFunctions: {
  26916. name: string;
  26917. shader: string;
  26918. };
  26919. }
  26920. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26921. /** @hidden */
  26922. export var shadowsFragmentFunctions: {
  26923. name: string;
  26924. shader: string;
  26925. };
  26926. }
  26927. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26928. /** @hidden */
  26929. export var fresnelFunction: {
  26930. name: string;
  26931. shader: string;
  26932. };
  26933. }
  26934. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26935. /** @hidden */
  26936. export var reflectionFunction: {
  26937. name: string;
  26938. shader: string;
  26939. };
  26940. }
  26941. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26942. /** @hidden */
  26943. export var bumpFragmentFunctions: {
  26944. name: string;
  26945. shader: string;
  26946. };
  26947. }
  26948. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26949. /** @hidden */
  26950. export var logDepthDeclaration: {
  26951. name: string;
  26952. shader: string;
  26953. };
  26954. }
  26955. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26956. /** @hidden */
  26957. export var bumpFragment: {
  26958. name: string;
  26959. shader: string;
  26960. };
  26961. }
  26962. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26963. /** @hidden */
  26964. export var depthPrePass: {
  26965. name: string;
  26966. shader: string;
  26967. };
  26968. }
  26969. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26970. /** @hidden */
  26971. export var lightFragment: {
  26972. name: string;
  26973. shader: string;
  26974. };
  26975. }
  26976. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26977. /** @hidden */
  26978. export var logDepthFragment: {
  26979. name: string;
  26980. shader: string;
  26981. };
  26982. }
  26983. declare module "babylonjs/Shaders/default.fragment" {
  26984. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26992. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26993. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26997. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27002. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27003. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27004. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27005. /** @hidden */
  27006. export var defaultPixelShader: {
  27007. name: string;
  27008. shader: string;
  27009. };
  27010. }
  27011. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27012. /** @hidden */
  27013. export var defaultVertexDeclaration: {
  27014. name: string;
  27015. shader: string;
  27016. };
  27017. }
  27018. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27019. /** @hidden */
  27020. export var bumpVertexDeclaration: {
  27021. name: string;
  27022. shader: string;
  27023. };
  27024. }
  27025. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27026. /** @hidden */
  27027. export var bumpVertex: {
  27028. name: string;
  27029. shader: string;
  27030. };
  27031. }
  27032. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27033. /** @hidden */
  27034. export var fogVertex: {
  27035. name: string;
  27036. shader: string;
  27037. };
  27038. }
  27039. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27040. /** @hidden */
  27041. export var shadowsVertex: {
  27042. name: string;
  27043. shader: string;
  27044. };
  27045. }
  27046. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27047. /** @hidden */
  27048. export var pointCloudVertex: {
  27049. name: string;
  27050. shader: string;
  27051. };
  27052. }
  27053. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27054. /** @hidden */
  27055. export var logDepthVertex: {
  27056. name: string;
  27057. shader: string;
  27058. };
  27059. }
  27060. declare module "babylonjs/Shaders/default.vertex" {
  27061. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27064. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27073. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27080. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27081. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27082. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27083. /** @hidden */
  27084. export var defaultVertexShader: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Materials/standardMaterial" {
  27090. import { SmartArray } from "babylonjs/Misc/smartArray";
  27091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27092. import { Nullable } from "babylonjs/types";
  27093. import { Scene } from "babylonjs/scene";
  27094. import { Matrix } from "babylonjs/Maths/math.vector";
  27095. import { Color3 } from "babylonjs/Maths/math.color";
  27096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27098. import { Mesh } from "babylonjs/Meshes/mesh";
  27099. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27100. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27101. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27103. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27106. import "babylonjs/Shaders/default.fragment";
  27107. import "babylonjs/Shaders/default.vertex";
  27108. /** @hidden */
  27109. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27110. MAINUV1: boolean;
  27111. MAINUV2: boolean;
  27112. DIFFUSE: boolean;
  27113. DIFFUSEDIRECTUV: number;
  27114. AMBIENT: boolean;
  27115. AMBIENTDIRECTUV: number;
  27116. OPACITY: boolean;
  27117. OPACITYDIRECTUV: number;
  27118. OPACITYRGB: boolean;
  27119. REFLECTION: boolean;
  27120. EMISSIVE: boolean;
  27121. EMISSIVEDIRECTUV: number;
  27122. SPECULAR: boolean;
  27123. SPECULARDIRECTUV: number;
  27124. BUMP: boolean;
  27125. BUMPDIRECTUV: number;
  27126. PARALLAX: boolean;
  27127. PARALLAXOCCLUSION: boolean;
  27128. SPECULAROVERALPHA: boolean;
  27129. CLIPPLANE: boolean;
  27130. CLIPPLANE2: boolean;
  27131. CLIPPLANE3: boolean;
  27132. CLIPPLANE4: boolean;
  27133. CLIPPLANE5: boolean;
  27134. CLIPPLANE6: boolean;
  27135. ALPHATEST: boolean;
  27136. DEPTHPREPASS: boolean;
  27137. ALPHAFROMDIFFUSE: boolean;
  27138. POINTSIZE: boolean;
  27139. FOG: boolean;
  27140. SPECULARTERM: boolean;
  27141. DIFFUSEFRESNEL: boolean;
  27142. OPACITYFRESNEL: boolean;
  27143. REFLECTIONFRESNEL: boolean;
  27144. REFRACTIONFRESNEL: boolean;
  27145. EMISSIVEFRESNEL: boolean;
  27146. FRESNEL: boolean;
  27147. NORMAL: boolean;
  27148. UV1: boolean;
  27149. UV2: boolean;
  27150. VERTEXCOLOR: boolean;
  27151. VERTEXALPHA: boolean;
  27152. NUM_BONE_INFLUENCERS: number;
  27153. BonesPerMesh: number;
  27154. BONETEXTURE: boolean;
  27155. INSTANCES: boolean;
  27156. GLOSSINESS: boolean;
  27157. ROUGHNESS: boolean;
  27158. EMISSIVEASILLUMINATION: boolean;
  27159. LINKEMISSIVEWITHDIFFUSE: boolean;
  27160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27161. LIGHTMAP: boolean;
  27162. LIGHTMAPDIRECTUV: number;
  27163. OBJECTSPACE_NORMALMAP: boolean;
  27164. USELIGHTMAPASSHADOWMAP: boolean;
  27165. REFLECTIONMAP_3D: boolean;
  27166. REFLECTIONMAP_SPHERICAL: boolean;
  27167. REFLECTIONMAP_PLANAR: boolean;
  27168. REFLECTIONMAP_CUBIC: boolean;
  27169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27170. REFLECTIONMAP_PROJECTION: boolean;
  27171. REFLECTIONMAP_SKYBOX: boolean;
  27172. REFLECTIONMAP_EXPLICIT: boolean;
  27173. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27174. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27175. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27176. INVERTCUBICMAP: boolean;
  27177. LOGARITHMICDEPTH: boolean;
  27178. REFRACTION: boolean;
  27179. REFRACTIONMAP_3D: boolean;
  27180. REFLECTIONOVERALPHA: boolean;
  27181. TWOSIDEDLIGHTING: boolean;
  27182. SHADOWFLOAT: boolean;
  27183. MORPHTARGETS: boolean;
  27184. MORPHTARGETS_NORMAL: boolean;
  27185. MORPHTARGETS_TANGENT: boolean;
  27186. MORPHTARGETS_UV: boolean;
  27187. NUM_MORPH_INFLUENCERS: number;
  27188. NONUNIFORMSCALING: boolean;
  27189. PREMULTIPLYALPHA: boolean;
  27190. IMAGEPROCESSING: boolean;
  27191. VIGNETTE: boolean;
  27192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27193. VIGNETTEBLENDMODEOPAQUE: boolean;
  27194. TONEMAPPING: boolean;
  27195. TONEMAPPING_ACES: boolean;
  27196. CONTRAST: boolean;
  27197. COLORCURVES: boolean;
  27198. COLORGRADING: boolean;
  27199. COLORGRADING3D: boolean;
  27200. SAMPLER3DGREENDEPTH: boolean;
  27201. SAMPLER3DBGRMAP: boolean;
  27202. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27203. MULTIVIEW: boolean;
  27204. /**
  27205. * If the reflection texture on this material is in linear color space
  27206. * @hidden
  27207. */
  27208. IS_REFLECTION_LINEAR: boolean;
  27209. /**
  27210. * If the refraction texture on this material is in linear color space
  27211. * @hidden
  27212. */
  27213. IS_REFRACTION_LINEAR: boolean;
  27214. EXPOSURE: boolean;
  27215. constructor();
  27216. setReflectionMode(modeToEnable: string): void;
  27217. }
  27218. /**
  27219. * This is the default material used in Babylon. It is the best trade off between quality
  27220. * and performances.
  27221. * @see http://doc.babylonjs.com/babylon101/materials
  27222. */
  27223. export class StandardMaterial extends PushMaterial {
  27224. private _diffuseTexture;
  27225. /**
  27226. * The basic texture of the material as viewed under a light.
  27227. */
  27228. diffuseTexture: Nullable<BaseTexture>;
  27229. private _ambientTexture;
  27230. /**
  27231. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27232. */
  27233. ambientTexture: Nullable<BaseTexture>;
  27234. private _opacityTexture;
  27235. /**
  27236. * Define the transparency of the material from a texture.
  27237. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27238. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27239. */
  27240. opacityTexture: Nullable<BaseTexture>;
  27241. private _reflectionTexture;
  27242. /**
  27243. * Define the texture used to display the reflection.
  27244. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27245. */
  27246. reflectionTexture: Nullable<BaseTexture>;
  27247. private _emissiveTexture;
  27248. /**
  27249. * Define texture of the material as if self lit.
  27250. * This will be mixed in the final result even in the absence of light.
  27251. */
  27252. emissiveTexture: Nullable<BaseTexture>;
  27253. private _specularTexture;
  27254. /**
  27255. * Define how the color and intensity of the highlight given by the light in the material.
  27256. */
  27257. specularTexture: Nullable<BaseTexture>;
  27258. private _bumpTexture;
  27259. /**
  27260. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27261. * 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.
  27262. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27263. */
  27264. bumpTexture: Nullable<BaseTexture>;
  27265. private _lightmapTexture;
  27266. /**
  27267. * Complex lighting can be computationally expensive to compute at runtime.
  27268. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27269. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27270. */
  27271. lightmapTexture: Nullable<BaseTexture>;
  27272. private _refractionTexture;
  27273. /**
  27274. * Define the texture used to display the refraction.
  27275. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27276. */
  27277. refractionTexture: Nullable<BaseTexture>;
  27278. /**
  27279. * The color of the material lit by the environmental background lighting.
  27280. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27281. */
  27282. ambientColor: Color3;
  27283. /**
  27284. * The basic color of the material as viewed under a light.
  27285. */
  27286. diffuseColor: Color3;
  27287. /**
  27288. * Define how the color and intensity of the highlight given by the light in the material.
  27289. */
  27290. specularColor: Color3;
  27291. /**
  27292. * Define the color of the material as if self lit.
  27293. * This will be mixed in the final result even in the absence of light.
  27294. */
  27295. emissiveColor: Color3;
  27296. /**
  27297. * Defines how sharp are the highlights in the material.
  27298. * The bigger the value the sharper giving a more glossy feeling to the result.
  27299. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27300. */
  27301. specularPower: number;
  27302. private _useAlphaFromDiffuseTexture;
  27303. /**
  27304. * Does the transparency come from the diffuse texture alpha channel.
  27305. */
  27306. useAlphaFromDiffuseTexture: boolean;
  27307. private _useEmissiveAsIllumination;
  27308. /**
  27309. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27310. */
  27311. useEmissiveAsIllumination: boolean;
  27312. private _linkEmissiveWithDiffuse;
  27313. /**
  27314. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27315. * the emissive level when the final color is close to one.
  27316. */
  27317. linkEmissiveWithDiffuse: boolean;
  27318. private _useSpecularOverAlpha;
  27319. /**
  27320. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27321. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27322. */
  27323. useSpecularOverAlpha: boolean;
  27324. private _useReflectionOverAlpha;
  27325. /**
  27326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27328. */
  27329. useReflectionOverAlpha: boolean;
  27330. private _disableLighting;
  27331. /**
  27332. * Does lights from the scene impacts this material.
  27333. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27334. */
  27335. disableLighting: boolean;
  27336. private _useObjectSpaceNormalMap;
  27337. /**
  27338. * Allows using an object space normal map (instead of tangent space).
  27339. */
  27340. useObjectSpaceNormalMap: boolean;
  27341. private _useParallax;
  27342. /**
  27343. * Is parallax enabled or not.
  27344. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27345. */
  27346. useParallax: boolean;
  27347. private _useParallaxOcclusion;
  27348. /**
  27349. * Is parallax occlusion enabled or not.
  27350. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27351. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27352. */
  27353. useParallaxOcclusion: boolean;
  27354. /**
  27355. * 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.
  27356. */
  27357. parallaxScaleBias: number;
  27358. private _roughness;
  27359. /**
  27360. * Helps to define how blurry the reflections should appears in the material.
  27361. */
  27362. roughness: number;
  27363. /**
  27364. * In case of refraction, define the value of the index of refraction.
  27365. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27366. */
  27367. indexOfRefraction: number;
  27368. /**
  27369. * Invert the refraction texture alongside the y axis.
  27370. * It can be useful with procedural textures or probe for instance.
  27371. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27372. */
  27373. invertRefractionY: boolean;
  27374. /**
  27375. * Defines the alpha limits in alpha test mode.
  27376. */
  27377. alphaCutOff: number;
  27378. private _useLightmapAsShadowmap;
  27379. /**
  27380. * In case of light mapping, define whether the map contains light or shadow informations.
  27381. */
  27382. useLightmapAsShadowmap: boolean;
  27383. private _diffuseFresnelParameters;
  27384. /**
  27385. * Define the diffuse fresnel parameters of the material.
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27387. */
  27388. diffuseFresnelParameters: FresnelParameters;
  27389. private _opacityFresnelParameters;
  27390. /**
  27391. * Define the opacity fresnel parameters of the material.
  27392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27393. */
  27394. opacityFresnelParameters: FresnelParameters;
  27395. private _reflectionFresnelParameters;
  27396. /**
  27397. * Define the reflection fresnel parameters of the material.
  27398. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27399. */
  27400. reflectionFresnelParameters: FresnelParameters;
  27401. private _refractionFresnelParameters;
  27402. /**
  27403. * Define the refraction fresnel parameters of the material.
  27404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27405. */
  27406. refractionFresnelParameters: FresnelParameters;
  27407. private _emissiveFresnelParameters;
  27408. /**
  27409. * Define the emissive fresnel parameters of the material.
  27410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27411. */
  27412. emissiveFresnelParameters: FresnelParameters;
  27413. private _useReflectionFresnelFromSpecular;
  27414. /**
  27415. * If true automatically deducts the fresnels values from the material specularity.
  27416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27417. */
  27418. useReflectionFresnelFromSpecular: boolean;
  27419. private _useGlossinessFromSpecularMapAlpha;
  27420. /**
  27421. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27422. */
  27423. useGlossinessFromSpecularMapAlpha: boolean;
  27424. private _maxSimultaneousLights;
  27425. /**
  27426. * Defines the maximum number of lights that can be used in the material
  27427. */
  27428. maxSimultaneousLights: number;
  27429. private _invertNormalMapX;
  27430. /**
  27431. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27432. */
  27433. invertNormalMapX: boolean;
  27434. private _invertNormalMapY;
  27435. /**
  27436. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27437. */
  27438. invertNormalMapY: boolean;
  27439. private _twoSidedLighting;
  27440. /**
  27441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27442. */
  27443. twoSidedLighting: boolean;
  27444. /**
  27445. * Default configuration related to image processing available in the standard Material.
  27446. */
  27447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27448. /**
  27449. * Gets the image processing configuration used either in this material.
  27450. */
  27451. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27452. /**
  27453. * Sets the Default image processing configuration used either in the this material.
  27454. *
  27455. * If sets to null, the scene one is in use.
  27456. */
  27457. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27458. /**
  27459. * Keep track of the image processing observer to allow dispose and replace.
  27460. */
  27461. private _imageProcessingObserver;
  27462. /**
  27463. * Attaches a new image processing configuration to the Standard Material.
  27464. * @param configuration
  27465. */
  27466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27467. /**
  27468. * Gets wether the color curves effect is enabled.
  27469. */
  27470. get cameraColorCurvesEnabled(): boolean;
  27471. /**
  27472. * Sets wether the color curves effect is enabled.
  27473. */
  27474. set cameraColorCurvesEnabled(value: boolean);
  27475. /**
  27476. * Gets wether the color grading effect is enabled.
  27477. */
  27478. get cameraColorGradingEnabled(): boolean;
  27479. /**
  27480. * Gets wether the color grading effect is enabled.
  27481. */
  27482. set cameraColorGradingEnabled(value: boolean);
  27483. /**
  27484. * Gets wether tonemapping is enabled or not.
  27485. */
  27486. get cameraToneMappingEnabled(): boolean;
  27487. /**
  27488. * Sets wether tonemapping is enabled or not
  27489. */
  27490. set cameraToneMappingEnabled(value: boolean);
  27491. /**
  27492. * The camera exposure used on this material.
  27493. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27494. * This corresponds to a photographic exposure.
  27495. */
  27496. get cameraExposure(): number;
  27497. /**
  27498. * The camera exposure used on this material.
  27499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27500. * This corresponds to a photographic exposure.
  27501. */
  27502. set cameraExposure(value: number);
  27503. /**
  27504. * Gets The camera contrast used on this material.
  27505. */
  27506. get cameraContrast(): number;
  27507. /**
  27508. * Sets The camera contrast used on this material.
  27509. */
  27510. set cameraContrast(value: number);
  27511. /**
  27512. * Gets the Color Grading 2D Lookup Texture.
  27513. */
  27514. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27515. /**
  27516. * Sets the Color Grading 2D Lookup Texture.
  27517. */
  27518. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27519. /**
  27520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27522. * 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;
  27523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27524. */
  27525. get cameraColorCurves(): Nullable<ColorCurves>;
  27526. /**
  27527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27529. * 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;
  27530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27531. */
  27532. set cameraColorCurves(value: Nullable<ColorCurves>);
  27533. /**
  27534. * Custom callback helping to override the default shader used in the material.
  27535. */
  27536. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27537. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27538. protected _worldViewProjectionMatrix: Matrix;
  27539. protected _globalAmbientColor: Color3;
  27540. protected _useLogarithmicDepth: boolean;
  27541. protected _rebuildInParallel: boolean;
  27542. /**
  27543. * Instantiates a new standard material.
  27544. * This is the default material used in Babylon. It is the best trade off between quality
  27545. * and performances.
  27546. * @see http://doc.babylonjs.com/babylon101/materials
  27547. * @param name Define the name of the material in the scene
  27548. * @param scene Define the scene the material belong to
  27549. */
  27550. constructor(name: string, scene: Scene);
  27551. /**
  27552. * Gets a boolean indicating that current material needs to register RTT
  27553. */
  27554. get hasRenderTargetTextures(): boolean;
  27555. /**
  27556. * Gets the current class name of the material e.g. "StandardMaterial"
  27557. * Mainly use in serialization.
  27558. * @returns the class name
  27559. */
  27560. getClassName(): string;
  27561. /**
  27562. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27563. * You can try switching to logarithmic depth.
  27564. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27565. */
  27566. get useLogarithmicDepth(): boolean;
  27567. set useLogarithmicDepth(value: boolean);
  27568. /**
  27569. * Specifies if the material will require alpha blending
  27570. * @returns a boolean specifying if alpha blending is needed
  27571. */
  27572. needAlphaBlending(): boolean;
  27573. /**
  27574. * Specifies if this material should be rendered in alpha test mode
  27575. * @returns a boolean specifying if an alpha test is needed.
  27576. */
  27577. needAlphaTesting(): boolean;
  27578. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27579. /**
  27580. * Get the texture used for alpha test purpose.
  27581. * @returns the diffuse texture in case of the standard material.
  27582. */
  27583. getAlphaTestTexture(): Nullable<BaseTexture>;
  27584. /**
  27585. * Get if the submesh is ready to be used and all its information available.
  27586. * Child classes can use it to update shaders
  27587. * @param mesh defines the mesh to check
  27588. * @param subMesh defines which submesh to check
  27589. * @param useInstances specifies that instances should be used
  27590. * @returns a boolean indicating that the submesh is ready or not
  27591. */
  27592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27593. /**
  27594. * Builds the material UBO layouts.
  27595. * Used internally during the effect preparation.
  27596. */
  27597. buildUniformLayout(): void;
  27598. /**
  27599. * Unbinds the material from the mesh
  27600. */
  27601. unbind(): void;
  27602. /**
  27603. * Binds the submesh to this material by preparing the effect and shader to draw
  27604. * @param world defines the world transformation matrix
  27605. * @param mesh defines the mesh containing the submesh
  27606. * @param subMesh defines the submesh to bind the material to
  27607. */
  27608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27609. /**
  27610. * Get the list of animatables in the material.
  27611. * @returns the list of animatables object used in the material
  27612. */
  27613. getAnimatables(): IAnimatable[];
  27614. /**
  27615. * Gets the active textures from the material
  27616. * @returns an array of textures
  27617. */
  27618. getActiveTextures(): BaseTexture[];
  27619. /**
  27620. * Specifies if the material uses a texture
  27621. * @param texture defines the texture to check against the material
  27622. * @returns a boolean specifying if the material uses the texture
  27623. */
  27624. hasTexture(texture: BaseTexture): boolean;
  27625. /**
  27626. * Disposes the material
  27627. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27628. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27629. */
  27630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27631. /**
  27632. * Makes a duplicate of the material, and gives it a new name
  27633. * @param name defines the new name for the duplicated material
  27634. * @returns the cloned material
  27635. */
  27636. clone(name: string): StandardMaterial;
  27637. /**
  27638. * Serializes this material in a JSON representation
  27639. * @returns the serialized material object
  27640. */
  27641. serialize(): any;
  27642. /**
  27643. * Creates a standard material from parsed material data
  27644. * @param source defines the JSON representation of the material
  27645. * @param scene defines the hosting scene
  27646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27647. * @returns a new standard material
  27648. */
  27649. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27650. /**
  27651. * Are diffuse textures enabled in the application.
  27652. */
  27653. static get DiffuseTextureEnabled(): boolean;
  27654. static set DiffuseTextureEnabled(value: boolean);
  27655. /**
  27656. * Are ambient textures enabled in the application.
  27657. */
  27658. static get AmbientTextureEnabled(): boolean;
  27659. static set AmbientTextureEnabled(value: boolean);
  27660. /**
  27661. * Are opacity textures enabled in the application.
  27662. */
  27663. static get OpacityTextureEnabled(): boolean;
  27664. static set OpacityTextureEnabled(value: boolean);
  27665. /**
  27666. * Are reflection textures enabled in the application.
  27667. */
  27668. static get ReflectionTextureEnabled(): boolean;
  27669. static set ReflectionTextureEnabled(value: boolean);
  27670. /**
  27671. * Are emissive textures enabled in the application.
  27672. */
  27673. static get EmissiveTextureEnabled(): boolean;
  27674. static set EmissiveTextureEnabled(value: boolean);
  27675. /**
  27676. * Are specular textures enabled in the application.
  27677. */
  27678. static get SpecularTextureEnabled(): boolean;
  27679. static set SpecularTextureEnabled(value: boolean);
  27680. /**
  27681. * Are bump textures enabled in the application.
  27682. */
  27683. static get BumpTextureEnabled(): boolean;
  27684. static set BumpTextureEnabled(value: boolean);
  27685. /**
  27686. * Are lightmap textures enabled in the application.
  27687. */
  27688. static get LightmapTextureEnabled(): boolean;
  27689. static set LightmapTextureEnabled(value: boolean);
  27690. /**
  27691. * Are refraction textures enabled in the application.
  27692. */
  27693. static get RefractionTextureEnabled(): boolean;
  27694. static set RefractionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are color grading textures enabled in the application.
  27697. */
  27698. static get ColorGradingTextureEnabled(): boolean;
  27699. static set ColorGradingTextureEnabled(value: boolean);
  27700. /**
  27701. * Are fresnels enabled in the application.
  27702. */
  27703. static get FresnelEnabled(): boolean;
  27704. static set FresnelEnabled(value: boolean);
  27705. }
  27706. }
  27707. declare module "babylonjs/Particles/solidParticleSystem" {
  27708. import { Nullable } from "babylonjs/types";
  27709. import { Vector3 } from "babylonjs/Maths/math.vector";
  27710. import { Mesh } from "babylonjs/Meshes/mesh";
  27711. import { Scene, IDisposable } from "babylonjs/scene";
  27712. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27713. import { Material } from "babylonjs/Materials/material";
  27714. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27715. /**
  27716. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27717. *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.
  27718. * The SPS is also a particle system. It provides some methods to manage the particles.
  27719. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27720. *
  27721. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27722. */
  27723. export class SolidParticleSystem implements IDisposable {
  27724. /**
  27725. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27726. * Example : var p = SPS.particles[i];
  27727. */
  27728. particles: SolidParticle[];
  27729. /**
  27730. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27731. */
  27732. nbParticles: number;
  27733. /**
  27734. * If the particles must ever face the camera (default false). Useful for planar particles.
  27735. */
  27736. billboard: boolean;
  27737. /**
  27738. * Recompute normals when adding a shape
  27739. */
  27740. recomputeNormals: boolean;
  27741. /**
  27742. * This a counter ofr your own usage. It's not set by any SPS functions.
  27743. */
  27744. counter: number;
  27745. /**
  27746. * The SPS name. This name is also given to the underlying mesh.
  27747. */
  27748. name: string;
  27749. /**
  27750. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27751. */
  27752. mesh: Mesh;
  27753. /**
  27754. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27755. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27756. */
  27757. vars: any;
  27758. /**
  27759. * This array is populated when the SPS is set as 'pickable'.
  27760. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27761. * Each element of this array is an object `{idx: int, faceId: int}`.
  27762. * `idx` is the picked particle index in the `SPS.particles` array
  27763. * `faceId` is the picked face index counted within this particle.
  27764. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27765. */
  27766. pickedParticles: {
  27767. idx: number;
  27768. faceId: number;
  27769. }[];
  27770. /**
  27771. * This array is populated when `enableDepthSort` is set to true.
  27772. * Each element of this array is an instance of the class DepthSortedParticle.
  27773. */
  27774. depthSortedParticles: DepthSortedParticle[];
  27775. /**
  27776. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27777. * @hidden
  27778. */
  27779. _bSphereOnly: boolean;
  27780. /**
  27781. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27782. * @hidden
  27783. */
  27784. _bSphereRadiusFactor: number;
  27785. private _scene;
  27786. private _positions;
  27787. private _indices;
  27788. private _normals;
  27789. private _colors;
  27790. private _uvs;
  27791. private _indices32;
  27792. private _positions32;
  27793. private _normals32;
  27794. private _fixedNormal32;
  27795. private _colors32;
  27796. private _uvs32;
  27797. private _index;
  27798. private _updatable;
  27799. private _pickable;
  27800. private _isVisibilityBoxLocked;
  27801. private _alwaysVisible;
  27802. private _depthSort;
  27803. private _expandable;
  27804. private _shapeCounter;
  27805. private _copy;
  27806. private _color;
  27807. private _computeParticleColor;
  27808. private _computeParticleTexture;
  27809. private _computeParticleRotation;
  27810. private _computeParticleVertex;
  27811. private _computeBoundingBox;
  27812. private _depthSortParticles;
  27813. private _camera;
  27814. private _mustUnrotateFixedNormals;
  27815. private _particlesIntersect;
  27816. private _needs32Bits;
  27817. private _isNotBuilt;
  27818. private _lastParticleId;
  27819. private _idxOfId;
  27820. private _multimaterialEnabled;
  27821. private _useModelMaterial;
  27822. private _indicesByMaterial;
  27823. private _materialIndexes;
  27824. private _depthSortFunction;
  27825. private _materialSortFunction;
  27826. private _materials;
  27827. private _multimaterial;
  27828. private _materialIndexesById;
  27829. private _defaultMaterial;
  27830. private _autoUpdateSubMeshes;
  27831. /**
  27832. * Creates a SPS (Solid Particle System) object.
  27833. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27834. * @param scene (Scene) is the scene in which the SPS is added.
  27835. * @param options defines the options of the sps e.g.
  27836. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27837. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27838. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27839. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27840. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27841. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27842. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27843. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27844. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27845. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27846. */
  27847. constructor(name: string, scene: Scene, options?: {
  27848. updatable?: boolean;
  27849. isPickable?: boolean;
  27850. enableDepthSort?: boolean;
  27851. particleIntersection?: boolean;
  27852. boundingSphereOnly?: boolean;
  27853. bSphereRadiusFactor?: number;
  27854. expandable?: boolean;
  27855. useModelMaterial?: boolean;
  27856. enableMultiMaterial?: boolean;
  27857. });
  27858. /**
  27859. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27860. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27861. * @returns the created mesh
  27862. */
  27863. buildMesh(): Mesh;
  27864. /**
  27865. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27866. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27867. * Thus the particles generated from `digest()` have their property `position` set yet.
  27868. * @param mesh ( Mesh ) is the mesh to be digested
  27869. * @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
  27870. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27871. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27872. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27873. * @returns the current SPS
  27874. */
  27875. digest(mesh: Mesh, options?: {
  27876. facetNb?: number;
  27877. number?: number;
  27878. delta?: number;
  27879. storage?: [];
  27880. }): SolidParticleSystem;
  27881. /**
  27882. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27883. * @hidden
  27884. */
  27885. private _unrotateFixedNormals;
  27886. /**
  27887. * Resets the temporary working copy particle
  27888. * @hidden
  27889. */
  27890. private _resetCopy;
  27891. /**
  27892. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27893. * @param p the current index in the positions array to be updated
  27894. * @param ind the current index in the indices array
  27895. * @param shape a Vector3 array, the shape geometry
  27896. * @param positions the positions array to be updated
  27897. * @param meshInd the shape indices array
  27898. * @param indices the indices array to be updated
  27899. * @param meshUV the shape uv array
  27900. * @param uvs the uv array to be updated
  27901. * @param meshCol the shape color array
  27902. * @param colors the color array to be updated
  27903. * @param meshNor the shape normals array
  27904. * @param normals the normals array to be updated
  27905. * @param idx the particle index
  27906. * @param idxInShape the particle index in its shape
  27907. * @param options the addShape() method passed options
  27908. * @model the particle model
  27909. * @hidden
  27910. */
  27911. private _meshBuilder;
  27912. /**
  27913. * Returns a shape Vector3 array from positions float array
  27914. * @param positions float array
  27915. * @returns a vector3 array
  27916. * @hidden
  27917. */
  27918. private _posToShape;
  27919. /**
  27920. * Returns a shapeUV array from a float uvs (array deep copy)
  27921. * @param uvs as a float array
  27922. * @returns a shapeUV array
  27923. * @hidden
  27924. */
  27925. private _uvsToShapeUV;
  27926. /**
  27927. * Adds a new particle object in the particles array
  27928. * @param idx particle index in particles array
  27929. * @param id particle id
  27930. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27931. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27932. * @param model particle ModelShape object
  27933. * @param shapeId model shape identifier
  27934. * @param idxInShape index of the particle in the current model
  27935. * @param bInfo model bounding info object
  27936. * @param storage target storage array, if any
  27937. * @hidden
  27938. */
  27939. private _addParticle;
  27940. /**
  27941. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27942. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27943. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27944. * @param nb (positive integer) the number of particles to be created from this model
  27945. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27946. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27947. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27948. * @returns the number of shapes in the system
  27949. */
  27950. addShape(mesh: Mesh, nb: number, options?: {
  27951. positionFunction?: any;
  27952. vertexFunction?: any;
  27953. storage?: [];
  27954. }): number;
  27955. /**
  27956. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27957. * @hidden
  27958. */
  27959. private _rebuildParticle;
  27960. /**
  27961. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27962. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27963. * @returns the SPS.
  27964. */
  27965. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27966. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27967. * Returns an array with the removed particles.
  27968. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27969. * The SPS can't be empty so at least one particle needs to remain in place.
  27970. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27971. * @param start index of the first particle to remove
  27972. * @param end index of the last particle to remove (included)
  27973. * @returns an array populated with the removed particles
  27974. */
  27975. removeParticles(start: number, end: number): SolidParticle[];
  27976. /**
  27977. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27978. * @param solidParticleArray an array populated with Solid Particles objects
  27979. * @returns the SPS
  27980. */
  27981. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27982. /**
  27983. * Creates a new particle and modifies the SPS mesh geometry :
  27984. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27985. * - calls _addParticle() to populate the particle array
  27986. * factorized code from addShape() and insertParticlesFromArray()
  27987. * @param idx particle index in the particles array
  27988. * @param i particle index in its shape
  27989. * @param modelShape particle ModelShape object
  27990. * @param shape shape vertex array
  27991. * @param meshInd shape indices array
  27992. * @param meshUV shape uv array
  27993. * @param meshCol shape color array
  27994. * @param meshNor shape normals array
  27995. * @param bbInfo shape bounding info
  27996. * @param storage target particle storage
  27997. * @options addShape() passed options
  27998. * @hidden
  27999. */
  28000. private _insertNewParticle;
  28001. /**
  28002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28003. * This method calls `updateParticle()` for each particle of the SPS.
  28004. * For an animated SPS, it is usually called within the render loop.
  28005. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28006. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28007. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28008. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28009. * @returns the SPS.
  28010. */
  28011. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28012. /**
  28013. * Disposes the SPS.
  28014. */
  28015. dispose(): void;
  28016. /**
  28017. * Returns a SolidParticle object from its identifier : particle.id
  28018. * @param id (integer) the particle Id
  28019. * @returns the searched particle or null if not found in the SPS.
  28020. */
  28021. getParticleById(id: number): Nullable<SolidParticle>;
  28022. /**
  28023. * Returns a new array populated with the particles having the passed shapeId.
  28024. * @param shapeId (integer) the shape identifier
  28025. * @returns a new solid particle array
  28026. */
  28027. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28028. /**
  28029. * Populates the passed array "ref" with the particles having the passed shapeId.
  28030. * @param shapeId the shape identifier
  28031. * @returns the SPS
  28032. * @param ref
  28033. */
  28034. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28035. /**
  28036. * Computes the required SubMeshes according the materials assigned to the particles.
  28037. * @returns the solid particle system.
  28038. * Does nothing if called before the SPS mesh is built.
  28039. */
  28040. computeSubMeshes(): SolidParticleSystem;
  28041. /**
  28042. * Sorts the solid particles by material when MultiMaterial is enabled.
  28043. * Updates the indices32 array.
  28044. * Updates the indicesByMaterial array.
  28045. * Updates the mesh indices array.
  28046. * @returns the SPS
  28047. * @hidden
  28048. */
  28049. private _sortParticlesByMaterial;
  28050. /**
  28051. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28052. * @hidden
  28053. */
  28054. private _setMaterialIndexesById;
  28055. /**
  28056. * Returns an array with unique values of Materials from the passed array
  28057. * @param array the material array to be checked and filtered
  28058. * @hidden
  28059. */
  28060. private _filterUniqueMaterialId;
  28061. /**
  28062. * Sets a new Standard Material as _defaultMaterial if not already set.
  28063. * @hidden
  28064. */
  28065. private _setDefaultMaterial;
  28066. /**
  28067. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28069. * @returns the SPS.
  28070. */
  28071. refreshVisibleSize(): SolidParticleSystem;
  28072. /**
  28073. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28074. * @param size the size (float) of the visibility box
  28075. * note : this doesn't lock the SPS mesh bounding box.
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28077. */
  28078. setVisibilityBox(size: number): void;
  28079. /**
  28080. * Gets whether the SPS as always visible or not
  28081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28082. */
  28083. get isAlwaysVisible(): boolean;
  28084. /**
  28085. * Sets the SPS as always visible or not
  28086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28087. */
  28088. set isAlwaysVisible(val: boolean);
  28089. /**
  28090. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28091. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28092. */
  28093. set isVisibilityBoxLocked(val: boolean);
  28094. /**
  28095. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28096. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28097. */
  28098. get isVisibilityBoxLocked(): boolean;
  28099. /**
  28100. * Tells to `setParticles()` to compute the particle rotations or not.
  28101. * Default value : true. The SPS is faster when it's set to false.
  28102. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28103. */
  28104. set computeParticleRotation(val: boolean);
  28105. /**
  28106. * Tells to `setParticles()` to compute the particle colors or not.
  28107. * Default value : true. The SPS is faster when it's set to false.
  28108. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28109. */
  28110. set computeParticleColor(val: boolean);
  28111. set computeParticleTexture(val: boolean);
  28112. /**
  28113. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28114. * Default value : false. The SPS is faster when it's set to false.
  28115. * Note : the particle custom vertex positions aren't stored values.
  28116. */
  28117. set computeParticleVertex(val: boolean);
  28118. /**
  28119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28120. */
  28121. set computeBoundingBox(val: boolean);
  28122. /**
  28123. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28124. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28125. * Default : `true`
  28126. */
  28127. set depthSortParticles(val: boolean);
  28128. /**
  28129. * Gets if `setParticles()` computes the particle rotations or not.
  28130. * Default value : true. The SPS is faster when it's set to false.
  28131. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28132. */
  28133. get computeParticleRotation(): boolean;
  28134. /**
  28135. * Gets if `setParticles()` computes the particle colors or not.
  28136. * Default value : true. The SPS is faster when it's set to false.
  28137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28138. */
  28139. get computeParticleColor(): boolean;
  28140. /**
  28141. * Gets if `setParticles()` computes the particle textures or not.
  28142. * Default value : true. The SPS is faster when it's set to false.
  28143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28144. */
  28145. get computeParticleTexture(): boolean;
  28146. /**
  28147. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28148. * Default value : false. The SPS is faster when it's set to false.
  28149. * Note : the particle custom vertex positions aren't stored values.
  28150. */
  28151. get computeParticleVertex(): boolean;
  28152. /**
  28153. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28154. */
  28155. get computeBoundingBox(): boolean;
  28156. /**
  28157. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28158. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28159. * Default : `true`
  28160. */
  28161. get depthSortParticles(): boolean;
  28162. /**
  28163. * Gets if the SPS is created as expandable at construction time.
  28164. * Default : `false`
  28165. */
  28166. get expandable(): boolean;
  28167. /**
  28168. * Gets if the SPS supports the Multi Materials
  28169. */
  28170. get multimaterialEnabled(): boolean;
  28171. /**
  28172. * Gets if the SPS uses the model materials for its own multimaterial.
  28173. */
  28174. get useModelMaterial(): boolean;
  28175. /**
  28176. * The SPS used material array.
  28177. */
  28178. get materials(): Material[];
  28179. /**
  28180. * Sets the SPS MultiMaterial from the passed materials.
  28181. * Note : the passed array is internally copied and not used then by reference.
  28182. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28183. */
  28184. setMultiMaterial(materials: Material[]): void;
  28185. /**
  28186. * The SPS computed multimaterial object
  28187. */
  28188. get multimaterial(): MultiMaterial;
  28189. set multimaterial(mm: MultiMaterial);
  28190. /**
  28191. * If the subMeshes must be updated on the next call to setParticles()
  28192. */
  28193. get autoUpdateSubMeshes(): boolean;
  28194. set autoUpdateSubMeshes(val: boolean);
  28195. /**
  28196. * This function does nothing. It may be overwritten to set all the particle first values.
  28197. * The SPS doesn't call this function, you may have to call it by your own.
  28198. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28199. */
  28200. initParticles(): void;
  28201. /**
  28202. * This function does nothing. It may be overwritten to recycle a particle.
  28203. * The SPS doesn't call this function, you may have to call it by your own.
  28204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28205. * @param particle The particle to recycle
  28206. * @returns the recycled particle
  28207. */
  28208. recycleParticle(particle: SolidParticle): SolidParticle;
  28209. /**
  28210. * Updates a particle : this function should be overwritten by the user.
  28211. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28213. * @example : just set a particle position or velocity and recycle conditions
  28214. * @param particle The particle to update
  28215. * @returns the updated particle
  28216. */
  28217. updateParticle(particle: SolidParticle): SolidParticle;
  28218. /**
  28219. * Updates a vertex of a particle : it can be overwritten by the user.
  28220. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28221. * @param particle the current particle
  28222. * @param vertex the current index of the current particle
  28223. * @param pt the index of the current vertex in the particle shape
  28224. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28225. * @example : just set a vertex particle position
  28226. * @returns the updated vertex
  28227. */
  28228. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28229. /**
  28230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28231. * This does nothing and may be overwritten by the user.
  28232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28234. * @param update the boolean update value actually passed to setParticles()
  28235. */
  28236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28237. /**
  28238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28239. * This will be passed three parameters.
  28240. * This does nothing and may be overwritten by the user.
  28241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28243. * @param update the boolean update value actually passed to setParticles()
  28244. */
  28245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28246. }
  28247. }
  28248. declare module "babylonjs/Particles/solidParticle" {
  28249. import { Nullable } from "babylonjs/types";
  28250. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28251. import { Color4 } from "babylonjs/Maths/math.color";
  28252. import { Mesh } from "babylonjs/Meshes/mesh";
  28253. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28254. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28255. import { Plane } from "babylonjs/Maths/math.plane";
  28256. import { Material } from "babylonjs/Materials/material";
  28257. /**
  28258. * Represents one particle of a solid particle system.
  28259. */
  28260. export class SolidParticle {
  28261. /**
  28262. * particle global index
  28263. */
  28264. idx: number;
  28265. /**
  28266. * particle identifier
  28267. */
  28268. id: number;
  28269. /**
  28270. * The color of the particle
  28271. */
  28272. color: Nullable<Color4>;
  28273. /**
  28274. * The world space position of the particle.
  28275. */
  28276. position: Vector3;
  28277. /**
  28278. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28279. */
  28280. rotation: Vector3;
  28281. /**
  28282. * The world space rotation quaternion of the particle.
  28283. */
  28284. rotationQuaternion: Nullable<Quaternion>;
  28285. /**
  28286. * The scaling of the particle.
  28287. */
  28288. scaling: Vector3;
  28289. /**
  28290. * The uvs of the particle.
  28291. */
  28292. uvs: Vector4;
  28293. /**
  28294. * The current speed of the particle.
  28295. */
  28296. velocity: Vector3;
  28297. /**
  28298. * The pivot point in the particle local space.
  28299. */
  28300. pivot: Vector3;
  28301. /**
  28302. * Must the particle be translated from its pivot point in its local space ?
  28303. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28304. * Default : false
  28305. */
  28306. translateFromPivot: boolean;
  28307. /**
  28308. * Is the particle active or not ?
  28309. */
  28310. alive: boolean;
  28311. /**
  28312. * Is the particle visible or not ?
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Index of this particle in the global "positions" array (Internal use)
  28317. * @hidden
  28318. */
  28319. _pos: number;
  28320. /**
  28321. * @hidden Index of this particle in the global "indices" array (Internal use)
  28322. */
  28323. _ind: number;
  28324. /**
  28325. * @hidden ModelShape of this particle (Internal use)
  28326. */
  28327. _model: ModelShape;
  28328. /**
  28329. * ModelShape id of this particle
  28330. */
  28331. shapeId: number;
  28332. /**
  28333. * Index of the particle in its shape id
  28334. */
  28335. idxInShape: number;
  28336. /**
  28337. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28338. */
  28339. _modelBoundingInfo: BoundingInfo;
  28340. /**
  28341. * @hidden Particle BoundingInfo object (Internal use)
  28342. */
  28343. _boundingInfo: BoundingInfo;
  28344. /**
  28345. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28346. */
  28347. _sps: SolidParticleSystem;
  28348. /**
  28349. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28350. */
  28351. _stillInvisible: boolean;
  28352. /**
  28353. * @hidden Last computed particle rotation matrix
  28354. */
  28355. _rotationMatrix: number[];
  28356. /**
  28357. * Parent particle Id, if any.
  28358. * Default null.
  28359. */
  28360. parentId: Nullable<number>;
  28361. /**
  28362. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28363. */
  28364. materialIndex: Nullable<number>;
  28365. /**
  28366. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28367. * The possible values are :
  28368. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28369. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28370. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28372. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28373. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28374. * */
  28375. cullingStrategy: number;
  28376. /**
  28377. * @hidden Internal global position in the SPS.
  28378. */
  28379. _globalPosition: Vector3;
  28380. /**
  28381. * Creates a Solid Particle object.
  28382. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28383. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28384. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28385. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28386. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28387. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28388. * @param shapeId (integer) is the model shape identifier in the SPS.
  28389. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28390. * @param sps defines the sps it is associated to
  28391. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28392. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28393. */
  28394. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28395. /**
  28396. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28397. * @param target the particle target
  28398. * @returns the current particle
  28399. */
  28400. copyToRef(target: SolidParticle): SolidParticle;
  28401. /**
  28402. * Legacy support, changed scale to scaling
  28403. */
  28404. get scale(): Vector3;
  28405. /**
  28406. * Legacy support, changed scale to scaling
  28407. */
  28408. set scale(scale: Vector3);
  28409. /**
  28410. * Legacy support, changed quaternion to rotationQuaternion
  28411. */
  28412. get quaternion(): Nullable<Quaternion>;
  28413. /**
  28414. * Legacy support, changed quaternion to rotationQuaternion
  28415. */
  28416. set quaternion(q: Nullable<Quaternion>);
  28417. /**
  28418. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28419. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28420. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28421. * @returns true if it intersects
  28422. */
  28423. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28424. /**
  28425. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28426. * A particle is in the frustum if its bounding box intersects the frustum
  28427. * @param frustumPlanes defines the frustum to test
  28428. * @returns true if the particle is in the frustum planes
  28429. */
  28430. isInFrustum(frustumPlanes: Plane[]): boolean;
  28431. /**
  28432. * get the rotation matrix of the particle
  28433. * @hidden
  28434. */
  28435. getRotationMatrix(m: Matrix): void;
  28436. }
  28437. /**
  28438. * Represents the shape of the model used by one particle of a solid particle system.
  28439. * SPS internal tool, don't use it manually.
  28440. */
  28441. export class ModelShape {
  28442. /**
  28443. * The shape id
  28444. * @hidden
  28445. */
  28446. shapeID: number;
  28447. /**
  28448. * flat array of model positions (internal use)
  28449. * @hidden
  28450. */
  28451. _shape: Vector3[];
  28452. /**
  28453. * flat array of model UVs (internal use)
  28454. * @hidden
  28455. */
  28456. _shapeUV: number[];
  28457. /**
  28458. * color array of the model
  28459. * @hidden
  28460. */
  28461. _shapeColors: number[];
  28462. /**
  28463. * indices array of the model
  28464. * @hidden
  28465. */
  28466. _indices: number[];
  28467. /**
  28468. * normals array of the model
  28469. * @hidden
  28470. */
  28471. _normals: number[];
  28472. /**
  28473. * length of the shape in the model indices array (internal use)
  28474. * @hidden
  28475. */
  28476. _indicesLength: number;
  28477. /**
  28478. * Custom position function (internal use)
  28479. * @hidden
  28480. */
  28481. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28482. /**
  28483. * Custom vertex function (internal use)
  28484. * @hidden
  28485. */
  28486. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28487. /**
  28488. * Model material (internal use)
  28489. * @hidden
  28490. */
  28491. _material: Nullable<Material>;
  28492. /**
  28493. * 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.
  28494. * SPS internal tool, don't use it manually.
  28495. * @hidden
  28496. */
  28497. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28498. }
  28499. /**
  28500. * Represents a Depth Sorted Particle in the solid particle system.
  28501. * @hidden
  28502. */
  28503. export class DepthSortedParticle {
  28504. /**
  28505. * Index of the particle in the "indices" array
  28506. */
  28507. ind: number;
  28508. /**
  28509. * Length of the particle shape in the "indices" array
  28510. */
  28511. indicesLength: number;
  28512. /**
  28513. * Squared distance from the particle to the camera
  28514. */
  28515. sqDistance: number;
  28516. /**
  28517. * Material index when used with MultiMaterials
  28518. */
  28519. materialIndex: number;
  28520. /**
  28521. * Creates a new sorted particle
  28522. * @param materialIndex
  28523. */
  28524. constructor(ind: number, indLength: number, materialIndex: number);
  28525. }
  28526. }
  28527. declare module "babylonjs/Collisions/meshCollisionData" {
  28528. import { Collider } from "babylonjs/Collisions/collider";
  28529. import { Vector3 } from "babylonjs/Maths/math.vector";
  28530. import { Nullable } from "babylonjs/types";
  28531. import { Observer } from "babylonjs/Misc/observable";
  28532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28533. /**
  28534. * @hidden
  28535. */
  28536. export class _MeshCollisionData {
  28537. _checkCollisions: boolean;
  28538. _collisionMask: number;
  28539. _collisionGroup: number;
  28540. _collider: Nullable<Collider>;
  28541. _oldPositionForCollisions: Vector3;
  28542. _diffPositionForCollisions: Vector3;
  28543. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28544. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28545. }
  28546. }
  28547. declare module "babylonjs/Meshes/abstractMesh" {
  28548. import { Observable } from "babylonjs/Misc/observable";
  28549. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28550. import { Camera } from "babylonjs/Cameras/camera";
  28551. import { Scene, IDisposable } from "babylonjs/scene";
  28552. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28553. import { Node } from "babylonjs/node";
  28554. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28556. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28557. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28558. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28559. import { Material } from "babylonjs/Materials/material";
  28560. import { Light } from "babylonjs/Lights/light";
  28561. import { Skeleton } from "babylonjs/Bones/skeleton";
  28562. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28563. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28564. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28565. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28566. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28567. import { Plane } from "babylonjs/Maths/math.plane";
  28568. import { Ray } from "babylonjs/Culling/ray";
  28569. import { Collider } from "babylonjs/Collisions/collider";
  28570. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28571. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28572. /** @hidden */
  28573. class _FacetDataStorage {
  28574. facetPositions: Vector3[];
  28575. facetNormals: Vector3[];
  28576. facetPartitioning: number[][];
  28577. facetNb: number;
  28578. partitioningSubdivisions: number;
  28579. partitioningBBoxRatio: number;
  28580. facetDataEnabled: boolean;
  28581. facetParameters: any;
  28582. bbSize: Vector3;
  28583. subDiv: {
  28584. max: number;
  28585. X: number;
  28586. Y: number;
  28587. Z: number;
  28588. };
  28589. facetDepthSort: boolean;
  28590. facetDepthSortEnabled: boolean;
  28591. depthSortedIndices: IndicesArray;
  28592. depthSortedFacets: {
  28593. ind: number;
  28594. sqDistance: number;
  28595. }[];
  28596. facetDepthSortFunction: (f1: {
  28597. ind: number;
  28598. sqDistance: number;
  28599. }, f2: {
  28600. ind: number;
  28601. sqDistance: number;
  28602. }) => number;
  28603. facetDepthSortFrom: Vector3;
  28604. facetDepthSortOrigin: Vector3;
  28605. invertedMatrix: Matrix;
  28606. }
  28607. /**
  28608. * @hidden
  28609. **/
  28610. class _InternalAbstractMeshDataInfo {
  28611. _hasVertexAlpha: boolean;
  28612. _useVertexColors: boolean;
  28613. _numBoneInfluencers: number;
  28614. _applyFog: boolean;
  28615. _receiveShadows: boolean;
  28616. _facetData: _FacetDataStorage;
  28617. _visibility: number;
  28618. _skeleton: Nullable<Skeleton>;
  28619. _layerMask: number;
  28620. _computeBonesUsingShaders: boolean;
  28621. _isActive: boolean;
  28622. _onlyForInstances: boolean;
  28623. _isActiveIntermediate: boolean;
  28624. _onlyForInstancesIntermediate: boolean;
  28625. _actAsRegularMesh: boolean;
  28626. }
  28627. /**
  28628. * Class used to store all common mesh properties
  28629. */
  28630. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28631. /** No occlusion */
  28632. static OCCLUSION_TYPE_NONE: number;
  28633. /** Occlusion set to optimisitic */
  28634. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28635. /** Occlusion set to strict */
  28636. static OCCLUSION_TYPE_STRICT: number;
  28637. /** Use an accurante occlusion algorithm */
  28638. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28639. /** Use a conservative occlusion algorithm */
  28640. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28641. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28642. * Test order :
  28643. * Is the bounding sphere outside the frustum ?
  28644. * If not, are the bounding box vertices outside the frustum ?
  28645. * It not, then the cullable object is in the frustum.
  28646. */
  28647. static readonly CULLINGSTRATEGY_STANDARD: number;
  28648. /** Culling strategy : Bounding Sphere Only.
  28649. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28650. * It's also less accurate than the standard because some not visible objects can still be selected.
  28651. * Test : is the bounding sphere outside the frustum ?
  28652. * If not, then the cullable object is in the frustum.
  28653. */
  28654. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28655. /** Culling strategy : Optimistic Inclusion.
  28656. * This in an inclusion test first, then the standard exclusion test.
  28657. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28658. * 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.
  28659. * Anyway, it's as accurate as the standard strategy.
  28660. * Test :
  28661. * Is the cullable object bounding sphere center in the frustum ?
  28662. * If not, apply the default culling strategy.
  28663. */
  28664. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28665. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28666. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28667. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28668. * 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.
  28669. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28670. * Test :
  28671. * Is the cullable object bounding sphere center in the frustum ?
  28672. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28673. */
  28674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28675. /**
  28676. * No billboard
  28677. */
  28678. static get BILLBOARDMODE_NONE(): number;
  28679. /** Billboard on X axis */
  28680. static get BILLBOARDMODE_X(): number;
  28681. /** Billboard on Y axis */
  28682. static get BILLBOARDMODE_Y(): number;
  28683. /** Billboard on Z axis */
  28684. static get BILLBOARDMODE_Z(): number;
  28685. /** Billboard on all axes */
  28686. static get BILLBOARDMODE_ALL(): number;
  28687. /** Billboard on using position instead of orientation */
  28688. static get BILLBOARDMODE_USE_POSITION(): number;
  28689. /** @hidden */
  28690. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28691. /**
  28692. * The culling strategy to use to check whether the mesh must be rendered or not.
  28693. * This value can be changed at any time and will be used on the next render mesh selection.
  28694. * The possible values are :
  28695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28699. * Please read each static variable documentation to get details about the culling process.
  28700. * */
  28701. cullingStrategy: number;
  28702. /**
  28703. * Gets the number of facets in the mesh
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28705. */
  28706. get facetNb(): number;
  28707. /**
  28708. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28710. */
  28711. get partitioningSubdivisions(): number;
  28712. set partitioningSubdivisions(nb: number);
  28713. /**
  28714. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28715. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28717. */
  28718. get partitioningBBoxRatio(): number;
  28719. set partitioningBBoxRatio(ratio: number);
  28720. /**
  28721. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28722. * Works only for updatable meshes.
  28723. * Doesn't work with multi-materials
  28724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28725. */
  28726. get mustDepthSortFacets(): boolean;
  28727. set mustDepthSortFacets(sort: boolean);
  28728. /**
  28729. * The location (Vector3) where the facet depth sort must be computed from.
  28730. * By default, the active camera position.
  28731. * Used only when facet depth sort is enabled
  28732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28733. */
  28734. get facetDepthSortFrom(): Vector3;
  28735. set facetDepthSortFrom(location: Vector3);
  28736. /**
  28737. * gets a boolean indicating if facetData is enabled
  28738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28739. */
  28740. get isFacetDataEnabled(): boolean;
  28741. /** @hidden */
  28742. _updateNonUniformScalingState(value: boolean): boolean;
  28743. /**
  28744. * An event triggered when this mesh collides with another one
  28745. */
  28746. onCollideObservable: Observable<AbstractMesh>;
  28747. /** Set a function to call when this mesh collides with another one */
  28748. set onCollide(callback: () => void);
  28749. /**
  28750. * An event triggered when the collision's position changes
  28751. */
  28752. onCollisionPositionChangeObservable: Observable<Vector3>;
  28753. /** Set a function to call when the collision's position changes */
  28754. set onCollisionPositionChange(callback: () => void);
  28755. /**
  28756. * An event triggered when material is changed
  28757. */
  28758. onMaterialChangedObservable: Observable<AbstractMesh>;
  28759. /**
  28760. * Gets or sets the orientation for POV movement & rotation
  28761. */
  28762. definedFacingForward: boolean;
  28763. /** @hidden */
  28764. _occlusionQuery: Nullable<WebGLQuery>;
  28765. /** @hidden */
  28766. _renderingGroup: Nullable<RenderingGroup>;
  28767. /**
  28768. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28769. */
  28770. get visibility(): number;
  28771. /**
  28772. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28773. */
  28774. set visibility(value: number);
  28775. /** Gets or sets the alpha index used to sort transparent meshes
  28776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28777. */
  28778. alphaIndex: number;
  28779. /**
  28780. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28781. */
  28782. isVisible: boolean;
  28783. /**
  28784. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28785. */
  28786. isPickable: boolean;
  28787. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28788. showSubMeshesBoundingBox: boolean;
  28789. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28790. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28791. */
  28792. isBlocker: boolean;
  28793. /**
  28794. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28795. */
  28796. enablePointerMoveEvents: boolean;
  28797. /**
  28798. * Specifies the rendering group id for this mesh (0 by default)
  28799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28800. */
  28801. renderingGroupId: number;
  28802. private _material;
  28803. /** Gets or sets current material */
  28804. get material(): Nullable<Material>;
  28805. set material(value: Nullable<Material>);
  28806. /**
  28807. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28808. * @see http://doc.babylonjs.com/babylon101/shadows
  28809. */
  28810. get receiveShadows(): boolean;
  28811. set receiveShadows(value: boolean);
  28812. /** Defines color to use when rendering outline */
  28813. outlineColor: Color3;
  28814. /** Define width to use when rendering outline */
  28815. outlineWidth: number;
  28816. /** Defines color to use when rendering overlay */
  28817. overlayColor: Color3;
  28818. /** Defines alpha to use when rendering overlay */
  28819. overlayAlpha: number;
  28820. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28821. get hasVertexAlpha(): boolean;
  28822. set hasVertexAlpha(value: boolean);
  28823. /** 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) */
  28824. get useVertexColors(): boolean;
  28825. set useVertexColors(value: boolean);
  28826. /**
  28827. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28828. */
  28829. get computeBonesUsingShaders(): boolean;
  28830. set computeBonesUsingShaders(value: boolean);
  28831. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28832. get numBoneInfluencers(): number;
  28833. set numBoneInfluencers(value: number);
  28834. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28835. get applyFog(): boolean;
  28836. set applyFog(value: boolean);
  28837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28838. useOctreeForRenderingSelection: boolean;
  28839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28840. useOctreeForPicking: boolean;
  28841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28842. useOctreeForCollisions: boolean;
  28843. /**
  28844. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28845. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28846. */
  28847. get layerMask(): number;
  28848. set layerMask(value: number);
  28849. /**
  28850. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28851. */
  28852. alwaysSelectAsActiveMesh: boolean;
  28853. /**
  28854. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28855. */
  28856. doNotSyncBoundingInfo: boolean;
  28857. /**
  28858. * Gets or sets the current action manager
  28859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28860. */
  28861. actionManager: Nullable<AbstractActionManager>;
  28862. private _meshCollisionData;
  28863. /**
  28864. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28866. */
  28867. ellipsoid: Vector3;
  28868. /**
  28869. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28870. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28871. */
  28872. ellipsoidOffset: Vector3;
  28873. /**
  28874. * Gets or sets a collision mask used to mask collisions (default is -1).
  28875. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28876. */
  28877. get collisionMask(): number;
  28878. set collisionMask(mask: number);
  28879. /**
  28880. * Gets or sets the current collision group mask (-1 by default).
  28881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28882. */
  28883. get collisionGroup(): number;
  28884. set collisionGroup(mask: number);
  28885. /**
  28886. * Defines edge width used when edgesRenderer is enabled
  28887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28888. */
  28889. edgesWidth: number;
  28890. /**
  28891. * Defines edge color used when edgesRenderer is enabled
  28892. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28893. */
  28894. edgesColor: Color4;
  28895. /** @hidden */
  28896. _edgesRenderer: Nullable<IEdgesRenderer>;
  28897. /** @hidden */
  28898. _masterMesh: Nullable<AbstractMesh>;
  28899. /** @hidden */
  28900. _boundingInfo: Nullable<BoundingInfo>;
  28901. /** @hidden */
  28902. _renderId: number;
  28903. /**
  28904. * Gets or sets the list of subMeshes
  28905. * @see http://doc.babylonjs.com/how_to/multi_materials
  28906. */
  28907. subMeshes: SubMesh[];
  28908. /** @hidden */
  28909. _intersectionsInProgress: AbstractMesh[];
  28910. /** @hidden */
  28911. _unIndexed: boolean;
  28912. /** @hidden */
  28913. _lightSources: Light[];
  28914. /** Gets the list of lights affecting that mesh */
  28915. get lightSources(): Light[];
  28916. /** @hidden */
  28917. get _positions(): Nullable<Vector3[]>;
  28918. /** @hidden */
  28919. _waitingData: {
  28920. lods: Nullable<any>;
  28921. actions: Nullable<any>;
  28922. freezeWorldMatrix: Nullable<boolean>;
  28923. };
  28924. /** @hidden */
  28925. _bonesTransformMatrices: Nullable<Float32Array>;
  28926. /** @hidden */
  28927. _transformMatrixTexture: Nullable<RawTexture>;
  28928. /**
  28929. * Gets or sets a skeleton to apply skining transformations
  28930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28931. */
  28932. set skeleton(value: Nullable<Skeleton>);
  28933. get skeleton(): Nullable<Skeleton>;
  28934. /**
  28935. * An event triggered when the mesh is rebuilt.
  28936. */
  28937. onRebuildObservable: Observable<AbstractMesh>;
  28938. /**
  28939. * Creates a new AbstractMesh
  28940. * @param name defines the name of the mesh
  28941. * @param scene defines the hosting scene
  28942. */
  28943. constructor(name: string, scene?: Nullable<Scene>);
  28944. /**
  28945. * Returns the string "AbstractMesh"
  28946. * @returns "AbstractMesh"
  28947. */
  28948. getClassName(): string;
  28949. /**
  28950. * Gets a string representation of the current mesh
  28951. * @param fullDetails defines a boolean indicating if full details must be included
  28952. * @returns a string representation of the current mesh
  28953. */
  28954. toString(fullDetails?: boolean): string;
  28955. /**
  28956. * @hidden
  28957. */
  28958. protected _getEffectiveParent(): Nullable<Node>;
  28959. /** @hidden */
  28960. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28961. /** @hidden */
  28962. _rebuild(): void;
  28963. /** @hidden */
  28964. _resyncLightSources(): void;
  28965. /** @hidden */
  28966. _resyncLightSource(light: Light): void;
  28967. /** @hidden */
  28968. _unBindEffect(): void;
  28969. /** @hidden */
  28970. _removeLightSource(light: Light, dispose: boolean): void;
  28971. private _markSubMeshesAsDirty;
  28972. /** @hidden */
  28973. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28974. /** @hidden */
  28975. _markSubMeshesAsAttributesDirty(): void;
  28976. /** @hidden */
  28977. _markSubMeshesAsMiscDirty(): void;
  28978. /**
  28979. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28980. */
  28981. get scaling(): Vector3;
  28982. set scaling(newScaling: Vector3);
  28983. /**
  28984. * Returns true if the mesh is blocked. Implemented by child classes
  28985. */
  28986. get isBlocked(): boolean;
  28987. /**
  28988. * Returns the mesh itself by default. Implemented by child classes
  28989. * @param camera defines the camera to use to pick the right LOD level
  28990. * @returns the currentAbstractMesh
  28991. */
  28992. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28993. /**
  28994. * Returns 0 by default. Implemented by child classes
  28995. * @returns an integer
  28996. */
  28997. getTotalVertices(): number;
  28998. /**
  28999. * Returns a positive integer : the total number of indices in this mesh geometry.
  29000. * @returns the numner of indices or zero if the mesh has no geometry.
  29001. */
  29002. getTotalIndices(): number;
  29003. /**
  29004. * Returns null by default. Implemented by child classes
  29005. * @returns null
  29006. */
  29007. getIndices(): Nullable<IndicesArray>;
  29008. /**
  29009. * Returns the array of the requested vertex data kind. Implemented by child classes
  29010. * @param kind defines the vertex data kind to use
  29011. * @returns null
  29012. */
  29013. getVerticesData(kind: string): Nullable<FloatArray>;
  29014. /**
  29015. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29016. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29017. * Note that a new underlying VertexBuffer object is created each call.
  29018. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29019. * @param kind defines vertex data kind:
  29020. * * VertexBuffer.PositionKind
  29021. * * VertexBuffer.UVKind
  29022. * * VertexBuffer.UV2Kind
  29023. * * VertexBuffer.UV3Kind
  29024. * * VertexBuffer.UV4Kind
  29025. * * VertexBuffer.UV5Kind
  29026. * * VertexBuffer.UV6Kind
  29027. * * VertexBuffer.ColorKind
  29028. * * VertexBuffer.MatricesIndicesKind
  29029. * * VertexBuffer.MatricesIndicesExtraKind
  29030. * * VertexBuffer.MatricesWeightsKind
  29031. * * VertexBuffer.MatricesWeightsExtraKind
  29032. * @param data defines the data source
  29033. * @param updatable defines if the data must be flagged as updatable (or static)
  29034. * @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
  29035. * @returns the current mesh
  29036. */
  29037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29038. /**
  29039. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29040. * If the mesh has no geometry, it is simply returned as it is.
  29041. * @param kind defines vertex data kind:
  29042. * * VertexBuffer.PositionKind
  29043. * * VertexBuffer.UVKind
  29044. * * VertexBuffer.UV2Kind
  29045. * * VertexBuffer.UV3Kind
  29046. * * VertexBuffer.UV4Kind
  29047. * * VertexBuffer.UV5Kind
  29048. * * VertexBuffer.UV6Kind
  29049. * * VertexBuffer.ColorKind
  29050. * * VertexBuffer.MatricesIndicesKind
  29051. * * VertexBuffer.MatricesIndicesExtraKind
  29052. * * VertexBuffer.MatricesWeightsKind
  29053. * * VertexBuffer.MatricesWeightsExtraKind
  29054. * @param data defines the data source
  29055. * @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
  29056. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29057. * @returns the current mesh
  29058. */
  29059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29060. /**
  29061. * Sets the mesh indices,
  29062. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29063. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29064. * @param totalVertices Defines the total number of vertices
  29065. * @returns the current mesh
  29066. */
  29067. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29068. /**
  29069. * Gets a boolean indicating if specific vertex data is present
  29070. * @param kind defines the vertex data kind to use
  29071. * @returns true is data kind is present
  29072. */
  29073. isVerticesDataPresent(kind: string): boolean;
  29074. /**
  29075. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29076. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29077. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29078. * @returns a BoundingInfo
  29079. */
  29080. getBoundingInfo(): BoundingInfo;
  29081. /**
  29082. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29083. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29084. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29085. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29086. * @returns the current mesh
  29087. */
  29088. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29089. /**
  29090. * Overwrite the current bounding info
  29091. * @param boundingInfo defines the new bounding info
  29092. * @returns the current mesh
  29093. */
  29094. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29095. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29096. get useBones(): boolean;
  29097. /** @hidden */
  29098. _preActivate(): void;
  29099. /** @hidden */
  29100. _preActivateForIntermediateRendering(renderId: number): void;
  29101. /** @hidden */
  29102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29103. /** @hidden */
  29104. _postActivate(): void;
  29105. /** @hidden */
  29106. _freeze(): void;
  29107. /** @hidden */
  29108. _unFreeze(): void;
  29109. /**
  29110. * Gets the current world matrix
  29111. * @returns a Matrix
  29112. */
  29113. getWorldMatrix(): Matrix;
  29114. /** @hidden */
  29115. _getWorldMatrixDeterminant(): number;
  29116. /**
  29117. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29118. */
  29119. get isAnInstance(): boolean;
  29120. /**
  29121. * Gets a boolean indicating if this mesh has instances
  29122. */
  29123. get hasInstances(): boolean;
  29124. /**
  29125. * Perform relative position change from the point of view of behind the front of the mesh.
  29126. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29127. * Supports definition of mesh facing forward or backward
  29128. * @param amountRight defines the distance on the right axis
  29129. * @param amountUp defines the distance on the up axis
  29130. * @param amountForward defines the distance on the forward axis
  29131. * @returns the current mesh
  29132. */
  29133. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29134. /**
  29135. * Calculate relative position change from the point of view of behind the front of the mesh.
  29136. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29137. * Supports definition of mesh facing forward or backward
  29138. * @param amountRight defines the distance on the right axis
  29139. * @param amountUp defines the distance on the up axis
  29140. * @param amountForward defines the distance on the forward axis
  29141. * @returns the new displacement vector
  29142. */
  29143. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29144. /**
  29145. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29146. * Supports definition of mesh facing forward or backward
  29147. * @param flipBack defines the flip
  29148. * @param twirlClockwise defines the twirl
  29149. * @param tiltRight defines the tilt
  29150. * @returns the current mesh
  29151. */
  29152. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29153. /**
  29154. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29155. * Supports definition of mesh facing forward or backward.
  29156. * @param flipBack defines the flip
  29157. * @param twirlClockwise defines the twirl
  29158. * @param tiltRight defines the tilt
  29159. * @returns the new rotation vector
  29160. */
  29161. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29162. /**
  29163. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29164. * This means the mesh underlying bounding box and sphere are recomputed.
  29165. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29166. * @returns the current mesh
  29167. */
  29168. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29169. /** @hidden */
  29170. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29171. /** @hidden */
  29172. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29173. /** @hidden */
  29174. _updateBoundingInfo(): AbstractMesh;
  29175. /** @hidden */
  29176. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29177. /** @hidden */
  29178. protected _afterComputeWorldMatrix(): void;
  29179. /** @hidden */
  29180. get _effectiveMesh(): AbstractMesh;
  29181. /**
  29182. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29183. * A mesh is in the frustum if its bounding box intersects the frustum
  29184. * @param frustumPlanes defines the frustum to test
  29185. * @returns true if the mesh is in the frustum planes
  29186. */
  29187. isInFrustum(frustumPlanes: Plane[]): boolean;
  29188. /**
  29189. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29190. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29191. * @param frustumPlanes defines the frustum to test
  29192. * @returns true if the mesh is completely in the frustum planes
  29193. */
  29194. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29195. /**
  29196. * True if the mesh intersects another mesh or a SolidParticle object
  29197. * @param mesh defines a target mesh or SolidParticle to test
  29198. * @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)
  29199. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29200. * @returns true if there is an intersection
  29201. */
  29202. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29203. /**
  29204. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29205. * @param point defines the point to test
  29206. * @returns true if there is an intersection
  29207. */
  29208. intersectsPoint(point: Vector3): boolean;
  29209. /**
  29210. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29212. */
  29213. get checkCollisions(): boolean;
  29214. set checkCollisions(collisionEnabled: boolean);
  29215. /**
  29216. * Gets Collider object used to compute collisions (not physics)
  29217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29218. */
  29219. get collider(): Nullable<Collider>;
  29220. /**
  29221. * Move the mesh using collision engine
  29222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29223. * @param displacement defines the requested displacement vector
  29224. * @returns the current mesh
  29225. */
  29226. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29227. private _onCollisionPositionChange;
  29228. /** @hidden */
  29229. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29230. /** @hidden */
  29231. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29232. /** @hidden */
  29233. _checkCollision(collider: Collider): AbstractMesh;
  29234. /** @hidden */
  29235. _generatePointsArray(): boolean;
  29236. /**
  29237. * Checks if the passed Ray intersects with the mesh
  29238. * @param ray defines the ray to use
  29239. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29241. * @returns the picking info
  29242. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29243. */
  29244. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29245. /**
  29246. * Clones the current mesh
  29247. * @param name defines the mesh name
  29248. * @param newParent defines the new mesh parent
  29249. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29250. * @returns the new mesh
  29251. */
  29252. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29253. /**
  29254. * Disposes all the submeshes of the current meshnp
  29255. * @returns the current mesh
  29256. */
  29257. releaseSubMeshes(): AbstractMesh;
  29258. /**
  29259. * Releases resources associated with this abstract mesh.
  29260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29262. */
  29263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29264. /**
  29265. * Adds the passed mesh as a child to the current mesh
  29266. * @param mesh defines the child mesh
  29267. * @returns the current mesh
  29268. */
  29269. addChild(mesh: AbstractMesh): AbstractMesh;
  29270. /**
  29271. * Removes the passed mesh from the current mesh children list
  29272. * @param mesh defines the child mesh
  29273. * @returns the current mesh
  29274. */
  29275. removeChild(mesh: AbstractMesh): AbstractMesh;
  29276. /** @hidden */
  29277. private _initFacetData;
  29278. /**
  29279. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29280. * This method can be called within the render loop.
  29281. * 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
  29282. * @returns the current mesh
  29283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29284. */
  29285. updateFacetData(): AbstractMesh;
  29286. /**
  29287. * Returns the facetLocalNormals array.
  29288. * The normals are expressed in the mesh local spac
  29289. * @returns an array of Vector3
  29290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29291. */
  29292. getFacetLocalNormals(): Vector3[];
  29293. /**
  29294. * Returns the facetLocalPositions array.
  29295. * The facet positions are expressed in the mesh local space
  29296. * @returns an array of Vector3
  29297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29298. */
  29299. getFacetLocalPositions(): Vector3[];
  29300. /**
  29301. * Returns the facetLocalPartioning array
  29302. * @returns an array of array of numbers
  29303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29304. */
  29305. getFacetLocalPartitioning(): number[][];
  29306. /**
  29307. * Returns the i-th facet position in the world system.
  29308. * This method allocates a new Vector3 per call
  29309. * @param i defines the facet index
  29310. * @returns a new Vector3
  29311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29312. */
  29313. getFacetPosition(i: number): Vector3;
  29314. /**
  29315. * Sets the reference Vector3 with the i-th facet position in the world system
  29316. * @param i defines the facet index
  29317. * @param ref defines the target vector
  29318. * @returns the current mesh
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29320. */
  29321. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29322. /**
  29323. * Returns the i-th facet normal in the world system.
  29324. * This method allocates a new Vector3 per call
  29325. * @param i defines the facet index
  29326. * @returns a new Vector3
  29327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29328. */
  29329. getFacetNormal(i: number): Vector3;
  29330. /**
  29331. * Sets the reference Vector3 with the i-th facet normal in the world system
  29332. * @param i defines the facet index
  29333. * @param ref defines the target vector
  29334. * @returns the current mesh
  29335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29336. */
  29337. getFacetNormalToRef(i: number, ref: Vector3): this;
  29338. /**
  29339. * 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)
  29340. * @param x defines x coordinate
  29341. * @param y defines y coordinate
  29342. * @param z defines z coordinate
  29343. * @returns the array of facet indexes
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29347. /**
  29348. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29349. * @param projected sets as the (x,y,z) world projection on the facet
  29350. * @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
  29351. * @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
  29352. * @param x defines x coordinate
  29353. * @param y defines y coordinate
  29354. * @param z defines z coordinate
  29355. * @returns the face index if found (or null instead)
  29356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29357. */
  29358. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29359. /**
  29360. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29361. * @param projected sets as the (x,y,z) local projection on the facet
  29362. * @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
  29363. * @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
  29364. * @param x defines x coordinate
  29365. * @param y defines y coordinate
  29366. * @param z defines z coordinate
  29367. * @returns the face index if found (or null instead)
  29368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29369. */
  29370. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29371. /**
  29372. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29373. * @returns the parameters
  29374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29375. */
  29376. getFacetDataParameters(): any;
  29377. /**
  29378. * Disables the feature FacetData and frees the related memory
  29379. * @returns the current mesh
  29380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29381. */
  29382. disableFacetData(): AbstractMesh;
  29383. /**
  29384. * Updates the AbstractMesh indices array
  29385. * @param indices defines the data source
  29386. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29387. * @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)
  29388. * @returns the current mesh
  29389. */
  29390. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29391. /**
  29392. * Creates new normals data for the mesh
  29393. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29394. * @returns the current mesh
  29395. */
  29396. createNormals(updatable: boolean): AbstractMesh;
  29397. /**
  29398. * Align the mesh with a normal
  29399. * @param normal defines the normal to use
  29400. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29401. * @returns the current mesh
  29402. */
  29403. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29404. /** @hidden */
  29405. _checkOcclusionQuery(): boolean;
  29406. /**
  29407. * Disables the mesh edge rendering mode
  29408. * @returns the currentAbstractMesh
  29409. */
  29410. disableEdgesRendering(): AbstractMesh;
  29411. /**
  29412. * Enables the edge rendering mode on the mesh.
  29413. * This mode makes the mesh edges visible
  29414. * @param epsilon defines the maximal distance between two angles to detect a face
  29415. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29416. * @returns the currentAbstractMesh
  29417. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29418. */
  29419. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29420. }
  29421. }
  29422. declare module "babylonjs/Actions/actionEvent" {
  29423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29424. import { Nullable } from "babylonjs/types";
  29425. import { Sprite } from "babylonjs/Sprites/sprite";
  29426. import { Scene } from "babylonjs/scene";
  29427. import { Vector2 } from "babylonjs/Maths/math.vector";
  29428. /**
  29429. * Interface used to define ActionEvent
  29430. */
  29431. export interface IActionEvent {
  29432. /** The mesh or sprite that triggered the action */
  29433. source: any;
  29434. /** The X mouse cursor position at the time of the event */
  29435. pointerX: number;
  29436. /** The Y mouse cursor position at the time of the event */
  29437. pointerY: number;
  29438. /** The mesh that is currently pointed at (can be null) */
  29439. meshUnderPointer: Nullable<AbstractMesh>;
  29440. /** the original (browser) event that triggered the ActionEvent */
  29441. sourceEvent?: any;
  29442. /** additional data for the event */
  29443. additionalData?: any;
  29444. }
  29445. /**
  29446. * ActionEvent is the event being sent when an action is triggered.
  29447. */
  29448. export class ActionEvent implements IActionEvent {
  29449. /** The mesh or sprite that triggered the action */
  29450. source: any;
  29451. /** The X mouse cursor position at the time of the event */
  29452. pointerX: number;
  29453. /** The Y mouse cursor position at the time of the event */
  29454. pointerY: number;
  29455. /** The mesh that is currently pointed at (can be null) */
  29456. meshUnderPointer: Nullable<AbstractMesh>;
  29457. /** the original (browser) event that triggered the ActionEvent */
  29458. sourceEvent?: any;
  29459. /** additional data for the event */
  29460. additionalData?: any;
  29461. /**
  29462. * Creates a new ActionEvent
  29463. * @param source The mesh or sprite that triggered the action
  29464. * @param pointerX The X mouse cursor position at the time of the event
  29465. * @param pointerY The Y mouse cursor position at the time of the event
  29466. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29467. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29468. * @param additionalData additional data for the event
  29469. */
  29470. constructor(
  29471. /** The mesh or sprite that triggered the action */
  29472. source: any,
  29473. /** The X mouse cursor position at the time of the event */
  29474. pointerX: number,
  29475. /** The Y mouse cursor position at the time of the event */
  29476. pointerY: number,
  29477. /** The mesh that is currently pointed at (can be null) */
  29478. meshUnderPointer: Nullable<AbstractMesh>,
  29479. /** the original (browser) event that triggered the ActionEvent */
  29480. sourceEvent?: any,
  29481. /** additional data for the event */
  29482. additionalData?: any);
  29483. /**
  29484. * Helper function to auto-create an ActionEvent from a source mesh.
  29485. * @param source The source mesh that triggered the event
  29486. * @param evt The original (browser) event
  29487. * @param additionalData additional data for the event
  29488. * @returns the new ActionEvent
  29489. */
  29490. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29491. /**
  29492. * Helper function to auto-create an ActionEvent from a source sprite
  29493. * @param source The source sprite that triggered the event
  29494. * @param scene Scene associated with the sprite
  29495. * @param evt The original (browser) event
  29496. * @param additionalData additional data for the event
  29497. * @returns the new ActionEvent
  29498. */
  29499. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29500. /**
  29501. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29502. * @param scene the scene where the event occurred
  29503. * @param evt The original (browser) event
  29504. * @returns the new ActionEvent
  29505. */
  29506. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29507. /**
  29508. * Helper function to auto-create an ActionEvent from a primitive
  29509. * @param prim defines the target primitive
  29510. * @param pointerPos defines the pointer position
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29516. }
  29517. }
  29518. declare module "babylonjs/Actions/abstractActionManager" {
  29519. import { IDisposable } from "babylonjs/scene";
  29520. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29521. import { IAction } from "babylonjs/Actions/action";
  29522. import { Nullable } from "babylonjs/types";
  29523. /**
  29524. * Abstract class used to decouple action Manager from scene and meshes.
  29525. * Do not instantiate.
  29526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29527. */
  29528. export abstract class AbstractActionManager implements IDisposable {
  29529. /** Gets the list of active triggers */
  29530. static Triggers: {
  29531. [key: string]: number;
  29532. };
  29533. /** Gets the cursor to use when hovering items */
  29534. hoverCursor: string;
  29535. /** Gets the list of actions */
  29536. actions: IAction[];
  29537. /**
  29538. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29539. */
  29540. isRecursive: boolean;
  29541. /**
  29542. * Releases all associated resources
  29543. */
  29544. abstract dispose(): void;
  29545. /**
  29546. * Does this action manager has pointer triggers
  29547. */
  29548. abstract get hasPointerTriggers(): boolean;
  29549. /**
  29550. * Does this action manager has pick triggers
  29551. */
  29552. abstract get hasPickTriggers(): boolean;
  29553. /**
  29554. * Process a specific trigger
  29555. * @param trigger defines the trigger to process
  29556. * @param evt defines the event details to be processed
  29557. */
  29558. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29559. /**
  29560. * Does this action manager handles actions of any of the given triggers
  29561. * @param triggers defines the triggers to be tested
  29562. * @return a boolean indicating whether one (or more) of the triggers is handled
  29563. */
  29564. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29565. /**
  29566. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29567. * speed.
  29568. * @param triggerA defines the trigger to be tested
  29569. * @param triggerB defines the trigger to be tested
  29570. * @return a boolean indicating whether one (or more) of the triggers is handled
  29571. */
  29572. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29573. /**
  29574. * Does this action manager handles actions of a given trigger
  29575. * @param trigger defines the trigger to be tested
  29576. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29577. * @return whether the trigger is handled
  29578. */
  29579. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29580. /**
  29581. * Serialize this manager to a JSON object
  29582. * @param name defines the property name to store this manager
  29583. * @returns a JSON representation of this manager
  29584. */
  29585. abstract serialize(name: string): any;
  29586. /**
  29587. * Registers an action to this action manager
  29588. * @param action defines the action to be registered
  29589. * @return the action amended (prepared) after registration
  29590. */
  29591. abstract registerAction(action: IAction): Nullable<IAction>;
  29592. /**
  29593. * Unregisters an action to this action manager
  29594. * @param action defines the action to be unregistered
  29595. * @return a boolean indicating whether the action has been unregistered
  29596. */
  29597. abstract unregisterAction(action: IAction): Boolean;
  29598. /**
  29599. * Does exist one action manager with at least one trigger
  29600. **/
  29601. static get HasTriggers(): boolean;
  29602. /**
  29603. * Does exist one action manager with at least one pick trigger
  29604. **/
  29605. static get HasPickTriggers(): boolean;
  29606. /**
  29607. * Does exist one action manager that handles actions of a given trigger
  29608. * @param trigger defines the trigger to be tested
  29609. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29610. **/
  29611. static HasSpecificTrigger(trigger: number): boolean;
  29612. }
  29613. }
  29614. declare module "babylonjs/node" {
  29615. import { Scene } from "babylonjs/scene";
  29616. import { Nullable } from "babylonjs/types";
  29617. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29618. import { Engine } from "babylonjs/Engines/engine";
  29619. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29620. import { Observable } from "babylonjs/Misc/observable";
  29621. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29622. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29623. import { Animatable } from "babylonjs/Animations/animatable";
  29624. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29625. import { Animation } from "babylonjs/Animations/animation";
  29626. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29628. /**
  29629. * Defines how a node can be built from a string name.
  29630. */
  29631. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29632. /**
  29633. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29634. */
  29635. export class Node implements IBehaviorAware<Node> {
  29636. /** @hidden */
  29637. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29638. private static _NodeConstructors;
  29639. /**
  29640. * Add a new node constructor
  29641. * @param type defines the type name of the node to construct
  29642. * @param constructorFunc defines the constructor function
  29643. */
  29644. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29645. /**
  29646. * Returns a node constructor based on type name
  29647. * @param type defines the type name
  29648. * @param name defines the new node name
  29649. * @param scene defines the hosting scene
  29650. * @param options defines optional options to transmit to constructors
  29651. * @returns the new constructor or null
  29652. */
  29653. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29654. /**
  29655. * Gets or sets the name of the node
  29656. */
  29657. name: string;
  29658. /**
  29659. * Gets or sets the id of the node
  29660. */
  29661. id: string;
  29662. /**
  29663. * Gets or sets the unique id of the node
  29664. */
  29665. uniqueId: number;
  29666. /**
  29667. * Gets or sets a string used to store user defined state for the node
  29668. */
  29669. state: string;
  29670. /**
  29671. * Gets or sets an object used to store user defined information for the node
  29672. */
  29673. metadata: any;
  29674. /**
  29675. * For internal use only. Please do not use.
  29676. */
  29677. reservedDataStore: any;
  29678. /**
  29679. * List of inspectable custom properties (used by the Inspector)
  29680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29681. */
  29682. inspectableCustomProperties: IInspectable[];
  29683. private _doNotSerialize;
  29684. /**
  29685. * Gets or sets a boolean used to define if the node must be serialized
  29686. */
  29687. get doNotSerialize(): boolean;
  29688. set doNotSerialize(value: boolean);
  29689. /** @hidden */
  29690. _isDisposed: boolean;
  29691. /**
  29692. * Gets a list of Animations associated with the node
  29693. */
  29694. animations: import("babylonjs/Animations/animation").Animation[];
  29695. protected _ranges: {
  29696. [name: string]: Nullable<AnimationRange>;
  29697. };
  29698. /**
  29699. * Callback raised when the node is ready to be used
  29700. */
  29701. onReady: Nullable<(node: Node) => void>;
  29702. private _isEnabled;
  29703. private _isParentEnabled;
  29704. private _isReady;
  29705. /** @hidden */
  29706. _currentRenderId: number;
  29707. private _parentUpdateId;
  29708. /** @hidden */
  29709. _childUpdateId: number;
  29710. /** @hidden */
  29711. _waitingParentId: Nullable<string>;
  29712. /** @hidden */
  29713. _scene: Scene;
  29714. /** @hidden */
  29715. _cache: any;
  29716. private _parentNode;
  29717. private _children;
  29718. /** @hidden */
  29719. _worldMatrix: Matrix;
  29720. /** @hidden */
  29721. _worldMatrixDeterminant: number;
  29722. /** @hidden */
  29723. _worldMatrixDeterminantIsDirty: boolean;
  29724. /** @hidden */
  29725. private _sceneRootNodesIndex;
  29726. /**
  29727. * Gets a boolean indicating if the node has been disposed
  29728. * @returns true if the node was disposed
  29729. */
  29730. isDisposed(): boolean;
  29731. /**
  29732. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29733. * @see https://doc.babylonjs.com/how_to/parenting
  29734. */
  29735. set parent(parent: Nullable<Node>);
  29736. get parent(): Nullable<Node>;
  29737. /** @hidden */
  29738. _addToSceneRootNodes(): void;
  29739. /** @hidden */
  29740. _removeFromSceneRootNodes(): void;
  29741. private _animationPropertiesOverride;
  29742. /**
  29743. * Gets or sets the animation properties override
  29744. */
  29745. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29746. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29747. /**
  29748. * Gets a string idenfifying the name of the class
  29749. * @returns "Node" string
  29750. */
  29751. getClassName(): string;
  29752. /** @hidden */
  29753. readonly _isNode: boolean;
  29754. /**
  29755. * An event triggered when the mesh is disposed
  29756. */
  29757. onDisposeObservable: Observable<Node>;
  29758. private _onDisposeObserver;
  29759. /**
  29760. * Sets a callback that will be raised when the node will be disposed
  29761. */
  29762. set onDispose(callback: () => void);
  29763. /**
  29764. * Creates a new Node
  29765. * @param name the name and id to be given to this node
  29766. * @param scene the scene this node will be added to
  29767. */
  29768. constructor(name: string, scene?: Nullable<Scene>);
  29769. /**
  29770. * Gets the scene of the node
  29771. * @returns a scene
  29772. */
  29773. getScene(): Scene;
  29774. /**
  29775. * Gets the engine of the node
  29776. * @returns a Engine
  29777. */
  29778. getEngine(): Engine;
  29779. private _behaviors;
  29780. /**
  29781. * Attach a behavior to the node
  29782. * @see http://doc.babylonjs.com/features/behaviour
  29783. * @param behavior defines the behavior to attach
  29784. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29785. * @returns the current Node
  29786. */
  29787. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29788. /**
  29789. * Remove an attached behavior
  29790. * @see http://doc.babylonjs.com/features/behaviour
  29791. * @param behavior defines the behavior to attach
  29792. * @returns the current Node
  29793. */
  29794. removeBehavior(behavior: Behavior<Node>): Node;
  29795. /**
  29796. * Gets the list of attached behaviors
  29797. * @see http://doc.babylonjs.com/features/behaviour
  29798. */
  29799. get behaviors(): Behavior<Node>[];
  29800. /**
  29801. * Gets an attached behavior by name
  29802. * @param name defines the name of the behavior to look for
  29803. * @see http://doc.babylonjs.com/features/behaviour
  29804. * @returns null if behavior was not found else the requested behavior
  29805. */
  29806. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29807. /**
  29808. * Returns the latest update of the World matrix
  29809. * @returns a Matrix
  29810. */
  29811. getWorldMatrix(): Matrix;
  29812. /** @hidden */
  29813. _getWorldMatrixDeterminant(): number;
  29814. /**
  29815. * Returns directly the latest state of the mesh World matrix.
  29816. * A Matrix is returned.
  29817. */
  29818. get worldMatrixFromCache(): Matrix;
  29819. /** @hidden */
  29820. _initCache(): void;
  29821. /** @hidden */
  29822. updateCache(force?: boolean): void;
  29823. /** @hidden */
  29824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29825. /** @hidden */
  29826. _updateCache(ignoreParentClass?: boolean): void;
  29827. /** @hidden */
  29828. _isSynchronized(): boolean;
  29829. /** @hidden */
  29830. _markSyncedWithParent(): void;
  29831. /** @hidden */
  29832. isSynchronizedWithParent(): boolean;
  29833. /** @hidden */
  29834. isSynchronized(): boolean;
  29835. /**
  29836. * Is this node ready to be used/rendered
  29837. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29838. * @return true if the node is ready
  29839. */
  29840. isReady(completeCheck?: boolean): boolean;
  29841. /**
  29842. * Is this node enabled?
  29843. * 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
  29844. * @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
  29845. * @return whether this node (and its parent) is enabled
  29846. */
  29847. isEnabled(checkAncestors?: boolean): boolean;
  29848. /** @hidden */
  29849. protected _syncParentEnabledState(): void;
  29850. /**
  29851. * Set the enabled state of this node
  29852. * @param value defines the new enabled state
  29853. */
  29854. setEnabled(value: boolean): void;
  29855. /**
  29856. * Is this node a descendant of the given node?
  29857. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29858. * @param ancestor defines the parent node to inspect
  29859. * @returns a boolean indicating if this node is a descendant of the given node
  29860. */
  29861. isDescendantOf(ancestor: Node): boolean;
  29862. /** @hidden */
  29863. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29864. /**
  29865. * Will return all nodes that have this node as ascendant
  29866. * @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
  29867. * @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
  29868. * @return all children nodes of all types
  29869. */
  29870. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29871. /**
  29872. * Get all child-meshes of this node
  29873. * @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)
  29874. * @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
  29875. * @returns an array of AbstractMesh
  29876. */
  29877. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29878. /**
  29879. * Get all direct children of this node
  29880. * @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
  29881. * @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)
  29882. * @returns an array of Node
  29883. */
  29884. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29885. /** @hidden */
  29886. _setReady(state: boolean): void;
  29887. /**
  29888. * Get an animation by name
  29889. * @param name defines the name of the animation to look for
  29890. * @returns null if not found else the requested animation
  29891. */
  29892. getAnimationByName(name: string): Nullable<Animation>;
  29893. /**
  29894. * Creates an animation range for this node
  29895. * @param name defines the name of the range
  29896. * @param from defines the starting key
  29897. * @param to defines the end key
  29898. */
  29899. createAnimationRange(name: string, from: number, to: number): void;
  29900. /**
  29901. * Delete a specific animation range
  29902. * @param name defines the name of the range to delete
  29903. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29904. */
  29905. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29906. /**
  29907. * Get an animation range by name
  29908. * @param name defines the name of the animation range to look for
  29909. * @returns null if not found else the requested animation range
  29910. */
  29911. getAnimationRange(name: string): Nullable<AnimationRange>;
  29912. /**
  29913. * Gets the list of all animation ranges defined on this node
  29914. * @returns an array
  29915. */
  29916. getAnimationRanges(): Nullable<AnimationRange>[];
  29917. /**
  29918. * Will start the animation sequence
  29919. * @param name defines the range frames for animation sequence
  29920. * @param loop defines if the animation should loop (false by default)
  29921. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29922. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29923. * @returns the object created for this animation. If range does not exist, it will return null
  29924. */
  29925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29926. /**
  29927. * Serialize animation ranges into a JSON compatible object
  29928. * @returns serialization object
  29929. */
  29930. serializeAnimationRanges(): any;
  29931. /**
  29932. * Computes the world matrix of the node
  29933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29934. * @returns the world matrix
  29935. */
  29936. computeWorldMatrix(force?: boolean): Matrix;
  29937. /**
  29938. * Releases resources associated with this node.
  29939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29941. */
  29942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29943. /**
  29944. * Parse animation range data from a serialization object and store them into a given node
  29945. * @param node defines where to store the animation ranges
  29946. * @param parsedNode defines the serialization object to read data from
  29947. * @param scene defines the hosting scene
  29948. */
  29949. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29950. /**
  29951. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29952. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29953. * @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
  29954. * @returns the new bounding vectors
  29955. */
  29956. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29957. min: Vector3;
  29958. max: Vector3;
  29959. };
  29960. }
  29961. }
  29962. declare module "babylonjs/Animations/animation" {
  29963. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29964. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29965. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29966. import { Nullable } from "babylonjs/types";
  29967. import { Scene } from "babylonjs/scene";
  29968. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29970. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29971. import { Node } from "babylonjs/node";
  29972. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29973. import { Size } from "babylonjs/Maths/math.size";
  29974. import { Animatable } from "babylonjs/Animations/animatable";
  29975. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29976. /**
  29977. * @hidden
  29978. */
  29979. export class _IAnimationState {
  29980. key: number;
  29981. repeatCount: number;
  29982. workValue?: any;
  29983. loopMode?: number;
  29984. offsetValue?: any;
  29985. highLimitValue?: any;
  29986. }
  29987. /**
  29988. * Class used to store any kind of animation
  29989. */
  29990. export class Animation {
  29991. /**Name of the animation */
  29992. name: string;
  29993. /**Property to animate */
  29994. targetProperty: string;
  29995. /**The frames per second of the animation */
  29996. framePerSecond: number;
  29997. /**The data type of the animation */
  29998. dataType: number;
  29999. /**The loop mode of the animation */
  30000. loopMode?: number | undefined;
  30001. /**Specifies if blending should be enabled */
  30002. enableBlending?: boolean | undefined;
  30003. /**
  30004. * Use matrix interpolation instead of using direct key value when animating matrices
  30005. */
  30006. static AllowMatricesInterpolation: boolean;
  30007. /**
  30008. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30009. */
  30010. static AllowMatrixDecomposeForInterpolation: boolean;
  30011. /**
  30012. * Stores the key frames of the animation
  30013. */
  30014. private _keys;
  30015. /**
  30016. * Stores the easing function of the animation
  30017. */
  30018. private _easingFunction;
  30019. /**
  30020. * @hidden Internal use only
  30021. */
  30022. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30023. /**
  30024. * The set of event that will be linked to this animation
  30025. */
  30026. private _events;
  30027. /**
  30028. * Stores an array of target property paths
  30029. */
  30030. targetPropertyPath: string[];
  30031. /**
  30032. * Stores the blending speed of the animation
  30033. */
  30034. blendingSpeed: number;
  30035. /**
  30036. * Stores the animation ranges for the animation
  30037. */
  30038. private _ranges;
  30039. /**
  30040. * @hidden Internal use
  30041. */
  30042. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30043. /**
  30044. * Sets up an animation
  30045. * @param property The property to animate
  30046. * @param animationType The animation type to apply
  30047. * @param framePerSecond The frames per second of the animation
  30048. * @param easingFunction The easing function used in the animation
  30049. * @returns The created animation
  30050. */
  30051. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30052. /**
  30053. * Create and start an animation on a node
  30054. * @param name defines the name of the global animation that will be run on all nodes
  30055. * @param node defines the root node where the animation will take place
  30056. * @param targetProperty defines property to animate
  30057. * @param framePerSecond defines the number of frame per second yo use
  30058. * @param totalFrame defines the number of frames in total
  30059. * @param from defines the initial value
  30060. * @param to defines the final value
  30061. * @param loopMode defines which loop mode you want to use (off by default)
  30062. * @param easingFunction defines the easing function to use (linear by default)
  30063. * @param onAnimationEnd defines the callback to call when animation end
  30064. * @returns the animatable created for this animation
  30065. */
  30066. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30067. /**
  30068. * Create and start an animation on a node and its descendants
  30069. * @param name defines the name of the global animation that will be run on all nodes
  30070. * @param node defines the root node where the animation will take place
  30071. * @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
  30072. * @param targetProperty defines property to animate
  30073. * @param framePerSecond defines the number of frame per second to use
  30074. * @param totalFrame defines the number of frames in total
  30075. * @param from defines the initial value
  30076. * @param to defines the final value
  30077. * @param loopMode defines which loop mode you want to use (off by default)
  30078. * @param easingFunction defines the easing function to use (linear by default)
  30079. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30080. * @returns the list of animatables created for all nodes
  30081. * @example https://www.babylonjs-playground.com/#MH0VLI
  30082. */
  30083. 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[]>;
  30084. /**
  30085. * Creates a new animation, merges it with the existing animations and starts it
  30086. * @param name Name of the animation
  30087. * @param node Node which contains the scene that begins the animations
  30088. * @param targetProperty Specifies which property to animate
  30089. * @param framePerSecond The frames per second of the animation
  30090. * @param totalFrame The total number of frames
  30091. * @param from The frame at the beginning of the animation
  30092. * @param to The frame at the end of the animation
  30093. * @param loopMode Specifies the loop mode of the animation
  30094. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30095. * @param onAnimationEnd Callback to run once the animation is complete
  30096. * @returns Nullable animation
  30097. */
  30098. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30099. /**
  30100. * Transition property of an host to the target Value
  30101. * @param property The property to transition
  30102. * @param targetValue The target Value of the property
  30103. * @param host The object where the property to animate belongs
  30104. * @param scene Scene used to run the animation
  30105. * @param frameRate Framerate (in frame/s) to use
  30106. * @param transition The transition type we want to use
  30107. * @param duration The duration of the animation, in milliseconds
  30108. * @param onAnimationEnd Callback trigger at the end of the animation
  30109. * @returns Nullable animation
  30110. */
  30111. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30112. /**
  30113. * Return the array of runtime animations currently using this animation
  30114. */
  30115. get runtimeAnimations(): RuntimeAnimation[];
  30116. /**
  30117. * Specifies if any of the runtime animations are currently running
  30118. */
  30119. get hasRunningRuntimeAnimations(): boolean;
  30120. /**
  30121. * Initializes the animation
  30122. * @param name Name of the animation
  30123. * @param targetProperty Property to animate
  30124. * @param framePerSecond The frames per second of the animation
  30125. * @param dataType The data type of the animation
  30126. * @param loopMode The loop mode of the animation
  30127. * @param enableBlending Specifies if blending should be enabled
  30128. */
  30129. constructor(
  30130. /**Name of the animation */
  30131. name: string,
  30132. /**Property to animate */
  30133. targetProperty: string,
  30134. /**The frames per second of the animation */
  30135. framePerSecond: number,
  30136. /**The data type of the animation */
  30137. dataType: number,
  30138. /**The loop mode of the animation */
  30139. loopMode?: number | undefined,
  30140. /**Specifies if blending should be enabled */
  30141. enableBlending?: boolean | undefined);
  30142. /**
  30143. * Converts the animation to a string
  30144. * @param fullDetails support for multiple levels of logging within scene loading
  30145. * @returns String form of the animation
  30146. */
  30147. toString(fullDetails?: boolean): string;
  30148. /**
  30149. * Add an event to this animation
  30150. * @param event Event to add
  30151. */
  30152. addEvent(event: AnimationEvent): void;
  30153. /**
  30154. * Remove all events found at the given frame
  30155. * @param frame The frame to remove events from
  30156. */
  30157. removeEvents(frame: number): void;
  30158. /**
  30159. * Retrieves all the events from the animation
  30160. * @returns Events from the animation
  30161. */
  30162. getEvents(): AnimationEvent[];
  30163. /**
  30164. * Creates an animation range
  30165. * @param name Name of the animation range
  30166. * @param from Starting frame of the animation range
  30167. * @param to Ending frame of the animation
  30168. */
  30169. createRange(name: string, from: number, to: number): void;
  30170. /**
  30171. * Deletes an animation range by name
  30172. * @param name Name of the animation range to delete
  30173. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30174. */
  30175. deleteRange(name: string, deleteFrames?: boolean): void;
  30176. /**
  30177. * Gets the animation range by name, or null if not defined
  30178. * @param name Name of the animation range
  30179. * @returns Nullable animation range
  30180. */
  30181. getRange(name: string): Nullable<AnimationRange>;
  30182. /**
  30183. * Gets the key frames from the animation
  30184. * @returns The key frames of the animation
  30185. */
  30186. getKeys(): Array<IAnimationKey>;
  30187. /**
  30188. * Gets the highest frame rate of the animation
  30189. * @returns Highest frame rate of the animation
  30190. */
  30191. getHighestFrame(): number;
  30192. /**
  30193. * Gets the easing function of the animation
  30194. * @returns Easing function of the animation
  30195. */
  30196. getEasingFunction(): IEasingFunction;
  30197. /**
  30198. * Sets the easing function of the animation
  30199. * @param easingFunction A custom mathematical formula for animation
  30200. */
  30201. setEasingFunction(easingFunction: EasingFunction): void;
  30202. /**
  30203. * Interpolates a scalar linearly
  30204. * @param startValue Start value of the animation curve
  30205. * @param endValue End value of the animation curve
  30206. * @param gradient Scalar amount to interpolate
  30207. * @returns Interpolated scalar value
  30208. */
  30209. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30210. /**
  30211. * Interpolates a scalar cubically
  30212. * @param startValue Start value of the animation curve
  30213. * @param outTangent End tangent of the animation
  30214. * @param endValue End value of the animation curve
  30215. * @param inTangent Start tangent of the animation curve
  30216. * @param gradient Scalar amount to interpolate
  30217. * @returns Interpolated scalar value
  30218. */
  30219. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30220. /**
  30221. * Interpolates a quaternion using a spherical linear interpolation
  30222. * @param startValue Start value of the animation curve
  30223. * @param endValue End value of the animation curve
  30224. * @param gradient Scalar amount to interpolate
  30225. * @returns Interpolated quaternion value
  30226. */
  30227. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30228. /**
  30229. * Interpolates a quaternion cubically
  30230. * @param startValue Start value of the animation curve
  30231. * @param outTangent End tangent of the animation curve
  30232. * @param endValue End value of the animation curve
  30233. * @param inTangent Start tangent of the animation curve
  30234. * @param gradient Scalar amount to interpolate
  30235. * @returns Interpolated quaternion value
  30236. */
  30237. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30238. /**
  30239. * Interpolates a Vector3 linearl
  30240. * @param startValue Start value of the animation curve
  30241. * @param endValue End value of the animation curve
  30242. * @param gradient Scalar amount to interpolate
  30243. * @returns Interpolated scalar value
  30244. */
  30245. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30246. /**
  30247. * Interpolates a Vector3 cubically
  30248. * @param startValue Start value of the animation curve
  30249. * @param outTangent End tangent of the animation
  30250. * @param endValue End value of the animation curve
  30251. * @param inTangent Start tangent of the animation curve
  30252. * @param gradient Scalar amount to interpolate
  30253. * @returns InterpolatedVector3 value
  30254. */
  30255. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30256. /**
  30257. * Interpolates a Vector2 linearly
  30258. * @param startValue Start value of the animation curve
  30259. * @param endValue End value of the animation curve
  30260. * @param gradient Scalar amount to interpolate
  30261. * @returns Interpolated Vector2 value
  30262. */
  30263. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30264. /**
  30265. * Interpolates a Vector2 cubically
  30266. * @param startValue Start value of the animation curve
  30267. * @param outTangent End tangent of the animation
  30268. * @param endValue End value of the animation curve
  30269. * @param inTangent Start tangent of the animation curve
  30270. * @param gradient Scalar amount to interpolate
  30271. * @returns Interpolated Vector2 value
  30272. */
  30273. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30274. /**
  30275. * Interpolates a size linearly
  30276. * @param startValue Start value of the animation curve
  30277. * @param endValue End value of the animation curve
  30278. * @param gradient Scalar amount to interpolate
  30279. * @returns Interpolated Size value
  30280. */
  30281. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30282. /**
  30283. * Interpolates a Color3 linearly
  30284. * @param startValue Start value of the animation curve
  30285. * @param endValue End value of the animation curve
  30286. * @param gradient Scalar amount to interpolate
  30287. * @returns Interpolated Color3 value
  30288. */
  30289. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30290. /**
  30291. * Interpolates a Color4 linearly
  30292. * @param startValue Start value of the animation curve
  30293. * @param endValue End value of the animation curve
  30294. * @param gradient Scalar amount to interpolate
  30295. * @returns Interpolated Color3 value
  30296. */
  30297. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30298. /**
  30299. * @hidden Internal use only
  30300. */
  30301. _getKeyValue(value: any): any;
  30302. /**
  30303. * @hidden Internal use only
  30304. */
  30305. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30306. /**
  30307. * Defines the function to use to interpolate matrices
  30308. * @param startValue defines the start matrix
  30309. * @param endValue defines the end matrix
  30310. * @param gradient defines the gradient between both matrices
  30311. * @param result defines an optional target matrix where to store the interpolation
  30312. * @returns the interpolated matrix
  30313. */
  30314. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30315. /**
  30316. * Makes a copy of the animation
  30317. * @returns Cloned animation
  30318. */
  30319. clone(): Animation;
  30320. /**
  30321. * Sets the key frames of the animation
  30322. * @param values The animation key frames to set
  30323. */
  30324. setKeys(values: Array<IAnimationKey>): void;
  30325. /**
  30326. * Serializes the animation to an object
  30327. * @returns Serialized object
  30328. */
  30329. serialize(): any;
  30330. /**
  30331. * Float animation type
  30332. */
  30333. static readonly ANIMATIONTYPE_FLOAT: number;
  30334. /**
  30335. * Vector3 animation type
  30336. */
  30337. static readonly ANIMATIONTYPE_VECTOR3: number;
  30338. /**
  30339. * Quaternion animation type
  30340. */
  30341. static readonly ANIMATIONTYPE_QUATERNION: number;
  30342. /**
  30343. * Matrix animation type
  30344. */
  30345. static readonly ANIMATIONTYPE_MATRIX: number;
  30346. /**
  30347. * Color3 animation type
  30348. */
  30349. static readonly ANIMATIONTYPE_COLOR3: number;
  30350. /**
  30351. * Color3 animation type
  30352. */
  30353. static readonly ANIMATIONTYPE_COLOR4: number;
  30354. /**
  30355. * Vector2 animation type
  30356. */
  30357. static readonly ANIMATIONTYPE_VECTOR2: number;
  30358. /**
  30359. * Size animation type
  30360. */
  30361. static readonly ANIMATIONTYPE_SIZE: number;
  30362. /**
  30363. * Relative Loop Mode
  30364. */
  30365. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30366. /**
  30367. * Cycle Loop Mode
  30368. */
  30369. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30370. /**
  30371. * Constant Loop Mode
  30372. */
  30373. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30374. /** @hidden */
  30375. static _UniversalLerp(left: any, right: any, amount: number): any;
  30376. /**
  30377. * Parses an animation object and creates an animation
  30378. * @param parsedAnimation Parsed animation object
  30379. * @returns Animation object
  30380. */
  30381. static Parse(parsedAnimation: any): Animation;
  30382. /**
  30383. * Appends the serialized animations from the source animations
  30384. * @param source Source containing the animations
  30385. * @param destination Target to store the animations
  30386. */
  30387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30388. }
  30389. }
  30390. declare module "babylonjs/Animations/animatable.interface" {
  30391. import { Nullable } from "babylonjs/types";
  30392. import { Animation } from "babylonjs/Animations/animation";
  30393. /**
  30394. * Interface containing an array of animations
  30395. */
  30396. export interface IAnimatable {
  30397. /**
  30398. * Array of animations
  30399. */
  30400. animations: Nullable<Array<Animation>>;
  30401. }
  30402. }
  30403. declare module "babylonjs/Misc/decorators" {
  30404. import { Nullable } from "babylonjs/types";
  30405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30406. import { Scene } from "babylonjs/scene";
  30407. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30408. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. /**
  30421. * Decorator used to define property that can be serialized as reference to a camera
  30422. * @param sourceName defines the name of the property to decorate
  30423. */
  30424. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30425. /**
  30426. * Class used to help serialization objects
  30427. */
  30428. export class SerializationHelper {
  30429. /** @hidden */
  30430. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30431. /** @hidden */
  30432. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30433. /** @hidden */
  30434. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30435. /** @hidden */
  30436. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30437. /**
  30438. * Appends the serialized animations from the source animations
  30439. * @param source Source containing the animations
  30440. * @param destination Target to store the animations
  30441. */
  30442. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30443. /**
  30444. * Static function used to serialized a specific entity
  30445. * @param entity defines the entity to serialize
  30446. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30447. * @returns a JSON compatible object representing the serialization of the entity
  30448. */
  30449. static Serialize<T>(entity: T, serializationObject?: any): any;
  30450. /**
  30451. * Creates a new entity from a serialization data object
  30452. * @param creationFunction defines a function used to instanciated the new entity
  30453. * @param source defines the source serialization data
  30454. * @param scene defines the hosting scene
  30455. * @param rootUrl defines the root url for resources
  30456. * @returns a new entity
  30457. */
  30458. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30459. /**
  30460. * Clones an object
  30461. * @param creationFunction defines the function used to instanciate the new object
  30462. * @param source defines the source object
  30463. * @returns the cloned object
  30464. */
  30465. static Clone<T>(creationFunction: () => T, source: T): T;
  30466. /**
  30467. * Instanciates a new object based on a source one (some data will be shared between both object)
  30468. * @param creationFunction defines the function used to instanciate the new object
  30469. * @param source defines the source object
  30470. * @returns the new object
  30471. */
  30472. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30473. }
  30474. }
  30475. declare module "babylonjs/Misc/guid" {
  30476. /**
  30477. * Class used to manipulate GUIDs
  30478. */
  30479. export class GUID {
  30480. /**
  30481. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30482. * Be aware Math.random() could cause collisions, but:
  30483. * "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"
  30484. * @returns a pseudo random id
  30485. */
  30486. static RandomId(): string;
  30487. }
  30488. }
  30489. declare module "babylonjs/Materials/Textures/baseTexture" {
  30490. import { Observable } from "babylonjs/Misc/observable";
  30491. import { Nullable } from "babylonjs/types";
  30492. import { Scene } from "babylonjs/scene";
  30493. import { Matrix } from "babylonjs/Maths/math.vector";
  30494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30495. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30496. import { ISize } from "babylonjs/Maths/math.size";
  30497. import "babylonjs/Misc/fileTools";
  30498. /**
  30499. * Base class of all the textures in babylon.
  30500. * It groups all the common properties the materials, post process, lights... might need
  30501. * in order to make a correct use of the texture.
  30502. */
  30503. export class BaseTexture implements IAnimatable {
  30504. /**
  30505. * Default anisotropic filtering level for the application.
  30506. * It is set to 4 as a good tradeoff between perf and quality.
  30507. */
  30508. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30509. /**
  30510. * Gets or sets the unique id of the texture
  30511. */
  30512. uniqueId: number;
  30513. /**
  30514. * Define the name of the texture.
  30515. */
  30516. name: string;
  30517. /**
  30518. * Gets or sets an object used to store user defined information.
  30519. */
  30520. metadata: any;
  30521. /**
  30522. * For internal use only. Please do not use.
  30523. */
  30524. reservedDataStore: any;
  30525. private _hasAlpha;
  30526. /**
  30527. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30528. */
  30529. set hasAlpha(value: boolean);
  30530. get hasAlpha(): boolean;
  30531. /**
  30532. * Defines if the alpha value should be determined via the rgb values.
  30533. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30534. */
  30535. getAlphaFromRGB: boolean;
  30536. /**
  30537. * Intensity or strength of the texture.
  30538. * It is commonly used by materials to fine tune the intensity of the texture
  30539. */
  30540. level: number;
  30541. /**
  30542. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30543. * This is part of the texture as textures usually maps to one uv set.
  30544. */
  30545. coordinatesIndex: number;
  30546. private _coordinatesMode;
  30547. /**
  30548. * How a texture is mapped.
  30549. *
  30550. * | Value | Type | Description |
  30551. * | ----- | ----------------------------------- | ----------- |
  30552. * | 0 | EXPLICIT_MODE | |
  30553. * | 1 | SPHERICAL_MODE | |
  30554. * | 2 | PLANAR_MODE | |
  30555. * | 3 | CUBIC_MODE | |
  30556. * | 4 | PROJECTION_MODE | |
  30557. * | 5 | SKYBOX_MODE | |
  30558. * | 6 | INVCUBIC_MODE | |
  30559. * | 7 | EQUIRECTANGULAR_MODE | |
  30560. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30561. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30562. */
  30563. set coordinatesMode(value: number);
  30564. get coordinatesMode(): number;
  30565. /**
  30566. * | Value | Type | Description |
  30567. * | ----- | ------------------ | ----------- |
  30568. * | 0 | CLAMP_ADDRESSMODE | |
  30569. * | 1 | WRAP_ADDRESSMODE | |
  30570. * | 2 | MIRROR_ADDRESSMODE | |
  30571. */
  30572. wrapU: number;
  30573. /**
  30574. * | Value | Type | Description |
  30575. * | ----- | ------------------ | ----------- |
  30576. * | 0 | CLAMP_ADDRESSMODE | |
  30577. * | 1 | WRAP_ADDRESSMODE | |
  30578. * | 2 | MIRROR_ADDRESSMODE | |
  30579. */
  30580. wrapV: number;
  30581. /**
  30582. * | Value | Type | Description |
  30583. * | ----- | ------------------ | ----------- |
  30584. * | 0 | CLAMP_ADDRESSMODE | |
  30585. * | 1 | WRAP_ADDRESSMODE | |
  30586. * | 2 | MIRROR_ADDRESSMODE | |
  30587. */
  30588. wrapR: number;
  30589. /**
  30590. * With compliant hardware and browser (supporting anisotropic filtering)
  30591. * this defines the level of anisotropic filtering in the texture.
  30592. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30593. */
  30594. anisotropicFilteringLevel: number;
  30595. /**
  30596. * Define if the texture is a cube texture or if false a 2d texture.
  30597. */
  30598. get isCube(): boolean;
  30599. set isCube(value: boolean);
  30600. /**
  30601. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30602. */
  30603. get is3D(): boolean;
  30604. set is3D(value: boolean);
  30605. /**
  30606. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30607. */
  30608. get is2DArray(): boolean;
  30609. set is2DArray(value: boolean);
  30610. /**
  30611. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30612. * HDR texture are usually stored in linear space.
  30613. * This only impacts the PBR and Background materials
  30614. */
  30615. gammaSpace: boolean;
  30616. /**
  30617. * Gets or sets whether or not the texture contains RGBD data.
  30618. */
  30619. get isRGBD(): boolean;
  30620. set isRGBD(value: boolean);
  30621. /**
  30622. * Is Z inverted in the texture (useful in a cube texture).
  30623. */
  30624. invertZ: boolean;
  30625. /**
  30626. * Are mip maps generated for this texture or not.
  30627. */
  30628. get noMipmap(): boolean;
  30629. /**
  30630. * @hidden
  30631. */
  30632. lodLevelInAlpha: boolean;
  30633. /**
  30634. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30635. */
  30636. get lodGenerationOffset(): number;
  30637. set lodGenerationOffset(value: number);
  30638. /**
  30639. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30640. */
  30641. get lodGenerationScale(): number;
  30642. set lodGenerationScale(value: number);
  30643. /**
  30644. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30645. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30646. * average roughness values.
  30647. */
  30648. get linearSpecularLOD(): boolean;
  30649. set linearSpecularLOD(value: boolean);
  30650. /**
  30651. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30652. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30653. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30654. */
  30655. get irradianceTexture(): Nullable<BaseTexture>;
  30656. set irradianceTexture(value: Nullable<BaseTexture>);
  30657. /**
  30658. * Define if the texture is a render target.
  30659. */
  30660. isRenderTarget: boolean;
  30661. /**
  30662. * Define the unique id of the texture in the scene.
  30663. */
  30664. get uid(): string;
  30665. /**
  30666. * Return a string representation of the texture.
  30667. * @returns the texture as a string
  30668. */
  30669. toString(): string;
  30670. /**
  30671. * Get the class name of the texture.
  30672. * @returns "BaseTexture"
  30673. */
  30674. getClassName(): string;
  30675. /**
  30676. * Define the list of animation attached to the texture.
  30677. */
  30678. animations: import("babylonjs/Animations/animation").Animation[];
  30679. /**
  30680. * An event triggered when the texture is disposed.
  30681. */
  30682. onDisposeObservable: Observable<BaseTexture>;
  30683. private _onDisposeObserver;
  30684. /**
  30685. * Callback triggered when the texture has been disposed.
  30686. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30687. */
  30688. set onDispose(callback: () => void);
  30689. /**
  30690. * Define the current state of the loading sequence when in delayed load mode.
  30691. */
  30692. delayLoadState: number;
  30693. private _scene;
  30694. /** @hidden */
  30695. _texture: Nullable<InternalTexture>;
  30696. private _uid;
  30697. /**
  30698. * Define if the texture is preventinga material to render or not.
  30699. * If not and the texture is not ready, the engine will use a default black texture instead.
  30700. */
  30701. get isBlocking(): boolean;
  30702. /**
  30703. * Instantiates a new BaseTexture.
  30704. * Base class of all the textures in babylon.
  30705. * It groups all the common properties the materials, post process, lights... might need
  30706. * in order to make a correct use of the texture.
  30707. * @param scene Define the scene the texture blongs to
  30708. */
  30709. constructor(scene: Nullable<Scene>);
  30710. /**
  30711. * Get the scene the texture belongs to.
  30712. * @returns the scene or null if undefined
  30713. */
  30714. getScene(): Nullable<Scene>;
  30715. /**
  30716. * Get the texture transform matrix used to offset tile the texture for istance.
  30717. * @returns the transformation matrix
  30718. */
  30719. getTextureMatrix(): Matrix;
  30720. /**
  30721. * Get the texture reflection matrix used to rotate/transform the reflection.
  30722. * @returns the reflection matrix
  30723. */
  30724. getReflectionTextureMatrix(): Matrix;
  30725. /**
  30726. * Get the underlying lower level texture from Babylon.
  30727. * @returns the insternal texture
  30728. */
  30729. getInternalTexture(): Nullable<InternalTexture>;
  30730. /**
  30731. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30732. * @returns true if ready or not blocking
  30733. */
  30734. isReadyOrNotBlocking(): boolean;
  30735. /**
  30736. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30737. * @returns true if fully ready
  30738. */
  30739. isReady(): boolean;
  30740. private _cachedSize;
  30741. /**
  30742. * Get the size of the texture.
  30743. * @returns the texture size.
  30744. */
  30745. getSize(): ISize;
  30746. /**
  30747. * Get the base size of the texture.
  30748. * It can be different from the size if the texture has been resized for POT for instance
  30749. * @returns the base size
  30750. */
  30751. getBaseSize(): ISize;
  30752. /**
  30753. * Update the sampling mode of the texture.
  30754. * Default is Trilinear mode.
  30755. *
  30756. * | Value | Type | Description |
  30757. * | ----- | ------------------ | ----------- |
  30758. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30759. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30760. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30761. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30762. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30763. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30764. * | 7 | NEAREST_LINEAR | |
  30765. * | 8 | NEAREST_NEAREST | |
  30766. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30767. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30768. * | 11 | LINEAR_LINEAR | |
  30769. * | 12 | LINEAR_NEAREST | |
  30770. *
  30771. * > _mag_: magnification filter (close to the viewer)
  30772. * > _min_: minification filter (far from the viewer)
  30773. * > _mip_: filter used between mip map levels
  30774. *@param samplingMode Define the new sampling mode of the texture
  30775. */
  30776. updateSamplingMode(samplingMode: number): void;
  30777. /**
  30778. * Scales the texture if is `canRescale()`
  30779. * @param ratio the resize factor we want to use to rescale
  30780. */
  30781. scale(ratio: number): void;
  30782. /**
  30783. * Get if the texture can rescale.
  30784. */
  30785. get canRescale(): boolean;
  30786. /** @hidden */
  30787. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30788. /** @hidden */
  30789. _rebuild(): void;
  30790. /**
  30791. * Triggers the load sequence in delayed load mode.
  30792. */
  30793. delayLoad(): void;
  30794. /**
  30795. * Clones the texture.
  30796. * @returns the cloned texture
  30797. */
  30798. clone(): Nullable<BaseTexture>;
  30799. /**
  30800. * Get the texture underlying type (INT, FLOAT...)
  30801. */
  30802. get textureType(): number;
  30803. /**
  30804. * Get the texture underlying format (RGB, RGBA...)
  30805. */
  30806. get textureFormat(): number;
  30807. /**
  30808. * Indicates that textures need to be re-calculated for all materials
  30809. */
  30810. protected _markAllSubMeshesAsTexturesDirty(): void;
  30811. /**
  30812. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30813. * This will returns an RGBA array buffer containing either in values (0-255) or
  30814. * float values (0-1) depending of the underlying buffer type.
  30815. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30816. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30817. * @param buffer defines a user defined buffer to fill with data (can be null)
  30818. * @returns The Array buffer containing the pixels data.
  30819. */
  30820. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30821. /**
  30822. * Release and destroy the underlying lower level texture aka internalTexture.
  30823. */
  30824. releaseInternalTexture(): void;
  30825. /** @hidden */
  30826. get _lodTextureHigh(): Nullable<BaseTexture>;
  30827. /** @hidden */
  30828. get _lodTextureMid(): Nullable<BaseTexture>;
  30829. /** @hidden */
  30830. get _lodTextureLow(): Nullable<BaseTexture>;
  30831. /**
  30832. * Dispose the texture and release its associated resources.
  30833. */
  30834. dispose(): void;
  30835. /**
  30836. * Serialize the texture into a JSON representation that can be parsed later on.
  30837. * @returns the JSON representation of the texture
  30838. */
  30839. serialize(): any;
  30840. /**
  30841. * Helper function to be called back once a list of texture contains only ready textures.
  30842. * @param textures Define the list of textures to wait for
  30843. * @param callback Define the callback triggered once the entire list will be ready
  30844. */
  30845. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30846. }
  30847. }
  30848. declare module "babylonjs/Materials/effect" {
  30849. import { Observable } from "babylonjs/Misc/observable";
  30850. import { Nullable } from "babylonjs/types";
  30851. import { IDisposable } from "babylonjs/scene";
  30852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30854. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30855. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30856. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30857. import { Engine } from "babylonjs/Engines/engine";
  30858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30861. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30862. /**
  30863. * Options to be used when creating an effect.
  30864. */
  30865. export interface IEffectCreationOptions {
  30866. /**
  30867. * Atrributes that will be used in the shader.
  30868. */
  30869. attributes: string[];
  30870. /**
  30871. * Uniform varible names that will be set in the shader.
  30872. */
  30873. uniformsNames: string[];
  30874. /**
  30875. * Uniform buffer variable names that will be set in the shader.
  30876. */
  30877. uniformBuffersNames: string[];
  30878. /**
  30879. * Sampler texture variable names that will be set in the shader.
  30880. */
  30881. samplers: string[];
  30882. /**
  30883. * Define statements that will be set in the shader.
  30884. */
  30885. defines: any;
  30886. /**
  30887. * Possible fallbacks for this effect to improve performance when needed.
  30888. */
  30889. fallbacks: Nullable<IEffectFallbacks>;
  30890. /**
  30891. * Callback that will be called when the shader is compiled.
  30892. */
  30893. onCompiled: Nullable<(effect: Effect) => void>;
  30894. /**
  30895. * Callback that will be called if an error occurs during shader compilation.
  30896. */
  30897. onError: Nullable<(effect: Effect, errors: string) => void>;
  30898. /**
  30899. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30900. */
  30901. indexParameters?: any;
  30902. /**
  30903. * Max number of lights that can be used in the shader.
  30904. */
  30905. maxSimultaneousLights?: number;
  30906. /**
  30907. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30908. */
  30909. transformFeedbackVaryings?: Nullable<string[]>;
  30910. }
  30911. /**
  30912. * Effect containing vertex and fragment shader that can be executed on an object.
  30913. */
  30914. export class Effect implements IDisposable {
  30915. /**
  30916. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30917. */
  30918. static ShadersRepository: string;
  30919. /**
  30920. * Name of the effect.
  30921. */
  30922. name: any;
  30923. /**
  30924. * String container all the define statements that should be set on the shader.
  30925. */
  30926. defines: string;
  30927. /**
  30928. * Callback that will be called when the shader is compiled.
  30929. */
  30930. onCompiled: Nullable<(effect: Effect) => void>;
  30931. /**
  30932. * Callback that will be called if an error occurs during shader compilation.
  30933. */
  30934. onError: Nullable<(effect: Effect, errors: string) => void>;
  30935. /**
  30936. * Callback that will be called when effect is bound.
  30937. */
  30938. onBind: Nullable<(effect: Effect) => void>;
  30939. /**
  30940. * Unique ID of the effect.
  30941. */
  30942. uniqueId: number;
  30943. /**
  30944. * Observable that will be called when the shader is compiled.
  30945. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30946. */
  30947. onCompileObservable: Observable<Effect>;
  30948. /**
  30949. * Observable that will be called if an error occurs during shader compilation.
  30950. */
  30951. onErrorObservable: Observable<Effect>;
  30952. /** @hidden */
  30953. _onBindObservable: Nullable<Observable<Effect>>;
  30954. /**
  30955. * @hidden
  30956. * Specifies if the effect was previously ready
  30957. */
  30958. _wasPreviouslyReady: boolean;
  30959. /**
  30960. * Observable that will be called when effect is bound.
  30961. */
  30962. get onBindObservable(): Observable<Effect>;
  30963. /** @hidden */
  30964. _bonesComputationForcedToCPU: boolean;
  30965. private static _uniqueIdSeed;
  30966. private _engine;
  30967. private _uniformBuffersNames;
  30968. private _uniformsNames;
  30969. private _samplerList;
  30970. private _samplers;
  30971. private _isReady;
  30972. private _compilationError;
  30973. private _allFallbacksProcessed;
  30974. private _attributesNames;
  30975. private _attributes;
  30976. private _attributeLocationByName;
  30977. private _uniforms;
  30978. /**
  30979. * Key for the effect.
  30980. * @hidden
  30981. */
  30982. _key: string;
  30983. private _indexParameters;
  30984. private _fallbacks;
  30985. private _vertexSourceCode;
  30986. private _fragmentSourceCode;
  30987. private _vertexSourceCodeOverride;
  30988. private _fragmentSourceCodeOverride;
  30989. private _transformFeedbackVaryings;
  30990. /**
  30991. * Compiled shader to webGL program.
  30992. * @hidden
  30993. */
  30994. _pipelineContext: Nullable<IPipelineContext>;
  30995. private _valueCache;
  30996. private static _baseCache;
  30997. /**
  30998. * Instantiates an effect.
  30999. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31000. * @param baseName Name of the effect.
  31001. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31002. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31003. * @param samplers List of sampler variables that will be passed to the shader.
  31004. * @param engine Engine to be used to render the effect
  31005. * @param defines Define statements to be added to the shader.
  31006. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31007. * @param onCompiled Callback that will be called when the shader is compiled.
  31008. * @param onError Callback that will be called if an error occurs during shader compilation.
  31009. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31010. */
  31011. 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);
  31012. private _useFinalCode;
  31013. /**
  31014. * Unique key for this effect
  31015. */
  31016. get key(): string;
  31017. /**
  31018. * If the effect has been compiled and prepared.
  31019. * @returns if the effect is compiled and prepared.
  31020. */
  31021. isReady(): boolean;
  31022. private _isReadyInternal;
  31023. /**
  31024. * The engine the effect was initialized with.
  31025. * @returns the engine.
  31026. */
  31027. getEngine(): Engine;
  31028. /**
  31029. * The pipeline context for this effect
  31030. * @returns the associated pipeline context
  31031. */
  31032. getPipelineContext(): Nullable<IPipelineContext>;
  31033. /**
  31034. * The set of names of attribute variables for the shader.
  31035. * @returns An array of attribute names.
  31036. */
  31037. getAttributesNames(): string[];
  31038. /**
  31039. * Returns the attribute at the given index.
  31040. * @param index The index of the attribute.
  31041. * @returns The location of the attribute.
  31042. */
  31043. getAttributeLocation(index: number): number;
  31044. /**
  31045. * Returns the attribute based on the name of the variable.
  31046. * @param name of the attribute to look up.
  31047. * @returns the attribute location.
  31048. */
  31049. getAttributeLocationByName(name: string): number;
  31050. /**
  31051. * The number of attributes.
  31052. * @returns the numnber of attributes.
  31053. */
  31054. getAttributesCount(): number;
  31055. /**
  31056. * Gets the index of a uniform variable.
  31057. * @param uniformName of the uniform to look up.
  31058. * @returns the index.
  31059. */
  31060. getUniformIndex(uniformName: string): number;
  31061. /**
  31062. * Returns the attribute based on the name of the variable.
  31063. * @param uniformName of the uniform to look up.
  31064. * @returns the location of the uniform.
  31065. */
  31066. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31067. /**
  31068. * Returns an array of sampler variable names
  31069. * @returns The array of sampler variable neames.
  31070. */
  31071. getSamplers(): string[];
  31072. /**
  31073. * The error from the last compilation.
  31074. * @returns the error string.
  31075. */
  31076. getCompilationError(): string;
  31077. /**
  31078. * Gets a boolean indicating that all fallbacks were used during compilation
  31079. * @returns true if all fallbacks were used
  31080. */
  31081. allFallbacksProcessed(): boolean;
  31082. /**
  31083. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31084. * @param func The callback to be used.
  31085. */
  31086. executeWhenCompiled(func: (effect: Effect) => void): void;
  31087. private _checkIsReady;
  31088. private _loadShader;
  31089. /**
  31090. * Recompiles the webGL program
  31091. * @param vertexSourceCode The source code for the vertex shader.
  31092. * @param fragmentSourceCode The source code for the fragment shader.
  31093. * @param onCompiled Callback called when completed.
  31094. * @param onError Callback called on error.
  31095. * @hidden
  31096. */
  31097. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31098. /**
  31099. * Prepares the effect
  31100. * @hidden
  31101. */
  31102. _prepareEffect(): void;
  31103. private _processCompilationErrors;
  31104. /**
  31105. * Checks if the effect is supported. (Must be called after compilation)
  31106. */
  31107. get isSupported(): boolean;
  31108. /**
  31109. * Binds a texture to the engine to be used as output of the shader.
  31110. * @param channel Name of the output variable.
  31111. * @param texture Texture to bind.
  31112. * @hidden
  31113. */
  31114. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31115. /**
  31116. * Sets a texture on the engine to be used in the shader.
  31117. * @param channel Name of the sampler variable.
  31118. * @param texture Texture to set.
  31119. */
  31120. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31121. /**
  31122. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31123. * @param channel Name of the sampler variable.
  31124. * @param texture Texture to set.
  31125. */
  31126. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31127. /**
  31128. * Sets an array of textures on the engine to be used in the shader.
  31129. * @param channel Name of the variable.
  31130. * @param textures Textures to set.
  31131. */
  31132. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31133. /**
  31134. * 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)
  31135. * @param channel Name of the sampler variable.
  31136. * @param postProcess Post process to get the input texture from.
  31137. */
  31138. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31139. /**
  31140. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31141. * 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)
  31142. * @param channel Name of the sampler variable.
  31143. * @param postProcess Post process to get the output texture from.
  31144. */
  31145. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31146. /** @hidden */
  31147. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31148. /** @hidden */
  31149. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31150. /** @hidden */
  31151. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31152. /** @hidden */
  31153. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31154. /**
  31155. * Binds a buffer to a uniform.
  31156. * @param buffer Buffer to bind.
  31157. * @param name Name of the uniform variable to bind to.
  31158. */
  31159. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31160. /**
  31161. * Binds block to a uniform.
  31162. * @param blockName Name of the block to bind.
  31163. * @param index Index to bind.
  31164. */
  31165. bindUniformBlock(blockName: string, index: number): void;
  31166. /**
  31167. * Sets an interger value on a uniform variable.
  31168. * @param uniformName Name of the variable.
  31169. * @param value Value to be set.
  31170. * @returns this effect.
  31171. */
  31172. setInt(uniformName: string, value: number): Effect;
  31173. /**
  31174. * Sets an int array on a uniform variable.
  31175. * @param uniformName Name of the variable.
  31176. * @param array array to be set.
  31177. * @returns this effect.
  31178. */
  31179. setIntArray(uniformName: string, array: Int32Array): Effect;
  31180. /**
  31181. * 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)
  31182. * @param uniformName Name of the variable.
  31183. * @param array array to be set.
  31184. * @returns this effect.
  31185. */
  31186. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31187. /**
  31188. * 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)
  31189. * @param uniformName Name of the variable.
  31190. * @param array array to be set.
  31191. * @returns this effect.
  31192. */
  31193. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31194. /**
  31195. * 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)
  31196. * @param uniformName Name of the variable.
  31197. * @param array array to be set.
  31198. * @returns this effect.
  31199. */
  31200. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31201. /**
  31202. * Sets an float array on a uniform variable.
  31203. * @param uniformName Name of the variable.
  31204. * @param array array to be set.
  31205. * @returns this effect.
  31206. */
  31207. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31208. /**
  31209. * 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)
  31210. * @param uniformName Name of the variable.
  31211. * @param array array to be set.
  31212. * @returns this effect.
  31213. */
  31214. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31215. /**
  31216. * 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)
  31217. * @param uniformName Name of the variable.
  31218. * @param array array to be set.
  31219. * @returns this effect.
  31220. */
  31221. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31222. /**
  31223. * 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)
  31224. * @param uniformName Name of the variable.
  31225. * @param array array to be set.
  31226. * @returns this effect.
  31227. */
  31228. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31229. /**
  31230. * Sets an array on a uniform variable.
  31231. * @param uniformName Name of the variable.
  31232. * @param array array to be set.
  31233. * @returns this effect.
  31234. */
  31235. setArray(uniformName: string, array: number[]): Effect;
  31236. /**
  31237. * 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)
  31238. * @param uniformName Name of the variable.
  31239. * @param array array to be set.
  31240. * @returns this effect.
  31241. */
  31242. setArray2(uniformName: string, array: number[]): Effect;
  31243. /**
  31244. * 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)
  31245. * @param uniformName Name of the variable.
  31246. * @param array array to be set.
  31247. * @returns this effect.
  31248. */
  31249. setArray3(uniformName: string, array: number[]): Effect;
  31250. /**
  31251. * 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)
  31252. * @param uniformName Name of the variable.
  31253. * @param array array to be set.
  31254. * @returns this effect.
  31255. */
  31256. setArray4(uniformName: string, array: number[]): Effect;
  31257. /**
  31258. * Sets matrices on a uniform variable.
  31259. * @param uniformName Name of the variable.
  31260. * @param matrices matrices to be set.
  31261. * @returns this effect.
  31262. */
  31263. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31264. /**
  31265. * Sets matrix on a uniform variable.
  31266. * @param uniformName Name of the variable.
  31267. * @param matrix matrix to be set.
  31268. * @returns this effect.
  31269. */
  31270. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31271. /**
  31272. * 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)
  31273. * @param uniformName Name of the variable.
  31274. * @param matrix matrix to be set.
  31275. * @returns this effect.
  31276. */
  31277. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31278. /**
  31279. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31280. * @param uniformName Name of the variable.
  31281. * @param matrix matrix to be set.
  31282. * @returns this effect.
  31283. */
  31284. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31285. /**
  31286. * Sets a float on a uniform variable.
  31287. * @param uniformName Name of the variable.
  31288. * @param value value to be set.
  31289. * @returns this effect.
  31290. */
  31291. setFloat(uniformName: string, value: number): Effect;
  31292. /**
  31293. * Sets a boolean on a uniform variable.
  31294. * @param uniformName Name of the variable.
  31295. * @param bool value to be set.
  31296. * @returns this effect.
  31297. */
  31298. setBool(uniformName: string, bool: boolean): Effect;
  31299. /**
  31300. * Sets a Vector2 on a uniform variable.
  31301. * @param uniformName Name of the variable.
  31302. * @param vector2 vector2 to be set.
  31303. * @returns this effect.
  31304. */
  31305. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31306. /**
  31307. * Sets a float2 on a uniform variable.
  31308. * @param uniformName Name of the variable.
  31309. * @param x First float in float2.
  31310. * @param y Second float in float2.
  31311. * @returns this effect.
  31312. */
  31313. setFloat2(uniformName: string, x: number, y: number): Effect;
  31314. /**
  31315. * Sets a Vector3 on a uniform variable.
  31316. * @param uniformName Name of the variable.
  31317. * @param vector3 Value to be set.
  31318. * @returns this effect.
  31319. */
  31320. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31321. /**
  31322. * Sets a float3 on a uniform variable.
  31323. * @param uniformName Name of the variable.
  31324. * @param x First float in float3.
  31325. * @param y Second float in float3.
  31326. * @param z Third float in float3.
  31327. * @returns this effect.
  31328. */
  31329. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31330. /**
  31331. * Sets a Vector4 on a uniform variable.
  31332. * @param uniformName Name of the variable.
  31333. * @param vector4 Value to be set.
  31334. * @returns this effect.
  31335. */
  31336. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31337. /**
  31338. * Sets a float4 on a uniform variable.
  31339. * @param uniformName Name of the variable.
  31340. * @param x First float in float4.
  31341. * @param y Second float in float4.
  31342. * @param z Third float in float4.
  31343. * @param w Fourth float in float4.
  31344. * @returns this effect.
  31345. */
  31346. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31347. /**
  31348. * Sets a Color3 on a uniform variable.
  31349. * @param uniformName Name of the variable.
  31350. * @param color3 Value to be set.
  31351. * @returns this effect.
  31352. */
  31353. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31354. /**
  31355. * Sets a Color4 on a uniform variable.
  31356. * @param uniformName Name of the variable.
  31357. * @param color3 Value to be set.
  31358. * @param alpha Alpha value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31362. /**
  31363. * Sets a Color4 on a uniform variable
  31364. * @param uniformName defines the name of the variable
  31365. * @param color4 defines the value to be set
  31366. * @returns this effect.
  31367. */
  31368. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31369. /** Release all associated resources */
  31370. dispose(): void;
  31371. /**
  31372. * This function will add a new shader to the shader store
  31373. * @param name the name of the shader
  31374. * @param pixelShader optional pixel shader content
  31375. * @param vertexShader optional vertex shader content
  31376. */
  31377. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31378. /**
  31379. * Store of each shader (The can be looked up using effect.key)
  31380. */
  31381. static ShadersStore: {
  31382. [key: string]: string;
  31383. };
  31384. /**
  31385. * Store of each included file for a shader (The can be looked up using effect.key)
  31386. */
  31387. static IncludesShadersStore: {
  31388. [key: string]: string;
  31389. };
  31390. /**
  31391. * Resets the cache of effects.
  31392. */
  31393. static ResetCache(): void;
  31394. }
  31395. }
  31396. declare module "babylonjs/Engines/engineCapabilities" {
  31397. /**
  31398. * Interface used to describe the capabilities of the engine relatively to the current browser
  31399. */
  31400. export interface EngineCapabilities {
  31401. /** Maximum textures units per fragment shader */
  31402. maxTexturesImageUnits: number;
  31403. /** Maximum texture units per vertex shader */
  31404. maxVertexTextureImageUnits: number;
  31405. /** Maximum textures units in the entire pipeline */
  31406. maxCombinedTexturesImageUnits: number;
  31407. /** Maximum texture size */
  31408. maxTextureSize: number;
  31409. /** Maximum texture samples */
  31410. maxSamples?: number;
  31411. /** Maximum cube texture size */
  31412. maxCubemapTextureSize: number;
  31413. /** Maximum render texture size */
  31414. maxRenderTextureSize: number;
  31415. /** Maximum number of vertex attributes */
  31416. maxVertexAttribs: number;
  31417. /** Maximum number of varyings */
  31418. maxVaryingVectors: number;
  31419. /** Maximum number of uniforms per vertex shader */
  31420. maxVertexUniformVectors: number;
  31421. /** Maximum number of uniforms per fragment shader */
  31422. maxFragmentUniformVectors: number;
  31423. /** Defines if standard derivates (dx/dy) are supported */
  31424. standardDerivatives: boolean;
  31425. /** Defines if s3tc texture compression is supported */
  31426. s3tc?: WEBGL_compressed_texture_s3tc;
  31427. /** Defines if pvrtc texture compression is supported */
  31428. pvrtc: any;
  31429. /** Defines if etc1 texture compression is supported */
  31430. etc1: any;
  31431. /** Defines if etc2 texture compression is supported */
  31432. etc2: any;
  31433. /** Defines if astc texture compression is supported */
  31434. astc: any;
  31435. /** Defines if float textures are supported */
  31436. textureFloat: boolean;
  31437. /** Defines if vertex array objects are supported */
  31438. vertexArrayObject: boolean;
  31439. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31440. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31441. /** Gets the maximum level of anisotropy supported */
  31442. maxAnisotropy: number;
  31443. /** Defines if instancing is supported */
  31444. instancedArrays: boolean;
  31445. /** Defines if 32 bits indices are supported */
  31446. uintIndices: boolean;
  31447. /** Defines if high precision shaders are supported */
  31448. highPrecisionShaderSupported: boolean;
  31449. /** Defines if depth reading in the fragment shader is supported */
  31450. fragmentDepthSupported: boolean;
  31451. /** Defines if float texture linear filtering is supported*/
  31452. textureFloatLinearFiltering: boolean;
  31453. /** Defines if rendering to float textures is supported */
  31454. textureFloatRender: boolean;
  31455. /** Defines if half float textures are supported*/
  31456. textureHalfFloat: boolean;
  31457. /** Defines if half float texture linear filtering is supported*/
  31458. textureHalfFloatLinearFiltering: boolean;
  31459. /** Defines if rendering to half float textures is supported */
  31460. textureHalfFloatRender: boolean;
  31461. /** Defines if textureLOD shader command is supported */
  31462. textureLOD: boolean;
  31463. /** Defines if draw buffers extension is supported */
  31464. drawBuffersExtension: boolean;
  31465. /** Defines if depth textures are supported */
  31466. depthTextureExtension: boolean;
  31467. /** Defines if float color buffer are supported */
  31468. colorBufferFloat: boolean;
  31469. /** Gets disjoint timer query extension (null if not supported) */
  31470. timerQuery?: EXT_disjoint_timer_query;
  31471. /** Defines if timestamp can be used with timer query */
  31472. canUseTimestampForTimerQuery: boolean;
  31473. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31474. multiview?: any;
  31475. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31476. oculusMultiview?: any;
  31477. /** Function used to let the system compiles shaders in background */
  31478. parallelShaderCompile?: {
  31479. COMPLETION_STATUS_KHR: number;
  31480. };
  31481. /** Max number of texture samples for MSAA */
  31482. maxMSAASamples: number;
  31483. /** Defines if the blend min max extension is supported */
  31484. blendMinMax: boolean;
  31485. }
  31486. }
  31487. declare module "babylonjs/States/depthCullingState" {
  31488. import { Nullable } from "babylonjs/types";
  31489. /**
  31490. * @hidden
  31491. **/
  31492. export class DepthCullingState {
  31493. private _isDepthTestDirty;
  31494. private _isDepthMaskDirty;
  31495. private _isDepthFuncDirty;
  31496. private _isCullFaceDirty;
  31497. private _isCullDirty;
  31498. private _isZOffsetDirty;
  31499. private _isFrontFaceDirty;
  31500. private _depthTest;
  31501. private _depthMask;
  31502. private _depthFunc;
  31503. private _cull;
  31504. private _cullFace;
  31505. private _zOffset;
  31506. private _frontFace;
  31507. /**
  31508. * Initializes the state.
  31509. */
  31510. constructor();
  31511. get isDirty(): boolean;
  31512. get zOffset(): number;
  31513. set zOffset(value: number);
  31514. get cullFace(): Nullable<number>;
  31515. set cullFace(value: Nullable<number>);
  31516. get cull(): Nullable<boolean>;
  31517. set cull(value: Nullable<boolean>);
  31518. get depthFunc(): Nullable<number>;
  31519. set depthFunc(value: Nullable<number>);
  31520. get depthMask(): boolean;
  31521. set depthMask(value: boolean);
  31522. get depthTest(): boolean;
  31523. set depthTest(value: boolean);
  31524. get frontFace(): Nullable<number>;
  31525. set frontFace(value: Nullable<number>);
  31526. reset(): void;
  31527. apply(gl: WebGLRenderingContext): void;
  31528. }
  31529. }
  31530. declare module "babylonjs/States/stencilState" {
  31531. /**
  31532. * @hidden
  31533. **/
  31534. export class StencilState {
  31535. /** 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 */
  31536. static readonly ALWAYS: number;
  31537. /** Passed to stencilOperation to specify that stencil value must be kept */
  31538. static readonly KEEP: number;
  31539. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31540. static readonly REPLACE: number;
  31541. private _isStencilTestDirty;
  31542. private _isStencilMaskDirty;
  31543. private _isStencilFuncDirty;
  31544. private _isStencilOpDirty;
  31545. private _stencilTest;
  31546. private _stencilMask;
  31547. private _stencilFunc;
  31548. private _stencilFuncRef;
  31549. private _stencilFuncMask;
  31550. private _stencilOpStencilFail;
  31551. private _stencilOpDepthFail;
  31552. private _stencilOpStencilDepthPass;
  31553. get isDirty(): boolean;
  31554. get stencilFunc(): number;
  31555. set stencilFunc(value: number);
  31556. get stencilFuncRef(): number;
  31557. set stencilFuncRef(value: number);
  31558. get stencilFuncMask(): number;
  31559. set stencilFuncMask(value: number);
  31560. get stencilOpStencilFail(): number;
  31561. set stencilOpStencilFail(value: number);
  31562. get stencilOpDepthFail(): number;
  31563. set stencilOpDepthFail(value: number);
  31564. get stencilOpStencilDepthPass(): number;
  31565. set stencilOpStencilDepthPass(value: number);
  31566. get stencilMask(): number;
  31567. set stencilMask(value: number);
  31568. get stencilTest(): boolean;
  31569. set stencilTest(value: boolean);
  31570. constructor();
  31571. reset(): void;
  31572. apply(gl: WebGLRenderingContext): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/States/alphaCullingState" {
  31576. /**
  31577. * @hidden
  31578. **/
  31579. export class AlphaState {
  31580. private _isAlphaBlendDirty;
  31581. private _isBlendFunctionParametersDirty;
  31582. private _isBlendEquationParametersDirty;
  31583. private _isBlendConstantsDirty;
  31584. private _alphaBlend;
  31585. private _blendFunctionParameters;
  31586. private _blendEquationParameters;
  31587. private _blendConstants;
  31588. /**
  31589. * Initializes the state.
  31590. */
  31591. constructor();
  31592. get isDirty(): boolean;
  31593. get alphaBlend(): boolean;
  31594. set alphaBlend(value: boolean);
  31595. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31596. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31597. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31598. reset(): void;
  31599. apply(gl: WebGLRenderingContext): void;
  31600. }
  31601. }
  31602. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31603. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31604. /** @hidden */
  31605. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31606. attributeProcessor(attribute: string): string;
  31607. varyingProcessor(varying: string, isFragment: boolean): string;
  31608. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31609. }
  31610. }
  31611. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31612. /**
  31613. * Interface for attribute information associated with buffer instanciation
  31614. */
  31615. export interface InstancingAttributeInfo {
  31616. /**
  31617. * Name of the GLSL attribute
  31618. * if attribute index is not specified, this is used to retrieve the index from the effect
  31619. */
  31620. attributeName: string;
  31621. /**
  31622. * Index/offset of the attribute in the vertex shader
  31623. * if not specified, this will be computes from the name.
  31624. */
  31625. index?: number;
  31626. /**
  31627. * size of the attribute, 1, 2, 3 or 4
  31628. */
  31629. attributeSize: number;
  31630. /**
  31631. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31632. */
  31633. offset: number;
  31634. /**
  31635. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31636. * default to 1
  31637. */
  31638. divisor?: number;
  31639. /**
  31640. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31641. * default is FLOAT
  31642. */
  31643. attributeType?: number;
  31644. /**
  31645. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31646. */
  31647. normalized?: boolean;
  31648. }
  31649. }
  31650. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31652. import { Nullable } from "babylonjs/types";
  31653. module "babylonjs/Engines/thinEngine" {
  31654. interface ThinEngine {
  31655. /**
  31656. * Update a video texture
  31657. * @param texture defines the texture to update
  31658. * @param video defines the video element to use
  31659. * @param invertY defines if data must be stored with Y axis inverted
  31660. */
  31661. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31662. }
  31663. }
  31664. }
  31665. declare module "babylonjs/Materials/Textures/videoTexture" {
  31666. import { Observable } from "babylonjs/Misc/observable";
  31667. import { Nullable } from "babylonjs/types";
  31668. import { Scene } from "babylonjs/scene";
  31669. import { Texture } from "babylonjs/Materials/Textures/texture";
  31670. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31671. /**
  31672. * Settings for finer control over video usage
  31673. */
  31674. export interface VideoTextureSettings {
  31675. /**
  31676. * Applies `autoplay` to video, if specified
  31677. */
  31678. autoPlay?: boolean;
  31679. /**
  31680. * Applies `loop` to video, if specified
  31681. */
  31682. loop?: boolean;
  31683. /**
  31684. * Automatically updates internal texture from video at every frame in the render loop
  31685. */
  31686. autoUpdateTexture: boolean;
  31687. /**
  31688. * Image src displayed during the video loading or until the user interacts with the video.
  31689. */
  31690. poster?: string;
  31691. }
  31692. /**
  31693. * If you want to display a video in your scene, this is the special texture for that.
  31694. * This special texture works similar to other textures, with the exception of a few parameters.
  31695. * @see https://doc.babylonjs.com/how_to/video_texture
  31696. */
  31697. export class VideoTexture extends Texture {
  31698. /**
  31699. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31700. */
  31701. readonly autoUpdateTexture: boolean;
  31702. /**
  31703. * The video instance used by the texture internally
  31704. */
  31705. readonly video: HTMLVideoElement;
  31706. private _onUserActionRequestedObservable;
  31707. /**
  31708. * Event triggerd when a dom action is required by the user to play the video.
  31709. * This happens due to recent changes in browser policies preventing video to auto start.
  31710. */
  31711. get onUserActionRequestedObservable(): Observable<Texture>;
  31712. private _generateMipMaps;
  31713. private _engine;
  31714. private _stillImageCaptured;
  31715. private _displayingPosterTexture;
  31716. private _settings;
  31717. private _createInternalTextureOnEvent;
  31718. private _frameId;
  31719. private _currentSrc;
  31720. /**
  31721. * Creates a video texture.
  31722. * If you want to display a video in your scene, this is the special texture for that.
  31723. * This special texture works similar to other textures, with the exception of a few parameters.
  31724. * @see https://doc.babylonjs.com/how_to/video_texture
  31725. * @param name optional name, will detect from video source, if not defined
  31726. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31727. * @param scene is obviously the current scene.
  31728. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31729. * @param invertY is false by default but can be used to invert video on Y axis
  31730. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31731. * @param settings allows finer control over video usage
  31732. */
  31733. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31734. private _getName;
  31735. private _getVideo;
  31736. private _createInternalTexture;
  31737. private reset;
  31738. /**
  31739. * @hidden Internal method to initiate `update`.
  31740. */
  31741. _rebuild(): void;
  31742. /**
  31743. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31744. */
  31745. update(): void;
  31746. /**
  31747. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31748. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31749. */
  31750. updateTexture(isVisible: boolean): void;
  31751. protected _updateInternalTexture: () => void;
  31752. /**
  31753. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31754. * @param url New url.
  31755. */
  31756. updateURL(url: string): void;
  31757. /**
  31758. * Clones the texture.
  31759. * @returns the cloned texture
  31760. */
  31761. clone(): VideoTexture;
  31762. /**
  31763. * Dispose the texture and release its associated resources.
  31764. */
  31765. dispose(): void;
  31766. /**
  31767. * Creates a video texture straight from a stream.
  31768. * @param scene Define the scene the texture should be created in
  31769. * @param stream Define the stream the texture should be created from
  31770. * @returns The created video texture as a promise
  31771. */
  31772. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31773. /**
  31774. * Creates a video texture straight from your WebCam video feed.
  31775. * @param scene Define the scene the texture should be created in
  31776. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31777. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31778. * @returns The created video texture as a promise
  31779. */
  31780. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31781. minWidth: number;
  31782. maxWidth: number;
  31783. minHeight: number;
  31784. maxHeight: number;
  31785. deviceId: string;
  31786. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31787. /**
  31788. * Creates a video texture straight from your WebCam video feed.
  31789. * @param scene Define the scene the texture should be created in
  31790. * @param onReady Define a callback to triggered once the texture will be ready
  31791. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31792. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31793. */
  31794. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31795. minWidth: number;
  31796. maxWidth: number;
  31797. minHeight: number;
  31798. maxHeight: number;
  31799. deviceId: string;
  31800. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31801. }
  31802. }
  31803. declare module "babylonjs/Engines/thinEngine" {
  31804. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31805. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31806. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31807. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31808. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31809. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31810. import { Observable } from "babylonjs/Misc/observable";
  31811. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31812. import { StencilState } from "babylonjs/States/stencilState";
  31813. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31815. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31816. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31817. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31818. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31819. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31820. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31821. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31823. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31824. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31825. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31826. import { WebRequest } from "babylonjs/Misc/webRequest";
  31827. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31828. /**
  31829. * Defines the interface used by objects working like Scene
  31830. * @hidden
  31831. */
  31832. interface ISceneLike {
  31833. _addPendingData(data: any): void;
  31834. _removePendingData(data: any): void;
  31835. offlineProvider: IOfflineProvider;
  31836. }
  31837. /** Interface defining initialization parameters for Engine class */
  31838. export interface EngineOptions extends WebGLContextAttributes {
  31839. /**
  31840. * Defines if the engine should no exceed a specified device ratio
  31841. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31842. */
  31843. limitDeviceRatio?: number;
  31844. /**
  31845. * Defines if webvr should be enabled automatically
  31846. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31847. */
  31848. autoEnableWebVR?: boolean;
  31849. /**
  31850. * Defines if webgl2 should be turned off even if supported
  31851. * @see http://doc.babylonjs.com/features/webgl2
  31852. */
  31853. disableWebGL2Support?: boolean;
  31854. /**
  31855. * Defines if webaudio should be initialized as well
  31856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31857. */
  31858. audioEngine?: boolean;
  31859. /**
  31860. * Defines if animations should run using a deterministic lock step
  31861. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31862. */
  31863. deterministicLockstep?: boolean;
  31864. /** Defines the maximum steps to use with deterministic lock step mode */
  31865. lockstepMaxSteps?: number;
  31866. /** Defines the seconds between each deterministic lock step */
  31867. timeStep?: number;
  31868. /**
  31869. * Defines that engine should ignore context lost events
  31870. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31871. */
  31872. doNotHandleContextLost?: boolean;
  31873. /**
  31874. * Defines that engine should ignore modifying touch action attribute and style
  31875. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31876. */
  31877. doNotHandleTouchAction?: boolean;
  31878. /**
  31879. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31880. */
  31881. useHighPrecisionFloats?: boolean;
  31882. }
  31883. /**
  31884. * The base engine class (root of all engines)
  31885. */
  31886. export class ThinEngine {
  31887. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31888. static ExceptionList: ({
  31889. key: string;
  31890. capture: string;
  31891. captureConstraint: number;
  31892. targets: string[];
  31893. } | {
  31894. key: string;
  31895. capture: null;
  31896. captureConstraint: null;
  31897. targets: string[];
  31898. })[];
  31899. /** @hidden */
  31900. static _TextureLoaders: IInternalTextureLoader[];
  31901. /**
  31902. * Returns the current npm package of the sdk
  31903. */
  31904. static get NpmPackage(): string;
  31905. /**
  31906. * Returns the current version of the framework
  31907. */
  31908. static get Version(): string;
  31909. /**
  31910. * Returns a string describing the current engine
  31911. */
  31912. get description(): string;
  31913. /**
  31914. * Gets or sets the epsilon value used by collision engine
  31915. */
  31916. static CollisionsEpsilon: number;
  31917. /**
  31918. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31919. */
  31920. static get ShadersRepository(): string;
  31921. static set ShadersRepository(value: string);
  31922. /**
  31923. * Gets or sets the textures that the engine should not attempt to load as compressed
  31924. */
  31925. protected _excludedCompressedTextures: string[];
  31926. /**
  31927. * Filters the compressed texture formats to only include
  31928. * files that are not included in the skippable list
  31929. *
  31930. * @param url the current extension
  31931. * @param textureFormatInUse the current compressed texture format
  31932. * @returns "format" string
  31933. */
  31934. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31935. /** @hidden */
  31936. _shaderProcessor: IShaderProcessor;
  31937. /**
  31938. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31939. */
  31940. forcePOTTextures: boolean;
  31941. /**
  31942. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31943. */
  31944. isFullscreen: boolean;
  31945. /**
  31946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31947. */
  31948. cullBackFaces: boolean;
  31949. /**
  31950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31951. */
  31952. renderEvenInBackground: boolean;
  31953. /**
  31954. * Gets or sets a boolean indicating that cache can be kept between frames
  31955. */
  31956. preventCacheWipeBetweenFrames: boolean;
  31957. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31958. validateShaderPrograms: boolean;
  31959. /**
  31960. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31961. * This can provide greater z depth for distant objects.
  31962. */
  31963. useReverseDepthBuffer: boolean;
  31964. /**
  31965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31966. */
  31967. disableUniformBuffers: boolean;
  31968. /** @hidden */
  31969. _uniformBuffers: UniformBuffer[];
  31970. /**
  31971. * Gets a boolean indicating that the engine supports uniform buffers
  31972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31973. */
  31974. get supportsUniformBuffers(): boolean;
  31975. /** @hidden */
  31976. _gl: WebGLRenderingContext;
  31977. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31978. protected _windowIsBackground: boolean;
  31979. protected _webGLVersion: number;
  31980. protected _creationOptions: EngineOptions;
  31981. protected _highPrecisionShadersAllowed: boolean;
  31982. /** @hidden */
  31983. get _shouldUseHighPrecisionShader(): boolean;
  31984. /**
  31985. * Gets a boolean indicating that only power of 2 textures are supported
  31986. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31987. */
  31988. get needPOTTextures(): boolean;
  31989. /** @hidden */
  31990. _badOS: boolean;
  31991. /** @hidden */
  31992. _badDesktopOS: boolean;
  31993. private _hardwareScalingLevel;
  31994. /** @hidden */
  31995. _caps: EngineCapabilities;
  31996. private _isStencilEnable;
  31997. private _glVersion;
  31998. private _glRenderer;
  31999. private _glVendor;
  32000. /** @hidden */
  32001. _videoTextureSupported: boolean;
  32002. protected _renderingQueueLaunched: boolean;
  32003. protected _activeRenderLoops: (() => void)[];
  32004. /**
  32005. * Observable signaled when a context lost event is raised
  32006. */
  32007. onContextLostObservable: Observable<ThinEngine>;
  32008. /**
  32009. * Observable signaled when a context restored event is raised
  32010. */
  32011. onContextRestoredObservable: Observable<ThinEngine>;
  32012. private _onContextLost;
  32013. private _onContextRestored;
  32014. protected _contextWasLost: boolean;
  32015. /** @hidden */
  32016. _doNotHandleContextLost: boolean;
  32017. /**
  32018. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32020. */
  32021. get doNotHandleContextLost(): boolean;
  32022. set doNotHandleContextLost(value: boolean);
  32023. /**
  32024. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32025. */
  32026. disableVertexArrayObjects: boolean;
  32027. /** @hidden */
  32028. protected _colorWrite: boolean;
  32029. /** @hidden */
  32030. protected _colorWriteChanged: boolean;
  32031. /** @hidden */
  32032. protected _depthCullingState: DepthCullingState;
  32033. /** @hidden */
  32034. protected _stencilState: StencilState;
  32035. /** @hidden */
  32036. _alphaState: AlphaState;
  32037. /** @hidden */
  32038. _alphaMode: number;
  32039. /** @hidden */
  32040. _alphaEquation: number;
  32041. /** @hidden */
  32042. _internalTexturesCache: InternalTexture[];
  32043. /** @hidden */
  32044. protected _activeChannel: number;
  32045. private _currentTextureChannel;
  32046. /** @hidden */
  32047. protected _boundTexturesCache: {
  32048. [key: string]: Nullable<InternalTexture>;
  32049. };
  32050. /** @hidden */
  32051. protected _currentEffect: Nullable<Effect>;
  32052. /** @hidden */
  32053. protected _currentProgram: Nullable<WebGLProgram>;
  32054. private _compiledEffects;
  32055. private _vertexAttribArraysEnabled;
  32056. /** @hidden */
  32057. protected _cachedViewport: Nullable<IViewportLike>;
  32058. private _cachedVertexArrayObject;
  32059. /** @hidden */
  32060. protected _cachedVertexBuffers: any;
  32061. /** @hidden */
  32062. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32063. /** @hidden */
  32064. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32065. /** @hidden */
  32066. _currentRenderTarget: Nullable<InternalTexture>;
  32067. private _uintIndicesCurrentlySet;
  32068. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32069. /** @hidden */
  32070. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32071. private _currentBufferPointers;
  32072. private _currentInstanceLocations;
  32073. private _currentInstanceBuffers;
  32074. private _textureUnits;
  32075. /** @hidden */
  32076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32077. /** @hidden */
  32078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32079. /** @hidden */
  32080. _boundRenderFunction: any;
  32081. private _vaoRecordInProgress;
  32082. private _mustWipeVertexAttributes;
  32083. private _emptyTexture;
  32084. private _emptyCubeTexture;
  32085. private _emptyTexture3D;
  32086. private _emptyTexture2DArray;
  32087. /** @hidden */
  32088. _frameHandler: number;
  32089. private _nextFreeTextureSlots;
  32090. private _maxSimultaneousTextures;
  32091. private _activeRequests;
  32092. protected _texturesSupported: string[];
  32093. /** @hidden */
  32094. _textureFormatInUse: Nullable<string>;
  32095. protected get _supportsHardwareTextureRescaling(): boolean;
  32096. /**
  32097. * Gets the list of texture formats supported
  32098. */
  32099. get texturesSupported(): Array<string>;
  32100. /**
  32101. * Gets the list of texture formats in use
  32102. */
  32103. get textureFormatInUse(): Nullable<string>;
  32104. /**
  32105. * Gets the current viewport
  32106. */
  32107. get currentViewport(): Nullable<IViewportLike>;
  32108. /**
  32109. * Gets the default empty texture
  32110. */
  32111. get emptyTexture(): InternalTexture;
  32112. /**
  32113. * Gets the default empty 3D texture
  32114. */
  32115. get emptyTexture3D(): InternalTexture;
  32116. /**
  32117. * Gets the default empty 2D array texture
  32118. */
  32119. get emptyTexture2DArray(): InternalTexture;
  32120. /**
  32121. * Gets the default empty cube texture
  32122. */
  32123. get emptyCubeTexture(): InternalTexture;
  32124. /**
  32125. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32126. */
  32127. readonly premultipliedAlpha: boolean;
  32128. /**
  32129. * Observable event triggered before each texture is initialized
  32130. */
  32131. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32132. /**
  32133. * Creates a new engine
  32134. * @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
  32135. * @param antialias defines enable antialiasing (default: false)
  32136. * @param options defines further options to be sent to the getContext() function
  32137. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32138. */
  32139. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32140. private _rebuildInternalTextures;
  32141. private _rebuildEffects;
  32142. /**
  32143. * Gets a boolean indicating if all created effects are ready
  32144. * @returns true if all effects are ready
  32145. */
  32146. areAllEffectsReady(): boolean;
  32147. protected _rebuildBuffers(): void;
  32148. private _initGLContext;
  32149. /**
  32150. * Gets version of the current webGL context
  32151. */
  32152. get webGLVersion(): number;
  32153. /**
  32154. * Gets a string idenfifying the name of the class
  32155. * @returns "Engine" string
  32156. */
  32157. getClassName(): string;
  32158. /**
  32159. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32160. */
  32161. get isStencilEnable(): boolean;
  32162. /** @hidden */
  32163. _prepareWorkingCanvas(): void;
  32164. /**
  32165. * Reset the texture cache to empty state
  32166. */
  32167. resetTextureCache(): void;
  32168. /**
  32169. * Gets an object containing information about the current webGL context
  32170. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32171. */
  32172. getGlInfo(): {
  32173. vendor: string;
  32174. renderer: string;
  32175. version: string;
  32176. };
  32177. /**
  32178. * Defines the hardware scaling level.
  32179. * By default the hardware scaling level is computed from the window device ratio.
  32180. * 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.
  32181. * @param level defines the level to use
  32182. */
  32183. setHardwareScalingLevel(level: number): void;
  32184. /**
  32185. * Gets the current hardware scaling level.
  32186. * By default the hardware scaling level is computed from the window device ratio.
  32187. * 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.
  32188. * @returns a number indicating the current hardware scaling level
  32189. */
  32190. getHardwareScalingLevel(): number;
  32191. /**
  32192. * Gets the list of loaded textures
  32193. * @returns an array containing all loaded textures
  32194. */
  32195. getLoadedTexturesCache(): InternalTexture[];
  32196. /**
  32197. * Gets the object containing all engine capabilities
  32198. * @returns the EngineCapabilities object
  32199. */
  32200. getCaps(): EngineCapabilities;
  32201. /**
  32202. * stop executing a render loop function and remove it from the execution array
  32203. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32204. */
  32205. stopRenderLoop(renderFunction?: () => void): void;
  32206. /** @hidden */
  32207. _renderLoop(): void;
  32208. /**
  32209. * Gets the HTML canvas attached with the current webGL context
  32210. * @returns a HTML canvas
  32211. */
  32212. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32213. /**
  32214. * Gets host window
  32215. * @returns the host window object
  32216. */
  32217. getHostWindow(): Nullable<Window>;
  32218. /**
  32219. * Gets the current render width
  32220. * @param useScreen defines if screen size must be used (or the current render target if any)
  32221. * @returns a number defining the current render width
  32222. */
  32223. getRenderWidth(useScreen?: boolean): number;
  32224. /**
  32225. * Gets the current render height
  32226. * @param useScreen defines if screen size must be used (or the current render target if any)
  32227. * @returns a number defining the current render height
  32228. */
  32229. getRenderHeight(useScreen?: boolean): number;
  32230. /**
  32231. * Can be used to override the current requestAnimationFrame requester.
  32232. * @hidden
  32233. */
  32234. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32235. /**
  32236. * Register and execute a render loop. The engine can have more than one render function
  32237. * @param renderFunction defines the function to continuously execute
  32238. */
  32239. runRenderLoop(renderFunction: () => void): void;
  32240. /**
  32241. * Clear the current render buffer or the current render target (if any is set up)
  32242. * @param color defines the color to use
  32243. * @param backBuffer defines if the back buffer must be cleared
  32244. * @param depth defines if the depth buffer must be cleared
  32245. * @param stencil defines if the stencil buffer must be cleared
  32246. */
  32247. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32248. private _viewportCached;
  32249. /** @hidden */
  32250. _viewport(x: number, y: number, width: number, height: number): void;
  32251. /**
  32252. * Set the WebGL's viewport
  32253. * @param viewport defines the viewport element to be used
  32254. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32255. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32256. */
  32257. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32258. /**
  32259. * Begin a new frame
  32260. */
  32261. beginFrame(): void;
  32262. /**
  32263. * Enf the current frame
  32264. */
  32265. endFrame(): void;
  32266. /**
  32267. * Resize the view according to the canvas' size
  32268. */
  32269. resize(): void;
  32270. /**
  32271. * Force a specific size of the canvas
  32272. * @param width defines the new canvas' width
  32273. * @param height defines the new canvas' height
  32274. */
  32275. setSize(width: number, height: number): void;
  32276. /**
  32277. * Binds the frame buffer to the specified texture.
  32278. * @param texture The texture to render to or null for the default canvas
  32279. * @param faceIndex The face of the texture to render to in case of cube texture
  32280. * @param requiredWidth The width of the target to render to
  32281. * @param requiredHeight The height of the target to render to
  32282. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32283. * @param lodLevel defines the lod level to bind to the frame buffer
  32284. * @param layer defines the 2d array index to bind to frame buffer to
  32285. */
  32286. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32287. /** @hidden */
  32288. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32289. /**
  32290. * Unbind the current render target texture from the webGL context
  32291. * @param texture defines the render target texture to unbind
  32292. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32293. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32294. */
  32295. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32296. /**
  32297. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32298. */
  32299. flushFramebuffer(): void;
  32300. /**
  32301. * Unbind the current render target and bind the default framebuffer
  32302. */
  32303. restoreDefaultFramebuffer(): void;
  32304. /** @hidden */
  32305. protected _resetVertexBufferBinding(): void;
  32306. /**
  32307. * Creates a vertex buffer
  32308. * @param data the data for the vertex buffer
  32309. * @returns the new WebGL static buffer
  32310. */
  32311. createVertexBuffer(data: DataArray): DataBuffer;
  32312. private _createVertexBuffer;
  32313. /**
  32314. * Creates a dynamic vertex buffer
  32315. * @param data the data for the dynamic vertex buffer
  32316. * @returns the new WebGL dynamic buffer
  32317. */
  32318. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32319. protected _resetIndexBufferBinding(): void;
  32320. /**
  32321. * Creates a new index buffer
  32322. * @param indices defines the content of the index buffer
  32323. * @param updatable defines if the index buffer must be updatable
  32324. * @returns a new webGL buffer
  32325. */
  32326. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32327. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32328. /**
  32329. * Bind a webGL buffer to the webGL context
  32330. * @param buffer defines the buffer to bind
  32331. */
  32332. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32333. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32334. private bindBuffer;
  32335. /**
  32336. * update the bound buffer with the given data
  32337. * @param data defines the data to update
  32338. */
  32339. updateArrayBuffer(data: Float32Array): void;
  32340. private _vertexAttribPointer;
  32341. /** @hidden */
  32342. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32343. private _bindVertexBuffersAttributes;
  32344. /**
  32345. * Records a vertex array object
  32346. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32347. * @param vertexBuffers defines the list of vertex buffers to store
  32348. * @param indexBuffer defines the index buffer to store
  32349. * @param effect defines the effect to store
  32350. * @returns the new vertex array object
  32351. */
  32352. recordVertexArrayObject(vertexBuffers: {
  32353. [key: string]: VertexBuffer;
  32354. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32355. /**
  32356. * Bind a specific vertex array object
  32357. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32358. * @param vertexArrayObject defines the vertex array object to bind
  32359. * @param indexBuffer defines the index buffer to bind
  32360. */
  32361. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32362. /**
  32363. * Bind webGl buffers directly to the webGL context
  32364. * @param vertexBuffer defines the vertex buffer to bind
  32365. * @param indexBuffer defines the index buffer to bind
  32366. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32367. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32368. * @param effect defines the effect associated with the vertex buffer
  32369. */
  32370. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32371. private _unbindVertexArrayObject;
  32372. /**
  32373. * Bind a list of vertex buffers to the webGL context
  32374. * @param vertexBuffers defines the list of vertex buffers to bind
  32375. * @param indexBuffer defines the index buffer to bind
  32376. * @param effect defines the effect associated with the vertex buffers
  32377. */
  32378. bindBuffers(vertexBuffers: {
  32379. [key: string]: Nullable<VertexBuffer>;
  32380. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32381. /**
  32382. * Unbind all instance attributes
  32383. */
  32384. unbindInstanceAttributes(): void;
  32385. /**
  32386. * Release and free the memory of a vertex array object
  32387. * @param vao defines the vertex array object to delete
  32388. */
  32389. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32390. /** @hidden */
  32391. _releaseBuffer(buffer: DataBuffer): boolean;
  32392. protected _deleteBuffer(buffer: DataBuffer): void;
  32393. /**
  32394. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32395. * @param instancesBuffer defines the webGL buffer to update and bind
  32396. * @param data defines the data to store in the buffer
  32397. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32398. */
  32399. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32400. /**
  32401. * Bind the content of a webGL buffer used with instantiation
  32402. * @param instancesBuffer defines the webGL buffer to bind
  32403. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32404. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32405. */
  32406. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32407. /**
  32408. * Disable the instance attribute corresponding to the name in parameter
  32409. * @param name defines the name of the attribute to disable
  32410. */
  32411. disableInstanceAttributeByName(name: string): void;
  32412. /**
  32413. * Disable the instance attribute corresponding to the location in parameter
  32414. * @param attributeLocation defines the attribute location of the attribute to disable
  32415. */
  32416. disableInstanceAttribute(attributeLocation: number): void;
  32417. /**
  32418. * Disable the attribute corresponding to the location in parameter
  32419. * @param attributeLocation defines the attribute location of the attribute to disable
  32420. */
  32421. disableAttributeByIndex(attributeLocation: number): void;
  32422. /**
  32423. * Send a draw order
  32424. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32425. * @param indexStart defines the starting index
  32426. * @param indexCount defines the number of index to draw
  32427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32428. */
  32429. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32430. /**
  32431. * Draw a list of points
  32432. * @param verticesStart defines the index of first vertex to draw
  32433. * @param verticesCount defines the count of vertices to draw
  32434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32435. */
  32436. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32437. /**
  32438. * Draw a list of unindexed primitives
  32439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32440. * @param verticesStart defines the index of first vertex to draw
  32441. * @param verticesCount defines the count of vertices to draw
  32442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32443. */
  32444. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32445. /**
  32446. * Draw a list of indexed primitives
  32447. * @param fillMode defines the primitive to use
  32448. * @param indexStart defines the starting index
  32449. * @param indexCount defines the number of index to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of unindexed primitives
  32455. * @param fillMode defines the primitive to use
  32456. * @param verticesStart defines the index of first vertex to draw
  32457. * @param verticesCount defines the count of vertices to draw
  32458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32459. */
  32460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32461. private _drawMode;
  32462. /** @hidden */
  32463. protected _reportDrawCall(): void;
  32464. /** @hidden */
  32465. _releaseEffect(effect: Effect): void;
  32466. /** @hidden */
  32467. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32468. /**
  32469. * Create a new effect (used to store vertex/fragment shaders)
  32470. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32471. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32472. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32473. * @param samplers defines an array of string used to represent textures
  32474. * @param defines defines the string containing the defines to use to compile the shaders
  32475. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32476. * @param onCompiled defines a function to call when the effect creation is successful
  32477. * @param onError defines a function to call when the effect creation has failed
  32478. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32479. * @returns the new Effect
  32480. */
  32481. 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;
  32482. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32483. private _compileShader;
  32484. private _compileRawShader;
  32485. /**
  32486. * Directly creates a webGL program
  32487. * @param pipelineContext defines the pipeline context to attach to
  32488. * @param vertexCode defines the vertex shader code to use
  32489. * @param fragmentCode defines the fragment shader code to use
  32490. * @param context defines the webGL context to use (if not set, the current one will be used)
  32491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32492. * @returns the new webGL program
  32493. */
  32494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32495. /**
  32496. * Creates a webGL program
  32497. * @param pipelineContext defines the pipeline context to attach to
  32498. * @param vertexCode defines the vertex shader code to use
  32499. * @param fragmentCode defines the fragment shader code to use
  32500. * @param defines defines the string containing the defines to use to compile the shaders
  32501. * @param context defines the webGL context to use (if not set, the current one will be used)
  32502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32503. * @returns the new webGL program
  32504. */
  32505. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32506. /**
  32507. * Creates a new pipeline context
  32508. * @returns the new pipeline
  32509. */
  32510. createPipelineContext(): IPipelineContext;
  32511. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32512. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32513. /** @hidden */
  32514. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32515. /** @hidden */
  32516. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32517. /** @hidden */
  32518. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32519. /**
  32520. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32521. * @param pipelineContext defines the pipeline context to use
  32522. * @param uniformsNames defines the list of uniform names
  32523. * @returns an array of webGL uniform locations
  32524. */
  32525. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32526. /**
  32527. * Gets the lsit of active attributes for a given webGL program
  32528. * @param pipelineContext defines the pipeline context to use
  32529. * @param attributesNames defines the list of attribute names to get
  32530. * @returns an array of indices indicating the offset of each attribute
  32531. */
  32532. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32533. /**
  32534. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32535. * @param effect defines the effect to activate
  32536. */
  32537. enableEffect(effect: Nullable<Effect>): void;
  32538. /**
  32539. * Set the value of an uniform to a number (int)
  32540. * @param uniform defines the webGL uniform location where to store the value
  32541. * @param value defines the int number to store
  32542. */
  32543. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32544. /**
  32545. * Set the value of an uniform to an array of int32
  32546. * @param uniform defines the webGL uniform location where to store the value
  32547. * @param array defines the array of int32 to store
  32548. */
  32549. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32550. /**
  32551. * Set the value of an uniform to an array of int32 (stored as vec2)
  32552. * @param uniform defines the webGL uniform location where to store the value
  32553. * @param array defines the array of int32 to store
  32554. */
  32555. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32556. /**
  32557. * Set the value of an uniform to an array of int32 (stored as vec3)
  32558. * @param uniform defines the webGL uniform location where to store the value
  32559. * @param array defines the array of int32 to store
  32560. */
  32561. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32562. /**
  32563. * Set the value of an uniform to an array of int32 (stored as vec4)
  32564. * @param uniform defines the webGL uniform location where to store the value
  32565. * @param array defines the array of int32 to store
  32566. */
  32567. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32568. /**
  32569. * Set the value of an uniform to an array of number
  32570. * @param uniform defines the webGL uniform location where to store the value
  32571. * @param array defines the array of number to store
  32572. */
  32573. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32574. /**
  32575. * Set the value of an uniform to an array of number (stored as vec2)
  32576. * @param uniform defines the webGL uniform location where to store the value
  32577. * @param array defines the array of number to store
  32578. */
  32579. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32580. /**
  32581. * Set the value of an uniform to an array of number (stored as vec3)
  32582. * @param uniform defines the webGL uniform location where to store the value
  32583. * @param array defines the array of number to store
  32584. */
  32585. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32586. /**
  32587. * Set the value of an uniform to an array of number (stored as vec4)
  32588. * @param uniform defines the webGL uniform location where to store the value
  32589. * @param array defines the array of number to store
  32590. */
  32591. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32592. /**
  32593. * Set the value of an uniform to an array of float32 (stored as matrices)
  32594. * @param uniform defines the webGL uniform location where to store the value
  32595. * @param matrices defines the array of float32 to store
  32596. */
  32597. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32598. /**
  32599. * Set the value of an uniform to a matrix (3x3)
  32600. * @param uniform defines the webGL uniform location where to store the value
  32601. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32602. */
  32603. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32604. /**
  32605. * Set the value of an uniform to a matrix (2x2)
  32606. * @param uniform defines the webGL uniform location where to store the value
  32607. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32608. */
  32609. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32610. /**
  32611. * Set the value of an uniform to a number (float)
  32612. * @param uniform defines the webGL uniform location where to store the value
  32613. * @param value defines the float number to store
  32614. */
  32615. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32616. /**
  32617. * Set the value of an uniform to a vec2
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param x defines the 1st component of the value
  32620. * @param y defines the 2nd component of the value
  32621. */
  32622. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32623. /**
  32624. * Set the value of an uniform to a vec3
  32625. * @param uniform defines the webGL uniform location where to store the value
  32626. * @param x defines the 1st component of the value
  32627. * @param y defines the 2nd component of the value
  32628. * @param z defines the 3rd component of the value
  32629. */
  32630. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32631. /**
  32632. * Set the value of an uniform to a vec4
  32633. * @param uniform defines the webGL uniform location where to store the value
  32634. * @param x defines the 1st component of the value
  32635. * @param y defines the 2nd component of the value
  32636. * @param z defines the 3rd component of the value
  32637. * @param w defines the 4th component of the value
  32638. */
  32639. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32640. /**
  32641. * Apply all cached states (depth, culling, stencil and alpha)
  32642. */
  32643. applyStates(): void;
  32644. /**
  32645. * Enable or disable color writing
  32646. * @param enable defines the state to set
  32647. */
  32648. setColorWrite(enable: boolean): void;
  32649. /**
  32650. * Gets a boolean indicating if color writing is enabled
  32651. * @returns the current color writing state
  32652. */
  32653. getColorWrite(): boolean;
  32654. /**
  32655. * Gets the depth culling state manager
  32656. */
  32657. get depthCullingState(): DepthCullingState;
  32658. /**
  32659. * Gets the alpha state manager
  32660. */
  32661. get alphaState(): AlphaState;
  32662. /**
  32663. * Gets the stencil state manager
  32664. */
  32665. get stencilState(): StencilState;
  32666. /**
  32667. * Clears the list of texture accessible through engine.
  32668. * This can help preventing texture load conflict due to name collision.
  32669. */
  32670. clearInternalTexturesCache(): void;
  32671. /**
  32672. * Force the entire cache to be cleared
  32673. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32674. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32675. */
  32676. wipeCaches(bruteForce?: boolean): void;
  32677. /** @hidden */
  32678. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32679. min: number;
  32680. mag: number;
  32681. };
  32682. /** @hidden */
  32683. _createTexture(): WebGLTexture;
  32684. /**
  32685. * Usually called from Texture.ts.
  32686. * Passed information to create a WebGLTexture
  32687. * @param urlArg defines a value which contains one of the following:
  32688. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32689. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32690. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32691. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32692. * @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)
  32693. * @param scene needed for loading to the correct scene
  32694. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32695. * @param onLoad optional callback to be called upon successful completion
  32696. * @param onError optional callback to be called upon failure
  32697. * @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
  32698. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32699. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32700. * @param forcedExtension defines the extension to use to pick the right loader
  32701. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32702. * @param mimeType defines an optional mime type
  32703. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32704. */
  32705. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32706. /**
  32707. * Loads an image as an HTMLImageElement.
  32708. * @param input url string, ArrayBuffer, or Blob to load
  32709. * @param onLoad callback called when the image successfully loads
  32710. * @param onError callback called when the image fails to load
  32711. * @param offlineProvider offline provider for caching
  32712. * @param mimeType optional mime type
  32713. * @returns the HTMLImageElement of the loaded image
  32714. * @hidden
  32715. */
  32716. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32717. /**
  32718. * @hidden
  32719. */
  32720. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32721. /**
  32722. * Creates a raw texture
  32723. * @param data defines the data to store in the texture
  32724. * @param width defines the width of the texture
  32725. * @param height defines the height of the texture
  32726. * @param format defines the format of the data
  32727. * @param generateMipMaps defines if the engine should generate the mip levels
  32728. * @param invertY defines if data must be stored with Y axis inverted
  32729. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32730. * @param compression defines the compression used (null by default)
  32731. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32732. * @returns the raw texture inside an InternalTexture
  32733. */
  32734. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32735. /**
  32736. * Creates a new raw cube texture
  32737. * @param data defines the array of data to use to create each face
  32738. * @param size defines the size of the textures
  32739. * @param format defines the format of the data
  32740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32741. * @param generateMipMaps defines if the engine should generate the mip levels
  32742. * @param invertY defines if data must be stored with Y axis inverted
  32743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32744. * @param compression defines the compression used (null by default)
  32745. * @returns the cube texture as an InternalTexture
  32746. */
  32747. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32748. /**
  32749. * Creates a new raw 3D texture
  32750. * @param data defines the data used to create the texture
  32751. * @param width defines the width of the texture
  32752. * @param height defines the height of the texture
  32753. * @param depth defines the depth of the texture
  32754. * @param format defines the format of the texture
  32755. * @param generateMipMaps defines if the engine must generate mip levels
  32756. * @param invertY defines if data must be stored with Y axis inverted
  32757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32758. * @param compression defines the compressed used (can be null)
  32759. * @param textureType defines the compressed used (can be null)
  32760. * @returns a new raw 3D texture (stored in an InternalTexture)
  32761. */
  32762. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32763. /**
  32764. * Creates a new raw 2D array texture
  32765. * @param data defines the data used to create the texture
  32766. * @param width defines the width of the texture
  32767. * @param height defines the height of the texture
  32768. * @param depth defines the number of layers of the texture
  32769. * @param format defines the format of the texture
  32770. * @param generateMipMaps defines if the engine must generate mip levels
  32771. * @param invertY defines if data must be stored with Y axis inverted
  32772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32773. * @param compression defines the compressed used (can be null)
  32774. * @param textureType defines the compressed used (can be null)
  32775. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32776. */
  32777. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32778. private _unpackFlipYCached;
  32779. /**
  32780. * In case you are sharing the context with other applications, it might
  32781. * be interested to not cache the unpack flip y state to ensure a consistent
  32782. * value would be set.
  32783. */
  32784. enableUnpackFlipYCached: boolean;
  32785. /** @hidden */
  32786. _unpackFlipY(value: boolean): void;
  32787. /** @hidden */
  32788. _getUnpackAlignement(): number;
  32789. private _getTextureTarget;
  32790. /**
  32791. * Update the sampling mode of a given texture
  32792. * @param samplingMode defines the required sampling mode
  32793. * @param texture defines the texture to update
  32794. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32795. */
  32796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32797. /**
  32798. * Update the sampling mode of a given texture
  32799. * @param texture defines the texture to update
  32800. * @param wrapU defines the texture wrap mode of the u coordinates
  32801. * @param wrapV defines the texture wrap mode of the v coordinates
  32802. * @param wrapR defines the texture wrap mode of the r coordinates
  32803. */
  32804. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32805. /** @hidden */
  32806. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32807. width: number;
  32808. height: number;
  32809. layers?: number;
  32810. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32811. /** @hidden */
  32812. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32813. /** @hidden */
  32814. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32815. /**
  32816. * Update a portion of an internal texture
  32817. * @param texture defines the texture to update
  32818. * @param imageData defines the data to store into the texture
  32819. * @param xOffset defines the x coordinates of the update rectangle
  32820. * @param yOffset defines the y coordinates of the update rectangle
  32821. * @param width defines the width of the update rectangle
  32822. * @param height defines the height of the update rectangle
  32823. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32824. * @param lod defines the lod level to update (0 by default)
  32825. */
  32826. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32827. /** @hidden */
  32828. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32829. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32830. private _prepareWebGLTexture;
  32831. /** @hidden */
  32832. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32833. private _getDepthStencilBuffer;
  32834. /** @hidden */
  32835. _releaseFramebufferObjects(texture: InternalTexture): void;
  32836. /** @hidden */
  32837. _releaseTexture(texture: InternalTexture): void;
  32838. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32839. protected _setProgram(program: WebGLProgram): void;
  32840. protected _boundUniforms: {
  32841. [key: number]: WebGLUniformLocation;
  32842. };
  32843. /**
  32844. * Binds an effect to the webGL context
  32845. * @param effect defines the effect to bind
  32846. */
  32847. bindSamplers(effect: Effect): void;
  32848. private _activateCurrentTexture;
  32849. /** @hidden */
  32850. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32851. /** @hidden */
  32852. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32853. /**
  32854. * Unbind all textures from the webGL context
  32855. */
  32856. unbindAllTextures(): void;
  32857. /**
  32858. * Sets a texture to the according uniform.
  32859. * @param channel The texture channel
  32860. * @param uniform The uniform to set
  32861. * @param texture The texture to apply
  32862. */
  32863. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32864. private _bindSamplerUniformToChannel;
  32865. private _getTextureWrapMode;
  32866. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32867. /**
  32868. * Sets an array of texture to the webGL context
  32869. * @param channel defines the channel where the texture array must be set
  32870. * @param uniform defines the associated uniform location
  32871. * @param textures defines the array of textures to bind
  32872. */
  32873. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32874. /** @hidden */
  32875. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32876. private _setTextureParameterFloat;
  32877. private _setTextureParameterInteger;
  32878. /**
  32879. * Unbind all vertex attributes from the webGL context
  32880. */
  32881. unbindAllAttributes(): void;
  32882. /**
  32883. * 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
  32884. */
  32885. releaseEffects(): void;
  32886. /**
  32887. * Dispose and release all associated resources
  32888. */
  32889. dispose(): void;
  32890. /**
  32891. * Attach a new callback raised when context lost event is fired
  32892. * @param callback defines the callback to call
  32893. */
  32894. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32895. /**
  32896. * Attach a new callback raised when context restored event is fired
  32897. * @param callback defines the callback to call
  32898. */
  32899. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32900. /**
  32901. * Get the current error code of the webGL context
  32902. * @returns the error code
  32903. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32904. */
  32905. getError(): number;
  32906. private _canRenderToFloatFramebuffer;
  32907. private _canRenderToHalfFloatFramebuffer;
  32908. private _canRenderToFramebuffer;
  32909. /** @hidden */
  32910. _getWebGLTextureType(type: number): number;
  32911. /** @hidden */
  32912. _getInternalFormat(format: number): number;
  32913. /** @hidden */
  32914. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32915. /** @hidden */
  32916. _getRGBAMultiSampleBufferFormat(type: number): number;
  32917. /** @hidden */
  32918. _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;
  32919. /**
  32920. * Loads a file from a url
  32921. * @param url url to load
  32922. * @param onSuccess callback called when the file successfully loads
  32923. * @param onProgress callback called while file is loading (if the server supports this mode)
  32924. * @param offlineProvider defines the offline provider for caching
  32925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32926. * @param onError callback called when the file fails to load
  32927. * @returns a file request object
  32928. * @hidden
  32929. */
  32930. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32931. /**
  32932. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32933. * @param x defines the x coordinate of the rectangle where pixels must be read
  32934. * @param y defines the y coordinate of the rectangle where pixels must be read
  32935. * @param width defines the width of the rectangle where pixels must be read
  32936. * @param height defines the height of the rectangle where pixels must be read
  32937. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32938. * @returns a Uint8Array containing RGBA colors
  32939. */
  32940. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32941. private static _isSupported;
  32942. /**
  32943. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32944. * @returns true if the engine can be created
  32945. * @ignorenaming
  32946. */
  32947. static isSupported(): boolean;
  32948. /**
  32949. * Find the next highest power of two.
  32950. * @param x Number to start search from.
  32951. * @return Next highest power of two.
  32952. */
  32953. static CeilingPOT(x: number): number;
  32954. /**
  32955. * Find the next lowest power of two.
  32956. * @param x Number to start search from.
  32957. * @return Next lowest power of two.
  32958. */
  32959. static FloorPOT(x: number): number;
  32960. /**
  32961. * Find the nearest power of two.
  32962. * @param x Number to start search from.
  32963. * @return Next nearest power of two.
  32964. */
  32965. static NearestPOT(x: number): number;
  32966. /**
  32967. * Get the closest exponent of two
  32968. * @param value defines the value to approximate
  32969. * @param max defines the maximum value to return
  32970. * @param mode defines how to define the closest value
  32971. * @returns closest exponent of two of the given value
  32972. */
  32973. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32974. /**
  32975. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32976. * @param func - the function to be called
  32977. * @param requester - the object that will request the next frame. Falls back to window.
  32978. * @returns frame number
  32979. */
  32980. static QueueNewFrame(func: () => void, requester?: any): number;
  32981. /**
  32982. * Gets host document
  32983. * @returns the host document object
  32984. */
  32985. getHostDocument(): Nullable<Document>;
  32986. }
  32987. }
  32988. declare module "babylonjs/Maths/sphericalPolynomial" {
  32989. import { Vector3 } from "babylonjs/Maths/math.vector";
  32990. import { Color3 } from "babylonjs/Maths/math.color";
  32991. /**
  32992. * Class representing spherical harmonics coefficients to the 3rd degree
  32993. */
  32994. export class SphericalHarmonics {
  32995. /**
  32996. * Defines whether or not the harmonics have been prescaled for rendering.
  32997. */
  32998. preScaled: boolean;
  32999. /**
  33000. * The l0,0 coefficients of the spherical harmonics
  33001. */
  33002. l00: Vector3;
  33003. /**
  33004. * The l1,-1 coefficients of the spherical harmonics
  33005. */
  33006. l1_1: Vector3;
  33007. /**
  33008. * The l1,0 coefficients of the spherical harmonics
  33009. */
  33010. l10: Vector3;
  33011. /**
  33012. * The l1,1 coefficients of the spherical harmonics
  33013. */
  33014. l11: Vector3;
  33015. /**
  33016. * The l2,-2 coefficients of the spherical harmonics
  33017. */
  33018. l2_2: Vector3;
  33019. /**
  33020. * The l2,-1 coefficients of the spherical harmonics
  33021. */
  33022. l2_1: Vector3;
  33023. /**
  33024. * The l2,0 coefficients of the spherical harmonics
  33025. */
  33026. l20: Vector3;
  33027. /**
  33028. * The l2,1 coefficients of the spherical harmonics
  33029. */
  33030. l21: Vector3;
  33031. /**
  33032. * The l2,2 coefficients of the spherical harmonics
  33033. */
  33034. l22: Vector3;
  33035. /**
  33036. * Adds a light to the spherical harmonics
  33037. * @param direction the direction of the light
  33038. * @param color the color of the light
  33039. * @param deltaSolidAngle the delta solid angle of the light
  33040. */
  33041. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33042. /**
  33043. * Scales the spherical harmonics by the given amount
  33044. * @param scale the amount to scale
  33045. */
  33046. scaleInPlace(scale: number): void;
  33047. /**
  33048. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33049. *
  33050. * ```
  33051. * E_lm = A_l * L_lm
  33052. * ```
  33053. *
  33054. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33055. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33056. * the scaling factors are given in equation 9.
  33057. */
  33058. convertIncidentRadianceToIrradiance(): void;
  33059. /**
  33060. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33061. *
  33062. * ```
  33063. * L = (1/pi) * E * rho
  33064. * ```
  33065. *
  33066. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33067. */
  33068. convertIrradianceToLambertianRadiance(): void;
  33069. /**
  33070. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33071. * required operations at run time.
  33072. *
  33073. * This is simply done by scaling back the SH with Ylm constants parameter.
  33074. * The trigonometric part being applied by the shader at run time.
  33075. */
  33076. preScaleForRendering(): void;
  33077. /**
  33078. * Constructs a spherical harmonics from an array.
  33079. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33080. * @returns the spherical harmonics
  33081. */
  33082. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33083. /**
  33084. * Gets the spherical harmonics from polynomial
  33085. * @param polynomial the spherical polynomial
  33086. * @returns the spherical harmonics
  33087. */
  33088. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33089. }
  33090. /**
  33091. * Class representing spherical polynomial coefficients to the 3rd degree
  33092. */
  33093. export class SphericalPolynomial {
  33094. private _harmonics;
  33095. /**
  33096. * The spherical harmonics used to create the polynomials.
  33097. */
  33098. get preScaledHarmonics(): SphericalHarmonics;
  33099. /**
  33100. * The x coefficients of the spherical polynomial
  33101. */
  33102. x: Vector3;
  33103. /**
  33104. * The y coefficients of the spherical polynomial
  33105. */
  33106. y: Vector3;
  33107. /**
  33108. * The z coefficients of the spherical polynomial
  33109. */
  33110. z: Vector3;
  33111. /**
  33112. * The xx coefficients of the spherical polynomial
  33113. */
  33114. xx: Vector3;
  33115. /**
  33116. * The yy coefficients of the spherical polynomial
  33117. */
  33118. yy: Vector3;
  33119. /**
  33120. * The zz coefficients of the spherical polynomial
  33121. */
  33122. zz: Vector3;
  33123. /**
  33124. * The xy coefficients of the spherical polynomial
  33125. */
  33126. xy: Vector3;
  33127. /**
  33128. * The yz coefficients of the spherical polynomial
  33129. */
  33130. yz: Vector3;
  33131. /**
  33132. * The zx coefficients of the spherical polynomial
  33133. */
  33134. zx: Vector3;
  33135. /**
  33136. * Adds an ambient color to the spherical polynomial
  33137. * @param color the color to add
  33138. */
  33139. addAmbient(color: Color3): void;
  33140. /**
  33141. * Scales the spherical polynomial by the given amount
  33142. * @param scale the amount to scale
  33143. */
  33144. scaleInPlace(scale: number): void;
  33145. /**
  33146. * Gets the spherical polynomial from harmonics
  33147. * @param harmonics the spherical harmonics
  33148. * @returns the spherical polynomial
  33149. */
  33150. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33151. /**
  33152. * Constructs a spherical polynomial from an array.
  33153. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33154. * @returns the spherical polynomial
  33155. */
  33156. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33157. }
  33158. }
  33159. declare module "babylonjs/Materials/Textures/internalTexture" {
  33160. import { Observable } from "babylonjs/Misc/observable";
  33161. import { Nullable, int } from "babylonjs/types";
  33162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33164. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33165. /**
  33166. * Defines the source of the internal texture
  33167. */
  33168. export enum InternalTextureSource {
  33169. /**
  33170. * The source of the texture data is unknown
  33171. */
  33172. Unknown = 0,
  33173. /**
  33174. * Texture data comes from an URL
  33175. */
  33176. Url = 1,
  33177. /**
  33178. * Texture data is only used for temporary storage
  33179. */
  33180. Temp = 2,
  33181. /**
  33182. * Texture data comes from raw data (ArrayBuffer)
  33183. */
  33184. Raw = 3,
  33185. /**
  33186. * Texture content is dynamic (video or dynamic texture)
  33187. */
  33188. Dynamic = 4,
  33189. /**
  33190. * Texture content is generated by rendering to it
  33191. */
  33192. RenderTarget = 5,
  33193. /**
  33194. * Texture content is part of a multi render target process
  33195. */
  33196. MultiRenderTarget = 6,
  33197. /**
  33198. * Texture data comes from a cube data file
  33199. */
  33200. Cube = 7,
  33201. /**
  33202. * Texture data comes from a raw cube data
  33203. */
  33204. CubeRaw = 8,
  33205. /**
  33206. * Texture data come from a prefiltered cube data file
  33207. */
  33208. CubePrefiltered = 9,
  33209. /**
  33210. * Texture content is raw 3D data
  33211. */
  33212. Raw3D = 10,
  33213. /**
  33214. * Texture content is raw 2D array data
  33215. */
  33216. Raw2DArray = 11,
  33217. /**
  33218. * Texture content is a depth texture
  33219. */
  33220. Depth = 12,
  33221. /**
  33222. * Texture data comes from a raw cube data encoded with RGBD
  33223. */
  33224. CubeRawRGBD = 13
  33225. }
  33226. /**
  33227. * Class used to store data associated with WebGL texture data for the engine
  33228. * This class should not be used directly
  33229. */
  33230. export class InternalTexture {
  33231. /** @hidden */
  33232. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33233. /**
  33234. * Defines if the texture is ready
  33235. */
  33236. isReady: boolean;
  33237. /**
  33238. * Defines if the texture is a cube texture
  33239. */
  33240. isCube: boolean;
  33241. /**
  33242. * Defines if the texture contains 3D data
  33243. */
  33244. is3D: boolean;
  33245. /**
  33246. * Defines if the texture contains 2D array data
  33247. */
  33248. is2DArray: boolean;
  33249. /**
  33250. * Defines if the texture contains multiview data
  33251. */
  33252. isMultiview: boolean;
  33253. /**
  33254. * Gets the URL used to load this texture
  33255. */
  33256. url: string;
  33257. /**
  33258. * Gets the sampling mode of the texture
  33259. */
  33260. samplingMode: number;
  33261. /**
  33262. * Gets a boolean indicating if the texture needs mipmaps generation
  33263. */
  33264. generateMipMaps: boolean;
  33265. /**
  33266. * Gets the number of samples used by the texture (WebGL2+ only)
  33267. */
  33268. samples: number;
  33269. /**
  33270. * Gets the type of the texture (int, float...)
  33271. */
  33272. type: number;
  33273. /**
  33274. * Gets the format of the texture (RGB, RGBA...)
  33275. */
  33276. format: number;
  33277. /**
  33278. * Observable called when the texture is loaded
  33279. */
  33280. onLoadedObservable: Observable<InternalTexture>;
  33281. /**
  33282. * Gets the width of the texture
  33283. */
  33284. width: number;
  33285. /**
  33286. * Gets the height of the texture
  33287. */
  33288. height: number;
  33289. /**
  33290. * Gets the depth of the texture
  33291. */
  33292. depth: number;
  33293. /**
  33294. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33295. */
  33296. baseWidth: number;
  33297. /**
  33298. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33299. */
  33300. baseHeight: number;
  33301. /**
  33302. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33303. */
  33304. baseDepth: number;
  33305. /**
  33306. * Gets a boolean indicating if the texture is inverted on Y axis
  33307. */
  33308. invertY: boolean;
  33309. /** @hidden */
  33310. _invertVScale: boolean;
  33311. /** @hidden */
  33312. _associatedChannel: number;
  33313. /** @hidden */
  33314. _source: InternalTextureSource;
  33315. /** @hidden */
  33316. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33317. /** @hidden */
  33318. _bufferView: Nullable<ArrayBufferView>;
  33319. /** @hidden */
  33320. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33321. /** @hidden */
  33322. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33323. /** @hidden */
  33324. _size: number;
  33325. /** @hidden */
  33326. _extension: string;
  33327. /** @hidden */
  33328. _files: Nullable<string[]>;
  33329. /** @hidden */
  33330. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33331. /** @hidden */
  33332. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33333. /** @hidden */
  33334. _framebuffer: Nullable<WebGLFramebuffer>;
  33335. /** @hidden */
  33336. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33337. /** @hidden */
  33338. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33339. /** @hidden */
  33340. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33341. /** @hidden */
  33342. _attachments: Nullable<number[]>;
  33343. /** @hidden */
  33344. _cachedCoordinatesMode: Nullable<number>;
  33345. /** @hidden */
  33346. _cachedWrapU: Nullable<number>;
  33347. /** @hidden */
  33348. _cachedWrapV: Nullable<number>;
  33349. /** @hidden */
  33350. _cachedWrapR: Nullable<number>;
  33351. /** @hidden */
  33352. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33353. /** @hidden */
  33354. _isDisabled: boolean;
  33355. /** @hidden */
  33356. _compression: Nullable<string>;
  33357. /** @hidden */
  33358. _generateStencilBuffer: boolean;
  33359. /** @hidden */
  33360. _generateDepthBuffer: boolean;
  33361. /** @hidden */
  33362. _comparisonFunction: number;
  33363. /** @hidden */
  33364. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33365. /** @hidden */
  33366. _lodGenerationScale: number;
  33367. /** @hidden */
  33368. _lodGenerationOffset: number;
  33369. /** @hidden */
  33370. _depthStencilTexture: Nullable<InternalTexture>;
  33371. /** @hidden */
  33372. _colorTextureArray: Nullable<WebGLTexture>;
  33373. /** @hidden */
  33374. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33375. /** @hidden */
  33376. _lodTextureHigh: Nullable<BaseTexture>;
  33377. /** @hidden */
  33378. _lodTextureMid: Nullable<BaseTexture>;
  33379. /** @hidden */
  33380. _lodTextureLow: Nullable<BaseTexture>;
  33381. /** @hidden */
  33382. _isRGBD: boolean;
  33383. /** @hidden */
  33384. _linearSpecularLOD: boolean;
  33385. /** @hidden */
  33386. _irradianceTexture: Nullable<BaseTexture>;
  33387. /** @hidden */
  33388. _webGLTexture: Nullable<WebGLTexture>;
  33389. /** @hidden */
  33390. _references: number;
  33391. private _engine;
  33392. /**
  33393. * Gets the Engine the texture belongs to.
  33394. * @returns The babylon engine
  33395. */
  33396. getEngine(): ThinEngine;
  33397. /**
  33398. * Gets the data source type of the texture
  33399. */
  33400. get source(): InternalTextureSource;
  33401. /**
  33402. * Creates a new InternalTexture
  33403. * @param engine defines the engine to use
  33404. * @param source defines the type of data that will be used
  33405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33406. */
  33407. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33408. /**
  33409. * Increments the number of references (ie. the number of Texture that point to it)
  33410. */
  33411. incrementReferences(): void;
  33412. /**
  33413. * Change the size of the texture (not the size of the content)
  33414. * @param width defines the new width
  33415. * @param height defines the new height
  33416. * @param depth defines the new depth (1 by default)
  33417. */
  33418. updateSize(width: int, height: int, depth?: int): void;
  33419. /** @hidden */
  33420. _rebuild(): void;
  33421. /** @hidden */
  33422. _swapAndDie(target: InternalTexture): void;
  33423. /**
  33424. * Dispose the current allocated resources
  33425. */
  33426. dispose(): void;
  33427. }
  33428. }
  33429. declare module "babylonjs/Audio/analyser" {
  33430. import { Scene } from "babylonjs/scene";
  33431. /**
  33432. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33434. */
  33435. export class Analyser {
  33436. /**
  33437. * Gets or sets the smoothing
  33438. * @ignorenaming
  33439. */
  33440. SMOOTHING: number;
  33441. /**
  33442. * Gets or sets the FFT table size
  33443. * @ignorenaming
  33444. */
  33445. FFT_SIZE: number;
  33446. /**
  33447. * Gets or sets the bar graph amplitude
  33448. * @ignorenaming
  33449. */
  33450. BARGRAPHAMPLITUDE: number;
  33451. /**
  33452. * Gets or sets the position of the debug canvas
  33453. * @ignorenaming
  33454. */
  33455. DEBUGCANVASPOS: {
  33456. x: number;
  33457. y: number;
  33458. };
  33459. /**
  33460. * Gets or sets the debug canvas size
  33461. * @ignorenaming
  33462. */
  33463. DEBUGCANVASSIZE: {
  33464. width: number;
  33465. height: number;
  33466. };
  33467. private _byteFreqs;
  33468. private _byteTime;
  33469. private _floatFreqs;
  33470. private _webAudioAnalyser;
  33471. private _debugCanvas;
  33472. private _debugCanvasContext;
  33473. private _scene;
  33474. private _registerFunc;
  33475. private _audioEngine;
  33476. /**
  33477. * Creates a new analyser
  33478. * @param scene defines hosting scene
  33479. */
  33480. constructor(scene: Scene);
  33481. /**
  33482. * Get the number of data values you will have to play with for the visualization
  33483. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33484. * @returns a number
  33485. */
  33486. getFrequencyBinCount(): number;
  33487. /**
  33488. * Gets the current frequency data as a byte array
  33489. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33490. * @returns a Uint8Array
  33491. */
  33492. getByteFrequencyData(): Uint8Array;
  33493. /**
  33494. * Gets the current waveform as a byte array
  33495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33496. * @returns a Uint8Array
  33497. */
  33498. getByteTimeDomainData(): Uint8Array;
  33499. /**
  33500. * Gets the current frequency data as a float array
  33501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33502. * @returns a Float32Array
  33503. */
  33504. getFloatFrequencyData(): Float32Array;
  33505. /**
  33506. * Renders the debug canvas
  33507. */
  33508. drawDebugCanvas(): void;
  33509. /**
  33510. * Stops rendering the debug canvas and removes it
  33511. */
  33512. stopDebugCanvas(): void;
  33513. /**
  33514. * Connects two audio nodes
  33515. * @param inputAudioNode defines first node to connect
  33516. * @param outputAudioNode defines second node to connect
  33517. */
  33518. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33519. /**
  33520. * Releases all associated resources
  33521. */
  33522. dispose(): void;
  33523. }
  33524. }
  33525. declare module "babylonjs/Audio/audioEngine" {
  33526. import { IDisposable } from "babylonjs/scene";
  33527. import { Analyser } from "babylonjs/Audio/analyser";
  33528. import { Nullable } from "babylonjs/types";
  33529. import { Observable } from "babylonjs/Misc/observable";
  33530. /**
  33531. * This represents an audio engine and it is responsible
  33532. * to play, synchronize and analyse sounds throughout the application.
  33533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33534. */
  33535. export interface IAudioEngine extends IDisposable {
  33536. /**
  33537. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33538. */
  33539. readonly canUseWebAudio: boolean;
  33540. /**
  33541. * Gets the current AudioContext if available.
  33542. */
  33543. readonly audioContext: Nullable<AudioContext>;
  33544. /**
  33545. * The master gain node defines the global audio volume of your audio engine.
  33546. */
  33547. readonly masterGain: GainNode;
  33548. /**
  33549. * Gets whether or not mp3 are supported by your browser.
  33550. */
  33551. readonly isMP3supported: boolean;
  33552. /**
  33553. * Gets whether or not ogg are supported by your browser.
  33554. */
  33555. readonly isOGGsupported: boolean;
  33556. /**
  33557. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33558. * @ignoreNaming
  33559. */
  33560. WarnedWebAudioUnsupported: boolean;
  33561. /**
  33562. * Defines if the audio engine relies on a custom unlocked button.
  33563. * In this case, the embedded button will not be displayed.
  33564. */
  33565. useCustomUnlockedButton: boolean;
  33566. /**
  33567. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33568. */
  33569. readonly unlocked: boolean;
  33570. /**
  33571. * Event raised when audio has been unlocked on the browser.
  33572. */
  33573. onAudioUnlockedObservable: Observable<AudioEngine>;
  33574. /**
  33575. * Event raised when audio has been locked on the browser.
  33576. */
  33577. onAudioLockedObservable: Observable<AudioEngine>;
  33578. /**
  33579. * Flags the audio engine in Locked state.
  33580. * This happens due to new browser policies preventing audio to autoplay.
  33581. */
  33582. lock(): void;
  33583. /**
  33584. * Unlocks the audio engine once a user action has been done on the dom.
  33585. * This is helpful to resume play once browser policies have been satisfied.
  33586. */
  33587. unlock(): void;
  33588. }
  33589. /**
  33590. * This represents the default audio engine used in babylon.
  33591. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33593. */
  33594. export class AudioEngine implements IAudioEngine {
  33595. private _audioContext;
  33596. private _audioContextInitialized;
  33597. private _muteButton;
  33598. private _hostElement;
  33599. /**
  33600. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33601. */
  33602. canUseWebAudio: boolean;
  33603. /**
  33604. * The master gain node defines the global audio volume of your audio engine.
  33605. */
  33606. masterGain: GainNode;
  33607. /**
  33608. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33609. * @ignoreNaming
  33610. */
  33611. WarnedWebAudioUnsupported: boolean;
  33612. /**
  33613. * Gets whether or not mp3 are supported by your browser.
  33614. */
  33615. isMP3supported: boolean;
  33616. /**
  33617. * Gets whether or not ogg are supported by your browser.
  33618. */
  33619. isOGGsupported: boolean;
  33620. /**
  33621. * Gets whether audio has been unlocked on the device.
  33622. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33623. * a user interaction has happened.
  33624. */
  33625. unlocked: boolean;
  33626. /**
  33627. * Defines if the audio engine relies on a custom unlocked button.
  33628. * In this case, the embedded button will not be displayed.
  33629. */
  33630. useCustomUnlockedButton: boolean;
  33631. /**
  33632. * Event raised when audio has been unlocked on the browser.
  33633. */
  33634. onAudioUnlockedObservable: Observable<AudioEngine>;
  33635. /**
  33636. * Event raised when audio has been locked on the browser.
  33637. */
  33638. onAudioLockedObservable: Observable<AudioEngine>;
  33639. /**
  33640. * Gets the current AudioContext if available.
  33641. */
  33642. get audioContext(): Nullable<AudioContext>;
  33643. private _connectedAnalyser;
  33644. /**
  33645. * Instantiates a new audio engine.
  33646. *
  33647. * There should be only one per page as some browsers restrict the number
  33648. * of audio contexts you can create.
  33649. * @param hostElement defines the host element where to display the mute icon if necessary
  33650. */
  33651. constructor(hostElement?: Nullable<HTMLElement>);
  33652. /**
  33653. * Flags the audio engine in Locked state.
  33654. * This happens due to new browser policies preventing audio to autoplay.
  33655. */
  33656. lock(): void;
  33657. /**
  33658. * Unlocks the audio engine once a user action has been done on the dom.
  33659. * This is helpful to resume play once browser policies have been satisfied.
  33660. */
  33661. unlock(): void;
  33662. private _resumeAudioContext;
  33663. private _initializeAudioContext;
  33664. private _tryToRun;
  33665. private _triggerRunningState;
  33666. private _triggerSuspendedState;
  33667. private _displayMuteButton;
  33668. private _moveButtonToTopLeft;
  33669. private _onResize;
  33670. private _hideMuteButton;
  33671. /**
  33672. * Destroy and release the resources associated with the audio ccontext.
  33673. */
  33674. dispose(): void;
  33675. /**
  33676. * Gets the global volume sets on the master gain.
  33677. * @returns the global volume if set or -1 otherwise
  33678. */
  33679. getGlobalVolume(): number;
  33680. /**
  33681. * Sets the global volume of your experience (sets on the master gain).
  33682. * @param newVolume Defines the new global volume of the application
  33683. */
  33684. setGlobalVolume(newVolume: number): void;
  33685. /**
  33686. * Connect the audio engine to an audio analyser allowing some amazing
  33687. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33689. * @param analyser The analyser to connect to the engine
  33690. */
  33691. connectToAnalyser(analyser: Analyser): void;
  33692. }
  33693. }
  33694. declare module "babylonjs/Loading/loadingScreen" {
  33695. /**
  33696. * Interface used to present a loading screen while loading a scene
  33697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33698. */
  33699. export interface ILoadingScreen {
  33700. /**
  33701. * Function called to display the loading screen
  33702. */
  33703. displayLoadingUI: () => void;
  33704. /**
  33705. * Function called to hide the loading screen
  33706. */
  33707. hideLoadingUI: () => void;
  33708. /**
  33709. * Gets or sets the color to use for the background
  33710. */
  33711. loadingUIBackgroundColor: string;
  33712. /**
  33713. * Gets or sets the text to display while loading
  33714. */
  33715. loadingUIText: string;
  33716. }
  33717. /**
  33718. * Class used for the default loading screen
  33719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33720. */
  33721. export class DefaultLoadingScreen implements ILoadingScreen {
  33722. private _renderingCanvas;
  33723. private _loadingText;
  33724. private _loadingDivBackgroundColor;
  33725. private _loadingDiv;
  33726. private _loadingTextDiv;
  33727. /** Gets or sets the logo url to use for the default loading screen */
  33728. static DefaultLogoUrl: string;
  33729. /** Gets or sets the spinner url to use for the default loading screen */
  33730. static DefaultSpinnerUrl: string;
  33731. /**
  33732. * Creates a new default loading screen
  33733. * @param _renderingCanvas defines the canvas used to render the scene
  33734. * @param _loadingText defines the default text to display
  33735. * @param _loadingDivBackgroundColor defines the default background color
  33736. */
  33737. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33738. /**
  33739. * Function called to display the loading screen
  33740. */
  33741. displayLoadingUI(): void;
  33742. /**
  33743. * Function called to hide the loading screen
  33744. */
  33745. hideLoadingUI(): void;
  33746. /**
  33747. * Gets or sets the text to display while loading
  33748. */
  33749. set loadingUIText(text: string);
  33750. get loadingUIText(): string;
  33751. /**
  33752. * Gets or sets the color to use for the background
  33753. */
  33754. get loadingUIBackgroundColor(): string;
  33755. set loadingUIBackgroundColor(color: string);
  33756. private _resizeLoadingUI;
  33757. }
  33758. }
  33759. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33760. /**
  33761. * Interface for any object that can request an animation frame
  33762. */
  33763. export interface ICustomAnimationFrameRequester {
  33764. /**
  33765. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33766. */
  33767. renderFunction?: Function;
  33768. /**
  33769. * Called to request the next frame to render to
  33770. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33771. */
  33772. requestAnimationFrame: Function;
  33773. /**
  33774. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33775. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33776. */
  33777. requestID?: number;
  33778. }
  33779. }
  33780. declare module "babylonjs/Misc/performanceMonitor" {
  33781. /**
  33782. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33783. */
  33784. export class PerformanceMonitor {
  33785. private _enabled;
  33786. private _rollingFrameTime;
  33787. private _lastFrameTimeMs;
  33788. /**
  33789. * constructor
  33790. * @param frameSampleSize The number of samples required to saturate the sliding window
  33791. */
  33792. constructor(frameSampleSize?: number);
  33793. /**
  33794. * Samples current frame
  33795. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33796. */
  33797. sampleFrame(timeMs?: number): void;
  33798. /**
  33799. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33800. */
  33801. get averageFrameTime(): number;
  33802. /**
  33803. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33804. */
  33805. get averageFrameTimeVariance(): number;
  33806. /**
  33807. * Returns the frame time of the most recent frame
  33808. */
  33809. get instantaneousFrameTime(): number;
  33810. /**
  33811. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFPS(): number;
  33814. /**
  33815. * Returns the average framerate in frames per second using the most recent frame time
  33816. */
  33817. get instantaneousFPS(): number;
  33818. /**
  33819. * Returns true if enough samples have been taken to completely fill the sliding window
  33820. */
  33821. get isSaturated(): boolean;
  33822. /**
  33823. * Enables contributions to the sliding window sample set
  33824. */
  33825. enable(): void;
  33826. /**
  33827. * Disables contributions to the sliding window sample set
  33828. * Samples will not be interpolated over the disabled period
  33829. */
  33830. disable(): void;
  33831. /**
  33832. * Returns true if sampling is enabled
  33833. */
  33834. get isEnabled(): boolean;
  33835. /**
  33836. * Resets performance monitor
  33837. */
  33838. reset(): void;
  33839. }
  33840. /**
  33841. * RollingAverage
  33842. *
  33843. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33844. */
  33845. export class RollingAverage {
  33846. /**
  33847. * Current average
  33848. */
  33849. average: number;
  33850. /**
  33851. * Current variance
  33852. */
  33853. variance: number;
  33854. protected _samples: Array<number>;
  33855. protected _sampleCount: number;
  33856. protected _pos: number;
  33857. protected _m2: number;
  33858. /**
  33859. * constructor
  33860. * @param length The number of samples required to saturate the sliding window
  33861. */
  33862. constructor(length: number);
  33863. /**
  33864. * Adds a sample to the sample set
  33865. * @param v The sample value
  33866. */
  33867. add(v: number): void;
  33868. /**
  33869. * Returns previously added values or null if outside of history or outside the sliding window domain
  33870. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33871. * @return Value previously recorded with add() or null if outside of range
  33872. */
  33873. history(i: number): number;
  33874. /**
  33875. * Returns true if enough samples have been taken to completely fill the sliding window
  33876. * @return true if sample-set saturated
  33877. */
  33878. isSaturated(): boolean;
  33879. /**
  33880. * Resets the rolling average (equivalent to 0 samples taken so far)
  33881. */
  33882. reset(): void;
  33883. /**
  33884. * Wraps a value around the sample range boundaries
  33885. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33886. * @return Wrapped position in sample range
  33887. */
  33888. protected _wrapPosition(i: number): number;
  33889. }
  33890. }
  33891. declare module "babylonjs/Misc/perfCounter" {
  33892. /**
  33893. * This class is used to track a performance counter which is number based.
  33894. * The user has access to many properties which give statistics of different nature.
  33895. *
  33896. * The implementer can track two kinds of Performance Counter: time and count.
  33897. * 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.
  33898. * 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.
  33899. */
  33900. export class PerfCounter {
  33901. /**
  33902. * Gets or sets a global boolean to turn on and off all the counters
  33903. */
  33904. static Enabled: boolean;
  33905. /**
  33906. * Returns the smallest value ever
  33907. */
  33908. get min(): number;
  33909. /**
  33910. * Returns the biggest value ever
  33911. */
  33912. get max(): number;
  33913. /**
  33914. * Returns the average value since the performance counter is running
  33915. */
  33916. get average(): number;
  33917. /**
  33918. * Returns the average value of the last second the counter was monitored
  33919. */
  33920. get lastSecAverage(): number;
  33921. /**
  33922. * Returns the current value
  33923. */
  33924. get current(): number;
  33925. /**
  33926. * Gets the accumulated total
  33927. */
  33928. get total(): number;
  33929. /**
  33930. * Gets the total value count
  33931. */
  33932. get count(): number;
  33933. /**
  33934. * Creates a new counter
  33935. */
  33936. constructor();
  33937. /**
  33938. * Call this method to start monitoring a new frame.
  33939. * 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.
  33940. */
  33941. fetchNewFrame(): void;
  33942. /**
  33943. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33944. * @param newCount the count value to add to the monitored count
  33945. * @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.
  33946. */
  33947. addCount(newCount: number, fetchResult: boolean): void;
  33948. /**
  33949. * Start monitoring this performance counter
  33950. */
  33951. beginMonitoring(): void;
  33952. /**
  33953. * Compute the time lapsed since the previous beginMonitoring() call.
  33954. * @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
  33955. */
  33956. endMonitoring(newFrame?: boolean): void;
  33957. private _fetchResult;
  33958. private _startMonitoringTime;
  33959. private _min;
  33960. private _max;
  33961. private _average;
  33962. private _current;
  33963. private _totalValueCount;
  33964. private _totalAccumulated;
  33965. private _lastSecAverage;
  33966. private _lastSecAccumulated;
  33967. private _lastSecTime;
  33968. private _lastSecValueCount;
  33969. }
  33970. }
  33971. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33972. module "babylonjs/Engines/thinEngine" {
  33973. interface ThinEngine {
  33974. /**
  33975. * Sets alpha constants used by some alpha blending modes
  33976. * @param r defines the red component
  33977. * @param g defines the green component
  33978. * @param b defines the blue component
  33979. * @param a defines the alpha component
  33980. */
  33981. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33982. /**
  33983. * Sets the current alpha mode
  33984. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33985. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33987. */
  33988. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33989. /**
  33990. * Gets the current alpha mode
  33991. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33992. * @returns the current alpha mode
  33993. */
  33994. getAlphaMode(): number;
  33995. /**
  33996. * Sets the current alpha equation
  33997. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33998. */
  33999. setAlphaEquation(equation: number): void;
  34000. /**
  34001. * Gets the current alpha equation.
  34002. * @returns the current alpha equation
  34003. */
  34004. getAlphaEquation(): number;
  34005. }
  34006. }
  34007. }
  34008. declare module "babylonjs/Engines/engine" {
  34009. import { Observable } from "babylonjs/Misc/observable";
  34010. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34011. import { Scene } from "babylonjs/scene";
  34012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34013. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34014. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34015. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34016. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34017. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34018. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34019. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34020. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34022. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34024. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34025. import "babylonjs/Engines/Extensions/engine.alpha";
  34026. import { Material } from "babylonjs/Materials/material";
  34027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34028. /**
  34029. * Defines the interface used by display changed events
  34030. */
  34031. export interface IDisplayChangedEventArgs {
  34032. /** Gets the vrDisplay object (if any) */
  34033. vrDisplay: Nullable<any>;
  34034. /** Gets a boolean indicating if webVR is supported */
  34035. vrSupported: boolean;
  34036. }
  34037. /**
  34038. * Defines the interface used by objects containing a viewport (like a camera)
  34039. */
  34040. interface IViewportOwnerLike {
  34041. /**
  34042. * Gets or sets the viewport
  34043. */
  34044. viewport: IViewportLike;
  34045. }
  34046. /**
  34047. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34048. */
  34049. export class Engine extends ThinEngine {
  34050. /** Defines that alpha blending is disabled */
  34051. static readonly ALPHA_DISABLE: number;
  34052. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34053. static readonly ALPHA_ADD: number;
  34054. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34055. static readonly ALPHA_COMBINE: number;
  34056. /** Defines that alpha blending to DEST - SRC * DEST */
  34057. static readonly ALPHA_SUBTRACT: number;
  34058. /** Defines that alpha blending to SRC * DEST */
  34059. static readonly ALPHA_MULTIPLY: number;
  34060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34061. static readonly ALPHA_MAXIMIZED: number;
  34062. /** Defines that alpha blending to SRC + DEST */
  34063. static readonly ALPHA_ONEONE: number;
  34064. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34065. static readonly ALPHA_PREMULTIPLIED: number;
  34066. /**
  34067. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34068. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34069. */
  34070. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34071. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34072. static readonly ALPHA_INTERPOLATE: number;
  34073. /**
  34074. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34075. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34076. */
  34077. static readonly ALPHA_SCREENMODE: number;
  34078. /** Defines that the ressource is not delayed*/
  34079. static readonly DELAYLOADSTATE_NONE: number;
  34080. /** Defines that the ressource was successfully delay loaded */
  34081. static readonly DELAYLOADSTATE_LOADED: number;
  34082. /** Defines that the ressource is currently delay loading */
  34083. static readonly DELAYLOADSTATE_LOADING: number;
  34084. /** Defines that the ressource is delayed and has not started loading */
  34085. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34087. static readonly NEVER: number;
  34088. /** 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 */
  34089. static readonly ALWAYS: number;
  34090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34091. static readonly LESS: number;
  34092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34093. static readonly EQUAL: number;
  34094. /** 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 */
  34095. static readonly LEQUAL: number;
  34096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34097. static readonly GREATER: number;
  34098. /** 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 */
  34099. static readonly GEQUAL: number;
  34100. /** 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 */
  34101. static readonly NOTEQUAL: number;
  34102. /** Passed to stencilOperation to specify that stencil value must be kept */
  34103. static readonly KEEP: number;
  34104. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34105. static readonly REPLACE: number;
  34106. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34107. static readonly INCR: number;
  34108. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34109. static readonly DECR: number;
  34110. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34111. static readonly INVERT: number;
  34112. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34113. static readonly INCR_WRAP: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34115. static readonly DECR_WRAP: number;
  34116. /** Texture is not repeating outside of 0..1 UVs */
  34117. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34118. /** Texture is repeating outside of 0..1 UVs */
  34119. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34120. /** Texture is repeating and mirrored */
  34121. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34122. /** ALPHA */
  34123. static readonly TEXTUREFORMAT_ALPHA: number;
  34124. /** LUMINANCE */
  34125. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34126. /** LUMINANCE_ALPHA */
  34127. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34128. /** RGB */
  34129. static readonly TEXTUREFORMAT_RGB: number;
  34130. /** RGBA */
  34131. static readonly TEXTUREFORMAT_RGBA: number;
  34132. /** RED */
  34133. static readonly TEXTUREFORMAT_RED: number;
  34134. /** RED (2nd reference) */
  34135. static readonly TEXTUREFORMAT_R: number;
  34136. /** RG */
  34137. static readonly TEXTUREFORMAT_RG: number;
  34138. /** RED_INTEGER */
  34139. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34140. /** RED_INTEGER (2nd reference) */
  34141. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34142. /** RG_INTEGER */
  34143. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34144. /** RGB_INTEGER */
  34145. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34146. /** RGBA_INTEGER */
  34147. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34148. /** UNSIGNED_BYTE */
  34149. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34150. /** UNSIGNED_BYTE (2nd reference) */
  34151. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34152. /** FLOAT */
  34153. static readonly TEXTURETYPE_FLOAT: number;
  34154. /** HALF_FLOAT */
  34155. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34156. /** BYTE */
  34157. static readonly TEXTURETYPE_BYTE: number;
  34158. /** SHORT */
  34159. static readonly TEXTURETYPE_SHORT: number;
  34160. /** UNSIGNED_SHORT */
  34161. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34162. /** INT */
  34163. static readonly TEXTURETYPE_INT: number;
  34164. /** UNSIGNED_INT */
  34165. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34166. /** UNSIGNED_SHORT_4_4_4_4 */
  34167. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34168. /** UNSIGNED_SHORT_5_5_5_1 */
  34169. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34170. /** UNSIGNED_SHORT_5_6_5 */
  34171. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34172. /** UNSIGNED_INT_2_10_10_10_REV */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34174. /** UNSIGNED_INT_24_8 */
  34175. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34176. /** UNSIGNED_INT_10F_11F_11F_REV */
  34177. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34178. /** UNSIGNED_INT_5_9_9_9_REV */
  34179. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34180. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34181. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34182. /** nearest is mag = nearest and min = nearest and mip = linear */
  34183. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34185. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34186. /** Trilinear is mag = linear and min = linear and mip = linear */
  34187. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34188. /** nearest is mag = nearest and min = nearest and mip = linear */
  34189. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34191. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34192. /** Trilinear is mag = linear and min = linear and mip = linear */
  34193. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34194. /** mag = nearest and min = nearest and mip = nearest */
  34195. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34196. /** mag = nearest and min = linear and mip = nearest */
  34197. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34198. /** mag = nearest and min = linear and mip = linear */
  34199. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34200. /** mag = nearest and min = linear and mip = none */
  34201. static readonly TEXTURE_NEAREST_LINEAR: number;
  34202. /** mag = nearest and min = nearest and mip = none */
  34203. static readonly TEXTURE_NEAREST_NEAREST: number;
  34204. /** mag = linear and min = nearest and mip = nearest */
  34205. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34206. /** mag = linear and min = nearest and mip = linear */
  34207. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34208. /** mag = linear and min = linear and mip = none */
  34209. static readonly TEXTURE_LINEAR_LINEAR: number;
  34210. /** mag = linear and min = nearest and mip = none */
  34211. static readonly TEXTURE_LINEAR_NEAREST: number;
  34212. /** Explicit coordinates mode */
  34213. static readonly TEXTURE_EXPLICIT_MODE: number;
  34214. /** Spherical coordinates mode */
  34215. static readonly TEXTURE_SPHERICAL_MODE: number;
  34216. /** Planar coordinates mode */
  34217. static readonly TEXTURE_PLANAR_MODE: number;
  34218. /** Cubic coordinates mode */
  34219. static readonly TEXTURE_CUBIC_MODE: number;
  34220. /** Projection coordinates mode */
  34221. static readonly TEXTURE_PROJECTION_MODE: number;
  34222. /** Skybox coordinates mode */
  34223. static readonly TEXTURE_SKYBOX_MODE: number;
  34224. /** Inverse Cubic coordinates mode */
  34225. static readonly TEXTURE_INVCUBIC_MODE: number;
  34226. /** Equirectangular coordinates mode */
  34227. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34228. /** Equirectangular Fixed coordinates mode */
  34229. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34230. /** Equirectangular Fixed Mirrored coordinates mode */
  34231. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34232. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34233. static readonly SCALEMODE_FLOOR: number;
  34234. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34235. static readonly SCALEMODE_NEAREST: number;
  34236. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34237. static readonly SCALEMODE_CEILING: number;
  34238. /**
  34239. * Returns the current npm package of the sdk
  34240. */
  34241. static get NpmPackage(): string;
  34242. /**
  34243. * Returns the current version of the framework
  34244. */
  34245. static get Version(): string;
  34246. /** Gets the list of created engines */
  34247. static get Instances(): Engine[];
  34248. /**
  34249. * Gets the latest created engine
  34250. */
  34251. static get LastCreatedEngine(): Nullable<Engine>;
  34252. /**
  34253. * Gets the latest created scene
  34254. */
  34255. static get LastCreatedScene(): Nullable<Scene>;
  34256. /**
  34257. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34258. * @param flag defines which part of the materials must be marked as dirty
  34259. * @param predicate defines a predicate used to filter which materials should be affected
  34260. */
  34261. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34262. /**
  34263. * Method called to create the default loading screen.
  34264. * This can be overriden in your own app.
  34265. * @param canvas The rendering canvas element
  34266. * @returns The loading screen
  34267. */
  34268. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34269. /**
  34270. * Method called to create the default rescale post process on each engine.
  34271. */
  34272. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34273. /**
  34274. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34275. **/
  34276. enableOfflineSupport: boolean;
  34277. /**
  34278. * 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)
  34279. **/
  34280. disableManifestCheck: boolean;
  34281. /**
  34282. * Gets the list of created scenes
  34283. */
  34284. scenes: Scene[];
  34285. /**
  34286. * Event raised when a new scene is created
  34287. */
  34288. onNewSceneAddedObservable: Observable<Scene>;
  34289. /**
  34290. * Gets the list of created postprocesses
  34291. */
  34292. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34293. /**
  34294. * Gets a boolean indicating if the pointer is currently locked
  34295. */
  34296. isPointerLock: boolean;
  34297. /**
  34298. * Observable event triggered each time the rendering canvas is resized
  34299. */
  34300. onResizeObservable: Observable<Engine>;
  34301. /**
  34302. * Observable event triggered each time the canvas loses focus
  34303. */
  34304. onCanvasBlurObservable: Observable<Engine>;
  34305. /**
  34306. * Observable event triggered each time the canvas gains focus
  34307. */
  34308. onCanvasFocusObservable: Observable<Engine>;
  34309. /**
  34310. * Observable event triggered each time the canvas receives pointerout event
  34311. */
  34312. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34313. /**
  34314. * Observable raised when the engine begins a new frame
  34315. */
  34316. onBeginFrameObservable: Observable<Engine>;
  34317. /**
  34318. * If set, will be used to request the next animation frame for the render loop
  34319. */
  34320. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34321. /**
  34322. * Observable raised when the engine ends the current frame
  34323. */
  34324. onEndFrameObservable: Observable<Engine>;
  34325. /**
  34326. * Observable raised when the engine is about to compile a shader
  34327. */
  34328. onBeforeShaderCompilationObservable: Observable<Engine>;
  34329. /**
  34330. * Observable raised when the engine has jsut compiled a shader
  34331. */
  34332. onAfterShaderCompilationObservable: Observable<Engine>;
  34333. /**
  34334. * Gets the audio engine
  34335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34336. * @ignorenaming
  34337. */
  34338. static audioEngine: IAudioEngine;
  34339. /**
  34340. * Default AudioEngine factory responsible of creating the Audio Engine.
  34341. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34342. */
  34343. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34344. /**
  34345. * Default offline support factory responsible of creating a tool used to store data locally.
  34346. * By default, this will create a Database object if the workload has been embedded.
  34347. */
  34348. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34349. private _loadingScreen;
  34350. private _pointerLockRequested;
  34351. private _dummyFramebuffer;
  34352. private _rescalePostProcess;
  34353. private _deterministicLockstep;
  34354. private _lockstepMaxSteps;
  34355. private _timeStep;
  34356. protected get _supportsHardwareTextureRescaling(): boolean;
  34357. private _fps;
  34358. private _deltaTime;
  34359. /** @hidden */
  34360. _drawCalls: PerfCounter;
  34361. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34362. canvasTabIndex: number;
  34363. /**
  34364. * Turn this value on if you want to pause FPS computation when in background
  34365. */
  34366. disablePerformanceMonitorInBackground: boolean;
  34367. private _performanceMonitor;
  34368. /**
  34369. * Gets the performance monitor attached to this engine
  34370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34371. */
  34372. get performanceMonitor(): PerformanceMonitor;
  34373. private _onFocus;
  34374. private _onBlur;
  34375. private _onCanvasPointerOut;
  34376. private _onCanvasBlur;
  34377. private _onCanvasFocus;
  34378. private _onFullscreenChange;
  34379. private _onPointerLockChange;
  34380. /**
  34381. * Gets the HTML element used to attach event listeners
  34382. * @returns a HTML element
  34383. */
  34384. getInputElement(): Nullable<HTMLElement>;
  34385. /**
  34386. * Creates a new engine
  34387. * @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
  34388. * @param antialias defines enable antialiasing (default: false)
  34389. * @param options defines further options to be sent to the getContext() function
  34390. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34391. */
  34392. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34393. /**
  34394. * Gets current aspect ratio
  34395. * @param viewportOwner defines the camera to use to get the aspect ratio
  34396. * @param useScreen defines if screen size must be used (or the current render target if any)
  34397. * @returns a number defining the aspect ratio
  34398. */
  34399. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34400. /**
  34401. * Gets current screen aspect ratio
  34402. * @returns a number defining the aspect ratio
  34403. */
  34404. getScreenAspectRatio(): number;
  34405. /**
  34406. * Gets the client rect of the HTML canvas attached with the current webGL context
  34407. * @returns a client rectanglee
  34408. */
  34409. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34410. /**
  34411. * Gets the client rect of the HTML element used for events
  34412. * @returns a client rectanglee
  34413. */
  34414. getInputElementClientRect(): Nullable<ClientRect>;
  34415. /**
  34416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34418. * @returns true if engine is in deterministic lock step mode
  34419. */
  34420. isDeterministicLockStep(): boolean;
  34421. /**
  34422. * Gets the max steps when engine is running in deterministic lock step
  34423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34424. * @returns the max steps
  34425. */
  34426. getLockstepMaxSteps(): number;
  34427. /**
  34428. * Returns the time in ms between steps when using deterministic lock step.
  34429. * @returns time step in (ms)
  34430. */
  34431. getTimeStep(): number;
  34432. /**
  34433. * Force the mipmap generation for the given render target texture
  34434. * @param texture defines the render target texture to use
  34435. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34436. */
  34437. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34438. /** States */
  34439. /**
  34440. * Set various states to the webGL context
  34441. * @param culling defines backface culling state
  34442. * @param zOffset defines the value to apply to zOffset (0 by default)
  34443. * @param force defines if states must be applied even if cache is up to date
  34444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34445. */
  34446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34447. /**
  34448. * Set the z offset to apply to current rendering
  34449. * @param value defines the offset to apply
  34450. */
  34451. setZOffset(value: number): void;
  34452. /**
  34453. * Gets the current value of the zOffset
  34454. * @returns the current zOffset state
  34455. */
  34456. getZOffset(): number;
  34457. /**
  34458. * Enable or disable depth buffering
  34459. * @param enable defines the state to set
  34460. */
  34461. setDepthBuffer(enable: boolean): void;
  34462. /**
  34463. * Gets a boolean indicating if depth writing is enabled
  34464. * @returns the current depth writing state
  34465. */
  34466. getDepthWrite(): boolean;
  34467. /**
  34468. * Enable or disable depth writing
  34469. * @param enable defines the state to set
  34470. */
  34471. setDepthWrite(enable: boolean): void;
  34472. /**
  34473. * Gets a boolean indicating if stencil buffer is enabled
  34474. * @returns the current stencil buffer state
  34475. */
  34476. getStencilBuffer(): boolean;
  34477. /**
  34478. * Enable or disable the stencil buffer
  34479. * @param enable defines if the stencil buffer must be enabled or disabled
  34480. */
  34481. setStencilBuffer(enable: boolean): void;
  34482. /**
  34483. * Gets the current stencil mask
  34484. * @returns a number defining the new stencil mask to use
  34485. */
  34486. getStencilMask(): number;
  34487. /**
  34488. * Sets the current stencil mask
  34489. * @param mask defines the new stencil mask to use
  34490. */
  34491. setStencilMask(mask: number): void;
  34492. /**
  34493. * Gets the current stencil function
  34494. * @returns a number defining the stencil function to use
  34495. */
  34496. getStencilFunction(): number;
  34497. /**
  34498. * Gets the current stencil reference value
  34499. * @returns a number defining the stencil reference value to use
  34500. */
  34501. getStencilFunctionReference(): number;
  34502. /**
  34503. * Gets the current stencil mask
  34504. * @returns a number defining the stencil mask to use
  34505. */
  34506. getStencilFunctionMask(): number;
  34507. /**
  34508. * Sets the current stencil function
  34509. * @param stencilFunc defines the new stencil function to use
  34510. */
  34511. setStencilFunction(stencilFunc: number): void;
  34512. /**
  34513. * Sets the current stencil reference
  34514. * @param reference defines the new stencil reference to use
  34515. */
  34516. setStencilFunctionReference(reference: number): void;
  34517. /**
  34518. * Sets the current stencil mask
  34519. * @param mask defines the new stencil mask to use
  34520. */
  34521. setStencilFunctionMask(mask: number): void;
  34522. /**
  34523. * Gets the current stencil operation when stencil fails
  34524. * @returns a number defining stencil operation to use when stencil fails
  34525. */
  34526. getStencilOperationFail(): number;
  34527. /**
  34528. * Gets the current stencil operation when depth fails
  34529. * @returns a number defining stencil operation to use when depth fails
  34530. */
  34531. getStencilOperationDepthFail(): number;
  34532. /**
  34533. * Gets the current stencil operation when stencil passes
  34534. * @returns a number defining stencil operation to use when stencil passes
  34535. */
  34536. getStencilOperationPass(): number;
  34537. /**
  34538. * Sets the stencil operation to use when stencil fails
  34539. * @param operation defines the stencil operation to use when stencil fails
  34540. */
  34541. setStencilOperationFail(operation: number): void;
  34542. /**
  34543. * Sets the stencil operation to use when depth fails
  34544. * @param operation defines the stencil operation to use when depth fails
  34545. */
  34546. setStencilOperationDepthFail(operation: number): void;
  34547. /**
  34548. * Sets the stencil operation to use when stencil passes
  34549. * @param operation defines the stencil operation to use when stencil passes
  34550. */
  34551. setStencilOperationPass(operation: number): void;
  34552. /**
  34553. * Sets a boolean indicating if the dithering state is enabled or disabled
  34554. * @param value defines the dithering state
  34555. */
  34556. setDitheringState(value: boolean): void;
  34557. /**
  34558. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34559. * @param value defines the rasterizer state
  34560. */
  34561. setRasterizerState(value: boolean): void;
  34562. /**
  34563. * Gets the current depth function
  34564. * @returns a number defining the depth function
  34565. */
  34566. getDepthFunction(): Nullable<number>;
  34567. /**
  34568. * Sets the current depth function
  34569. * @param depthFunc defines the function to use
  34570. */
  34571. setDepthFunction(depthFunc: number): void;
  34572. /**
  34573. * Sets the current depth function to GREATER
  34574. */
  34575. setDepthFunctionToGreater(): void;
  34576. /**
  34577. * Sets the current depth function to GEQUAL
  34578. */
  34579. setDepthFunctionToGreaterOrEqual(): void;
  34580. /**
  34581. * Sets the current depth function to LESS
  34582. */
  34583. setDepthFunctionToLess(): void;
  34584. /**
  34585. * Sets the current depth function to LEQUAL
  34586. */
  34587. setDepthFunctionToLessOrEqual(): void;
  34588. private _cachedStencilBuffer;
  34589. private _cachedStencilFunction;
  34590. private _cachedStencilMask;
  34591. private _cachedStencilOperationPass;
  34592. private _cachedStencilOperationFail;
  34593. private _cachedStencilOperationDepthFail;
  34594. private _cachedStencilReference;
  34595. /**
  34596. * Caches the the state of the stencil buffer
  34597. */
  34598. cacheStencilState(): void;
  34599. /**
  34600. * Restores the state of the stencil buffer
  34601. */
  34602. restoreStencilState(): void;
  34603. /**
  34604. * Directly set the WebGL Viewport
  34605. * @param x defines the x coordinate of the viewport (in screen space)
  34606. * @param y defines the y coordinate of the viewport (in screen space)
  34607. * @param width defines the width of the viewport (in screen space)
  34608. * @param height defines the height of the viewport (in screen space)
  34609. * @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
  34610. */
  34611. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34612. /**
  34613. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34614. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34615. * @param y defines the y-coordinate of the corner of the clear rectangle
  34616. * @param width defines the width of the clear rectangle
  34617. * @param height defines the height of the clear rectangle
  34618. * @param clearColor defines the clear color
  34619. */
  34620. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34621. /**
  34622. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34623. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34624. * @param y defines the y-coordinate of the corner of the clear rectangle
  34625. * @param width defines the width of the clear rectangle
  34626. * @param height defines the height of the clear rectangle
  34627. */
  34628. enableScissor(x: number, y: number, width: number, height: number): void;
  34629. /**
  34630. * Disable previously set scissor test rectangle
  34631. */
  34632. disableScissor(): void;
  34633. protected _reportDrawCall(): void;
  34634. /**
  34635. * Initializes a webVR display and starts listening to display change events
  34636. * The onVRDisplayChangedObservable will be notified upon these changes
  34637. * @returns The onVRDisplayChangedObservable
  34638. */
  34639. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34640. /** @hidden */
  34641. _prepareVRComponent(): void;
  34642. /** @hidden */
  34643. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34644. /** @hidden */
  34645. _submitVRFrame(): void;
  34646. /**
  34647. * Call this function to leave webVR mode
  34648. * Will do nothing if webVR is not supported or if there is no webVR device
  34649. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34650. */
  34651. disableVR(): void;
  34652. /**
  34653. * Gets a boolean indicating that the system is in VR mode and is presenting
  34654. * @returns true if VR mode is engaged
  34655. */
  34656. isVRPresenting(): boolean;
  34657. /** @hidden */
  34658. _requestVRFrame(): void;
  34659. /** @hidden */
  34660. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34661. /**
  34662. * Gets the source code of the vertex shader associated with a specific webGL program
  34663. * @param program defines the program to use
  34664. * @returns a string containing the source code of the vertex shader associated with the program
  34665. */
  34666. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34667. /**
  34668. * Gets the source code of the fragment shader associated with a specific webGL program
  34669. * @param program defines the program to use
  34670. * @returns a string containing the source code of the fragment shader associated with the program
  34671. */
  34672. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34673. /**
  34674. * Sets a depth stencil texture from a render target to the according uniform.
  34675. * @param channel The texture channel
  34676. * @param uniform The uniform to set
  34677. * @param texture The render target texture containing the depth stencil texture to apply
  34678. */
  34679. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34680. /**
  34681. * Sets a texture to the webGL context from a postprocess
  34682. * @param channel defines the channel to use
  34683. * @param postProcess defines the source postprocess
  34684. */
  34685. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34686. /**
  34687. * Binds the output of the passed in post process to the texture channel specified
  34688. * @param channel The channel the texture should be bound to
  34689. * @param postProcess The post process which's output should be bound
  34690. */
  34691. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34692. /** @hidden */
  34693. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34694. protected _rebuildBuffers(): void;
  34695. /** @hidden */
  34696. _renderFrame(): void;
  34697. _renderLoop(): void;
  34698. /** @hidden */
  34699. _renderViews(): boolean;
  34700. /**
  34701. * Toggle full screen mode
  34702. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34703. */
  34704. switchFullscreen(requestPointerLock: boolean): void;
  34705. /**
  34706. * Enters full screen mode
  34707. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34708. */
  34709. enterFullscreen(requestPointerLock: boolean): void;
  34710. /**
  34711. * Exits full screen mode
  34712. */
  34713. exitFullscreen(): void;
  34714. /**
  34715. * Enters Pointerlock mode
  34716. */
  34717. enterPointerlock(): void;
  34718. /**
  34719. * Exits Pointerlock mode
  34720. */
  34721. exitPointerlock(): void;
  34722. /**
  34723. * Begin a new frame
  34724. */
  34725. beginFrame(): void;
  34726. /**
  34727. * Enf the current frame
  34728. */
  34729. endFrame(): void;
  34730. resize(): void;
  34731. /**
  34732. * Set the compressed texture format to use, based on the formats you have, and the formats
  34733. * supported by the hardware / browser.
  34734. *
  34735. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34736. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34737. * to API arguments needed to compressed textures. This puts the burden on the container
  34738. * generator to house the arcane code for determining these for current & future formats.
  34739. *
  34740. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34741. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34742. *
  34743. * Note: The result of this call is not taken into account when a texture is base64.
  34744. *
  34745. * @param formatsAvailable defines the list of those format families you have created
  34746. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34747. *
  34748. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34749. * @returns The extension selected.
  34750. */
  34751. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34752. /**
  34753. * Set the compressed texture extensions or file names to skip.
  34754. *
  34755. * @param skippedFiles defines the list of those texture files you want to skip
  34756. * Example: [".dds", ".env", "myfile.png"]
  34757. */
  34758. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34759. /**
  34760. * Force a specific size of the canvas
  34761. * @param width defines the new canvas' width
  34762. * @param height defines the new canvas' height
  34763. */
  34764. setSize(width: number, height: number): void;
  34765. /**
  34766. * Updates a dynamic vertex buffer.
  34767. * @param vertexBuffer the vertex buffer to update
  34768. * @param data the data used to update the vertex buffer
  34769. * @param byteOffset the byte offset of the data
  34770. * @param byteLength the byte length of the data
  34771. */
  34772. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34775. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34776. _releaseTexture(texture: InternalTexture): void;
  34777. /**
  34778. * @hidden
  34779. * Rescales a texture
  34780. * @param source input texutre
  34781. * @param destination destination texture
  34782. * @param scene scene to use to render the resize
  34783. * @param internalFormat format to use when resizing
  34784. * @param onComplete callback to be called when resize has completed
  34785. */
  34786. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34787. /**
  34788. * Gets the current framerate
  34789. * @returns a number representing the framerate
  34790. */
  34791. getFps(): number;
  34792. /**
  34793. * Gets the time spent between current and previous frame
  34794. * @returns a number representing the delta time in ms
  34795. */
  34796. getDeltaTime(): number;
  34797. private _measureFps;
  34798. /** @hidden */
  34799. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34800. /**
  34801. * Update a dynamic index buffer
  34802. * @param indexBuffer defines the target index buffer
  34803. * @param indices defines the data to update
  34804. * @param offset defines the offset in the target index buffer where update should start
  34805. */
  34806. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34807. /**
  34808. * Updates the sample count of a render target texture
  34809. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34810. * @param texture defines the texture to update
  34811. * @param samples defines the sample count to set
  34812. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34813. */
  34814. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34815. /**
  34816. * Updates a depth texture Comparison Mode and Function.
  34817. * If the comparison Function is equal to 0, the mode will be set to none.
  34818. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34819. * @param texture The texture to set the comparison function for
  34820. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34821. */
  34822. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34823. /**
  34824. * Creates a webGL buffer to use with instanciation
  34825. * @param capacity defines the size of the buffer
  34826. * @returns the webGL buffer
  34827. */
  34828. createInstancesBuffer(capacity: number): DataBuffer;
  34829. /**
  34830. * Delete a webGL buffer used with instanciation
  34831. * @param buffer defines the webGL buffer to delete
  34832. */
  34833. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34834. /** @hidden */
  34835. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34836. dispose(): void;
  34837. private _disableTouchAction;
  34838. /**
  34839. * Display the loading screen
  34840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34841. */
  34842. displayLoadingUI(): void;
  34843. /**
  34844. * Hide the loading screen
  34845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34846. */
  34847. hideLoadingUI(): void;
  34848. /**
  34849. * Gets the current loading screen object
  34850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34851. */
  34852. get loadingScreen(): ILoadingScreen;
  34853. /**
  34854. * Sets the current loading screen object
  34855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34856. */
  34857. set loadingScreen(loadingScreen: ILoadingScreen);
  34858. /**
  34859. * Sets the current loading screen text
  34860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34861. */
  34862. set loadingUIText(text: string);
  34863. /**
  34864. * Sets the current loading screen background color
  34865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34866. */
  34867. set loadingUIBackgroundColor(color: string);
  34868. /** Pointerlock and fullscreen */
  34869. /**
  34870. * Ask the browser to promote the current element to pointerlock mode
  34871. * @param element defines the DOM element to promote
  34872. */
  34873. static _RequestPointerlock(element: HTMLElement): void;
  34874. /**
  34875. * Asks the browser to exit pointerlock mode
  34876. */
  34877. static _ExitPointerlock(): void;
  34878. /**
  34879. * Ask the browser to promote the current element to fullscreen rendering mode
  34880. * @param element defines the DOM element to promote
  34881. */
  34882. static _RequestFullscreen(element: HTMLElement): void;
  34883. /**
  34884. * Asks the browser to exit fullscreen mode
  34885. */
  34886. static _ExitFullscreen(): void;
  34887. }
  34888. }
  34889. declare module "babylonjs/Engines/engineStore" {
  34890. import { Nullable } from "babylonjs/types";
  34891. import { Engine } from "babylonjs/Engines/engine";
  34892. import { Scene } from "babylonjs/scene";
  34893. /**
  34894. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34895. * during the life time of the application.
  34896. */
  34897. export class EngineStore {
  34898. /** Gets the list of created engines */
  34899. static Instances: import("babylonjs/Engines/engine").Engine[];
  34900. /** @hidden */
  34901. static _LastCreatedScene: Nullable<Scene>;
  34902. /**
  34903. * Gets the latest created engine
  34904. */
  34905. static get LastCreatedEngine(): Nullable<Engine>;
  34906. /**
  34907. * Gets the latest created scene
  34908. */
  34909. static get LastCreatedScene(): Nullable<Scene>;
  34910. /**
  34911. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34912. * @ignorenaming
  34913. */
  34914. static UseFallbackTexture: boolean;
  34915. /**
  34916. * Texture content used if a texture cannot loaded
  34917. * @ignorenaming
  34918. */
  34919. static FallbackTexture: string;
  34920. }
  34921. }
  34922. declare module "babylonjs/Misc/promise" {
  34923. /**
  34924. * Helper class that provides a small promise polyfill
  34925. */
  34926. export class PromisePolyfill {
  34927. /**
  34928. * Static function used to check if the polyfill is required
  34929. * If this is the case then the function will inject the polyfill to window.Promise
  34930. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34931. */
  34932. static Apply(force?: boolean): void;
  34933. }
  34934. }
  34935. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34936. /**
  34937. * Interface for screenshot methods with describe argument called `size` as object with options
  34938. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34939. */
  34940. export interface IScreenshotSize {
  34941. /**
  34942. * number in pixels for canvas height
  34943. */
  34944. height?: number;
  34945. /**
  34946. * multiplier allowing render at a higher or lower resolution
  34947. * If value is defined then height and width will be ignored and taken from camera
  34948. */
  34949. precision?: number;
  34950. /**
  34951. * number in pixels for canvas width
  34952. */
  34953. width?: number;
  34954. }
  34955. }
  34956. declare module "babylonjs/Misc/tools" {
  34957. import { Nullable, float } from "babylonjs/types";
  34958. import { DomManagement } from "babylonjs/Misc/domManagement";
  34959. import { WebRequest } from "babylonjs/Misc/webRequest";
  34960. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34961. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34962. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34963. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34964. import { Camera } from "babylonjs/Cameras/camera";
  34965. import { Engine } from "babylonjs/Engines/engine";
  34966. interface IColor4Like {
  34967. r: float;
  34968. g: float;
  34969. b: float;
  34970. a: float;
  34971. }
  34972. /**
  34973. * Class containing a set of static utilities functions
  34974. */
  34975. export class Tools {
  34976. /**
  34977. * Gets or sets the base URL to use to load assets
  34978. */
  34979. static get BaseUrl(): string;
  34980. static set BaseUrl(value: string);
  34981. /**
  34982. * Enable/Disable Custom HTTP Request Headers globally.
  34983. * default = false
  34984. * @see CustomRequestHeaders
  34985. */
  34986. static UseCustomRequestHeaders: boolean;
  34987. /**
  34988. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34989. * i.e. when loading files, where the server/service expects an Authorization header
  34990. */
  34991. static CustomRequestHeaders: {
  34992. [key: string]: string;
  34993. };
  34994. /**
  34995. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34996. */
  34997. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34998. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34999. /**
  35000. * Default behaviour for cors in the application.
  35001. * It can be a string if the expected behavior is identical in the entire app.
  35002. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35003. */
  35004. static CorsBehavior: string | ((url: string | string[]) => string);
  35005. /**
  35006. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35007. * @ignorenaming
  35008. */
  35009. static get UseFallbackTexture(): boolean;
  35010. static set UseFallbackTexture(value: boolean);
  35011. /**
  35012. * Use this object to register external classes like custom textures or material
  35013. * to allow the laoders to instantiate them
  35014. */
  35015. static get RegisteredExternalClasses(): {
  35016. [key: string]: Object;
  35017. };
  35018. static set RegisteredExternalClasses(classes: {
  35019. [key: string]: Object;
  35020. });
  35021. /**
  35022. * Texture content used if a texture cannot loaded
  35023. * @ignorenaming
  35024. */
  35025. static get fallbackTexture(): string;
  35026. static set fallbackTexture(value: string);
  35027. /**
  35028. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35029. * @param u defines the coordinate on X axis
  35030. * @param v defines the coordinate on Y axis
  35031. * @param width defines the width of the source data
  35032. * @param height defines the height of the source data
  35033. * @param pixels defines the source byte array
  35034. * @param color defines the output color
  35035. */
  35036. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35037. /**
  35038. * Interpolates between a and b via alpha
  35039. * @param a The lower value (returned when alpha = 0)
  35040. * @param b The upper value (returned when alpha = 1)
  35041. * @param alpha The interpolation-factor
  35042. * @return The mixed value
  35043. */
  35044. static Mix(a: number, b: number, alpha: number): number;
  35045. /**
  35046. * Tries to instantiate a new object from a given class name
  35047. * @param className defines the class name to instantiate
  35048. * @returns the new object or null if the system was not able to do the instantiation
  35049. */
  35050. static Instantiate(className: string): any;
  35051. /**
  35052. * Provides a slice function that will work even on IE
  35053. * @param data defines the array to slice
  35054. * @param start defines the start of the data (optional)
  35055. * @param end defines the end of the data (optional)
  35056. * @returns the new sliced array
  35057. */
  35058. static Slice<T>(data: T, start?: number, end?: number): T;
  35059. /**
  35060. * Polyfill for setImmediate
  35061. * @param action defines the action to execute after the current execution block
  35062. */
  35063. static SetImmediate(action: () => void): void;
  35064. /**
  35065. * Function indicating if a number is an exponent of 2
  35066. * @param value defines the value to test
  35067. * @returns true if the value is an exponent of 2
  35068. */
  35069. static IsExponentOfTwo(value: number): boolean;
  35070. private static _tmpFloatArray;
  35071. /**
  35072. * Returns the nearest 32-bit single precision float representation of a Number
  35073. * @param value A Number. If the parameter is of a different type, it will get converted
  35074. * to a number or to NaN if it cannot be converted
  35075. * @returns number
  35076. */
  35077. static FloatRound(value: number): number;
  35078. /**
  35079. * Extracts the filename from a path
  35080. * @param path defines the path to use
  35081. * @returns the filename
  35082. */
  35083. static GetFilename(path: string): string;
  35084. /**
  35085. * Extracts the "folder" part of a path (everything before the filename).
  35086. * @param uri The URI to extract the info from
  35087. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35088. * @returns The "folder" part of the path
  35089. */
  35090. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35091. /**
  35092. * Extracts text content from a DOM element hierarchy
  35093. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35094. */
  35095. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35096. /**
  35097. * Convert an angle in radians to degrees
  35098. * @param angle defines the angle to convert
  35099. * @returns the angle in degrees
  35100. */
  35101. static ToDegrees(angle: number): number;
  35102. /**
  35103. * Convert an angle in degrees to radians
  35104. * @param angle defines the angle to convert
  35105. * @returns the angle in radians
  35106. */
  35107. static ToRadians(angle: number): number;
  35108. /**
  35109. * Returns an array if obj is not an array
  35110. * @param obj defines the object to evaluate as an array
  35111. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35112. * @returns either obj directly if obj is an array or a new array containing obj
  35113. */
  35114. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35115. /**
  35116. * Gets the pointer prefix to use
  35117. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35118. */
  35119. static GetPointerPrefix(): string;
  35120. /**
  35121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35122. * @param url define the url we are trying
  35123. * @param element define the dom element where to configure the cors policy
  35124. */
  35125. static SetCorsBehavior(url: string | string[], element: {
  35126. crossOrigin: string | null;
  35127. }): void;
  35128. /**
  35129. * Removes unwanted characters from an url
  35130. * @param url defines the url to clean
  35131. * @returns the cleaned url
  35132. */
  35133. static CleanUrl(url: string): string;
  35134. /**
  35135. * Gets or sets a function used to pre-process url before using them to load assets
  35136. */
  35137. static get PreprocessUrl(): (url: string) => string;
  35138. static set PreprocessUrl(processor: (url: string) => string);
  35139. /**
  35140. * Loads an image as an HTMLImageElement.
  35141. * @param input url string, ArrayBuffer, or Blob to load
  35142. * @param onLoad callback called when the image successfully loads
  35143. * @param onError callback called when the image fails to load
  35144. * @param offlineProvider offline provider for caching
  35145. * @param mimeType optional mime type
  35146. * @returns the HTMLImageElement of the loaded image
  35147. */
  35148. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35149. /**
  35150. * Loads a file from a url
  35151. * @param url url string, ArrayBuffer, or Blob to load
  35152. * @param onSuccess callback called when the file successfully loads
  35153. * @param onProgress callback called while file is loading (if the server supports this mode)
  35154. * @param offlineProvider defines the offline provider for caching
  35155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35156. * @param onError callback called when the file fails to load
  35157. * @returns a file request object
  35158. */
  35159. 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;
  35160. /**
  35161. * Loads a file from a url
  35162. * @param url the file url to load
  35163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35164. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35165. */
  35166. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35167. /**
  35168. * Load a script (identified by an url). When the url returns, the
  35169. * content of this file is added into a new script element, attached to the DOM (body element)
  35170. * @param scriptUrl defines the url of the script to laod
  35171. * @param onSuccess defines the callback called when the script is loaded
  35172. * @param onError defines the callback to call if an error occurs
  35173. * @param scriptId defines the id of the script element
  35174. */
  35175. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35176. /**
  35177. * Load an asynchronous script (identified by an url). When the url returns, the
  35178. * content of this file is added into a new script element, attached to the DOM (body element)
  35179. * @param scriptUrl defines the url of the script to laod
  35180. * @param scriptId defines the id of the script element
  35181. * @returns a promise request object
  35182. */
  35183. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35184. /**
  35185. * Loads a file from a blob
  35186. * @param fileToLoad defines the blob to use
  35187. * @param callback defines the callback to call when data is loaded
  35188. * @param progressCallback defines the callback to call during loading process
  35189. * @returns a file request object
  35190. */
  35191. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35192. /**
  35193. * Reads a file from a File object
  35194. * @param file defines the file to load
  35195. * @param onSuccess defines the callback to call when data is loaded
  35196. * @param onProgress defines the callback to call during loading process
  35197. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35198. * @param onError defines the callback to call when an error occurs
  35199. * @returns a file request object
  35200. */
  35201. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35202. /**
  35203. * Creates a data url from a given string content
  35204. * @param content defines the content to convert
  35205. * @returns the new data url link
  35206. */
  35207. static FileAsURL(content: string): string;
  35208. /**
  35209. * Format the given number to a specific decimal format
  35210. * @param value defines the number to format
  35211. * @param decimals defines the number of decimals to use
  35212. * @returns the formatted string
  35213. */
  35214. static Format(value: number, decimals?: number): string;
  35215. /**
  35216. * Tries to copy an object by duplicating every property
  35217. * @param source defines the source object
  35218. * @param destination defines the target object
  35219. * @param doNotCopyList defines a list of properties to avoid
  35220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35221. */
  35222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35223. /**
  35224. * Gets a boolean indicating if the given object has no own property
  35225. * @param obj defines the object to test
  35226. * @returns true if object has no own property
  35227. */
  35228. static IsEmpty(obj: any): boolean;
  35229. /**
  35230. * Function used to register events at window level
  35231. * @param windowElement defines the Window object to use
  35232. * @param events defines the events to register
  35233. */
  35234. static RegisterTopRootEvents(windowElement: Window, events: {
  35235. name: string;
  35236. handler: Nullable<(e: FocusEvent) => any>;
  35237. }[]): void;
  35238. /**
  35239. * Function used to unregister events from window level
  35240. * @param windowElement defines the Window object to use
  35241. * @param events defines the events to unregister
  35242. */
  35243. static UnregisterTopRootEvents(windowElement: Window, events: {
  35244. name: string;
  35245. handler: Nullable<(e: FocusEvent) => any>;
  35246. }[]): void;
  35247. /**
  35248. * @ignore
  35249. */
  35250. static _ScreenshotCanvas: HTMLCanvasElement;
  35251. /**
  35252. * Dumps the current bound framebuffer
  35253. * @param width defines the rendering width
  35254. * @param height defines the rendering height
  35255. * @param engine defines the hosting engine
  35256. * @param successCallback defines the callback triggered once the data are available
  35257. * @param mimeType defines the mime type of the result
  35258. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35259. */
  35260. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35261. /**
  35262. * Converts the canvas data to blob.
  35263. * This acts as a polyfill for browsers not supporting the to blob function.
  35264. * @param canvas Defines the canvas to extract the data from
  35265. * @param successCallback Defines the callback triggered once the data are available
  35266. * @param mimeType Defines the mime type of the result
  35267. */
  35268. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35269. /**
  35270. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35271. * @param successCallback defines the callback triggered once the data are available
  35272. * @param mimeType defines the mime type of the result
  35273. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35274. */
  35275. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35276. /**
  35277. * Downloads a blob in the browser
  35278. * @param blob defines the blob to download
  35279. * @param fileName defines the name of the downloaded file
  35280. */
  35281. static Download(blob: Blob, fileName: string): void;
  35282. /**
  35283. * Captures a screenshot of the current rendering
  35284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35285. * @param engine defines the rendering engine
  35286. * @param camera defines the source camera
  35287. * @param size This parameter can be set to a single number or to an object with the
  35288. * following (optional) properties: precision, width, height. If a single number is passed,
  35289. * it will be used for both width and height. If an object is passed, the screenshot size
  35290. * will be derived from the parameters. The precision property is a multiplier allowing
  35291. * rendering at a higher or lower resolution
  35292. * @param successCallback defines the callback receives a single parameter which contains the
  35293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35294. * src parameter of an <img> to display it
  35295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35296. * Check your browser for supported MIME types
  35297. */
  35298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35299. /**
  35300. * Captures a screenshot of the current rendering
  35301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35302. * @param engine defines the rendering engine
  35303. * @param camera defines the source camera
  35304. * @param size This parameter can be set to a single number or to an object with the
  35305. * following (optional) properties: precision, width, height. If a single number is passed,
  35306. * it will be used for both width and height. If an object is passed, the screenshot size
  35307. * will be derived from the parameters. The precision property is a multiplier allowing
  35308. * rendering at a higher or lower resolution
  35309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35310. * Check your browser for supported MIME types
  35311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35312. * to the src parameter of an <img> to display it
  35313. */
  35314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35315. /**
  35316. * Generates an image screenshot from the specified camera.
  35317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35318. * @param engine The engine to use for rendering
  35319. * @param camera The camera to use for rendering
  35320. * @param size This parameter can be set to a single number or to an object with the
  35321. * following (optional) properties: precision, width, height. If a single number is passed,
  35322. * it will be used for both width and height. If an object is passed, the screenshot size
  35323. * will be derived from the parameters. The precision property is a multiplier allowing
  35324. * rendering at a higher or lower resolution
  35325. * @param successCallback The callback receives a single parameter which contains the
  35326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35327. * src parameter of an <img> to display it
  35328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35329. * Check your browser for supported MIME types
  35330. * @param samples Texture samples (default: 1)
  35331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35332. * @param fileName A name for for the downloaded file.
  35333. */
  35334. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35335. /**
  35336. * Generates an image screenshot from the specified camera.
  35337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35338. * @param engine The engine to use for rendering
  35339. * @param camera The camera to use for rendering
  35340. * @param size This parameter can be set to a single number or to an object with the
  35341. * following (optional) properties: precision, width, height. If a single number is passed,
  35342. * it will be used for both width and height. If an object is passed, the screenshot size
  35343. * will be derived from the parameters. The precision property is a multiplier allowing
  35344. * rendering at a higher or lower resolution
  35345. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35346. * Check your browser for supported MIME types
  35347. * @param samples Texture samples (default: 1)
  35348. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35349. * @param fileName A name for for the downloaded file.
  35350. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35351. * to the src parameter of an <img> to display it
  35352. */
  35353. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35354. /**
  35355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35356. * Be aware Math.random() could cause collisions, but:
  35357. * "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"
  35358. * @returns a pseudo random id
  35359. */
  35360. static RandomId(): string;
  35361. /**
  35362. * Test if the given uri is a base64 string
  35363. * @param uri The uri to test
  35364. * @return True if the uri is a base64 string or false otherwise
  35365. */
  35366. static IsBase64(uri: string): boolean;
  35367. /**
  35368. * Decode the given base64 uri.
  35369. * @param uri The uri to decode
  35370. * @return The decoded base64 data.
  35371. */
  35372. static DecodeBase64(uri: string): ArrayBuffer;
  35373. /**
  35374. * Gets the absolute url.
  35375. * @param url the input url
  35376. * @return the absolute url
  35377. */
  35378. static GetAbsoluteUrl(url: string): string;
  35379. /**
  35380. * No log
  35381. */
  35382. static readonly NoneLogLevel: number;
  35383. /**
  35384. * Only message logs
  35385. */
  35386. static readonly MessageLogLevel: number;
  35387. /**
  35388. * Only warning logs
  35389. */
  35390. static readonly WarningLogLevel: number;
  35391. /**
  35392. * Only error logs
  35393. */
  35394. static readonly ErrorLogLevel: number;
  35395. /**
  35396. * All logs
  35397. */
  35398. static readonly AllLogLevel: number;
  35399. /**
  35400. * Gets a value indicating the number of loading errors
  35401. * @ignorenaming
  35402. */
  35403. static get errorsCount(): number;
  35404. /**
  35405. * Callback called when a new log is added
  35406. */
  35407. static OnNewCacheEntry: (entry: string) => void;
  35408. /**
  35409. * Log a message to the console
  35410. * @param message defines the message to log
  35411. */
  35412. static Log(message: string): void;
  35413. /**
  35414. * Write a warning message to the console
  35415. * @param message defines the message to log
  35416. */
  35417. static Warn(message: string): void;
  35418. /**
  35419. * Write an error message to the console
  35420. * @param message defines the message to log
  35421. */
  35422. static Error(message: string): void;
  35423. /**
  35424. * Gets current log cache (list of logs)
  35425. */
  35426. static get LogCache(): string;
  35427. /**
  35428. * Clears the log cache
  35429. */
  35430. static ClearLogCache(): void;
  35431. /**
  35432. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35433. */
  35434. static set LogLevels(level: number);
  35435. /**
  35436. * Checks if the window object exists
  35437. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35438. */
  35439. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35440. /**
  35441. * No performance log
  35442. */
  35443. static readonly PerformanceNoneLogLevel: number;
  35444. /**
  35445. * Use user marks to log performance
  35446. */
  35447. static readonly PerformanceUserMarkLogLevel: number;
  35448. /**
  35449. * Log performance to the console
  35450. */
  35451. static readonly PerformanceConsoleLogLevel: number;
  35452. private static _performance;
  35453. /**
  35454. * Sets the current performance log level
  35455. */
  35456. static set PerformanceLogLevel(level: number);
  35457. private static _StartPerformanceCounterDisabled;
  35458. private static _EndPerformanceCounterDisabled;
  35459. private static _StartUserMark;
  35460. private static _EndUserMark;
  35461. private static _StartPerformanceConsole;
  35462. private static _EndPerformanceConsole;
  35463. /**
  35464. * Starts a performance counter
  35465. */
  35466. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35467. /**
  35468. * Ends a specific performance coutner
  35469. */
  35470. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35471. /**
  35472. * Gets either window.performance.now() if supported or Date.now() else
  35473. */
  35474. static get Now(): number;
  35475. /**
  35476. * This method will return the name of the class used to create the instance of the given object.
  35477. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35478. * @param object the object to get the class name from
  35479. * @param isType defines if the object is actually a type
  35480. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35481. */
  35482. static GetClassName(object: any, isType?: boolean): string;
  35483. /**
  35484. * Gets the first element of an array satisfying a given predicate
  35485. * @param array defines the array to browse
  35486. * @param predicate defines the predicate to use
  35487. * @returns null if not found or the element
  35488. */
  35489. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35490. /**
  35491. * This method will return the name of the full name of the class, including its owning module (if any).
  35492. * 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).
  35493. * @param object the object to get the class name from
  35494. * @param isType defines if the object is actually a type
  35495. * @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.
  35496. * @ignorenaming
  35497. */
  35498. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35499. /**
  35500. * Returns a promise that resolves after the given amount of time.
  35501. * @param delay Number of milliseconds to delay
  35502. * @returns Promise that resolves after the given amount of time
  35503. */
  35504. static DelayAsync(delay: number): Promise<void>;
  35505. /**
  35506. * Utility function to detect if the current user agent is Safari
  35507. * @returns whether or not the current user agent is safari
  35508. */
  35509. static IsSafari(): boolean;
  35510. }
  35511. /**
  35512. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35513. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35514. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35515. * @param name The name of the class, case should be preserved
  35516. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35517. */
  35518. export function className(name: string, module?: string): (target: Object) => void;
  35519. /**
  35520. * An implementation of a loop for asynchronous functions.
  35521. */
  35522. export class AsyncLoop {
  35523. /**
  35524. * Defines the number of iterations for the loop
  35525. */
  35526. iterations: number;
  35527. /**
  35528. * Defines the current index of the loop.
  35529. */
  35530. index: number;
  35531. private _done;
  35532. private _fn;
  35533. private _successCallback;
  35534. /**
  35535. * Constructor.
  35536. * @param iterations the number of iterations.
  35537. * @param func the function to run each iteration
  35538. * @param successCallback the callback that will be called upon succesful execution
  35539. * @param offset starting offset.
  35540. */
  35541. constructor(
  35542. /**
  35543. * Defines the number of iterations for the loop
  35544. */
  35545. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35546. /**
  35547. * Execute the next iteration. Must be called after the last iteration was finished.
  35548. */
  35549. executeNext(): void;
  35550. /**
  35551. * Break the loop and run the success callback.
  35552. */
  35553. breakLoop(): void;
  35554. /**
  35555. * Create and run an async loop.
  35556. * @param iterations the number of iterations.
  35557. * @param fn the function to run each iteration
  35558. * @param successCallback the callback that will be called upon succesful execution
  35559. * @param offset starting offset.
  35560. * @returns the created async loop object
  35561. */
  35562. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35563. /**
  35564. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35565. * @param iterations total number of iterations
  35566. * @param syncedIterations number of synchronous iterations in each async iteration.
  35567. * @param fn the function to call each iteration.
  35568. * @param callback a success call back that will be called when iterating stops.
  35569. * @param breakFunction a break condition (optional)
  35570. * @param timeout timeout settings for the setTimeout function. default - 0.
  35571. * @returns the created async loop object
  35572. */
  35573. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35574. }
  35575. }
  35576. declare module "babylonjs/Misc/stringDictionary" {
  35577. import { Nullable } from "babylonjs/types";
  35578. /**
  35579. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35580. * The underlying implementation relies on an associative array to ensure the best performances.
  35581. * The value can be anything including 'null' but except 'undefined'
  35582. */
  35583. export class StringDictionary<T> {
  35584. /**
  35585. * This will clear this dictionary and copy the content from the 'source' one.
  35586. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35587. * @param source the dictionary to take the content from and copy to this dictionary
  35588. */
  35589. copyFrom(source: StringDictionary<T>): void;
  35590. /**
  35591. * Get a value based from its key
  35592. * @param key the given key to get the matching value from
  35593. * @return the value if found, otherwise undefined is returned
  35594. */
  35595. get(key: string): T | undefined;
  35596. /**
  35597. * Get a value from its key or add it if it doesn't exist.
  35598. * This method will ensure you that a given key/data will be present in the dictionary.
  35599. * @param key the given key to get the matching value from
  35600. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35601. * The factory will only be invoked if there's no data for the given key.
  35602. * @return the value corresponding to the key.
  35603. */
  35604. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35605. /**
  35606. * Get a value from its key if present in the dictionary otherwise add it
  35607. * @param key the key to get the value from
  35608. * @param val if there's no such key/value pair in the dictionary add it with this value
  35609. * @return the value corresponding to the key
  35610. */
  35611. getOrAdd(key: string, val: T): T;
  35612. /**
  35613. * Check if there's a given key in the dictionary
  35614. * @param key the key to check for
  35615. * @return true if the key is present, false otherwise
  35616. */
  35617. contains(key: string): boolean;
  35618. /**
  35619. * Add a new key and its corresponding value
  35620. * @param key the key to add
  35621. * @param value the value corresponding to the key
  35622. * @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
  35623. */
  35624. add(key: string, value: T): boolean;
  35625. /**
  35626. * Update a specific value associated to a key
  35627. * @param key defines the key to use
  35628. * @param value defines the value to store
  35629. * @returns true if the value was updated (or false if the key was not found)
  35630. */
  35631. set(key: string, value: T): boolean;
  35632. /**
  35633. * Get the element of the given key and remove it from the dictionary
  35634. * @param key defines the key to search
  35635. * @returns the value associated with the key or null if not found
  35636. */
  35637. getAndRemove(key: string): Nullable<T>;
  35638. /**
  35639. * Remove a key/value from the dictionary.
  35640. * @param key the key to remove
  35641. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35642. */
  35643. remove(key: string): boolean;
  35644. /**
  35645. * Clear the whole content of the dictionary
  35646. */
  35647. clear(): void;
  35648. /**
  35649. * Gets the current count
  35650. */
  35651. get count(): number;
  35652. /**
  35653. * Execute a callback on each key/val of the dictionary.
  35654. * Note that you can remove any element in this dictionary in the callback implementation
  35655. * @param callback the callback to execute on a given key/value pair
  35656. */
  35657. forEach(callback: (key: string, val: T) => void): void;
  35658. /**
  35659. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35660. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35661. * Note that you can remove any element in this dictionary in the callback implementation
  35662. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35663. * @returns the first item
  35664. */
  35665. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35666. private _count;
  35667. private _data;
  35668. }
  35669. }
  35670. declare module "babylonjs/Collisions/collisionCoordinator" {
  35671. import { Nullable } from "babylonjs/types";
  35672. import { Scene } from "babylonjs/scene";
  35673. import { Vector3 } from "babylonjs/Maths/math.vector";
  35674. import { Collider } from "babylonjs/Collisions/collider";
  35675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35676. /** @hidden */
  35677. export interface ICollisionCoordinator {
  35678. createCollider(): Collider;
  35679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35680. init(scene: Scene): void;
  35681. }
  35682. /** @hidden */
  35683. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35684. private _scene;
  35685. private _scaledPosition;
  35686. private _scaledVelocity;
  35687. private _finalPosition;
  35688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35689. createCollider(): Collider;
  35690. init(scene: Scene): void;
  35691. private _collideWithWorld;
  35692. }
  35693. }
  35694. declare module "babylonjs/Inputs/scene.inputManager" {
  35695. import { Nullable } from "babylonjs/types";
  35696. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35697. import { Vector2 } from "babylonjs/Maths/math.vector";
  35698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35699. import { Scene } from "babylonjs/scene";
  35700. /**
  35701. * Class used to manage all inputs for the scene.
  35702. */
  35703. export class InputManager {
  35704. /** The distance in pixel that you have to move to prevent some events */
  35705. static DragMovementThreshold: number;
  35706. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35707. static LongPressDelay: number;
  35708. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35709. static DoubleClickDelay: number;
  35710. /** If you need to check double click without raising a single click at first click, enable this flag */
  35711. static ExclusiveDoubleClickMode: boolean;
  35712. private _wheelEventName;
  35713. private _onPointerMove;
  35714. private _onPointerDown;
  35715. private _onPointerUp;
  35716. private _initClickEvent;
  35717. private _initActionManager;
  35718. private _delayedSimpleClick;
  35719. private _delayedSimpleClickTimeout;
  35720. private _previousDelayedSimpleClickTimeout;
  35721. private _meshPickProceed;
  35722. private _previousButtonPressed;
  35723. private _currentPickResult;
  35724. private _previousPickResult;
  35725. private _totalPointersPressed;
  35726. private _doubleClickOccured;
  35727. private _pointerOverMesh;
  35728. private _pickedDownMesh;
  35729. private _pickedUpMesh;
  35730. private _pointerX;
  35731. private _pointerY;
  35732. private _unTranslatedPointerX;
  35733. private _unTranslatedPointerY;
  35734. private _startingPointerPosition;
  35735. private _previousStartingPointerPosition;
  35736. private _startingPointerTime;
  35737. private _previousStartingPointerTime;
  35738. private _pointerCaptures;
  35739. private _onKeyDown;
  35740. private _onKeyUp;
  35741. private _onCanvasFocusObserver;
  35742. private _onCanvasBlurObserver;
  35743. private _scene;
  35744. /**
  35745. * Creates a new InputManager
  35746. * @param scene defines the hosting scene
  35747. */
  35748. constructor(scene: Scene);
  35749. /**
  35750. * Gets the mesh that is currently under the pointer
  35751. */
  35752. get meshUnderPointer(): Nullable<AbstractMesh>;
  35753. /**
  35754. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35755. */
  35756. get unTranslatedPointer(): Vector2;
  35757. /**
  35758. * Gets or sets the current on-screen X position of the pointer
  35759. */
  35760. get pointerX(): number;
  35761. set pointerX(value: number);
  35762. /**
  35763. * Gets or sets the current on-screen Y position of the pointer
  35764. */
  35765. get pointerY(): number;
  35766. set pointerY(value: number);
  35767. private _updatePointerPosition;
  35768. private _processPointerMove;
  35769. private _setRayOnPointerInfo;
  35770. private _checkPrePointerObservable;
  35771. /**
  35772. * Use this method to simulate a pointer move on a mesh
  35773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35776. */
  35777. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35778. /**
  35779. * Use this method to simulate a pointer down on a mesh
  35780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35783. */
  35784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35785. private _processPointerDown;
  35786. /** @hidden */
  35787. _isPointerSwiping(): boolean;
  35788. /**
  35789. * Use this method to simulate a pointer up on a mesh
  35790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35793. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35794. */
  35795. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35796. private _processPointerUp;
  35797. /**
  35798. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35799. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35800. * @returns true if the pointer was captured
  35801. */
  35802. isPointerCaptured(pointerId?: number): boolean;
  35803. /**
  35804. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35805. * @param attachUp defines if you want to attach events to pointerup
  35806. * @param attachDown defines if you want to attach events to pointerdown
  35807. * @param attachMove defines if you want to attach events to pointermove
  35808. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35809. */
  35810. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35811. /**
  35812. * Detaches all event handlers
  35813. */
  35814. detachControl(): void;
  35815. /**
  35816. * Force the value of meshUnderPointer
  35817. * @param mesh defines the mesh to use
  35818. */
  35819. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35820. /**
  35821. * Gets the mesh under the pointer
  35822. * @returns a Mesh or null if no mesh is under the pointer
  35823. */
  35824. getPointerOverMesh(): Nullable<AbstractMesh>;
  35825. }
  35826. }
  35827. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35828. /**
  35829. * Helper class used to generate session unique ID
  35830. */
  35831. export class UniqueIdGenerator {
  35832. private static _UniqueIdCounter;
  35833. /**
  35834. * Gets an unique (relatively to the current scene) Id
  35835. */
  35836. static get UniqueId(): number;
  35837. }
  35838. }
  35839. declare module "babylonjs/Animations/animationGroup" {
  35840. import { Animatable } from "babylonjs/Animations/animatable";
  35841. import { Animation } from "babylonjs/Animations/animation";
  35842. import { Scene, IDisposable } from "babylonjs/scene";
  35843. import { Observable } from "babylonjs/Misc/observable";
  35844. import { Nullable } from "babylonjs/types";
  35845. import "babylonjs/Animations/animatable";
  35846. /**
  35847. * This class defines the direct association between an animation and a target
  35848. */
  35849. export class TargetedAnimation {
  35850. /**
  35851. * Animation to perform
  35852. */
  35853. animation: Animation;
  35854. /**
  35855. * Target to animate
  35856. */
  35857. target: any;
  35858. /**
  35859. * Serialize the object
  35860. * @returns the JSON object representing the current entity
  35861. */
  35862. serialize(): any;
  35863. }
  35864. /**
  35865. * Use this class to create coordinated animations on multiple targets
  35866. */
  35867. export class AnimationGroup implements IDisposable {
  35868. /** The name of the animation group */
  35869. name: string;
  35870. private _scene;
  35871. private _targetedAnimations;
  35872. private _animatables;
  35873. private _from;
  35874. private _to;
  35875. private _isStarted;
  35876. private _isPaused;
  35877. private _speedRatio;
  35878. private _loopAnimation;
  35879. /**
  35880. * Gets or sets the unique id of the node
  35881. */
  35882. uniqueId: number;
  35883. /**
  35884. * This observable will notify when one animation have ended
  35885. */
  35886. onAnimationEndObservable: Observable<TargetedAnimation>;
  35887. /**
  35888. * Observer raised when one animation loops
  35889. */
  35890. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35891. /**
  35892. * Observer raised when all animations have looped
  35893. */
  35894. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35895. /**
  35896. * This observable will notify when all animations have ended.
  35897. */
  35898. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35899. /**
  35900. * This observable will notify when all animations have paused.
  35901. */
  35902. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35903. /**
  35904. * This observable will notify when all animations are playing.
  35905. */
  35906. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35907. /**
  35908. * Gets the first frame
  35909. */
  35910. get from(): number;
  35911. /**
  35912. * Gets the last frame
  35913. */
  35914. get to(): number;
  35915. /**
  35916. * Define if the animations are started
  35917. */
  35918. get isStarted(): boolean;
  35919. /**
  35920. * Gets a value indicating that the current group is playing
  35921. */
  35922. get isPlaying(): boolean;
  35923. /**
  35924. * Gets or sets the speed ratio to use for all animations
  35925. */
  35926. get speedRatio(): number;
  35927. /**
  35928. * Gets or sets the speed ratio to use for all animations
  35929. */
  35930. set speedRatio(value: number);
  35931. /**
  35932. * Gets or sets if all animations should loop or not
  35933. */
  35934. get loopAnimation(): boolean;
  35935. set loopAnimation(value: boolean);
  35936. /**
  35937. * Gets the targeted animations for this animation group
  35938. */
  35939. get targetedAnimations(): Array<TargetedAnimation>;
  35940. /**
  35941. * returning the list of animatables controlled by this animation group.
  35942. */
  35943. get animatables(): Array<Animatable>;
  35944. /**
  35945. * Instantiates a new Animation Group.
  35946. * This helps managing several animations at once.
  35947. * @see http://doc.babylonjs.com/how_to/group
  35948. * @param name Defines the name of the group
  35949. * @param scene Defines the scene the group belongs to
  35950. */
  35951. constructor(
  35952. /** The name of the animation group */
  35953. name: string, scene?: Nullable<Scene>);
  35954. /**
  35955. * Add an animation (with its target) in the group
  35956. * @param animation defines the animation we want to add
  35957. * @param target defines the target of the animation
  35958. * @returns the TargetedAnimation object
  35959. */
  35960. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35961. /**
  35962. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35963. * It can add constant keys at begin or end
  35964. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35965. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35966. * @returns the animation group
  35967. */
  35968. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35969. private _animationLoopCount;
  35970. private _animationLoopFlags;
  35971. private _processLoop;
  35972. /**
  35973. * Start all animations on given targets
  35974. * @param loop defines if animations must loop
  35975. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35976. * @param from defines the from key (optional)
  35977. * @param to defines the to key (optional)
  35978. * @returns the current animation group
  35979. */
  35980. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35981. /**
  35982. * Pause all animations
  35983. * @returns the animation group
  35984. */
  35985. pause(): AnimationGroup;
  35986. /**
  35987. * Play all animations to initial state
  35988. * This function will start() the animations if they were not started or will restart() them if they were paused
  35989. * @param loop defines if animations must loop
  35990. * @returns the animation group
  35991. */
  35992. play(loop?: boolean): AnimationGroup;
  35993. /**
  35994. * Reset all animations to initial state
  35995. * @returns the animation group
  35996. */
  35997. reset(): AnimationGroup;
  35998. /**
  35999. * Restart animations from key 0
  36000. * @returns the animation group
  36001. */
  36002. restart(): AnimationGroup;
  36003. /**
  36004. * Stop all animations
  36005. * @returns the animation group
  36006. */
  36007. stop(): AnimationGroup;
  36008. /**
  36009. * Set animation weight for all animatables
  36010. * @param weight defines the weight to use
  36011. * @return the animationGroup
  36012. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36013. */
  36014. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36015. /**
  36016. * Synchronize and normalize all animatables with a source animatable
  36017. * @param root defines the root animatable to synchronize with
  36018. * @return the animationGroup
  36019. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36020. */
  36021. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36022. /**
  36023. * Goes to a specific frame in this animation group
  36024. * @param frame the frame number to go to
  36025. * @return the animationGroup
  36026. */
  36027. goToFrame(frame: number): AnimationGroup;
  36028. /**
  36029. * Dispose all associated resources
  36030. */
  36031. dispose(): void;
  36032. private _checkAnimationGroupEnded;
  36033. /**
  36034. * Clone the current animation group and returns a copy
  36035. * @param newName defines the name of the new group
  36036. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36037. * @returns the new aniamtion group
  36038. */
  36039. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36040. /**
  36041. * Serializes the animationGroup to an object
  36042. * @returns Serialized object
  36043. */
  36044. serialize(): any;
  36045. /**
  36046. * Returns a new AnimationGroup object parsed from the source provided.
  36047. * @param parsedAnimationGroup defines the source
  36048. * @param scene defines the scene that will receive the animationGroup
  36049. * @returns a new AnimationGroup
  36050. */
  36051. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36052. /**
  36053. * Returns the string "AnimationGroup"
  36054. * @returns "AnimationGroup"
  36055. */
  36056. getClassName(): string;
  36057. /**
  36058. * Creates a detailled string about the object
  36059. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36060. * @returns a string representing the object
  36061. */
  36062. toString(fullDetails?: boolean): string;
  36063. }
  36064. }
  36065. declare module "babylonjs/scene" {
  36066. import { Nullable } from "babylonjs/types";
  36067. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36068. import { Observable } from "babylonjs/Misc/observable";
  36069. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36070. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36071. import { Geometry } from "babylonjs/Meshes/geometry";
  36072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36075. import { Mesh } from "babylonjs/Meshes/mesh";
  36076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36077. import { Bone } from "babylonjs/Bones/bone";
  36078. import { Skeleton } from "babylonjs/Bones/skeleton";
  36079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36080. import { Camera } from "babylonjs/Cameras/camera";
  36081. import { AbstractScene } from "babylonjs/abstractScene";
  36082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36084. import { Material } from "babylonjs/Materials/material";
  36085. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36086. import { Effect } from "babylonjs/Materials/effect";
  36087. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36088. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36089. import { Light } from "babylonjs/Lights/light";
  36090. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36091. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36092. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36093. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36095. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36096. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36097. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36098. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36099. import { Engine } from "babylonjs/Engines/engine";
  36100. import { Node } from "babylonjs/node";
  36101. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36102. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36103. import { WebRequest } from "babylonjs/Misc/webRequest";
  36104. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36105. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36106. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36107. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36108. import { Plane } from "babylonjs/Maths/math.plane";
  36109. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36110. import { Ray } from "babylonjs/Culling/ray";
  36111. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36112. import { Animation } from "babylonjs/Animations/animation";
  36113. import { Animatable } from "babylonjs/Animations/animatable";
  36114. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36115. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36116. import { Collider } from "babylonjs/Collisions/collider";
  36117. /**
  36118. * Define an interface for all classes that will hold resources
  36119. */
  36120. export interface IDisposable {
  36121. /**
  36122. * Releases all held resources
  36123. */
  36124. dispose(): void;
  36125. }
  36126. /** Interface defining initialization parameters for Scene class */
  36127. export interface SceneOptions {
  36128. /**
  36129. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36130. * It will improve performance when the number of geometries becomes important.
  36131. */
  36132. useGeometryUniqueIdsMap?: boolean;
  36133. /**
  36134. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36136. */
  36137. useMaterialMeshMap?: boolean;
  36138. /**
  36139. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36140. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36141. */
  36142. useClonedMeshMap?: boolean;
  36143. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36144. virtual?: boolean;
  36145. }
  36146. /**
  36147. * Represents a scene to be rendered by the engine.
  36148. * @see http://doc.babylonjs.com/features/scene
  36149. */
  36150. export class Scene extends AbstractScene implements IAnimatable {
  36151. /** The fog is deactivated */
  36152. static readonly FOGMODE_NONE: number;
  36153. /** The fog density is following an exponential function */
  36154. static readonly FOGMODE_EXP: number;
  36155. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36156. static readonly FOGMODE_EXP2: number;
  36157. /** The fog density is following a linear function. */
  36158. static readonly FOGMODE_LINEAR: number;
  36159. /**
  36160. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36162. */
  36163. static MinDeltaTime: number;
  36164. /**
  36165. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36167. */
  36168. static MaxDeltaTime: number;
  36169. /**
  36170. * Factory used to create the default material.
  36171. * @param name The name of the material to create
  36172. * @param scene The scene to create the material for
  36173. * @returns The default material
  36174. */
  36175. static DefaultMaterialFactory(scene: Scene): Material;
  36176. /**
  36177. * Factory used to create the a collision coordinator.
  36178. * @returns The collision coordinator
  36179. */
  36180. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36181. /** @hidden */
  36182. _inputManager: InputManager;
  36183. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36184. cameraToUseForPointers: Nullable<Camera>;
  36185. /** @hidden */
  36186. readonly _isScene: boolean;
  36187. /** @hidden */
  36188. _blockEntityCollection: boolean;
  36189. /**
  36190. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36191. */
  36192. autoClear: boolean;
  36193. /**
  36194. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36195. */
  36196. autoClearDepthAndStencil: boolean;
  36197. /**
  36198. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36199. */
  36200. clearColor: Color4;
  36201. /**
  36202. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36203. */
  36204. ambientColor: Color3;
  36205. /**
  36206. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36207. * It should only be one of the following (if not the default embedded one):
  36208. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36209. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36210. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36211. * The material properties need to be setup according to the type of texture in use.
  36212. */
  36213. environmentBRDFTexture: BaseTexture;
  36214. /** @hidden */
  36215. protected _environmentTexture: Nullable<BaseTexture>;
  36216. /**
  36217. * Texture used in all pbr material as the reflection texture.
  36218. * As in the majority of the scene they are the same (exception for multi room and so on),
  36219. * this is easier to reference from here than from all the materials.
  36220. */
  36221. get environmentTexture(): Nullable<BaseTexture>;
  36222. /**
  36223. * Texture used in all pbr material as the reflection texture.
  36224. * As in the majority of the scene they are the same (exception for multi room and so on),
  36225. * this is easier to set here than in all the materials.
  36226. */
  36227. set environmentTexture(value: Nullable<BaseTexture>);
  36228. /** @hidden */
  36229. protected _environmentIntensity: number;
  36230. /**
  36231. * Intensity of the environment in all pbr material.
  36232. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36233. * As in the majority of the scene they are the same (exception for multi room and so on),
  36234. * this is easier to reference from here than from all the materials.
  36235. */
  36236. get environmentIntensity(): number;
  36237. /**
  36238. * Intensity of the environment in all pbr material.
  36239. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36240. * As in the majority of the scene they are the same (exception for multi room and so on),
  36241. * this is easier to set here than in all the materials.
  36242. */
  36243. set environmentIntensity(value: number);
  36244. /** @hidden */
  36245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36246. /**
  36247. * Default image processing configuration used either in the rendering
  36248. * Forward main pass or through the imageProcessingPostProcess if present.
  36249. * As in the majority of the scene they are the same (exception for multi camera),
  36250. * this is easier to reference from here than from all the materials and post process.
  36251. *
  36252. * No setter as we it is a shared configuration, you can set the values instead.
  36253. */
  36254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36255. private _forceWireframe;
  36256. /**
  36257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36258. */
  36259. set forceWireframe(value: boolean);
  36260. get forceWireframe(): boolean;
  36261. private _skipFrustumClipping;
  36262. /**
  36263. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36264. */
  36265. set skipFrustumClipping(value: boolean);
  36266. get skipFrustumClipping(): boolean;
  36267. private _forcePointsCloud;
  36268. /**
  36269. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36270. */
  36271. set forcePointsCloud(value: boolean);
  36272. get forcePointsCloud(): boolean;
  36273. /**
  36274. * Gets or sets the active clipplane 1
  36275. */
  36276. clipPlane: Nullable<Plane>;
  36277. /**
  36278. * Gets or sets the active clipplane 2
  36279. */
  36280. clipPlane2: Nullable<Plane>;
  36281. /**
  36282. * Gets or sets the active clipplane 3
  36283. */
  36284. clipPlane3: Nullable<Plane>;
  36285. /**
  36286. * Gets or sets the active clipplane 4
  36287. */
  36288. clipPlane4: Nullable<Plane>;
  36289. /**
  36290. * Gets or sets the active clipplane 5
  36291. */
  36292. clipPlane5: Nullable<Plane>;
  36293. /**
  36294. * Gets or sets the active clipplane 6
  36295. */
  36296. clipPlane6: Nullable<Plane>;
  36297. /**
  36298. * Gets or sets a boolean indicating if animations are enabled
  36299. */
  36300. animationsEnabled: boolean;
  36301. private _animationPropertiesOverride;
  36302. /**
  36303. * Gets or sets the animation properties override
  36304. */
  36305. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36306. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36307. /**
  36308. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36309. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36310. */
  36311. useConstantAnimationDeltaTime: boolean;
  36312. /**
  36313. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36314. * Please note that it requires to run a ray cast through the scene on every frame
  36315. */
  36316. constantlyUpdateMeshUnderPointer: boolean;
  36317. /**
  36318. * Defines the HTML cursor to use when hovering over interactive elements
  36319. */
  36320. hoverCursor: string;
  36321. /**
  36322. * Defines the HTML default cursor to use (empty by default)
  36323. */
  36324. defaultCursor: string;
  36325. /**
  36326. * Defines whether cursors are handled by the scene.
  36327. */
  36328. doNotHandleCursors: boolean;
  36329. /**
  36330. * This is used to call preventDefault() on pointer down
  36331. * in order to block unwanted artifacts like system double clicks
  36332. */
  36333. preventDefaultOnPointerDown: boolean;
  36334. /**
  36335. * This is used to call preventDefault() on pointer up
  36336. * in order to block unwanted artifacts like system double clicks
  36337. */
  36338. preventDefaultOnPointerUp: boolean;
  36339. /**
  36340. * Gets or sets user defined metadata
  36341. */
  36342. metadata: any;
  36343. /**
  36344. * For internal use only. Please do not use.
  36345. */
  36346. reservedDataStore: any;
  36347. /**
  36348. * Gets the name of the plugin used to load this scene (null by default)
  36349. */
  36350. loadingPluginName: string;
  36351. /**
  36352. * Use this array to add regular expressions used to disable offline support for specific urls
  36353. */
  36354. disableOfflineSupportExceptionRules: RegExp[];
  36355. /**
  36356. * An event triggered when the scene is disposed.
  36357. */
  36358. onDisposeObservable: Observable<Scene>;
  36359. private _onDisposeObserver;
  36360. /** Sets a function to be executed when this scene is disposed. */
  36361. set onDispose(callback: () => void);
  36362. /**
  36363. * An event triggered before rendering the scene (right after animations and physics)
  36364. */
  36365. onBeforeRenderObservable: Observable<Scene>;
  36366. private _onBeforeRenderObserver;
  36367. /** Sets a function to be executed before rendering this scene */
  36368. set beforeRender(callback: Nullable<() => void>);
  36369. /**
  36370. * An event triggered after rendering the scene
  36371. */
  36372. onAfterRenderObservable: Observable<Scene>;
  36373. /**
  36374. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36375. */
  36376. onAfterRenderCameraObservable: Observable<Camera>;
  36377. private _onAfterRenderObserver;
  36378. /** Sets a function to be executed after rendering this scene */
  36379. set afterRender(callback: Nullable<() => void>);
  36380. /**
  36381. * An event triggered before animating the scene
  36382. */
  36383. onBeforeAnimationsObservable: Observable<Scene>;
  36384. /**
  36385. * An event triggered after animations processing
  36386. */
  36387. onAfterAnimationsObservable: Observable<Scene>;
  36388. /**
  36389. * An event triggered before draw calls are ready to be sent
  36390. */
  36391. onBeforeDrawPhaseObservable: Observable<Scene>;
  36392. /**
  36393. * An event triggered after draw calls have been sent
  36394. */
  36395. onAfterDrawPhaseObservable: Observable<Scene>;
  36396. /**
  36397. * An event triggered when the scene is ready
  36398. */
  36399. onReadyObservable: Observable<Scene>;
  36400. /**
  36401. * An event triggered before rendering a camera
  36402. */
  36403. onBeforeCameraRenderObservable: Observable<Camera>;
  36404. private _onBeforeCameraRenderObserver;
  36405. /** Sets a function to be executed before rendering a camera*/
  36406. set beforeCameraRender(callback: () => void);
  36407. /**
  36408. * An event triggered after rendering a camera
  36409. */
  36410. onAfterCameraRenderObservable: Observable<Camera>;
  36411. private _onAfterCameraRenderObserver;
  36412. /** Sets a function to be executed after rendering a camera*/
  36413. set afterCameraRender(callback: () => void);
  36414. /**
  36415. * An event triggered when active meshes evaluation is about to start
  36416. */
  36417. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36418. /**
  36419. * An event triggered when active meshes evaluation is done
  36420. */
  36421. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36422. /**
  36423. * An event triggered when particles rendering is about to start
  36424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36425. */
  36426. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36427. /**
  36428. * An event triggered when particles rendering is done
  36429. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36430. */
  36431. onAfterParticlesRenderingObservable: Observable<Scene>;
  36432. /**
  36433. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36434. */
  36435. onDataLoadedObservable: Observable<Scene>;
  36436. /**
  36437. * An event triggered when a camera is created
  36438. */
  36439. onNewCameraAddedObservable: Observable<Camera>;
  36440. /**
  36441. * An event triggered when a camera is removed
  36442. */
  36443. onCameraRemovedObservable: Observable<Camera>;
  36444. /**
  36445. * An event triggered when a light is created
  36446. */
  36447. onNewLightAddedObservable: Observable<Light>;
  36448. /**
  36449. * An event triggered when a light is removed
  36450. */
  36451. onLightRemovedObservable: Observable<Light>;
  36452. /**
  36453. * An event triggered when a geometry is created
  36454. */
  36455. onNewGeometryAddedObservable: Observable<Geometry>;
  36456. /**
  36457. * An event triggered when a geometry is removed
  36458. */
  36459. onGeometryRemovedObservable: Observable<Geometry>;
  36460. /**
  36461. * An event triggered when a transform node is created
  36462. */
  36463. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36464. /**
  36465. * An event triggered when a transform node is removed
  36466. */
  36467. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36468. /**
  36469. * An event triggered when a mesh is created
  36470. */
  36471. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36472. /**
  36473. * An event triggered when a mesh is removed
  36474. */
  36475. onMeshRemovedObservable: Observable<AbstractMesh>;
  36476. /**
  36477. * An event triggered when a skeleton is created
  36478. */
  36479. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36480. /**
  36481. * An event triggered when a skeleton is removed
  36482. */
  36483. onSkeletonRemovedObservable: Observable<Skeleton>;
  36484. /**
  36485. * An event triggered when a material is created
  36486. */
  36487. onNewMaterialAddedObservable: Observable<Material>;
  36488. /**
  36489. * An event triggered when a material is removed
  36490. */
  36491. onMaterialRemovedObservable: Observable<Material>;
  36492. /**
  36493. * An event triggered when a texture is created
  36494. */
  36495. onNewTextureAddedObservable: Observable<BaseTexture>;
  36496. /**
  36497. * An event triggered when a texture is removed
  36498. */
  36499. onTextureRemovedObservable: Observable<BaseTexture>;
  36500. /**
  36501. * An event triggered when render targets are about to be rendered
  36502. * Can happen multiple times per frame.
  36503. */
  36504. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36505. /**
  36506. * An event triggered when render targets were rendered.
  36507. * Can happen multiple times per frame.
  36508. */
  36509. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36510. /**
  36511. * An event triggered before calculating deterministic simulation step
  36512. */
  36513. onBeforeStepObservable: Observable<Scene>;
  36514. /**
  36515. * An event triggered after calculating deterministic simulation step
  36516. */
  36517. onAfterStepObservable: Observable<Scene>;
  36518. /**
  36519. * An event triggered when the activeCamera property is updated
  36520. */
  36521. onActiveCameraChanged: Observable<Scene>;
  36522. /**
  36523. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36525. * 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)
  36526. */
  36527. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36528. /**
  36529. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36530. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36531. * 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)
  36532. */
  36533. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36534. /**
  36535. * This Observable will when a mesh has been imported into the scene.
  36536. */
  36537. onMeshImportedObservable: Observable<AbstractMesh>;
  36538. /**
  36539. * This Observable will when an animation file has been imported into the scene.
  36540. */
  36541. onAnimationFileImportedObservable: Observable<Scene>;
  36542. /**
  36543. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36544. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36545. */
  36546. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36547. /** @hidden */
  36548. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36549. /**
  36550. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36551. */
  36552. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36553. /**
  36554. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36555. */
  36556. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36557. /**
  36558. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36559. */
  36560. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36561. /** Callback called when a pointer move is detected */
  36562. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36563. /** Callback called when a pointer down is detected */
  36564. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36565. /** Callback called when a pointer up is detected */
  36566. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36567. /** Callback called when a pointer pick is detected */
  36568. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36569. /**
  36570. * 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).
  36571. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36572. */
  36573. onPrePointerObservable: Observable<PointerInfoPre>;
  36574. /**
  36575. * Observable event triggered each time an input event is received from the rendering canvas
  36576. */
  36577. onPointerObservable: Observable<PointerInfo>;
  36578. /**
  36579. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36580. */
  36581. get unTranslatedPointer(): Vector2;
  36582. /**
  36583. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36584. */
  36585. static get DragMovementThreshold(): number;
  36586. static set DragMovementThreshold(value: number);
  36587. /**
  36588. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36589. */
  36590. static get LongPressDelay(): number;
  36591. static set LongPressDelay(value: number);
  36592. /**
  36593. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36594. */
  36595. static get DoubleClickDelay(): number;
  36596. static set DoubleClickDelay(value: number);
  36597. /** If you need to check double click without raising a single click at first click, enable this flag */
  36598. static get ExclusiveDoubleClickMode(): boolean;
  36599. static set ExclusiveDoubleClickMode(value: boolean);
  36600. /** @hidden */
  36601. _mirroredCameraPosition: Nullable<Vector3>;
  36602. /**
  36603. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36604. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36605. */
  36606. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36607. /**
  36608. * Observable event triggered each time an keyboard event is received from the hosting window
  36609. */
  36610. onKeyboardObservable: Observable<KeyboardInfo>;
  36611. private _useRightHandedSystem;
  36612. /**
  36613. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36614. */
  36615. set useRightHandedSystem(value: boolean);
  36616. get useRightHandedSystem(): boolean;
  36617. private _timeAccumulator;
  36618. private _currentStepId;
  36619. private _currentInternalStep;
  36620. /**
  36621. * Sets the step Id used by deterministic lock step
  36622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36623. * @param newStepId defines the step Id
  36624. */
  36625. setStepId(newStepId: number): void;
  36626. /**
  36627. * Gets the step Id used by deterministic lock step
  36628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36629. * @returns the step Id
  36630. */
  36631. getStepId(): number;
  36632. /**
  36633. * Gets the internal step used by deterministic lock step
  36634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36635. * @returns the internal step
  36636. */
  36637. getInternalStep(): number;
  36638. private _fogEnabled;
  36639. /**
  36640. * Gets or sets a boolean indicating if fog is enabled on this scene
  36641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36642. * (Default is true)
  36643. */
  36644. set fogEnabled(value: boolean);
  36645. get fogEnabled(): boolean;
  36646. private _fogMode;
  36647. /**
  36648. * Gets or sets the fog mode to use
  36649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36650. * | mode | value |
  36651. * | --- | --- |
  36652. * | FOGMODE_NONE | 0 |
  36653. * | FOGMODE_EXP | 1 |
  36654. * | FOGMODE_EXP2 | 2 |
  36655. * | FOGMODE_LINEAR | 3 |
  36656. */
  36657. set fogMode(value: number);
  36658. get fogMode(): number;
  36659. /**
  36660. * Gets or sets the fog color to use
  36661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36662. * (Default is Color3(0.2, 0.2, 0.3))
  36663. */
  36664. fogColor: Color3;
  36665. /**
  36666. * Gets or sets the fog density to use
  36667. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36668. * (Default is 0.1)
  36669. */
  36670. fogDensity: number;
  36671. /**
  36672. * Gets or sets the fog start distance to use
  36673. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36674. * (Default is 0)
  36675. */
  36676. fogStart: number;
  36677. /**
  36678. * Gets or sets the fog end distance to use
  36679. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36680. * (Default is 1000)
  36681. */
  36682. fogEnd: number;
  36683. private _shadowsEnabled;
  36684. /**
  36685. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36686. */
  36687. set shadowsEnabled(value: boolean);
  36688. get shadowsEnabled(): boolean;
  36689. private _lightsEnabled;
  36690. /**
  36691. * Gets or sets a boolean indicating if lights are enabled on this scene
  36692. */
  36693. set lightsEnabled(value: boolean);
  36694. get lightsEnabled(): boolean;
  36695. /** All of the active cameras added to this scene. */
  36696. activeCameras: Camera[];
  36697. /** @hidden */
  36698. _activeCamera: Nullable<Camera>;
  36699. /** Gets or sets the current active camera */
  36700. get activeCamera(): Nullable<Camera>;
  36701. set activeCamera(value: Nullable<Camera>);
  36702. private _defaultMaterial;
  36703. /** The default material used on meshes when no material is affected */
  36704. get defaultMaterial(): Material;
  36705. /** The default material used on meshes when no material is affected */
  36706. set defaultMaterial(value: Material);
  36707. private _texturesEnabled;
  36708. /**
  36709. * Gets or sets a boolean indicating if textures are enabled on this scene
  36710. */
  36711. set texturesEnabled(value: boolean);
  36712. get texturesEnabled(): boolean;
  36713. /**
  36714. * Gets or sets a boolean indicating if particles are enabled on this scene
  36715. */
  36716. particlesEnabled: boolean;
  36717. /**
  36718. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36719. */
  36720. spritesEnabled: boolean;
  36721. private _skeletonsEnabled;
  36722. /**
  36723. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36724. */
  36725. set skeletonsEnabled(value: boolean);
  36726. get skeletonsEnabled(): boolean;
  36727. /**
  36728. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36729. */
  36730. lensFlaresEnabled: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36734. */
  36735. collisionsEnabled: boolean;
  36736. private _collisionCoordinator;
  36737. /** @hidden */
  36738. get collisionCoordinator(): ICollisionCoordinator;
  36739. /**
  36740. * Defines the gravity applied to this scene (used only for collisions)
  36741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36742. */
  36743. gravity: Vector3;
  36744. /**
  36745. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36746. */
  36747. postProcessesEnabled: boolean;
  36748. /**
  36749. * The list of postprocesses added to the scene
  36750. */
  36751. postProcesses: PostProcess[];
  36752. /**
  36753. * Gets the current postprocess manager
  36754. */
  36755. postProcessManager: PostProcessManager;
  36756. /**
  36757. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36758. */
  36759. renderTargetsEnabled: boolean;
  36760. /**
  36761. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36762. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36763. */
  36764. dumpNextRenderTargets: boolean;
  36765. /**
  36766. * The list of user defined render targets added to the scene
  36767. */
  36768. customRenderTargets: RenderTargetTexture[];
  36769. /**
  36770. * Defines if texture loading must be delayed
  36771. * If true, textures will only be loaded when they need to be rendered
  36772. */
  36773. useDelayedTextureLoading: boolean;
  36774. /**
  36775. * Gets the list of meshes imported to the scene through SceneLoader
  36776. */
  36777. importedMeshesFiles: String[];
  36778. /**
  36779. * Gets or sets a boolean indicating if probes are enabled on this scene
  36780. */
  36781. probesEnabled: boolean;
  36782. /**
  36783. * Gets or sets the current offline provider to use to store scene data
  36784. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36785. */
  36786. offlineProvider: IOfflineProvider;
  36787. /**
  36788. * Gets or sets the action manager associated with the scene
  36789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36790. */
  36791. actionManager: AbstractActionManager;
  36792. private _meshesForIntersections;
  36793. /**
  36794. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36795. */
  36796. proceduralTexturesEnabled: boolean;
  36797. private _engine;
  36798. private _totalVertices;
  36799. /** @hidden */
  36800. _activeIndices: PerfCounter;
  36801. /** @hidden */
  36802. _activeParticles: PerfCounter;
  36803. /** @hidden */
  36804. _activeBones: PerfCounter;
  36805. private _animationRatio;
  36806. /** @hidden */
  36807. _animationTimeLast: number;
  36808. /** @hidden */
  36809. _animationTime: number;
  36810. /**
  36811. * Gets or sets a general scale for animation speed
  36812. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36813. */
  36814. animationTimeScale: number;
  36815. /** @hidden */
  36816. _cachedMaterial: Nullable<Material>;
  36817. /** @hidden */
  36818. _cachedEffect: Nullable<Effect>;
  36819. /** @hidden */
  36820. _cachedVisibility: Nullable<number>;
  36821. private _renderId;
  36822. private _frameId;
  36823. private _executeWhenReadyTimeoutId;
  36824. private _intermediateRendering;
  36825. private _viewUpdateFlag;
  36826. private _projectionUpdateFlag;
  36827. /** @hidden */
  36828. _toBeDisposed: Nullable<IDisposable>[];
  36829. private _activeRequests;
  36830. /** @hidden */
  36831. _pendingData: any[];
  36832. private _isDisposed;
  36833. /**
  36834. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36835. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36836. */
  36837. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36838. private _activeMeshes;
  36839. private _processedMaterials;
  36840. private _renderTargets;
  36841. /** @hidden */
  36842. _activeParticleSystems: SmartArray<IParticleSystem>;
  36843. private _activeSkeletons;
  36844. private _softwareSkinnedMeshes;
  36845. private _renderingManager;
  36846. /** @hidden */
  36847. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36848. private _transformMatrix;
  36849. private _sceneUbo;
  36850. /** @hidden */
  36851. _viewMatrix: Matrix;
  36852. private _projectionMatrix;
  36853. /** @hidden */
  36854. _forcedViewPosition: Nullable<Vector3>;
  36855. /** @hidden */
  36856. _frustumPlanes: Plane[];
  36857. /**
  36858. * Gets the list of frustum planes (built from the active camera)
  36859. */
  36860. get frustumPlanes(): Plane[];
  36861. /**
  36862. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36863. * This is useful if there are more lights that the maximum simulteanous authorized
  36864. */
  36865. requireLightSorting: boolean;
  36866. /** @hidden */
  36867. readonly useMaterialMeshMap: boolean;
  36868. /** @hidden */
  36869. readonly useClonedMeshMap: boolean;
  36870. private _externalData;
  36871. private _uid;
  36872. /**
  36873. * @hidden
  36874. * Backing store of defined scene components.
  36875. */
  36876. _components: ISceneComponent[];
  36877. /**
  36878. * @hidden
  36879. * Backing store of defined scene components.
  36880. */
  36881. _serializableComponents: ISceneSerializableComponent[];
  36882. /**
  36883. * List of components to register on the next registration step.
  36884. */
  36885. private _transientComponents;
  36886. /**
  36887. * Registers the transient components if needed.
  36888. */
  36889. private _registerTransientComponents;
  36890. /**
  36891. * @hidden
  36892. * Add a component to the scene.
  36893. * Note that the ccomponent could be registered on th next frame if this is called after
  36894. * the register component stage.
  36895. * @param component Defines the component to add to the scene
  36896. */
  36897. _addComponent(component: ISceneComponent): void;
  36898. /**
  36899. * @hidden
  36900. * Gets a component from the scene.
  36901. * @param name defines the name of the component to retrieve
  36902. * @returns the component or null if not present
  36903. */
  36904. _getComponent(name: string): Nullable<ISceneComponent>;
  36905. /**
  36906. * @hidden
  36907. * Defines the actions happening before camera updates.
  36908. */
  36909. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36910. /**
  36911. * @hidden
  36912. * Defines the actions happening before clear the canvas.
  36913. */
  36914. _beforeClearStage: Stage<SimpleStageAction>;
  36915. /**
  36916. * @hidden
  36917. * Defines the actions when collecting render targets for the frame.
  36918. */
  36919. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36920. /**
  36921. * @hidden
  36922. * Defines the actions happening for one camera in the frame.
  36923. */
  36924. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36925. /**
  36926. * @hidden
  36927. * Defines the actions happening during the per mesh ready checks.
  36928. */
  36929. _isReadyForMeshStage: Stage<MeshStageAction>;
  36930. /**
  36931. * @hidden
  36932. * Defines the actions happening before evaluate active mesh checks.
  36933. */
  36934. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36935. /**
  36936. * @hidden
  36937. * Defines the actions happening during the evaluate sub mesh checks.
  36938. */
  36939. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36940. /**
  36941. * @hidden
  36942. * Defines the actions happening during the active mesh stage.
  36943. */
  36944. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36945. /**
  36946. * @hidden
  36947. * Defines the actions happening during the per camera render target step.
  36948. */
  36949. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36950. /**
  36951. * @hidden
  36952. * Defines the actions happening just before the active camera is drawing.
  36953. */
  36954. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36955. /**
  36956. * @hidden
  36957. * Defines the actions happening just before a render target is drawing.
  36958. */
  36959. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36960. /**
  36961. * @hidden
  36962. * Defines the actions happening just before a rendering group is drawing.
  36963. */
  36964. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36965. /**
  36966. * @hidden
  36967. * Defines the actions happening just before a mesh is drawing.
  36968. */
  36969. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36970. /**
  36971. * @hidden
  36972. * Defines the actions happening just after a mesh has been drawn.
  36973. */
  36974. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36975. /**
  36976. * @hidden
  36977. * Defines the actions happening just after a rendering group has been drawn.
  36978. */
  36979. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36980. /**
  36981. * @hidden
  36982. * Defines the actions happening just after the active camera has been drawn.
  36983. */
  36984. _afterCameraDrawStage: Stage<CameraStageAction>;
  36985. /**
  36986. * @hidden
  36987. * Defines the actions happening just after a render target has been drawn.
  36988. */
  36989. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36990. /**
  36991. * @hidden
  36992. * Defines the actions happening just after rendering all cameras and computing intersections.
  36993. */
  36994. _afterRenderStage: Stage<SimpleStageAction>;
  36995. /**
  36996. * @hidden
  36997. * Defines the actions happening when a pointer move event happens.
  36998. */
  36999. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37000. /**
  37001. * @hidden
  37002. * Defines the actions happening when a pointer down event happens.
  37003. */
  37004. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37005. /**
  37006. * @hidden
  37007. * Defines the actions happening when a pointer up event happens.
  37008. */
  37009. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37010. /**
  37011. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37012. */
  37013. private geometriesByUniqueId;
  37014. /**
  37015. * Creates a new Scene
  37016. * @param engine defines the engine to use to render this scene
  37017. * @param options defines the scene options
  37018. */
  37019. constructor(engine: Engine, options?: SceneOptions);
  37020. /**
  37021. * Gets a string idenfifying the name of the class
  37022. * @returns "Scene" string
  37023. */
  37024. getClassName(): string;
  37025. private _defaultMeshCandidates;
  37026. /**
  37027. * @hidden
  37028. */
  37029. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37030. private _defaultSubMeshCandidates;
  37031. /**
  37032. * @hidden
  37033. */
  37034. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37035. /**
  37036. * Sets the default candidate providers for the scene.
  37037. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37038. * and getCollidingSubMeshCandidates to their default function
  37039. */
  37040. setDefaultCandidateProviders(): void;
  37041. /**
  37042. * Gets the mesh that is currently under the pointer
  37043. */
  37044. get meshUnderPointer(): Nullable<AbstractMesh>;
  37045. /**
  37046. * Gets or sets the current on-screen X position of the pointer
  37047. */
  37048. get pointerX(): number;
  37049. set pointerX(value: number);
  37050. /**
  37051. * Gets or sets the current on-screen Y position of the pointer
  37052. */
  37053. get pointerY(): number;
  37054. set pointerY(value: number);
  37055. /**
  37056. * Gets the cached material (ie. the latest rendered one)
  37057. * @returns the cached material
  37058. */
  37059. getCachedMaterial(): Nullable<Material>;
  37060. /**
  37061. * Gets the cached effect (ie. the latest rendered one)
  37062. * @returns the cached effect
  37063. */
  37064. getCachedEffect(): Nullable<Effect>;
  37065. /**
  37066. * Gets the cached visibility state (ie. the latest rendered one)
  37067. * @returns the cached visibility state
  37068. */
  37069. getCachedVisibility(): Nullable<number>;
  37070. /**
  37071. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37072. * @param material defines the current material
  37073. * @param effect defines the current effect
  37074. * @param visibility defines the current visibility state
  37075. * @returns true if one parameter is not cached
  37076. */
  37077. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37078. /**
  37079. * Gets the engine associated with the scene
  37080. * @returns an Engine
  37081. */
  37082. getEngine(): Engine;
  37083. /**
  37084. * Gets the total number of vertices rendered per frame
  37085. * @returns the total number of vertices rendered per frame
  37086. */
  37087. getTotalVertices(): number;
  37088. /**
  37089. * Gets the performance counter for total vertices
  37090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37091. */
  37092. get totalVerticesPerfCounter(): PerfCounter;
  37093. /**
  37094. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37095. * @returns the total number of active indices rendered per frame
  37096. */
  37097. getActiveIndices(): number;
  37098. /**
  37099. * Gets the performance counter for active indices
  37100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37101. */
  37102. get totalActiveIndicesPerfCounter(): PerfCounter;
  37103. /**
  37104. * Gets the total number of active particles rendered per frame
  37105. * @returns the total number of active particles rendered per frame
  37106. */
  37107. getActiveParticles(): number;
  37108. /**
  37109. * Gets the performance counter for active particles
  37110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37111. */
  37112. get activeParticlesPerfCounter(): PerfCounter;
  37113. /**
  37114. * Gets the total number of active bones rendered per frame
  37115. * @returns the total number of active bones rendered per frame
  37116. */
  37117. getActiveBones(): number;
  37118. /**
  37119. * Gets the performance counter for active bones
  37120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37121. */
  37122. get activeBonesPerfCounter(): PerfCounter;
  37123. /**
  37124. * Gets the array of active meshes
  37125. * @returns an array of AbstractMesh
  37126. */
  37127. getActiveMeshes(): SmartArray<AbstractMesh>;
  37128. /**
  37129. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37130. * @returns a number
  37131. */
  37132. getAnimationRatio(): number;
  37133. /**
  37134. * Gets an unique Id for the current render phase
  37135. * @returns a number
  37136. */
  37137. getRenderId(): number;
  37138. /**
  37139. * Gets an unique Id for the current frame
  37140. * @returns a number
  37141. */
  37142. getFrameId(): number;
  37143. /** Call this function if you want to manually increment the render Id*/
  37144. incrementRenderId(): void;
  37145. private _createUbo;
  37146. /**
  37147. * Use this method to simulate a pointer move on a mesh
  37148. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37149. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37150. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37151. * @returns the current scene
  37152. */
  37153. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37154. /**
  37155. * Use this method to simulate a pointer down on a mesh
  37156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37159. * @returns the current scene
  37160. */
  37161. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37162. /**
  37163. * Use this method to simulate a pointer up on a mesh
  37164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37167. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37168. * @returns the current scene
  37169. */
  37170. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37171. /**
  37172. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37173. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37174. * @returns true if the pointer was captured
  37175. */
  37176. isPointerCaptured(pointerId?: number): boolean;
  37177. /**
  37178. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37179. * @param attachUp defines if you want to attach events to pointerup
  37180. * @param attachDown defines if you want to attach events to pointerdown
  37181. * @param attachMove defines if you want to attach events to pointermove
  37182. */
  37183. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37184. /** Detaches all event handlers*/
  37185. detachControl(): void;
  37186. /**
  37187. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37188. * Delay loaded resources are not taking in account
  37189. * @return true if all required resources are ready
  37190. */
  37191. isReady(): boolean;
  37192. /** Resets all cached information relative to material (including effect and visibility) */
  37193. resetCachedMaterial(): void;
  37194. /**
  37195. * Registers a function to be called before every frame render
  37196. * @param func defines the function to register
  37197. */
  37198. registerBeforeRender(func: () => void): void;
  37199. /**
  37200. * Unregisters a function called before every frame render
  37201. * @param func defines the function to unregister
  37202. */
  37203. unregisterBeforeRender(func: () => void): void;
  37204. /**
  37205. * Registers a function to be called after every frame render
  37206. * @param func defines the function to register
  37207. */
  37208. registerAfterRender(func: () => void): void;
  37209. /**
  37210. * Unregisters a function called after every frame render
  37211. * @param func defines the function to unregister
  37212. */
  37213. unregisterAfterRender(func: () => void): void;
  37214. private _executeOnceBeforeRender;
  37215. /**
  37216. * The provided function will run before render once and will be disposed afterwards.
  37217. * A timeout delay can be provided so that the function will be executed in N ms.
  37218. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37219. * @param func The function to be executed.
  37220. * @param timeout optional delay in ms
  37221. */
  37222. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37223. /** @hidden */
  37224. _addPendingData(data: any): void;
  37225. /** @hidden */
  37226. _removePendingData(data: any): void;
  37227. /**
  37228. * Returns the number of items waiting to be loaded
  37229. * @returns the number of items waiting to be loaded
  37230. */
  37231. getWaitingItemsCount(): number;
  37232. /**
  37233. * Returns a boolean indicating if the scene is still loading data
  37234. */
  37235. get isLoading(): boolean;
  37236. /**
  37237. * Registers a function to be executed when the scene is ready
  37238. * @param {Function} func - the function to be executed
  37239. */
  37240. executeWhenReady(func: () => void): void;
  37241. /**
  37242. * Returns a promise that resolves when the scene is ready
  37243. * @returns A promise that resolves when the scene is ready
  37244. */
  37245. whenReadyAsync(): Promise<void>;
  37246. /** @hidden */
  37247. _checkIsReady(): void;
  37248. /**
  37249. * Gets all animatable attached to the scene
  37250. */
  37251. get animatables(): Animatable[];
  37252. /**
  37253. * Resets the last animation time frame.
  37254. * Useful to override when animations start running when loading a scene for the first time.
  37255. */
  37256. resetLastAnimationTimeFrame(): void;
  37257. /**
  37258. * Gets the current view matrix
  37259. * @returns a Matrix
  37260. */
  37261. getViewMatrix(): Matrix;
  37262. /**
  37263. * Gets the current projection matrix
  37264. * @returns a Matrix
  37265. */
  37266. getProjectionMatrix(): Matrix;
  37267. /**
  37268. * Gets the current transform matrix
  37269. * @returns a Matrix made of View * Projection
  37270. */
  37271. getTransformMatrix(): Matrix;
  37272. /**
  37273. * Sets the current transform matrix
  37274. * @param viewL defines the View matrix to use
  37275. * @param projectionL defines the Projection matrix to use
  37276. * @param viewR defines the right View matrix to use (if provided)
  37277. * @param projectionR defines the right Projection matrix to use (if provided)
  37278. */
  37279. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37280. /**
  37281. * Gets the uniform buffer used to store scene data
  37282. * @returns a UniformBuffer
  37283. */
  37284. getSceneUniformBuffer(): UniformBuffer;
  37285. /**
  37286. * Gets an unique (relatively to the current scene) Id
  37287. * @returns an unique number for the scene
  37288. */
  37289. getUniqueId(): number;
  37290. /**
  37291. * Add a mesh to the list of scene's meshes
  37292. * @param newMesh defines the mesh to add
  37293. * @param recursive if all child meshes should also be added to the scene
  37294. */
  37295. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37296. /**
  37297. * Remove a mesh for the list of scene's meshes
  37298. * @param toRemove defines the mesh to remove
  37299. * @param recursive if all child meshes should also be removed from the scene
  37300. * @returns the index where the mesh was in the mesh list
  37301. */
  37302. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37303. /**
  37304. * Add a transform node to the list of scene's transform nodes
  37305. * @param newTransformNode defines the transform node to add
  37306. */
  37307. addTransformNode(newTransformNode: TransformNode): void;
  37308. /**
  37309. * Remove a transform node for the list of scene's transform nodes
  37310. * @param toRemove defines the transform node to remove
  37311. * @returns the index where the transform node was in the transform node list
  37312. */
  37313. removeTransformNode(toRemove: TransformNode): number;
  37314. /**
  37315. * Remove a skeleton for the list of scene's skeletons
  37316. * @param toRemove defines the skeleton to remove
  37317. * @returns the index where the skeleton was in the skeleton list
  37318. */
  37319. removeSkeleton(toRemove: Skeleton): number;
  37320. /**
  37321. * Remove a morph target for the list of scene's morph targets
  37322. * @param toRemove defines the morph target to remove
  37323. * @returns the index where the morph target was in the morph target list
  37324. */
  37325. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37326. /**
  37327. * Remove a light for the list of scene's lights
  37328. * @param toRemove defines the light to remove
  37329. * @returns the index where the light was in the light list
  37330. */
  37331. removeLight(toRemove: Light): number;
  37332. /**
  37333. * Remove a camera for the list of scene's cameras
  37334. * @param toRemove defines the camera to remove
  37335. * @returns the index where the camera was in the camera list
  37336. */
  37337. removeCamera(toRemove: Camera): number;
  37338. /**
  37339. * Remove a particle system for the list of scene's particle systems
  37340. * @param toRemove defines the particle system to remove
  37341. * @returns the index where the particle system was in the particle system list
  37342. */
  37343. removeParticleSystem(toRemove: IParticleSystem): number;
  37344. /**
  37345. * Remove a animation for the list of scene's animations
  37346. * @param toRemove defines the animation to remove
  37347. * @returns the index where the animation was in the animation list
  37348. */
  37349. removeAnimation(toRemove: Animation): number;
  37350. /**
  37351. * Will stop the animation of the given target
  37352. * @param target - the target
  37353. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37354. * @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)
  37355. */
  37356. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37357. /**
  37358. * Removes the given animation group from this scene.
  37359. * @param toRemove The animation group to remove
  37360. * @returns The index of the removed animation group
  37361. */
  37362. removeAnimationGroup(toRemove: AnimationGroup): number;
  37363. /**
  37364. * Removes the given multi-material from this scene.
  37365. * @param toRemove The multi-material to remove
  37366. * @returns The index of the removed multi-material
  37367. */
  37368. removeMultiMaterial(toRemove: MultiMaterial): number;
  37369. /**
  37370. * Removes the given material from this scene.
  37371. * @param toRemove The material to remove
  37372. * @returns The index of the removed material
  37373. */
  37374. removeMaterial(toRemove: Material): number;
  37375. /**
  37376. * Removes the given action manager from this scene.
  37377. * @param toRemove The action manager to remove
  37378. * @returns The index of the removed action manager
  37379. */
  37380. removeActionManager(toRemove: AbstractActionManager): number;
  37381. /**
  37382. * Removes the given texture from this scene.
  37383. * @param toRemove The texture to remove
  37384. * @returns The index of the removed texture
  37385. */
  37386. removeTexture(toRemove: BaseTexture): number;
  37387. /**
  37388. * Adds the given light to this scene
  37389. * @param newLight The light to add
  37390. */
  37391. addLight(newLight: Light): void;
  37392. /**
  37393. * Sorts the list list based on light priorities
  37394. */
  37395. sortLightsByPriority(): void;
  37396. /**
  37397. * Adds the given camera to this scene
  37398. * @param newCamera The camera to add
  37399. */
  37400. addCamera(newCamera: Camera): void;
  37401. /**
  37402. * Adds the given skeleton to this scene
  37403. * @param newSkeleton The skeleton to add
  37404. */
  37405. addSkeleton(newSkeleton: Skeleton): void;
  37406. /**
  37407. * Adds the given particle system to this scene
  37408. * @param newParticleSystem The particle system to add
  37409. */
  37410. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37411. /**
  37412. * Adds the given animation to this scene
  37413. * @param newAnimation The animation to add
  37414. */
  37415. addAnimation(newAnimation: Animation): void;
  37416. /**
  37417. * Adds the given animation group to this scene.
  37418. * @param newAnimationGroup The animation group to add
  37419. */
  37420. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37421. /**
  37422. * Adds the given multi-material to this scene
  37423. * @param newMultiMaterial The multi-material to add
  37424. */
  37425. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37426. /**
  37427. * Adds the given material to this scene
  37428. * @param newMaterial The material to add
  37429. */
  37430. addMaterial(newMaterial: Material): void;
  37431. /**
  37432. * Adds the given morph target to this scene
  37433. * @param newMorphTargetManager The morph target to add
  37434. */
  37435. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37436. /**
  37437. * Adds the given geometry to this scene
  37438. * @param newGeometry The geometry to add
  37439. */
  37440. addGeometry(newGeometry: Geometry): void;
  37441. /**
  37442. * Adds the given action manager to this scene
  37443. * @param newActionManager The action manager to add
  37444. */
  37445. addActionManager(newActionManager: AbstractActionManager): void;
  37446. /**
  37447. * Adds the given texture to this scene.
  37448. * @param newTexture The texture to add
  37449. */
  37450. addTexture(newTexture: BaseTexture): void;
  37451. /**
  37452. * Switch active camera
  37453. * @param newCamera defines the new active camera
  37454. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37455. */
  37456. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37457. /**
  37458. * sets the active camera of the scene using its ID
  37459. * @param id defines the camera's ID
  37460. * @return the new active camera or null if none found.
  37461. */
  37462. setActiveCameraByID(id: string): Nullable<Camera>;
  37463. /**
  37464. * sets the active camera of the scene using its name
  37465. * @param name defines the camera's name
  37466. * @returns the new active camera or null if none found.
  37467. */
  37468. setActiveCameraByName(name: string): Nullable<Camera>;
  37469. /**
  37470. * get an animation group using its name
  37471. * @param name defines the material's name
  37472. * @return the animation group or null if none found.
  37473. */
  37474. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37475. /**
  37476. * Get a material using its unique id
  37477. * @param uniqueId defines the material's unique id
  37478. * @return the material or null if none found.
  37479. */
  37480. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37481. /**
  37482. * get a material using its id
  37483. * @param id defines the material's ID
  37484. * @return the material or null if none found.
  37485. */
  37486. getMaterialByID(id: string): Nullable<Material>;
  37487. /**
  37488. * Gets a the last added material using a given id
  37489. * @param id defines the material's ID
  37490. * @return the last material with the given id or null if none found.
  37491. */
  37492. getLastMaterialByID(id: string): Nullable<Material>;
  37493. /**
  37494. * Gets a material using its name
  37495. * @param name defines the material's name
  37496. * @return the material or null if none found.
  37497. */
  37498. getMaterialByName(name: string): Nullable<Material>;
  37499. /**
  37500. * Get a texture using its unique id
  37501. * @param uniqueId defines the texture's unique id
  37502. * @return the texture or null if none found.
  37503. */
  37504. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37505. /**
  37506. * Gets a camera using its id
  37507. * @param id defines the id to look for
  37508. * @returns the camera or null if not found
  37509. */
  37510. getCameraByID(id: string): Nullable<Camera>;
  37511. /**
  37512. * Gets a camera using its unique id
  37513. * @param uniqueId defines the unique id to look for
  37514. * @returns the camera or null if not found
  37515. */
  37516. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37517. /**
  37518. * Gets a camera using its name
  37519. * @param name defines the camera's name
  37520. * @return the camera or null if none found.
  37521. */
  37522. getCameraByName(name: string): Nullable<Camera>;
  37523. /**
  37524. * Gets a bone using its id
  37525. * @param id defines the bone's id
  37526. * @return the bone or null if not found
  37527. */
  37528. getBoneByID(id: string): Nullable<Bone>;
  37529. /**
  37530. * Gets a bone using its id
  37531. * @param name defines the bone's name
  37532. * @return the bone or null if not found
  37533. */
  37534. getBoneByName(name: string): Nullable<Bone>;
  37535. /**
  37536. * Gets a light node using its name
  37537. * @param name defines the the light's name
  37538. * @return the light or null if none found.
  37539. */
  37540. getLightByName(name: string): Nullable<Light>;
  37541. /**
  37542. * Gets a light node using its id
  37543. * @param id defines the light's id
  37544. * @return the light or null if none found.
  37545. */
  37546. getLightByID(id: string): Nullable<Light>;
  37547. /**
  37548. * Gets a light node using its scene-generated unique ID
  37549. * @param uniqueId defines the light's unique id
  37550. * @return the light or null if none found.
  37551. */
  37552. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37553. /**
  37554. * Gets a particle system by id
  37555. * @param id defines the particle system id
  37556. * @return the corresponding system or null if none found
  37557. */
  37558. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37559. /**
  37560. * Gets a geometry using its ID
  37561. * @param id defines the geometry's id
  37562. * @return the geometry or null if none found.
  37563. */
  37564. getGeometryByID(id: string): Nullable<Geometry>;
  37565. private _getGeometryByUniqueID;
  37566. /**
  37567. * Add a new geometry to this scene
  37568. * @param geometry defines the geometry to be added to the scene.
  37569. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37570. * @return a boolean defining if the geometry was added or not
  37571. */
  37572. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37573. /**
  37574. * Removes an existing geometry
  37575. * @param geometry defines the geometry to be removed from the scene
  37576. * @return a boolean defining if the geometry was removed or not
  37577. */
  37578. removeGeometry(geometry: Geometry): boolean;
  37579. /**
  37580. * Gets the list of geometries attached to the scene
  37581. * @returns an array of Geometry
  37582. */
  37583. getGeometries(): Geometry[];
  37584. /**
  37585. * Gets the first added mesh found of a given ID
  37586. * @param id defines the id to search for
  37587. * @return the mesh found or null if not found at all
  37588. */
  37589. getMeshByID(id: string): Nullable<AbstractMesh>;
  37590. /**
  37591. * Gets a list of meshes using their id
  37592. * @param id defines the id to search for
  37593. * @returns a list of meshes
  37594. */
  37595. getMeshesByID(id: string): Array<AbstractMesh>;
  37596. /**
  37597. * Gets the first added transform node found of a given ID
  37598. * @param id defines the id to search for
  37599. * @return the found transform node or null if not found at all.
  37600. */
  37601. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37602. /**
  37603. * Gets a transform node with its auto-generated unique id
  37604. * @param uniqueId efines the unique id to search for
  37605. * @return the found transform node or null if not found at all.
  37606. */
  37607. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37608. /**
  37609. * Gets a list of transform nodes using their id
  37610. * @param id defines the id to search for
  37611. * @returns a list of transform nodes
  37612. */
  37613. getTransformNodesByID(id: string): Array<TransformNode>;
  37614. /**
  37615. * Gets a mesh with its auto-generated unique id
  37616. * @param uniqueId defines the unique id to search for
  37617. * @return the found mesh or null if not found at all.
  37618. */
  37619. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37620. /**
  37621. * Gets a the last added mesh using a given id
  37622. * @param id defines the id to search for
  37623. * @return the found mesh or null if not found at all.
  37624. */
  37625. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37626. /**
  37627. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37628. * @param id defines the id to search for
  37629. * @return the found node or null if not found at all
  37630. */
  37631. getLastEntryByID(id: string): Nullable<Node>;
  37632. /**
  37633. * Gets a node (Mesh, Camera, Light) using a given id
  37634. * @param id defines the id to search for
  37635. * @return the found node or null if not found at all
  37636. */
  37637. getNodeByID(id: string): Nullable<Node>;
  37638. /**
  37639. * Gets a node (Mesh, Camera, Light) using a given name
  37640. * @param name defines the name to search for
  37641. * @return the found node or null if not found at all.
  37642. */
  37643. getNodeByName(name: string): Nullable<Node>;
  37644. /**
  37645. * Gets a mesh using a given name
  37646. * @param name defines the name to search for
  37647. * @return the found mesh or null if not found at all.
  37648. */
  37649. getMeshByName(name: string): Nullable<AbstractMesh>;
  37650. /**
  37651. * Gets a transform node using a given name
  37652. * @param name defines the name to search for
  37653. * @return the found transform node or null if not found at all.
  37654. */
  37655. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37656. /**
  37657. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37658. * @param id defines the id to search for
  37659. * @return the found skeleton or null if not found at all.
  37660. */
  37661. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37662. /**
  37663. * Gets a skeleton using a given auto generated unique id
  37664. * @param uniqueId defines the unique id to search for
  37665. * @return the found skeleton or null if not found at all.
  37666. */
  37667. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37668. /**
  37669. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37670. * @param id defines the id to search for
  37671. * @return the found skeleton or null if not found at all.
  37672. */
  37673. getSkeletonById(id: string): Nullable<Skeleton>;
  37674. /**
  37675. * Gets a skeleton using a given name
  37676. * @param name defines the name to search for
  37677. * @return the found skeleton or null if not found at all.
  37678. */
  37679. getSkeletonByName(name: string): Nullable<Skeleton>;
  37680. /**
  37681. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37682. * @param id defines the id to search for
  37683. * @return the found morph target manager or null if not found at all.
  37684. */
  37685. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37686. /**
  37687. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37688. * @param id defines the id to search for
  37689. * @return the found morph target or null if not found at all.
  37690. */
  37691. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37692. /**
  37693. * Gets a boolean indicating if the given mesh is active
  37694. * @param mesh defines the mesh to look for
  37695. * @returns true if the mesh is in the active list
  37696. */
  37697. isActiveMesh(mesh: AbstractMesh): boolean;
  37698. /**
  37699. * Return a unique id as a string which can serve as an identifier for the scene
  37700. */
  37701. get uid(): string;
  37702. /**
  37703. * Add an externaly attached data from its key.
  37704. * This method call will fail and return false, if such key already exists.
  37705. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37706. * @param key the unique key that identifies the data
  37707. * @param data the data object to associate to the key for this Engine instance
  37708. * @return true if no such key were already present and the data was added successfully, false otherwise
  37709. */
  37710. addExternalData<T>(key: string, data: T): boolean;
  37711. /**
  37712. * Get an externaly attached data from its key
  37713. * @param key the unique key that identifies the data
  37714. * @return the associated data, if present (can be null), or undefined if not present
  37715. */
  37716. getExternalData<T>(key: string): Nullable<T>;
  37717. /**
  37718. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37719. * @param key the unique key that identifies the data
  37720. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37721. * @return the associated data, can be null if the factory returned null.
  37722. */
  37723. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37724. /**
  37725. * Remove an externaly attached data from the Engine instance
  37726. * @param key the unique key that identifies the data
  37727. * @return true if the data was successfully removed, false if it doesn't exist
  37728. */
  37729. removeExternalData(key: string): boolean;
  37730. private _evaluateSubMesh;
  37731. /**
  37732. * Clear the processed materials smart array preventing retention point in material dispose.
  37733. */
  37734. freeProcessedMaterials(): void;
  37735. private _preventFreeActiveMeshesAndRenderingGroups;
  37736. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37737. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37738. * when disposing several meshes in a row or a hierarchy of meshes.
  37739. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37740. */
  37741. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37742. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37743. /**
  37744. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37745. */
  37746. freeActiveMeshes(): void;
  37747. /**
  37748. * Clear the info related to rendering groups preventing retention points during dispose.
  37749. */
  37750. freeRenderingGroups(): void;
  37751. /** @hidden */
  37752. _isInIntermediateRendering(): boolean;
  37753. /**
  37754. * Lambda returning the list of potentially active meshes.
  37755. */
  37756. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37757. /**
  37758. * Lambda returning the list of potentially active sub meshes.
  37759. */
  37760. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37761. /**
  37762. * Lambda returning the list of potentially intersecting sub meshes.
  37763. */
  37764. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37765. /**
  37766. * Lambda returning the list of potentially colliding sub meshes.
  37767. */
  37768. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37769. private _activeMeshesFrozen;
  37770. private _skipEvaluateActiveMeshesCompletely;
  37771. /**
  37772. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37773. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37774. * @returns the current scene
  37775. */
  37776. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37777. /**
  37778. * Use this function to restart evaluating active meshes on every frame
  37779. * @returns the current scene
  37780. */
  37781. unfreezeActiveMeshes(): Scene;
  37782. private _evaluateActiveMeshes;
  37783. private _activeMesh;
  37784. /**
  37785. * Update the transform matrix to update from the current active camera
  37786. * @param force defines a boolean used to force the update even if cache is up to date
  37787. */
  37788. updateTransformMatrix(force?: boolean): void;
  37789. private _bindFrameBuffer;
  37790. /** @hidden */
  37791. _allowPostProcessClearColor: boolean;
  37792. /** @hidden */
  37793. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37794. private _processSubCameras;
  37795. private _checkIntersections;
  37796. /** @hidden */
  37797. _advancePhysicsEngineStep(step: number): void;
  37798. /**
  37799. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37800. */
  37801. getDeterministicFrameTime: () => number;
  37802. /** @hidden */
  37803. _animate(): void;
  37804. /** Execute all animations (for a frame) */
  37805. animate(): void;
  37806. /**
  37807. * Render the scene
  37808. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37809. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37810. */
  37811. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37812. /**
  37813. * Freeze all materials
  37814. * A frozen material will not be updatable but should be faster to render
  37815. */
  37816. freezeMaterials(): void;
  37817. /**
  37818. * Unfreeze all materials
  37819. * A frozen material will not be updatable but should be faster to render
  37820. */
  37821. unfreezeMaterials(): void;
  37822. /**
  37823. * Releases all held ressources
  37824. */
  37825. dispose(): void;
  37826. /**
  37827. * Gets if the scene is already disposed
  37828. */
  37829. get isDisposed(): boolean;
  37830. /**
  37831. * Call this function to reduce memory footprint of the scene.
  37832. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37833. */
  37834. clearCachedVertexData(): void;
  37835. /**
  37836. * This function will remove the local cached buffer data from texture.
  37837. * It will save memory but will prevent the texture from being rebuilt
  37838. */
  37839. cleanCachedTextureBuffer(): void;
  37840. /**
  37841. * Get the world extend vectors with an optional filter
  37842. *
  37843. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37844. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37845. */
  37846. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37847. min: Vector3;
  37848. max: Vector3;
  37849. };
  37850. /**
  37851. * Creates a ray that can be used to pick in the scene
  37852. * @param x defines the x coordinate of the origin (on-screen)
  37853. * @param y defines the y coordinate of the origin (on-screen)
  37854. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37855. * @param camera defines the camera to use for the picking
  37856. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37857. * @returns a Ray
  37858. */
  37859. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37860. /**
  37861. * Creates a ray that can be used to pick in the scene
  37862. * @param x defines the x coordinate of the origin (on-screen)
  37863. * @param y defines the y coordinate of the origin (on-screen)
  37864. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37865. * @param result defines the ray where to store the picking ray
  37866. * @param camera defines the camera to use for the picking
  37867. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37868. * @returns the current scene
  37869. */
  37870. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37871. /**
  37872. * Creates a ray that can be used to pick in the scene
  37873. * @param x defines the x coordinate of the origin (on-screen)
  37874. * @param y defines the y coordinate of the origin (on-screen)
  37875. * @param camera defines the camera to use for the picking
  37876. * @returns a Ray
  37877. */
  37878. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37879. /**
  37880. * Creates a ray that can be used to pick in the scene
  37881. * @param x defines the x coordinate of the origin (on-screen)
  37882. * @param y defines the y coordinate of the origin (on-screen)
  37883. * @param result defines the ray where to store the picking ray
  37884. * @param camera defines the camera to use for the picking
  37885. * @returns the current scene
  37886. */
  37887. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37888. /** Launch a ray to try to pick a mesh in the scene
  37889. * @param x position on screen
  37890. * @param y position on screen
  37891. * @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
  37892. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37893. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37895. * @returns a PickingInfo
  37896. */
  37897. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37898. /** Use the given ray to pick a mesh in the scene
  37899. * @param ray The ray to use to pick meshes
  37900. * @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
  37901. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37903. * @returns a PickingInfo
  37904. */
  37905. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37906. /**
  37907. * Launch a ray to try to pick a mesh in the scene
  37908. * @param x X position on screen
  37909. * @param y Y position on screen
  37910. * @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
  37911. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37913. * @returns an array of PickingInfo
  37914. */
  37915. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37916. /**
  37917. * Launch a ray to try to pick a mesh in the scene
  37918. * @param ray Ray to use
  37919. * @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
  37920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37921. * @returns an array of PickingInfo
  37922. */
  37923. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37924. /**
  37925. * Force the value of meshUnderPointer
  37926. * @param mesh defines the mesh to use
  37927. */
  37928. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37929. /**
  37930. * Gets the mesh under the pointer
  37931. * @returns a Mesh or null if no mesh is under the pointer
  37932. */
  37933. getPointerOverMesh(): Nullable<AbstractMesh>;
  37934. /** @hidden */
  37935. _rebuildGeometries(): void;
  37936. /** @hidden */
  37937. _rebuildTextures(): void;
  37938. private _getByTags;
  37939. /**
  37940. * Get a list of meshes by tags
  37941. * @param tagsQuery defines the tags query to use
  37942. * @param forEach defines a predicate used to filter results
  37943. * @returns an array of Mesh
  37944. */
  37945. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37946. /**
  37947. * Get a list of cameras by tags
  37948. * @param tagsQuery defines the tags query to use
  37949. * @param forEach defines a predicate used to filter results
  37950. * @returns an array of Camera
  37951. */
  37952. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37953. /**
  37954. * Get a list of lights by tags
  37955. * @param tagsQuery defines the tags query to use
  37956. * @param forEach defines a predicate used to filter results
  37957. * @returns an array of Light
  37958. */
  37959. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37960. /**
  37961. * Get a list of materials by tags
  37962. * @param tagsQuery defines the tags query to use
  37963. * @param forEach defines a predicate used to filter results
  37964. * @returns an array of Material
  37965. */
  37966. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37967. /**
  37968. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37969. * This allowed control for front to back rendering or reversly depending of the special needs.
  37970. *
  37971. * @param renderingGroupId The rendering group id corresponding to its index
  37972. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37973. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37974. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37975. */
  37976. 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;
  37977. /**
  37978. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37979. *
  37980. * @param renderingGroupId The rendering group id corresponding to its index
  37981. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37982. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37983. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37984. */
  37985. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37986. /**
  37987. * Gets the current auto clear configuration for one rendering group of the rendering
  37988. * manager.
  37989. * @param index the rendering group index to get the information for
  37990. * @returns The auto clear setup for the requested rendering group
  37991. */
  37992. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37993. private _blockMaterialDirtyMechanism;
  37994. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37995. get blockMaterialDirtyMechanism(): boolean;
  37996. set blockMaterialDirtyMechanism(value: boolean);
  37997. /**
  37998. * Will flag all materials as dirty to trigger new shader compilation
  37999. * @param flag defines the flag used to specify which material part must be marked as dirty
  38000. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38001. */
  38002. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38003. /** @hidden */
  38004. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38005. /** @hidden */
  38006. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38007. /** @hidden */
  38008. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38009. /** @hidden */
  38010. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38011. /** @hidden */
  38012. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38013. /** @hidden */
  38014. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38015. }
  38016. }
  38017. declare module "babylonjs/assetContainer" {
  38018. import { AbstractScene } from "babylonjs/abstractScene";
  38019. import { Scene } from "babylonjs/scene";
  38020. import { Mesh } from "babylonjs/Meshes/mesh";
  38021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38022. import { Skeleton } from "babylonjs/Bones/skeleton";
  38023. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38024. import { Animatable } from "babylonjs/Animations/animatable";
  38025. import { Nullable } from "babylonjs/types";
  38026. import { Node } from "babylonjs/node";
  38027. /**
  38028. * Set of assets to keep when moving a scene into an asset container.
  38029. */
  38030. export class KeepAssets extends AbstractScene {
  38031. }
  38032. /**
  38033. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38034. */
  38035. export class InstantiatedEntries {
  38036. /**
  38037. * List of new root nodes (eg. nodes with no parent)
  38038. */
  38039. rootNodes: TransformNode[];
  38040. /**
  38041. * List of new skeletons
  38042. */
  38043. skeletons: Skeleton[];
  38044. /**
  38045. * List of new animation groups
  38046. */
  38047. animationGroups: AnimationGroup[];
  38048. }
  38049. /**
  38050. * Container with a set of assets that can be added or removed from a scene.
  38051. */
  38052. export class AssetContainer extends AbstractScene {
  38053. private _wasAddedToScene;
  38054. /**
  38055. * The scene the AssetContainer belongs to.
  38056. */
  38057. scene: Scene;
  38058. /**
  38059. * Instantiates an AssetContainer.
  38060. * @param scene The scene the AssetContainer belongs to.
  38061. */
  38062. constructor(scene: Scene);
  38063. /**
  38064. * Instantiate or clone all meshes and add the new ones to the scene.
  38065. * Skeletons and animation groups will all be cloned
  38066. * @param nameFunction defines an optional function used to get new names for clones
  38067. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38068. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38069. */
  38070. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38071. /**
  38072. * Adds all the assets from the container to the scene.
  38073. */
  38074. addAllToScene(): void;
  38075. /**
  38076. * Removes all the assets in the container from the scene
  38077. */
  38078. removeAllFromScene(): void;
  38079. /**
  38080. * Disposes all the assets in the container
  38081. */
  38082. dispose(): void;
  38083. private _moveAssets;
  38084. /**
  38085. * Removes all the assets contained in the scene and adds them to the container.
  38086. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38087. */
  38088. moveAllFromScene(keepAssets?: KeepAssets): void;
  38089. /**
  38090. * 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.
  38091. * @returns the root mesh
  38092. */
  38093. createRootMesh(): Mesh;
  38094. /**
  38095. * Merge animations from this asset container into a scene
  38096. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38097. * @param animatables set of animatables to retarget to a node from the scene
  38098. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38099. */
  38100. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38101. }
  38102. }
  38103. declare module "babylonjs/abstractScene" {
  38104. import { Scene } from "babylonjs/scene";
  38105. import { Nullable } from "babylonjs/types";
  38106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38107. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38108. import { Geometry } from "babylonjs/Meshes/geometry";
  38109. import { Skeleton } from "babylonjs/Bones/skeleton";
  38110. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38111. import { AssetContainer } from "babylonjs/assetContainer";
  38112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38113. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38115. import { Material } from "babylonjs/Materials/material";
  38116. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38117. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38118. import { Camera } from "babylonjs/Cameras/camera";
  38119. import { Light } from "babylonjs/Lights/light";
  38120. import { Node } from "babylonjs/node";
  38121. import { Animation } from "babylonjs/Animations/animation";
  38122. /**
  38123. * Defines how the parser contract is defined.
  38124. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38125. */
  38126. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38127. /**
  38128. * Defines how the individual parser contract is defined.
  38129. * These parser can parse an individual asset
  38130. */
  38131. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38132. /**
  38133. * Base class of the scene acting as a container for the different elements composing a scene.
  38134. * This class is dynamically extended by the different components of the scene increasing
  38135. * flexibility and reducing coupling
  38136. */
  38137. export abstract class AbstractScene {
  38138. /**
  38139. * Stores the list of available parsers in the application.
  38140. */
  38141. private static _BabylonFileParsers;
  38142. /**
  38143. * Stores the list of available individual parsers in the application.
  38144. */
  38145. private static _IndividualBabylonFileParsers;
  38146. /**
  38147. * Adds a parser in the list of available ones
  38148. * @param name Defines the name of the parser
  38149. * @param parser Defines the parser to add
  38150. */
  38151. static AddParser(name: string, parser: BabylonFileParser): void;
  38152. /**
  38153. * Gets a general parser from the list of avaialble ones
  38154. * @param name Defines the name of the parser
  38155. * @returns the requested parser or null
  38156. */
  38157. static GetParser(name: string): Nullable<BabylonFileParser>;
  38158. /**
  38159. * Adds n individual parser in the list of available ones
  38160. * @param name Defines the name of the parser
  38161. * @param parser Defines the parser to add
  38162. */
  38163. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38164. /**
  38165. * Gets an individual parser from the list of avaialble ones
  38166. * @param name Defines the name of the parser
  38167. * @returns the requested parser or null
  38168. */
  38169. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38170. /**
  38171. * Parser json data and populate both a scene and its associated container object
  38172. * @param jsonData Defines the data to parse
  38173. * @param scene Defines the scene to parse the data for
  38174. * @param container Defines the container attached to the parsing sequence
  38175. * @param rootUrl Defines the root url of the data
  38176. */
  38177. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38178. /**
  38179. * Gets the list of root nodes (ie. nodes with no parent)
  38180. */
  38181. rootNodes: Node[];
  38182. /** All of the cameras added to this scene
  38183. * @see http://doc.babylonjs.com/babylon101/cameras
  38184. */
  38185. cameras: Camera[];
  38186. /**
  38187. * All of the lights added to this scene
  38188. * @see http://doc.babylonjs.com/babylon101/lights
  38189. */
  38190. lights: Light[];
  38191. /**
  38192. * All of the (abstract) meshes added to this scene
  38193. */
  38194. meshes: AbstractMesh[];
  38195. /**
  38196. * The list of skeletons added to the scene
  38197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38198. */
  38199. skeletons: Skeleton[];
  38200. /**
  38201. * All of the particle systems added to this scene
  38202. * @see http://doc.babylonjs.com/babylon101/particles
  38203. */
  38204. particleSystems: IParticleSystem[];
  38205. /**
  38206. * Gets a list of Animations associated with the scene
  38207. */
  38208. animations: Animation[];
  38209. /**
  38210. * All of the animation groups added to this scene
  38211. * @see http://doc.babylonjs.com/how_to/group
  38212. */
  38213. animationGroups: AnimationGroup[];
  38214. /**
  38215. * All of the multi-materials added to this scene
  38216. * @see http://doc.babylonjs.com/how_to/multi_materials
  38217. */
  38218. multiMaterials: MultiMaterial[];
  38219. /**
  38220. * All of the materials added to this scene
  38221. * In the context of a Scene, it is not supposed to be modified manually.
  38222. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38223. * Note also that the order of the Material within the array is not significant and might change.
  38224. * @see http://doc.babylonjs.com/babylon101/materials
  38225. */
  38226. materials: Material[];
  38227. /**
  38228. * The list of morph target managers added to the scene
  38229. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38230. */
  38231. morphTargetManagers: MorphTargetManager[];
  38232. /**
  38233. * The list of geometries used in the scene.
  38234. */
  38235. geometries: Geometry[];
  38236. /**
  38237. * All of the tranform nodes added to this scene
  38238. * In the context of a Scene, it is not supposed to be modified manually.
  38239. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38240. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38241. * @see http://doc.babylonjs.com/how_to/transformnode
  38242. */
  38243. transformNodes: TransformNode[];
  38244. /**
  38245. * ActionManagers available on the scene.
  38246. */
  38247. actionManagers: AbstractActionManager[];
  38248. /**
  38249. * Textures to keep.
  38250. */
  38251. textures: BaseTexture[];
  38252. /**
  38253. * Environment texture for the scene
  38254. */
  38255. environmentTexture: Nullable<BaseTexture>;
  38256. /**
  38257. * @returns all meshes, lights, cameras, transformNodes and bones
  38258. */
  38259. getNodes(): Array<Node>;
  38260. }
  38261. }
  38262. declare module "babylonjs/Audio/sound" {
  38263. import { Observable } from "babylonjs/Misc/observable";
  38264. import { Vector3 } from "babylonjs/Maths/math.vector";
  38265. import { Nullable } from "babylonjs/types";
  38266. import { Scene } from "babylonjs/scene";
  38267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38268. /**
  38269. * Interface used to define options for Sound class
  38270. */
  38271. export interface ISoundOptions {
  38272. /**
  38273. * Does the sound autoplay once loaded.
  38274. */
  38275. autoplay?: boolean;
  38276. /**
  38277. * Does the sound loop after it finishes playing once.
  38278. */
  38279. loop?: boolean;
  38280. /**
  38281. * Sound's volume
  38282. */
  38283. volume?: number;
  38284. /**
  38285. * Is it a spatial sound?
  38286. */
  38287. spatialSound?: boolean;
  38288. /**
  38289. * Maximum distance to hear that sound
  38290. */
  38291. maxDistance?: number;
  38292. /**
  38293. * Uses user defined attenuation function
  38294. */
  38295. useCustomAttenuation?: boolean;
  38296. /**
  38297. * Define the roll off factor of spatial sounds.
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38299. */
  38300. rolloffFactor?: number;
  38301. /**
  38302. * Define the reference distance the sound should be heard perfectly.
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38304. */
  38305. refDistance?: number;
  38306. /**
  38307. * Define the distance attenuation model the sound will follow.
  38308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38309. */
  38310. distanceModel?: string;
  38311. /**
  38312. * Defines the playback speed (1 by default)
  38313. */
  38314. playbackRate?: number;
  38315. /**
  38316. * Defines if the sound is from a streaming source
  38317. */
  38318. streaming?: boolean;
  38319. /**
  38320. * Defines an optional length (in seconds) inside the sound file
  38321. */
  38322. length?: number;
  38323. /**
  38324. * Defines an optional offset (in seconds) inside the sound file
  38325. */
  38326. offset?: number;
  38327. /**
  38328. * If true, URLs will not be required to state the audio file codec to use.
  38329. */
  38330. skipCodecCheck?: boolean;
  38331. }
  38332. /**
  38333. * Defines a sound that can be played in the application.
  38334. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38336. */
  38337. export class Sound {
  38338. /**
  38339. * The name of the sound in the scene.
  38340. */
  38341. name: string;
  38342. /**
  38343. * Does the sound autoplay once loaded.
  38344. */
  38345. autoplay: boolean;
  38346. /**
  38347. * Does the sound loop after it finishes playing once.
  38348. */
  38349. loop: boolean;
  38350. /**
  38351. * Does the sound use a custom attenuation curve to simulate the falloff
  38352. * happening when the source gets further away from the camera.
  38353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38354. */
  38355. useCustomAttenuation: boolean;
  38356. /**
  38357. * The sound track id this sound belongs to.
  38358. */
  38359. soundTrackId: number;
  38360. /**
  38361. * Is this sound currently played.
  38362. */
  38363. isPlaying: boolean;
  38364. /**
  38365. * Is this sound currently paused.
  38366. */
  38367. isPaused: boolean;
  38368. /**
  38369. * Does this sound enables spatial sound.
  38370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38371. */
  38372. spatialSound: boolean;
  38373. /**
  38374. * Define the reference distance the sound should be heard perfectly.
  38375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38376. */
  38377. refDistance: number;
  38378. /**
  38379. * Define the roll off factor of spatial sounds.
  38380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38381. */
  38382. rolloffFactor: number;
  38383. /**
  38384. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38386. */
  38387. maxDistance: number;
  38388. /**
  38389. * Define the distance attenuation model the sound will follow.
  38390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38391. */
  38392. distanceModel: string;
  38393. /**
  38394. * @hidden
  38395. * Back Compat
  38396. **/
  38397. onended: () => any;
  38398. /**
  38399. * Observable event when the current playing sound finishes.
  38400. */
  38401. onEndedObservable: Observable<Sound>;
  38402. private _panningModel;
  38403. private _playbackRate;
  38404. private _streaming;
  38405. private _startTime;
  38406. private _startOffset;
  38407. private _position;
  38408. /** @hidden */
  38409. _positionInEmitterSpace: boolean;
  38410. private _localDirection;
  38411. private _volume;
  38412. private _isReadyToPlay;
  38413. private _isDirectional;
  38414. private _readyToPlayCallback;
  38415. private _audioBuffer;
  38416. private _soundSource;
  38417. private _streamingSource;
  38418. private _soundPanner;
  38419. private _soundGain;
  38420. private _inputAudioNode;
  38421. private _outputAudioNode;
  38422. private _coneInnerAngle;
  38423. private _coneOuterAngle;
  38424. private _coneOuterGain;
  38425. private _scene;
  38426. private _connectedTransformNode;
  38427. private _customAttenuationFunction;
  38428. private _registerFunc;
  38429. private _isOutputConnected;
  38430. private _htmlAudioElement;
  38431. private _urlType;
  38432. private _length?;
  38433. private _offset?;
  38434. /** @hidden */
  38435. static _SceneComponentInitialization: (scene: Scene) => void;
  38436. /**
  38437. * Create a sound and attach it to a scene
  38438. * @param name Name of your sound
  38439. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38440. * @param scene defines the scene the sound belongs to
  38441. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38442. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38443. */
  38444. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38445. /**
  38446. * Release the sound and its associated resources
  38447. */
  38448. dispose(): void;
  38449. /**
  38450. * Gets if the sounds is ready to be played or not.
  38451. * @returns true if ready, otherwise false
  38452. */
  38453. isReady(): boolean;
  38454. private _soundLoaded;
  38455. /**
  38456. * Sets the data of the sound from an audiobuffer
  38457. * @param audioBuffer The audioBuffer containing the data
  38458. */
  38459. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38460. /**
  38461. * Updates the current sounds options such as maxdistance, loop...
  38462. * @param options A JSON object containing values named as the object properties
  38463. */
  38464. updateOptions(options: ISoundOptions): void;
  38465. private _createSpatialParameters;
  38466. private _updateSpatialParameters;
  38467. /**
  38468. * Switch the panning model to HRTF:
  38469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38471. */
  38472. switchPanningModelToHRTF(): void;
  38473. /**
  38474. * Switch the panning model to Equal Power:
  38475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38477. */
  38478. switchPanningModelToEqualPower(): void;
  38479. private _switchPanningModel;
  38480. /**
  38481. * Connect this sound to a sound track audio node like gain...
  38482. * @param soundTrackAudioNode the sound track audio node to connect to
  38483. */
  38484. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38485. /**
  38486. * Transform this sound into a directional source
  38487. * @param coneInnerAngle Size of the inner cone in degree
  38488. * @param coneOuterAngle Size of the outer cone in degree
  38489. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38490. */
  38491. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38492. /**
  38493. * Gets or sets the inner angle for the directional cone.
  38494. */
  38495. get directionalConeInnerAngle(): number;
  38496. /**
  38497. * Gets or sets the inner angle for the directional cone.
  38498. */
  38499. set directionalConeInnerAngle(value: number);
  38500. /**
  38501. * Gets or sets the outer angle for the directional cone.
  38502. */
  38503. get directionalConeOuterAngle(): number;
  38504. /**
  38505. * Gets or sets the outer angle for the directional cone.
  38506. */
  38507. set directionalConeOuterAngle(value: number);
  38508. /**
  38509. * Sets the position of the emitter if spatial sound is enabled
  38510. * @param newPosition Defines the new posisiton
  38511. */
  38512. setPosition(newPosition: Vector3): void;
  38513. /**
  38514. * Sets the local direction of the emitter if spatial sound is enabled
  38515. * @param newLocalDirection Defines the new local direction
  38516. */
  38517. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38518. private _updateDirection;
  38519. /** @hidden */
  38520. updateDistanceFromListener(): void;
  38521. /**
  38522. * Sets a new custom attenuation function for the sound.
  38523. * @param callback Defines the function used for the attenuation
  38524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38525. */
  38526. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38527. /**
  38528. * Play the sound
  38529. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38530. * @param offset (optional) Start the sound at a specific time in seconds
  38531. * @param length (optional) Sound duration (in seconds)
  38532. */
  38533. play(time?: number, offset?: number, length?: number): void;
  38534. private _onended;
  38535. /**
  38536. * Stop the sound
  38537. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38538. */
  38539. stop(time?: number): void;
  38540. /**
  38541. * Put the sound in pause
  38542. */
  38543. pause(): void;
  38544. /**
  38545. * Sets a dedicated volume for this sounds
  38546. * @param newVolume Define the new volume of the sound
  38547. * @param time Define time for gradual change to new volume
  38548. */
  38549. setVolume(newVolume: number, time?: number): void;
  38550. /**
  38551. * Set the sound play back rate
  38552. * @param newPlaybackRate Define the playback rate the sound should be played at
  38553. */
  38554. setPlaybackRate(newPlaybackRate: number): void;
  38555. /**
  38556. * Gets the volume of the sound.
  38557. * @returns the volume of the sound
  38558. */
  38559. getVolume(): number;
  38560. /**
  38561. * Attach the sound to a dedicated mesh
  38562. * @param transformNode The transform node to connect the sound with
  38563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38564. */
  38565. attachToMesh(transformNode: TransformNode): void;
  38566. /**
  38567. * Detach the sound from the previously attached mesh
  38568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38569. */
  38570. detachFromMesh(): void;
  38571. private _onRegisterAfterWorldMatrixUpdate;
  38572. /**
  38573. * Clone the current sound in the scene.
  38574. * @returns the new sound clone
  38575. */
  38576. clone(): Nullable<Sound>;
  38577. /**
  38578. * Gets the current underlying audio buffer containing the data
  38579. * @returns the audio buffer
  38580. */
  38581. getAudioBuffer(): Nullable<AudioBuffer>;
  38582. /**
  38583. * Serializes the Sound in a JSON representation
  38584. * @returns the JSON representation of the sound
  38585. */
  38586. serialize(): any;
  38587. /**
  38588. * Parse a JSON representation of a sound to innstantiate in a given scene
  38589. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38590. * @param scene Define the scene the new parsed sound should be created in
  38591. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38592. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38593. * @returns the newly parsed sound
  38594. */
  38595. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38596. }
  38597. }
  38598. declare module "babylonjs/Actions/directAudioActions" {
  38599. import { Action } from "babylonjs/Actions/action";
  38600. import { Condition } from "babylonjs/Actions/condition";
  38601. import { Sound } from "babylonjs/Audio/sound";
  38602. /**
  38603. * This defines an action helpful to play a defined sound on a triggered action.
  38604. */
  38605. export class PlaySoundAction extends Action {
  38606. private _sound;
  38607. /**
  38608. * Instantiate the action
  38609. * @param triggerOptions defines the trigger options
  38610. * @param sound defines the sound to play
  38611. * @param condition defines the trigger related conditions
  38612. */
  38613. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38614. /** @hidden */
  38615. _prepare(): void;
  38616. /**
  38617. * Execute the action and play the sound.
  38618. */
  38619. execute(): void;
  38620. /**
  38621. * Serializes the actions and its related information.
  38622. * @param parent defines the object to serialize in
  38623. * @returns the serialized object
  38624. */
  38625. serialize(parent: any): any;
  38626. }
  38627. /**
  38628. * This defines an action helpful to stop a defined sound on a triggered action.
  38629. */
  38630. export class StopSoundAction extends Action {
  38631. private _sound;
  38632. /**
  38633. * Instantiate the action
  38634. * @param triggerOptions defines the trigger options
  38635. * @param sound defines the sound to stop
  38636. * @param condition defines the trigger related conditions
  38637. */
  38638. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38639. /** @hidden */
  38640. _prepare(): void;
  38641. /**
  38642. * Execute the action and stop the sound.
  38643. */
  38644. execute(): void;
  38645. /**
  38646. * Serializes the actions and its related information.
  38647. * @param parent defines the object to serialize in
  38648. * @returns the serialized object
  38649. */
  38650. serialize(parent: any): any;
  38651. }
  38652. }
  38653. declare module "babylonjs/Actions/interpolateValueAction" {
  38654. import { Action } from "babylonjs/Actions/action";
  38655. import { Condition } from "babylonjs/Actions/condition";
  38656. import { Observable } from "babylonjs/Misc/observable";
  38657. /**
  38658. * This defines an action responsible to change the value of a property
  38659. * by interpolating between its current value and the newly set one once triggered.
  38660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38661. */
  38662. export class InterpolateValueAction extends Action {
  38663. /**
  38664. * Defines the path of the property where the value should be interpolated
  38665. */
  38666. propertyPath: string;
  38667. /**
  38668. * Defines the target value at the end of the interpolation.
  38669. */
  38670. value: any;
  38671. /**
  38672. * Defines the time it will take for the property to interpolate to the value.
  38673. */
  38674. duration: number;
  38675. /**
  38676. * Defines if the other scene animations should be stopped when the action has been triggered
  38677. */
  38678. stopOtherAnimations?: boolean;
  38679. /**
  38680. * Defines a callback raised once the interpolation animation has been done.
  38681. */
  38682. onInterpolationDone?: () => void;
  38683. /**
  38684. * Observable triggered once the interpolation animation has been done.
  38685. */
  38686. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38687. private _target;
  38688. private _effectiveTarget;
  38689. private _property;
  38690. /**
  38691. * Instantiate the action
  38692. * @param triggerOptions defines the trigger options
  38693. * @param target defines the object containing the value to interpolate
  38694. * @param propertyPath defines the path to the property in the target object
  38695. * @param value defines the target value at the end of the interpolation
  38696. * @param duration deines the time it will take for the property to interpolate to the value.
  38697. * @param condition defines the trigger related conditions
  38698. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38699. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38700. */
  38701. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38702. /** @hidden */
  38703. _prepare(): void;
  38704. /**
  38705. * Execute the action starts the value interpolation.
  38706. */
  38707. execute(): void;
  38708. /**
  38709. * Serializes the actions and its related information.
  38710. * @param parent defines the object to serialize in
  38711. * @returns the serialized object
  38712. */
  38713. serialize(parent: any): any;
  38714. }
  38715. }
  38716. declare module "babylonjs/Actions/index" {
  38717. export * from "babylonjs/Actions/abstractActionManager";
  38718. export * from "babylonjs/Actions/action";
  38719. export * from "babylonjs/Actions/actionEvent";
  38720. export * from "babylonjs/Actions/actionManager";
  38721. export * from "babylonjs/Actions/condition";
  38722. export * from "babylonjs/Actions/directActions";
  38723. export * from "babylonjs/Actions/directAudioActions";
  38724. export * from "babylonjs/Actions/interpolateValueAction";
  38725. }
  38726. declare module "babylonjs/Animations/index" {
  38727. export * from "babylonjs/Animations/animatable";
  38728. export * from "babylonjs/Animations/animation";
  38729. export * from "babylonjs/Animations/animationGroup";
  38730. export * from "babylonjs/Animations/animationPropertiesOverride";
  38731. export * from "babylonjs/Animations/easing";
  38732. export * from "babylonjs/Animations/runtimeAnimation";
  38733. export * from "babylonjs/Animations/animationEvent";
  38734. export * from "babylonjs/Animations/animationGroup";
  38735. export * from "babylonjs/Animations/animationKey";
  38736. export * from "babylonjs/Animations/animationRange";
  38737. export * from "babylonjs/Animations/animatable.interface";
  38738. }
  38739. declare module "babylonjs/Audio/soundTrack" {
  38740. import { Sound } from "babylonjs/Audio/sound";
  38741. import { Analyser } from "babylonjs/Audio/analyser";
  38742. import { Scene } from "babylonjs/scene";
  38743. /**
  38744. * Options allowed during the creation of a sound track.
  38745. */
  38746. export interface ISoundTrackOptions {
  38747. /**
  38748. * The volume the sound track should take during creation
  38749. */
  38750. volume?: number;
  38751. /**
  38752. * Define if the sound track is the main sound track of the scene
  38753. */
  38754. mainTrack?: boolean;
  38755. }
  38756. /**
  38757. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38758. * It will be also used in a future release to apply effects on a specific track.
  38759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38760. */
  38761. export class SoundTrack {
  38762. /**
  38763. * The unique identifier of the sound track in the scene.
  38764. */
  38765. id: number;
  38766. /**
  38767. * The list of sounds included in the sound track.
  38768. */
  38769. soundCollection: Array<Sound>;
  38770. private _outputAudioNode;
  38771. private _scene;
  38772. private _connectedAnalyser;
  38773. private _options;
  38774. private _isInitialized;
  38775. /**
  38776. * Creates a new sound track.
  38777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38778. * @param scene Define the scene the sound track belongs to
  38779. * @param options
  38780. */
  38781. constructor(scene: Scene, options?: ISoundTrackOptions);
  38782. private _initializeSoundTrackAudioGraph;
  38783. /**
  38784. * Release the sound track and its associated resources
  38785. */
  38786. dispose(): void;
  38787. /**
  38788. * Adds a sound to this sound track
  38789. * @param sound define the cound to add
  38790. * @ignoreNaming
  38791. */
  38792. AddSound(sound: Sound): void;
  38793. /**
  38794. * Removes a sound to this sound track
  38795. * @param sound define the cound to remove
  38796. * @ignoreNaming
  38797. */
  38798. RemoveSound(sound: Sound): void;
  38799. /**
  38800. * Set a global volume for the full sound track.
  38801. * @param newVolume Define the new volume of the sound track
  38802. */
  38803. setVolume(newVolume: number): void;
  38804. /**
  38805. * Switch the panning model to HRTF:
  38806. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38808. */
  38809. switchPanningModelToHRTF(): void;
  38810. /**
  38811. * Switch the panning model to Equal Power:
  38812. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38814. */
  38815. switchPanningModelToEqualPower(): void;
  38816. /**
  38817. * Connect the sound track to an audio analyser allowing some amazing
  38818. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38820. * @param analyser The analyser to connect to the engine
  38821. */
  38822. connectToAnalyser(analyser: Analyser): void;
  38823. }
  38824. }
  38825. declare module "babylonjs/Audio/audioSceneComponent" {
  38826. import { Sound } from "babylonjs/Audio/sound";
  38827. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38828. import { Nullable } from "babylonjs/types";
  38829. import { Vector3 } from "babylonjs/Maths/math.vector";
  38830. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { AbstractScene } from "babylonjs/abstractScene";
  38833. import "babylonjs/Audio/audioEngine";
  38834. module "babylonjs/abstractScene" {
  38835. interface AbstractScene {
  38836. /**
  38837. * The list of sounds used in the scene.
  38838. */
  38839. sounds: Nullable<Array<Sound>>;
  38840. }
  38841. }
  38842. module "babylonjs/scene" {
  38843. interface Scene {
  38844. /**
  38845. * @hidden
  38846. * Backing field
  38847. */
  38848. _mainSoundTrack: SoundTrack;
  38849. /**
  38850. * The main sound track played by the scene.
  38851. * It cotains your primary collection of sounds.
  38852. */
  38853. mainSoundTrack: SoundTrack;
  38854. /**
  38855. * The list of sound tracks added to the scene
  38856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38857. */
  38858. soundTracks: Nullable<Array<SoundTrack>>;
  38859. /**
  38860. * Gets a sound using a given name
  38861. * @param name defines the name to search for
  38862. * @return the found sound or null if not found at all.
  38863. */
  38864. getSoundByName(name: string): Nullable<Sound>;
  38865. /**
  38866. * Gets or sets if audio support is enabled
  38867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38868. */
  38869. audioEnabled: boolean;
  38870. /**
  38871. * Gets or sets if audio will be output to headphones
  38872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38873. */
  38874. headphone: boolean;
  38875. /**
  38876. * Gets or sets custom audio listener position provider
  38877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38878. */
  38879. audioListenerPositionProvider: Nullable<() => Vector3>;
  38880. /**
  38881. * Gets or sets a refresh rate when using 3D audio positioning
  38882. */
  38883. audioPositioningRefreshRate: number;
  38884. }
  38885. }
  38886. /**
  38887. * Defines the sound scene component responsible to manage any sounds
  38888. * in a given scene.
  38889. */
  38890. export class AudioSceneComponent implements ISceneSerializableComponent {
  38891. /**
  38892. * The component name helpfull to identify the component in the list of scene components.
  38893. */
  38894. readonly name: string;
  38895. /**
  38896. * The scene the component belongs to.
  38897. */
  38898. scene: Scene;
  38899. private _audioEnabled;
  38900. /**
  38901. * Gets whether audio is enabled or not.
  38902. * Please use related enable/disable method to switch state.
  38903. */
  38904. get audioEnabled(): boolean;
  38905. private _headphone;
  38906. /**
  38907. * Gets whether audio is outputing to headphone or not.
  38908. * Please use the according Switch methods to change output.
  38909. */
  38910. get headphone(): boolean;
  38911. /**
  38912. * Gets or sets a refresh rate when using 3D audio positioning
  38913. */
  38914. audioPositioningRefreshRate: number;
  38915. private _audioListenerPositionProvider;
  38916. /**
  38917. * Gets the current audio listener position provider
  38918. */
  38919. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38920. /**
  38921. * Sets a custom listener position for all sounds in the scene
  38922. * By default, this is the position of the first active camera
  38923. */
  38924. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38925. /**
  38926. * Creates a new instance of the component for the given scene
  38927. * @param scene Defines the scene to register the component in
  38928. */
  38929. constructor(scene: Scene);
  38930. /**
  38931. * Registers the component in a given scene
  38932. */
  38933. register(): void;
  38934. /**
  38935. * Rebuilds the elements related to this component in case of
  38936. * context lost for instance.
  38937. */
  38938. rebuild(): void;
  38939. /**
  38940. * Serializes the component data to the specified json object
  38941. * @param serializationObject The object to serialize to
  38942. */
  38943. serialize(serializationObject: any): void;
  38944. /**
  38945. * Adds all the elements from the container to the scene
  38946. * @param container the container holding the elements
  38947. */
  38948. addFromContainer(container: AbstractScene): void;
  38949. /**
  38950. * Removes all the elements in the container from the scene
  38951. * @param container contains the elements to remove
  38952. * @param dispose if the removed element should be disposed (default: false)
  38953. */
  38954. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38955. /**
  38956. * Disposes the component and the associated ressources.
  38957. */
  38958. dispose(): void;
  38959. /**
  38960. * Disables audio in the associated scene.
  38961. */
  38962. disableAudio(): void;
  38963. /**
  38964. * Enables audio in the associated scene.
  38965. */
  38966. enableAudio(): void;
  38967. /**
  38968. * Switch audio to headphone output.
  38969. */
  38970. switchAudioModeForHeadphones(): void;
  38971. /**
  38972. * Switch audio to normal speakers.
  38973. */
  38974. switchAudioModeForNormalSpeakers(): void;
  38975. private _cachedCameraDirection;
  38976. private _cachedCameraPosition;
  38977. private _lastCheck;
  38978. private _afterRender;
  38979. }
  38980. }
  38981. declare module "babylonjs/Audio/weightedsound" {
  38982. import { Sound } from "babylonjs/Audio/sound";
  38983. /**
  38984. * Wraps one or more Sound objects and selects one with random weight for playback.
  38985. */
  38986. export class WeightedSound {
  38987. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38988. loop: boolean;
  38989. private _coneInnerAngle;
  38990. private _coneOuterAngle;
  38991. private _volume;
  38992. /** A Sound is currently playing. */
  38993. isPlaying: boolean;
  38994. /** A Sound is currently paused. */
  38995. isPaused: boolean;
  38996. private _sounds;
  38997. private _weights;
  38998. private _currentIndex?;
  38999. /**
  39000. * Creates a new WeightedSound from the list of sounds given.
  39001. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39002. * @param sounds Array of Sounds that will be selected from.
  39003. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39004. */
  39005. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39006. /**
  39007. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39008. */
  39009. get directionalConeInnerAngle(): number;
  39010. /**
  39011. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39012. */
  39013. set directionalConeInnerAngle(value: number);
  39014. /**
  39015. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39016. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39017. */
  39018. get directionalConeOuterAngle(): number;
  39019. /**
  39020. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39021. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39022. */
  39023. set directionalConeOuterAngle(value: number);
  39024. /**
  39025. * Playback volume.
  39026. */
  39027. get volume(): number;
  39028. /**
  39029. * Playback volume.
  39030. */
  39031. set volume(value: number);
  39032. private _onended;
  39033. /**
  39034. * Suspend playback
  39035. */
  39036. pause(): void;
  39037. /**
  39038. * Stop playback
  39039. */
  39040. stop(): void;
  39041. /**
  39042. * Start playback.
  39043. * @param startOffset Position the clip head at a specific time in seconds.
  39044. */
  39045. play(startOffset?: number): void;
  39046. }
  39047. }
  39048. declare module "babylonjs/Audio/index" {
  39049. export * from "babylonjs/Audio/analyser";
  39050. export * from "babylonjs/Audio/audioEngine";
  39051. export * from "babylonjs/Audio/audioSceneComponent";
  39052. export * from "babylonjs/Audio/sound";
  39053. export * from "babylonjs/Audio/soundTrack";
  39054. export * from "babylonjs/Audio/weightedsound";
  39055. }
  39056. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39057. import { Behavior } from "babylonjs/Behaviors/behavior";
  39058. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39059. import { BackEase } from "babylonjs/Animations/easing";
  39060. /**
  39061. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39063. */
  39064. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39065. /**
  39066. * Gets the name of the behavior.
  39067. */
  39068. get name(): string;
  39069. /**
  39070. * The easing function used by animations
  39071. */
  39072. static EasingFunction: BackEase;
  39073. /**
  39074. * The easing mode used by animations
  39075. */
  39076. static EasingMode: number;
  39077. /**
  39078. * The duration of the animation, in milliseconds
  39079. */
  39080. transitionDuration: number;
  39081. /**
  39082. * Length of the distance animated by the transition when lower radius is reached
  39083. */
  39084. lowerRadiusTransitionRange: number;
  39085. /**
  39086. * Length of the distance animated by the transition when upper radius is reached
  39087. */
  39088. upperRadiusTransitionRange: number;
  39089. private _autoTransitionRange;
  39090. /**
  39091. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39092. */
  39093. get autoTransitionRange(): boolean;
  39094. /**
  39095. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39096. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39097. */
  39098. set autoTransitionRange(value: boolean);
  39099. private _attachedCamera;
  39100. private _onAfterCheckInputsObserver;
  39101. private _onMeshTargetChangedObserver;
  39102. /**
  39103. * Initializes the behavior.
  39104. */
  39105. init(): void;
  39106. /**
  39107. * Attaches the behavior to its arc rotate camera.
  39108. * @param camera Defines the camera to attach the behavior to
  39109. */
  39110. attach(camera: ArcRotateCamera): void;
  39111. /**
  39112. * Detaches the behavior from its current arc rotate camera.
  39113. */
  39114. detach(): void;
  39115. private _radiusIsAnimating;
  39116. private _radiusBounceTransition;
  39117. private _animatables;
  39118. private _cachedWheelPrecision;
  39119. /**
  39120. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39121. * @param radiusLimit The limit to check against.
  39122. * @return Bool to indicate if at limit.
  39123. */
  39124. private _isRadiusAtLimit;
  39125. /**
  39126. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39127. * @param radiusDelta The delta by which to animate to. Can be negative.
  39128. */
  39129. private _applyBoundRadiusAnimation;
  39130. /**
  39131. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39132. */
  39133. protected _clearAnimationLocks(): void;
  39134. /**
  39135. * Stops and removes all animations that have been applied to the camera
  39136. */
  39137. stopAllAnimations(): void;
  39138. }
  39139. }
  39140. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39141. import { Behavior } from "babylonjs/Behaviors/behavior";
  39142. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39143. import { ExponentialEase } from "babylonjs/Animations/easing";
  39144. import { Nullable } from "babylonjs/types";
  39145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39146. import { Vector3 } from "babylonjs/Maths/math.vector";
  39147. /**
  39148. * 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.
  39149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39150. */
  39151. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39152. /**
  39153. * Gets the name of the behavior.
  39154. */
  39155. get name(): string;
  39156. private _mode;
  39157. private _radiusScale;
  39158. private _positionScale;
  39159. private _defaultElevation;
  39160. private _elevationReturnTime;
  39161. private _elevationReturnWaitTime;
  39162. private _zoomStopsAnimation;
  39163. private _framingTime;
  39164. /**
  39165. * The easing function used by animations
  39166. */
  39167. static EasingFunction: ExponentialEase;
  39168. /**
  39169. * The easing mode used by animations
  39170. */
  39171. static EasingMode: number;
  39172. /**
  39173. * Sets the current mode used by the behavior
  39174. */
  39175. set mode(mode: number);
  39176. /**
  39177. * Gets current mode used by the behavior.
  39178. */
  39179. get mode(): number;
  39180. /**
  39181. * Sets the scale applied to the radius (1 by default)
  39182. */
  39183. set radiusScale(radius: number);
  39184. /**
  39185. * Gets the scale applied to the radius
  39186. */
  39187. get radiusScale(): number;
  39188. /**
  39189. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39190. */
  39191. set positionScale(scale: number);
  39192. /**
  39193. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39194. */
  39195. get positionScale(): number;
  39196. /**
  39197. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39198. * behaviour is triggered, in radians.
  39199. */
  39200. set defaultElevation(elevation: number);
  39201. /**
  39202. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39203. * behaviour is triggered, in radians.
  39204. */
  39205. get defaultElevation(): number;
  39206. /**
  39207. * Sets the time (in milliseconds) taken to return to the default beta position.
  39208. * Negative value indicates camera should not return to default.
  39209. */
  39210. set elevationReturnTime(speed: number);
  39211. /**
  39212. * Gets the time (in milliseconds) taken to return to the default beta position.
  39213. * Negative value indicates camera should not return to default.
  39214. */
  39215. get elevationReturnTime(): number;
  39216. /**
  39217. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39218. */
  39219. set elevationReturnWaitTime(time: number);
  39220. /**
  39221. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39222. */
  39223. get elevationReturnWaitTime(): number;
  39224. /**
  39225. * Sets the flag that indicates if user zooming should stop animation.
  39226. */
  39227. set zoomStopsAnimation(flag: boolean);
  39228. /**
  39229. * Gets the flag that indicates if user zooming should stop animation.
  39230. */
  39231. get zoomStopsAnimation(): boolean;
  39232. /**
  39233. * Sets the transition time when framing the mesh, in milliseconds
  39234. */
  39235. set framingTime(time: number);
  39236. /**
  39237. * Gets the transition time when framing the mesh, in milliseconds
  39238. */
  39239. get framingTime(): number;
  39240. /**
  39241. * Define if the behavior should automatically change the configured
  39242. * camera limits and sensibilities.
  39243. */
  39244. autoCorrectCameraLimitsAndSensibility: boolean;
  39245. private _onPrePointerObservableObserver;
  39246. private _onAfterCheckInputsObserver;
  39247. private _onMeshTargetChangedObserver;
  39248. private _attachedCamera;
  39249. private _isPointerDown;
  39250. private _lastInteractionTime;
  39251. /**
  39252. * Initializes the behavior.
  39253. */
  39254. init(): void;
  39255. /**
  39256. * Attaches the behavior to its arc rotate camera.
  39257. * @param camera Defines the camera to attach the behavior to
  39258. */
  39259. attach(camera: ArcRotateCamera): void;
  39260. /**
  39261. * Detaches the behavior from its current arc rotate camera.
  39262. */
  39263. detach(): void;
  39264. private _animatables;
  39265. private _betaIsAnimating;
  39266. private _betaTransition;
  39267. private _radiusTransition;
  39268. private _vectorTransition;
  39269. /**
  39270. * Targets the given mesh and updates zoom level accordingly.
  39271. * @param mesh The mesh to target.
  39272. * @param radius Optional. If a cached radius position already exists, overrides default.
  39273. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39274. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39275. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39276. */
  39277. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39278. /**
  39279. * Targets the given mesh with its children and updates zoom level accordingly.
  39280. * @param mesh The mesh to target.
  39281. * @param radius Optional. If a cached radius position already exists, overrides default.
  39282. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39285. */
  39286. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39287. /**
  39288. * Targets the given meshes with their children and updates zoom level accordingly.
  39289. * @param meshes The mesh to target.
  39290. * @param radius Optional. If a cached radius position already exists, overrides default.
  39291. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39294. */
  39295. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39296. /**
  39297. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39298. * @param minimumWorld Determines the smaller position of the bounding box extend
  39299. * @param maximumWorld Determines the bigger position of the bounding box extend
  39300. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39301. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39302. */
  39303. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39304. /**
  39305. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39306. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39307. * frustum width.
  39308. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39309. * to fully enclose the mesh in the viewing frustum.
  39310. */
  39311. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39312. /**
  39313. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39314. * is automatically returned to its default position (expected to be above ground plane).
  39315. */
  39316. private _maintainCameraAboveGround;
  39317. /**
  39318. * Returns the frustum slope based on the canvas ratio and camera FOV
  39319. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39320. */
  39321. private _getFrustumSlope;
  39322. /**
  39323. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39324. */
  39325. private _clearAnimationLocks;
  39326. /**
  39327. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39328. */
  39329. private _applyUserInteraction;
  39330. /**
  39331. * Stops and removes all animations that have been applied to the camera
  39332. */
  39333. stopAllAnimations(): void;
  39334. /**
  39335. * Gets a value indicating if the user is moving the camera
  39336. */
  39337. get isUserIsMoving(): boolean;
  39338. /**
  39339. * The camera can move all the way towards the mesh.
  39340. */
  39341. static IgnoreBoundsSizeMode: number;
  39342. /**
  39343. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39344. */
  39345. static FitFrustumSidesMode: number;
  39346. }
  39347. }
  39348. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39349. import { Nullable } from "babylonjs/types";
  39350. import { Camera } from "babylonjs/Cameras/camera";
  39351. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39352. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39353. /**
  39354. * Base class for Camera Pointer Inputs.
  39355. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39356. * for example usage.
  39357. */
  39358. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39359. /**
  39360. * Defines the camera the input is attached to.
  39361. */
  39362. abstract camera: Camera;
  39363. /**
  39364. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39365. */
  39366. protected _altKey: boolean;
  39367. protected _ctrlKey: boolean;
  39368. protected _metaKey: boolean;
  39369. protected _shiftKey: boolean;
  39370. /**
  39371. * Which mouse buttons were pressed at time of last mouse event.
  39372. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39373. */
  39374. protected _buttonsPressed: number;
  39375. /**
  39376. * Defines the buttons associated with the input to handle camera move.
  39377. */
  39378. buttons: number[];
  39379. /**
  39380. * Attach the input controls to a specific dom element to get the input from.
  39381. * @param element Defines the element the controls should be listened from
  39382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39383. */
  39384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39385. /**
  39386. * Detach the current controls from the specified dom element.
  39387. * @param element Defines the element to stop listening the inputs from
  39388. */
  39389. detachControl(element: Nullable<HTMLElement>): void;
  39390. /**
  39391. * Gets the class name of the current input.
  39392. * @returns the class name
  39393. */
  39394. getClassName(): string;
  39395. /**
  39396. * Get the friendly name associated with the input class.
  39397. * @returns the input friendly name
  39398. */
  39399. getSimpleName(): string;
  39400. /**
  39401. * Called on pointer POINTERDOUBLETAP event.
  39402. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39403. */
  39404. protected onDoubleTap(type: string): void;
  39405. /**
  39406. * Called on pointer POINTERMOVE event if only a single touch is active.
  39407. * Override this method to provide functionality.
  39408. */
  39409. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39410. /**
  39411. * Called on pointer POINTERMOVE event if multiple touches are active.
  39412. * Override this method to provide functionality.
  39413. */
  39414. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39415. /**
  39416. * Called on JS contextmenu event.
  39417. * Override this method to provide functionality.
  39418. */
  39419. protected onContextMenu(evt: PointerEvent): void;
  39420. /**
  39421. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39422. * press.
  39423. * Override this method to provide functionality.
  39424. */
  39425. protected onButtonDown(evt: PointerEvent): void;
  39426. /**
  39427. * Called each time a new POINTERUP event occurs. Ie, for each button
  39428. * release.
  39429. * Override this method to provide functionality.
  39430. */
  39431. protected onButtonUp(evt: PointerEvent): void;
  39432. /**
  39433. * Called when window becomes inactive.
  39434. * Override this method to provide functionality.
  39435. */
  39436. protected onLostFocus(): void;
  39437. private _pointerInput;
  39438. private _observer;
  39439. private _onLostFocus;
  39440. private pointA;
  39441. private pointB;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39445. import { Nullable } from "babylonjs/types";
  39446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39447. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39448. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39449. /**
  39450. * Manage the pointers inputs to control an arc rotate camera.
  39451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39452. */
  39453. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39454. /**
  39455. * Defines the camera the input is attached to.
  39456. */
  39457. camera: ArcRotateCamera;
  39458. /**
  39459. * Gets the class name of the current input.
  39460. * @returns the class name
  39461. */
  39462. getClassName(): string;
  39463. /**
  39464. * Defines the buttons associated with the input to handle camera move.
  39465. */
  39466. buttons: number[];
  39467. /**
  39468. * Defines the pointer angular sensibility along the X axis or how fast is
  39469. * the camera rotating.
  39470. */
  39471. angularSensibilityX: number;
  39472. /**
  39473. * Defines the pointer angular sensibility along the Y axis or how fast is
  39474. * the camera rotating.
  39475. */
  39476. angularSensibilityY: number;
  39477. /**
  39478. * Defines the pointer pinch precision or how fast is the camera zooming.
  39479. */
  39480. pinchPrecision: number;
  39481. /**
  39482. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39483. * from 0.
  39484. * It defines the percentage of current camera.radius to use as delta when
  39485. * pinch zoom is used.
  39486. */
  39487. pinchDeltaPercentage: number;
  39488. /**
  39489. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39490. * that any object in the plane at the camera's target point will scale
  39491. * perfectly with finger motion.
  39492. * Overrides pinchDeltaPercentage and pinchPrecision.
  39493. */
  39494. useNaturalPinchZoom: boolean;
  39495. /**
  39496. * Defines the pointer panning sensibility or how fast is the camera moving.
  39497. */
  39498. panningSensibility: number;
  39499. /**
  39500. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39501. */
  39502. multiTouchPanning: boolean;
  39503. /**
  39504. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39505. * zoom (pinch) through multitouch.
  39506. */
  39507. multiTouchPanAndZoom: boolean;
  39508. /**
  39509. * Revers pinch action direction.
  39510. */
  39511. pinchInwards: boolean;
  39512. private _isPanClick;
  39513. private _twoFingerActivityCount;
  39514. private _isPinching;
  39515. /**
  39516. * Called on pointer POINTERMOVE event if only a single touch is active.
  39517. */
  39518. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39519. /**
  39520. * Called on pointer POINTERDOUBLETAP event.
  39521. */
  39522. protected onDoubleTap(type: string): void;
  39523. /**
  39524. * Called on pointer POINTERMOVE event if multiple touches are active.
  39525. */
  39526. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39527. /**
  39528. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39529. * press.
  39530. */
  39531. protected onButtonDown(evt: PointerEvent): void;
  39532. /**
  39533. * Called each time a new POINTERUP event occurs. Ie, for each button
  39534. * release.
  39535. */
  39536. protected onButtonUp(evt: PointerEvent): void;
  39537. /**
  39538. * Called when window becomes inactive.
  39539. */
  39540. protected onLostFocus(): void;
  39541. }
  39542. }
  39543. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39544. import { Nullable } from "babylonjs/types";
  39545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39547. /**
  39548. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39550. */
  39551. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39552. /**
  39553. * Defines the camera the input is attached to.
  39554. */
  39555. camera: ArcRotateCamera;
  39556. /**
  39557. * Defines the list of key codes associated with the up action (increase alpha)
  39558. */
  39559. keysUp: number[];
  39560. /**
  39561. * Defines the list of key codes associated with the down action (decrease alpha)
  39562. */
  39563. keysDown: number[];
  39564. /**
  39565. * Defines the list of key codes associated with the left action (increase beta)
  39566. */
  39567. keysLeft: number[];
  39568. /**
  39569. * Defines the list of key codes associated with the right action (decrease beta)
  39570. */
  39571. keysRight: number[];
  39572. /**
  39573. * Defines the list of key codes associated with the reset action.
  39574. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39575. */
  39576. keysReset: number[];
  39577. /**
  39578. * Defines the panning sensibility of the inputs.
  39579. * (How fast is the camera panning)
  39580. */
  39581. panningSensibility: number;
  39582. /**
  39583. * Defines the zooming sensibility of the inputs.
  39584. * (How fast is the camera zooming)
  39585. */
  39586. zoomingSensibility: number;
  39587. /**
  39588. * Defines whether maintaining the alt key down switch the movement mode from
  39589. * orientation to zoom.
  39590. */
  39591. useAltToZoom: boolean;
  39592. /**
  39593. * Rotation speed of the camera
  39594. */
  39595. angularSpeed: number;
  39596. private _keys;
  39597. private _ctrlPressed;
  39598. private _altPressed;
  39599. private _onCanvasBlurObserver;
  39600. private _onKeyboardObserver;
  39601. private _engine;
  39602. private _scene;
  39603. /**
  39604. * Attach the input controls to a specific dom element to get the input from.
  39605. * @param element Defines the element the controls should be listened from
  39606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39607. */
  39608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39609. /**
  39610. * Detach the current controls from the specified dom element.
  39611. * @param element Defines the element to stop listening the inputs from
  39612. */
  39613. detachControl(element: Nullable<HTMLElement>): void;
  39614. /**
  39615. * Update the current camera state depending on the inputs that have been used this frame.
  39616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39617. */
  39618. checkInputs(): void;
  39619. /**
  39620. * Gets the class name of the current intput.
  39621. * @returns the class name
  39622. */
  39623. getClassName(): string;
  39624. /**
  39625. * Get the friendly name associated with the input class.
  39626. * @returns the input friendly name
  39627. */
  39628. getSimpleName(): string;
  39629. }
  39630. }
  39631. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39632. import { Nullable } from "babylonjs/types";
  39633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39634. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39635. /**
  39636. * Manage the mouse wheel inputs to control an arc rotate camera.
  39637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39638. */
  39639. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39640. /**
  39641. * Defines the camera the input is attached to.
  39642. */
  39643. camera: ArcRotateCamera;
  39644. /**
  39645. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39646. */
  39647. wheelPrecision: number;
  39648. /**
  39649. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39650. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39651. */
  39652. wheelDeltaPercentage: number;
  39653. private _wheel;
  39654. private _observer;
  39655. private computeDeltaFromMouseWheelLegacyEvent;
  39656. /**
  39657. * Attach the input controls to a specific dom element to get the input from.
  39658. * @param element Defines the element the controls should be listened from
  39659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39660. */
  39661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39662. /**
  39663. * Detach the current controls from the specified dom element.
  39664. * @param element Defines the element to stop listening the inputs from
  39665. */
  39666. detachControl(element: Nullable<HTMLElement>): void;
  39667. /**
  39668. * Gets the class name of the current intput.
  39669. * @returns the class name
  39670. */
  39671. getClassName(): string;
  39672. /**
  39673. * Get the friendly name associated with the input class.
  39674. * @returns the input friendly name
  39675. */
  39676. getSimpleName(): string;
  39677. }
  39678. }
  39679. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39680. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39681. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39682. /**
  39683. * Default Inputs manager for the ArcRotateCamera.
  39684. * It groups all the default supported inputs for ease of use.
  39685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39686. */
  39687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39688. /**
  39689. * Instantiates a new ArcRotateCameraInputsManager.
  39690. * @param camera Defines the camera the inputs belong to
  39691. */
  39692. constructor(camera: ArcRotateCamera);
  39693. /**
  39694. * Add mouse wheel input support to the input manager.
  39695. * @returns the current input manager
  39696. */
  39697. addMouseWheel(): ArcRotateCameraInputsManager;
  39698. /**
  39699. * Add pointers input support to the input manager.
  39700. * @returns the current input manager
  39701. */
  39702. addPointers(): ArcRotateCameraInputsManager;
  39703. /**
  39704. * Add keyboard input support to the input manager.
  39705. * @returns the current input manager
  39706. */
  39707. addKeyboard(): ArcRotateCameraInputsManager;
  39708. }
  39709. }
  39710. declare module "babylonjs/Cameras/arcRotateCamera" {
  39711. import { Observable } from "babylonjs/Misc/observable";
  39712. import { Nullable } from "babylonjs/types";
  39713. import { Scene } from "babylonjs/scene";
  39714. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39716. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39717. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39718. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39719. import { Camera } from "babylonjs/Cameras/camera";
  39720. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39721. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39722. import { Collider } from "babylonjs/Collisions/collider";
  39723. /**
  39724. * This represents an orbital type of camera.
  39725. *
  39726. * 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.
  39727. * 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.
  39728. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39729. */
  39730. export class ArcRotateCamera extends TargetCamera {
  39731. /**
  39732. * Defines the rotation angle of the camera along the longitudinal axis.
  39733. */
  39734. alpha: number;
  39735. /**
  39736. * Defines the rotation angle of the camera along the latitudinal axis.
  39737. */
  39738. beta: number;
  39739. /**
  39740. * Defines the radius of the camera from it s target point.
  39741. */
  39742. radius: number;
  39743. protected _target: Vector3;
  39744. protected _targetHost: Nullable<AbstractMesh>;
  39745. /**
  39746. * Defines the target point of the camera.
  39747. * The camera looks towards it form the radius distance.
  39748. */
  39749. get target(): Vector3;
  39750. set target(value: Vector3);
  39751. /**
  39752. * Define the current local position of the camera in the scene
  39753. */
  39754. get position(): Vector3;
  39755. set position(newPosition: Vector3);
  39756. protected _upVector: Vector3;
  39757. protected _upToYMatrix: Matrix;
  39758. protected _YToUpMatrix: Matrix;
  39759. /**
  39760. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39761. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39762. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39763. */
  39764. set upVector(vec: Vector3);
  39765. get upVector(): Vector3;
  39766. /**
  39767. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39768. */
  39769. setMatUp(): void;
  39770. /**
  39771. * Current inertia value on the longitudinal axis.
  39772. * The bigger this number the longer it will take for the camera to stop.
  39773. */
  39774. inertialAlphaOffset: number;
  39775. /**
  39776. * Current inertia value on the latitudinal axis.
  39777. * The bigger this number the longer it will take for the camera to stop.
  39778. */
  39779. inertialBetaOffset: number;
  39780. /**
  39781. * Current inertia value on the radius axis.
  39782. * The bigger this number the longer it will take for the camera to stop.
  39783. */
  39784. inertialRadiusOffset: number;
  39785. /**
  39786. * Minimum allowed angle on the longitudinal axis.
  39787. * This can help limiting how the Camera is able to move in the scene.
  39788. */
  39789. lowerAlphaLimit: Nullable<number>;
  39790. /**
  39791. * Maximum allowed angle on the longitudinal axis.
  39792. * This can help limiting how the Camera is able to move in the scene.
  39793. */
  39794. upperAlphaLimit: Nullable<number>;
  39795. /**
  39796. * Minimum allowed angle on the latitudinal axis.
  39797. * This can help limiting how the Camera is able to move in the scene.
  39798. */
  39799. lowerBetaLimit: number;
  39800. /**
  39801. * Maximum allowed angle on the latitudinal axis.
  39802. * This can help limiting how the Camera is able to move in the scene.
  39803. */
  39804. upperBetaLimit: number;
  39805. /**
  39806. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39807. * This can help limiting how the Camera is able to move in the scene.
  39808. */
  39809. lowerRadiusLimit: Nullable<number>;
  39810. /**
  39811. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39812. * This can help limiting how the Camera is able to move in the scene.
  39813. */
  39814. upperRadiusLimit: Nullable<number>;
  39815. /**
  39816. * Defines the current inertia value used during panning of the camera along the X axis.
  39817. */
  39818. inertialPanningX: number;
  39819. /**
  39820. * Defines the current inertia value used during panning of the camera along the Y axis.
  39821. */
  39822. inertialPanningY: number;
  39823. /**
  39824. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39825. * Basically if your fingers moves away from more than this distance you will be considered
  39826. * in pinch mode.
  39827. */
  39828. pinchToPanMaxDistance: number;
  39829. /**
  39830. * Defines the maximum distance the camera can pan.
  39831. * This could help keeping the cammera always in your scene.
  39832. */
  39833. panningDistanceLimit: Nullable<number>;
  39834. /**
  39835. * Defines the target of the camera before paning.
  39836. */
  39837. panningOriginTarget: Vector3;
  39838. /**
  39839. * Defines the value of the inertia used during panning.
  39840. * 0 would mean stop inertia and one would mean no decelleration at all.
  39841. */
  39842. panningInertia: number;
  39843. /**
  39844. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39845. */
  39846. get angularSensibilityX(): number;
  39847. set angularSensibilityX(value: number);
  39848. /**
  39849. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39850. */
  39851. get angularSensibilityY(): number;
  39852. set angularSensibilityY(value: number);
  39853. /**
  39854. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39855. */
  39856. get pinchPrecision(): number;
  39857. set pinchPrecision(value: number);
  39858. /**
  39859. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39860. * It will be used instead of pinchDeltaPrecision if different from 0.
  39861. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39862. */
  39863. get pinchDeltaPercentage(): number;
  39864. set pinchDeltaPercentage(value: number);
  39865. /**
  39866. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39867. * and pinch delta percentage.
  39868. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39869. * that any object in the plane at the camera's target point will scale
  39870. * perfectly with finger motion.
  39871. */
  39872. get useNaturalPinchZoom(): boolean;
  39873. set useNaturalPinchZoom(value: boolean);
  39874. /**
  39875. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39876. */
  39877. get panningSensibility(): number;
  39878. set panningSensibility(value: number);
  39879. /**
  39880. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39881. */
  39882. get keysUp(): number[];
  39883. set keysUp(value: number[]);
  39884. /**
  39885. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39886. */
  39887. get keysDown(): number[];
  39888. set keysDown(value: number[]);
  39889. /**
  39890. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39891. */
  39892. get keysLeft(): number[];
  39893. set keysLeft(value: number[]);
  39894. /**
  39895. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39896. */
  39897. get keysRight(): number[];
  39898. set keysRight(value: number[]);
  39899. /**
  39900. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39901. */
  39902. get wheelPrecision(): number;
  39903. set wheelPrecision(value: number);
  39904. /**
  39905. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39906. * It will be used instead of pinchDeltaPrecision if different from 0.
  39907. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39908. */
  39909. get wheelDeltaPercentage(): number;
  39910. set wheelDeltaPercentage(value: number);
  39911. /**
  39912. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39913. */
  39914. zoomOnFactor: number;
  39915. /**
  39916. * Defines a screen offset for the camera position.
  39917. */
  39918. targetScreenOffset: Vector2;
  39919. /**
  39920. * Allows the camera to be completely reversed.
  39921. * If false the camera can not arrive upside down.
  39922. */
  39923. allowUpsideDown: boolean;
  39924. /**
  39925. * Define if double tap/click is used to restore the previously saved state of the camera.
  39926. */
  39927. useInputToRestoreState: boolean;
  39928. /** @hidden */
  39929. _viewMatrix: Matrix;
  39930. /** @hidden */
  39931. _useCtrlForPanning: boolean;
  39932. /** @hidden */
  39933. _panningMouseButton: number;
  39934. /**
  39935. * Defines the input associated to the camera.
  39936. */
  39937. inputs: ArcRotateCameraInputsManager;
  39938. /** @hidden */
  39939. _reset: () => void;
  39940. /**
  39941. * Defines the allowed panning axis.
  39942. */
  39943. panningAxis: Vector3;
  39944. protected _localDirection: Vector3;
  39945. protected _transformedDirection: Vector3;
  39946. private _bouncingBehavior;
  39947. /**
  39948. * Gets the bouncing behavior of the camera if it has been enabled.
  39949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39950. */
  39951. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39952. /**
  39953. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39955. */
  39956. get useBouncingBehavior(): boolean;
  39957. set useBouncingBehavior(value: boolean);
  39958. private _framingBehavior;
  39959. /**
  39960. * Gets the framing behavior of the camera if it has been enabled.
  39961. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39962. */
  39963. get framingBehavior(): Nullable<FramingBehavior>;
  39964. /**
  39965. * Defines if the framing behavior of the camera is enabled on the camera.
  39966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39967. */
  39968. get useFramingBehavior(): boolean;
  39969. set useFramingBehavior(value: boolean);
  39970. private _autoRotationBehavior;
  39971. /**
  39972. * Gets the auto rotation behavior of the camera if it has been enabled.
  39973. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39974. */
  39975. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39976. /**
  39977. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39979. */
  39980. get useAutoRotationBehavior(): boolean;
  39981. set useAutoRotationBehavior(value: boolean);
  39982. /**
  39983. * Observable triggered when the mesh target has been changed on the camera.
  39984. */
  39985. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39986. /**
  39987. * Event raised when the camera is colliding with a mesh.
  39988. */
  39989. onCollide: (collidedMesh: AbstractMesh) => void;
  39990. /**
  39991. * Defines whether the camera should check collision with the objects oh the scene.
  39992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39993. */
  39994. checkCollisions: boolean;
  39995. /**
  39996. * Defines the collision radius of the camera.
  39997. * This simulates a sphere around the camera.
  39998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39999. */
  40000. collisionRadius: Vector3;
  40001. protected _collider: Collider;
  40002. protected _previousPosition: Vector3;
  40003. protected _collisionVelocity: Vector3;
  40004. protected _newPosition: Vector3;
  40005. protected _previousAlpha: number;
  40006. protected _previousBeta: number;
  40007. protected _previousRadius: number;
  40008. protected _collisionTriggered: boolean;
  40009. protected _targetBoundingCenter: Nullable<Vector3>;
  40010. private _computationVector;
  40011. /**
  40012. * Instantiates a new ArcRotateCamera in a given scene
  40013. * @param name Defines the name of the camera
  40014. * @param alpha Defines the camera rotation along the logitudinal axis
  40015. * @param beta Defines the camera rotation along the latitudinal axis
  40016. * @param radius Defines the camera distance from its target
  40017. * @param target Defines the camera target
  40018. * @param scene Defines the scene the camera belongs to
  40019. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40020. */
  40021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40022. /** @hidden */
  40023. _initCache(): void;
  40024. /** @hidden */
  40025. _updateCache(ignoreParentClass?: boolean): void;
  40026. protected _getTargetPosition(): Vector3;
  40027. private _storedAlpha;
  40028. private _storedBeta;
  40029. private _storedRadius;
  40030. private _storedTarget;
  40031. private _storedTargetScreenOffset;
  40032. /**
  40033. * Stores the current state of the camera (alpha, beta, radius and target)
  40034. * @returns the camera itself
  40035. */
  40036. storeState(): Camera;
  40037. /**
  40038. * @hidden
  40039. * Restored camera state. You must call storeState() first
  40040. */
  40041. _restoreStateValues(): boolean;
  40042. /** @hidden */
  40043. _isSynchronizedViewMatrix(): boolean;
  40044. /**
  40045. * Attached controls to the current camera.
  40046. * @param element Defines the element the controls should be listened from
  40047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40048. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40049. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40050. */
  40051. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40052. /**
  40053. * Detach the current controls from the camera.
  40054. * The camera will stop reacting to inputs.
  40055. * @param element Defines the element to stop listening the inputs from
  40056. */
  40057. detachControl(element: HTMLElement): void;
  40058. /** @hidden */
  40059. _checkInputs(): void;
  40060. protected _checkLimits(): void;
  40061. /**
  40062. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40063. */
  40064. rebuildAnglesAndRadius(): void;
  40065. /**
  40066. * Use a position to define the current camera related information like alpha, beta and radius
  40067. * @param position Defines the position to set the camera at
  40068. */
  40069. setPosition(position: Vector3): void;
  40070. /**
  40071. * Defines the target the camera should look at.
  40072. * This will automatically adapt alpha beta and radius to fit within the new target.
  40073. * @param target Defines the new target as a Vector or a mesh
  40074. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40075. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40076. */
  40077. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40078. /** @hidden */
  40079. _getViewMatrix(): Matrix;
  40080. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40081. /**
  40082. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40083. * @param meshes Defines the mesh to zoom on
  40084. * @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)
  40085. */
  40086. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40087. /**
  40088. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40089. * The target will be changed but the radius
  40090. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40091. * @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)
  40092. */
  40093. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40094. min: Vector3;
  40095. max: Vector3;
  40096. distance: number;
  40097. }, doNotUpdateMaxZ?: boolean): void;
  40098. /**
  40099. * @override
  40100. * Override Camera.createRigCamera
  40101. */
  40102. createRigCamera(name: string, cameraIndex: number): Camera;
  40103. /**
  40104. * @hidden
  40105. * @override
  40106. * Override Camera._updateRigCameras
  40107. */
  40108. _updateRigCameras(): void;
  40109. /**
  40110. * Destroy the camera and release the current resources hold by it.
  40111. */
  40112. dispose(): void;
  40113. /**
  40114. * Gets the current object class name.
  40115. * @return the class name
  40116. */
  40117. getClassName(): string;
  40118. }
  40119. }
  40120. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40121. import { Behavior } from "babylonjs/Behaviors/behavior";
  40122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40123. /**
  40124. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40126. */
  40127. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40128. /**
  40129. * Gets the name of the behavior.
  40130. */
  40131. get name(): string;
  40132. private _zoomStopsAnimation;
  40133. private _idleRotationSpeed;
  40134. private _idleRotationWaitTime;
  40135. private _idleRotationSpinupTime;
  40136. /**
  40137. * Sets the flag that indicates if user zooming should stop animation.
  40138. */
  40139. set zoomStopsAnimation(flag: boolean);
  40140. /**
  40141. * Gets the flag that indicates if user zooming should stop animation.
  40142. */
  40143. get zoomStopsAnimation(): boolean;
  40144. /**
  40145. * Sets the default speed at which the camera rotates around the model.
  40146. */
  40147. set idleRotationSpeed(speed: number);
  40148. /**
  40149. * Gets the default speed at which the camera rotates around the model.
  40150. */
  40151. get idleRotationSpeed(): number;
  40152. /**
  40153. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40154. */
  40155. set idleRotationWaitTime(time: number);
  40156. /**
  40157. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40158. */
  40159. get idleRotationWaitTime(): number;
  40160. /**
  40161. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40162. */
  40163. set idleRotationSpinupTime(time: number);
  40164. /**
  40165. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40166. */
  40167. get idleRotationSpinupTime(): number;
  40168. /**
  40169. * Gets a value indicating if the camera is currently rotating because of this behavior
  40170. */
  40171. get rotationInProgress(): boolean;
  40172. private _onPrePointerObservableObserver;
  40173. private _onAfterCheckInputsObserver;
  40174. private _attachedCamera;
  40175. private _isPointerDown;
  40176. private _lastFrameTime;
  40177. private _lastInteractionTime;
  40178. private _cameraRotationSpeed;
  40179. /**
  40180. * Initializes the behavior.
  40181. */
  40182. init(): void;
  40183. /**
  40184. * Attaches the behavior to its arc rotate camera.
  40185. * @param camera Defines the camera to attach the behavior to
  40186. */
  40187. attach(camera: ArcRotateCamera): void;
  40188. /**
  40189. * Detaches the behavior from its current arc rotate camera.
  40190. */
  40191. detach(): void;
  40192. /**
  40193. * Returns true if user is scrolling.
  40194. * @return true if user is scrolling.
  40195. */
  40196. private _userIsZooming;
  40197. private _lastFrameRadius;
  40198. private _shouldAnimationStopForInteraction;
  40199. /**
  40200. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40201. */
  40202. private _applyUserInteraction;
  40203. private _userIsMoving;
  40204. }
  40205. }
  40206. declare module "babylonjs/Behaviors/Cameras/index" {
  40207. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40208. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40209. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40210. }
  40211. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40212. import { Mesh } from "babylonjs/Meshes/mesh";
  40213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40214. import { Behavior } from "babylonjs/Behaviors/behavior";
  40215. /**
  40216. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40217. */
  40218. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40219. private ui;
  40220. /**
  40221. * The name of the behavior
  40222. */
  40223. name: string;
  40224. /**
  40225. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40226. */
  40227. distanceAwayFromFace: number;
  40228. /**
  40229. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40230. */
  40231. distanceAwayFromBottomOfFace: number;
  40232. private _faceVectors;
  40233. private _target;
  40234. private _scene;
  40235. private _onRenderObserver;
  40236. private _tmpMatrix;
  40237. private _tmpVector;
  40238. /**
  40239. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40240. * @param ui The transform node that should be attched to the mesh
  40241. */
  40242. constructor(ui: TransformNode);
  40243. /**
  40244. * Initializes the behavior
  40245. */
  40246. init(): void;
  40247. private _closestFace;
  40248. private _zeroVector;
  40249. private _lookAtTmpMatrix;
  40250. private _lookAtToRef;
  40251. /**
  40252. * Attaches the AttachToBoxBehavior to the passed in mesh
  40253. * @param target The mesh that the specified node will be attached to
  40254. */
  40255. attach(target: Mesh): void;
  40256. /**
  40257. * Detaches the behavior from the mesh
  40258. */
  40259. detach(): void;
  40260. }
  40261. }
  40262. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40263. import { Behavior } from "babylonjs/Behaviors/behavior";
  40264. import { Mesh } from "babylonjs/Meshes/mesh";
  40265. /**
  40266. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40267. */
  40268. export class FadeInOutBehavior implements Behavior<Mesh> {
  40269. /**
  40270. * Time in milliseconds to delay before fading in (Default: 0)
  40271. */
  40272. delay: number;
  40273. /**
  40274. * Time in milliseconds for the mesh to fade in (Default: 300)
  40275. */
  40276. fadeInTime: number;
  40277. private _millisecondsPerFrame;
  40278. private _hovered;
  40279. private _hoverValue;
  40280. private _ownerNode;
  40281. /**
  40282. * Instatiates the FadeInOutBehavior
  40283. */
  40284. constructor();
  40285. /**
  40286. * The name of the behavior
  40287. */
  40288. get name(): string;
  40289. /**
  40290. * Initializes the behavior
  40291. */
  40292. init(): void;
  40293. /**
  40294. * Attaches the fade behavior on the passed in mesh
  40295. * @param ownerNode The mesh that will be faded in/out once attached
  40296. */
  40297. attach(ownerNode: Mesh): void;
  40298. /**
  40299. * Detaches the behavior from the mesh
  40300. */
  40301. detach(): void;
  40302. /**
  40303. * Triggers the mesh to begin fading in or out
  40304. * @param value if the object should fade in or out (true to fade in)
  40305. */
  40306. fadeIn(value: boolean): void;
  40307. private _update;
  40308. private _setAllVisibility;
  40309. }
  40310. }
  40311. declare module "babylonjs/Misc/pivotTools" {
  40312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40313. /**
  40314. * Class containing a set of static utilities functions for managing Pivots
  40315. * @hidden
  40316. */
  40317. export class PivotTools {
  40318. private static _PivotCached;
  40319. private static _OldPivotPoint;
  40320. private static _PivotTranslation;
  40321. private static _PivotTmpVector;
  40322. /** @hidden */
  40323. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40324. /** @hidden */
  40325. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40326. }
  40327. }
  40328. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40329. import { Scene } from "babylonjs/scene";
  40330. import { Vector4 } from "babylonjs/Maths/math.vector";
  40331. import { Mesh } from "babylonjs/Meshes/mesh";
  40332. import { Nullable } from "babylonjs/types";
  40333. import { Plane } from "babylonjs/Maths/math.plane";
  40334. /**
  40335. * Class containing static functions to help procedurally build meshes
  40336. */
  40337. export class PlaneBuilder {
  40338. /**
  40339. * Creates a plane mesh
  40340. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40341. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40342. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40346. * @param name defines the name of the mesh
  40347. * @param options defines the options used to create the mesh
  40348. * @param scene defines the hosting scene
  40349. * @returns the plane mesh
  40350. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40351. */
  40352. static CreatePlane(name: string, options: {
  40353. size?: number;
  40354. width?: number;
  40355. height?: number;
  40356. sideOrientation?: number;
  40357. frontUVs?: Vector4;
  40358. backUVs?: Vector4;
  40359. updatable?: boolean;
  40360. sourcePlane?: Plane;
  40361. }, scene?: Nullable<Scene>): Mesh;
  40362. }
  40363. }
  40364. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40365. import { Behavior } from "babylonjs/Behaviors/behavior";
  40366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40367. import { Observable } from "babylonjs/Misc/observable";
  40368. import { Vector3 } from "babylonjs/Maths/math.vector";
  40369. import { Ray } from "babylonjs/Culling/ray";
  40370. import "babylonjs/Meshes/Builders/planeBuilder";
  40371. /**
  40372. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40373. */
  40374. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40375. private static _AnyMouseID;
  40376. /**
  40377. * Abstract mesh the behavior is set on
  40378. */
  40379. attachedNode: AbstractMesh;
  40380. private _dragPlane;
  40381. private _scene;
  40382. private _pointerObserver;
  40383. private _beforeRenderObserver;
  40384. private static _planeScene;
  40385. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40386. /**
  40387. * 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)
  40388. */
  40389. maxDragAngle: number;
  40390. /**
  40391. * @hidden
  40392. */
  40393. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40394. /**
  40395. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40396. */
  40397. currentDraggingPointerID: number;
  40398. /**
  40399. * The last position where the pointer hit the drag plane in world space
  40400. */
  40401. lastDragPosition: Vector3;
  40402. /**
  40403. * If the behavior is currently in a dragging state
  40404. */
  40405. dragging: boolean;
  40406. /**
  40407. * 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)
  40408. */
  40409. dragDeltaRatio: number;
  40410. /**
  40411. * If the drag plane orientation should be updated during the dragging (Default: true)
  40412. */
  40413. updateDragPlane: boolean;
  40414. private _debugMode;
  40415. private _moving;
  40416. /**
  40417. * Fires each time the attached mesh is dragged with the pointer
  40418. * * delta between last drag position and current drag position in world space
  40419. * * dragDistance along the drag axis
  40420. * * dragPlaneNormal normal of the current drag plane used during the drag
  40421. * * dragPlanePoint in world space where the drag intersects the drag plane
  40422. */
  40423. onDragObservable: Observable<{
  40424. delta: Vector3;
  40425. dragPlanePoint: Vector3;
  40426. dragPlaneNormal: Vector3;
  40427. dragDistance: number;
  40428. pointerId: number;
  40429. }>;
  40430. /**
  40431. * Fires each time a drag begins (eg. mouse down on mesh)
  40432. */
  40433. onDragStartObservable: Observable<{
  40434. dragPlanePoint: Vector3;
  40435. pointerId: number;
  40436. }>;
  40437. /**
  40438. * Fires each time a drag ends (eg. mouse release after drag)
  40439. */
  40440. onDragEndObservable: Observable<{
  40441. dragPlanePoint: Vector3;
  40442. pointerId: number;
  40443. }>;
  40444. /**
  40445. * If the attached mesh should be moved when dragged
  40446. */
  40447. moveAttached: boolean;
  40448. /**
  40449. * If the drag behavior will react to drag events (Default: true)
  40450. */
  40451. enabled: boolean;
  40452. /**
  40453. * If pointer events should start and release the drag (Default: true)
  40454. */
  40455. startAndReleaseDragOnPointerEvents: boolean;
  40456. /**
  40457. * If camera controls should be detached during the drag
  40458. */
  40459. detachCameraControls: boolean;
  40460. /**
  40461. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40462. */
  40463. useObjectOrientationForDragging: boolean;
  40464. private _options;
  40465. /**
  40466. * Gets the options used by the behavior
  40467. */
  40468. get options(): {
  40469. dragAxis?: Vector3;
  40470. dragPlaneNormal?: Vector3;
  40471. };
  40472. /**
  40473. * Sets the options used by the behavior
  40474. */
  40475. set options(options: {
  40476. dragAxis?: Vector3;
  40477. dragPlaneNormal?: Vector3;
  40478. });
  40479. /**
  40480. * Creates a pointer drag behavior that can be attached to a mesh
  40481. * @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)
  40482. */
  40483. constructor(options?: {
  40484. dragAxis?: Vector3;
  40485. dragPlaneNormal?: Vector3;
  40486. });
  40487. /**
  40488. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40489. */
  40490. validateDrag: (targetPosition: Vector3) => boolean;
  40491. /**
  40492. * The name of the behavior
  40493. */
  40494. get name(): string;
  40495. /**
  40496. * Initializes the behavior
  40497. */
  40498. init(): void;
  40499. private _tmpVector;
  40500. private _alternatePickedPoint;
  40501. private _worldDragAxis;
  40502. private _targetPosition;
  40503. private _attachedElement;
  40504. /**
  40505. * Attaches the drag behavior the passed in mesh
  40506. * @param ownerNode The mesh that will be dragged around once attached
  40507. * @param predicate Predicate to use for pick filtering
  40508. */
  40509. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40510. /**
  40511. * Force relase the drag action by code.
  40512. */
  40513. releaseDrag(): void;
  40514. private _startDragRay;
  40515. private _lastPointerRay;
  40516. /**
  40517. * Simulates the start of a pointer drag event on the behavior
  40518. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40519. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40520. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40521. */
  40522. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40523. private _startDrag;
  40524. private _dragDelta;
  40525. private _moveDrag;
  40526. private _pickWithRayOnDragPlane;
  40527. private _pointA;
  40528. private _pointB;
  40529. private _pointC;
  40530. private _lineA;
  40531. private _lineB;
  40532. private _localAxis;
  40533. private _lookAt;
  40534. private _updateDragPlanePosition;
  40535. /**
  40536. * Detaches the behavior from the mesh
  40537. */
  40538. detach(): void;
  40539. }
  40540. }
  40541. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40542. import { Mesh } from "babylonjs/Meshes/mesh";
  40543. import { Behavior } from "babylonjs/Behaviors/behavior";
  40544. /**
  40545. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40546. */
  40547. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40548. private _dragBehaviorA;
  40549. private _dragBehaviorB;
  40550. private _startDistance;
  40551. private _initialScale;
  40552. private _targetScale;
  40553. private _ownerNode;
  40554. private _sceneRenderObserver;
  40555. /**
  40556. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40557. */
  40558. constructor();
  40559. /**
  40560. * The name of the behavior
  40561. */
  40562. get name(): string;
  40563. /**
  40564. * Initializes the behavior
  40565. */
  40566. init(): void;
  40567. private _getCurrentDistance;
  40568. /**
  40569. * Attaches the scale behavior the passed in mesh
  40570. * @param ownerNode The mesh that will be scaled around once attached
  40571. */
  40572. attach(ownerNode: Mesh): void;
  40573. /**
  40574. * Detaches the behavior from the mesh
  40575. */
  40576. detach(): void;
  40577. }
  40578. }
  40579. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40580. import { Behavior } from "babylonjs/Behaviors/behavior";
  40581. import { Mesh } from "babylonjs/Meshes/mesh";
  40582. import { Observable } from "babylonjs/Misc/observable";
  40583. /**
  40584. * 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
  40585. */
  40586. export class SixDofDragBehavior implements Behavior<Mesh> {
  40587. private static _virtualScene;
  40588. private _ownerNode;
  40589. private _sceneRenderObserver;
  40590. private _scene;
  40591. private _targetPosition;
  40592. private _virtualOriginMesh;
  40593. private _virtualDragMesh;
  40594. private _pointerObserver;
  40595. private _moving;
  40596. private _startingOrientation;
  40597. /**
  40598. * 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)
  40599. */
  40600. private zDragFactor;
  40601. /**
  40602. * If the object should rotate to face the drag origin
  40603. */
  40604. rotateDraggedObject: boolean;
  40605. /**
  40606. * If the behavior is currently in a dragging state
  40607. */
  40608. dragging: boolean;
  40609. /**
  40610. * 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)
  40611. */
  40612. dragDeltaRatio: number;
  40613. /**
  40614. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40615. */
  40616. currentDraggingPointerID: number;
  40617. /**
  40618. * If camera controls should be detached during the drag
  40619. */
  40620. detachCameraControls: boolean;
  40621. /**
  40622. * Fires each time a drag starts
  40623. */
  40624. onDragStartObservable: Observable<{}>;
  40625. /**
  40626. * Fires each time a drag ends (eg. mouse release after drag)
  40627. */
  40628. onDragEndObservable: Observable<{}>;
  40629. /**
  40630. * 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
  40631. */
  40632. constructor();
  40633. /**
  40634. * The name of the behavior
  40635. */
  40636. get name(): string;
  40637. /**
  40638. * Initializes the behavior
  40639. */
  40640. init(): void;
  40641. /**
  40642. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40643. */
  40644. private get _pointerCamera();
  40645. /**
  40646. * Attaches the scale behavior the passed in mesh
  40647. * @param ownerNode The mesh that will be scaled around once attached
  40648. */
  40649. attach(ownerNode: Mesh): void;
  40650. /**
  40651. * Detaches the behavior from the mesh
  40652. */
  40653. detach(): void;
  40654. }
  40655. }
  40656. declare module "babylonjs/Behaviors/Meshes/index" {
  40657. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40658. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40659. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40660. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40661. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40662. }
  40663. declare module "babylonjs/Behaviors/index" {
  40664. export * from "babylonjs/Behaviors/behavior";
  40665. export * from "babylonjs/Behaviors/Cameras/index";
  40666. export * from "babylonjs/Behaviors/Meshes/index";
  40667. }
  40668. declare module "babylonjs/Bones/boneIKController" {
  40669. import { Bone } from "babylonjs/Bones/bone";
  40670. import { Vector3 } from "babylonjs/Maths/math.vector";
  40671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40672. import { Nullable } from "babylonjs/types";
  40673. /**
  40674. * Class used to apply inverse kinematics to bones
  40675. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40676. */
  40677. export class BoneIKController {
  40678. private static _tmpVecs;
  40679. private static _tmpQuat;
  40680. private static _tmpMats;
  40681. /**
  40682. * Gets or sets the target mesh
  40683. */
  40684. targetMesh: AbstractMesh;
  40685. /** Gets or sets the mesh used as pole */
  40686. poleTargetMesh: AbstractMesh;
  40687. /**
  40688. * Gets or sets the bone used as pole
  40689. */
  40690. poleTargetBone: Nullable<Bone>;
  40691. /**
  40692. * Gets or sets the target position
  40693. */
  40694. targetPosition: Vector3;
  40695. /**
  40696. * Gets or sets the pole target position
  40697. */
  40698. poleTargetPosition: Vector3;
  40699. /**
  40700. * Gets or sets the pole target local offset
  40701. */
  40702. poleTargetLocalOffset: Vector3;
  40703. /**
  40704. * Gets or sets the pole angle
  40705. */
  40706. poleAngle: number;
  40707. /**
  40708. * Gets or sets the mesh associated with the controller
  40709. */
  40710. mesh: AbstractMesh;
  40711. /**
  40712. * 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)
  40713. */
  40714. slerpAmount: number;
  40715. private _bone1Quat;
  40716. private _bone1Mat;
  40717. private _bone2Ang;
  40718. private _bone1;
  40719. private _bone2;
  40720. private _bone1Length;
  40721. private _bone2Length;
  40722. private _maxAngle;
  40723. private _maxReach;
  40724. private _rightHandedSystem;
  40725. private _bendAxis;
  40726. private _slerping;
  40727. private _adjustRoll;
  40728. /**
  40729. * Gets or sets maximum allowed angle
  40730. */
  40731. get maxAngle(): number;
  40732. set maxAngle(value: number);
  40733. /**
  40734. * Creates a new BoneIKController
  40735. * @param mesh defines the mesh to control
  40736. * @param bone defines the bone to control
  40737. * @param options defines options to set up the controller
  40738. */
  40739. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40740. targetMesh?: AbstractMesh;
  40741. poleTargetMesh?: AbstractMesh;
  40742. poleTargetBone?: Bone;
  40743. poleTargetLocalOffset?: Vector3;
  40744. poleAngle?: number;
  40745. bendAxis?: Vector3;
  40746. maxAngle?: number;
  40747. slerpAmount?: number;
  40748. });
  40749. private _setMaxAngle;
  40750. /**
  40751. * Force the controller to update the bones
  40752. */
  40753. update(): void;
  40754. }
  40755. }
  40756. declare module "babylonjs/Bones/boneLookController" {
  40757. import { Vector3 } from "babylonjs/Maths/math.vector";
  40758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40759. import { Bone } from "babylonjs/Bones/bone";
  40760. import { Space } from "babylonjs/Maths/math.axis";
  40761. /**
  40762. * Class used to make a bone look toward a point in space
  40763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40764. */
  40765. export class BoneLookController {
  40766. private static _tmpVecs;
  40767. private static _tmpQuat;
  40768. private static _tmpMats;
  40769. /**
  40770. * The target Vector3 that the bone will look at
  40771. */
  40772. target: Vector3;
  40773. /**
  40774. * The mesh that the bone is attached to
  40775. */
  40776. mesh: AbstractMesh;
  40777. /**
  40778. * The bone that will be looking to the target
  40779. */
  40780. bone: Bone;
  40781. /**
  40782. * The up axis of the coordinate system that is used when the bone is rotated
  40783. */
  40784. upAxis: Vector3;
  40785. /**
  40786. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40787. */
  40788. upAxisSpace: Space;
  40789. /**
  40790. * Used to make an adjustment to the yaw of the bone
  40791. */
  40792. adjustYaw: number;
  40793. /**
  40794. * Used to make an adjustment to the pitch of the bone
  40795. */
  40796. adjustPitch: number;
  40797. /**
  40798. * Used to make an adjustment to the roll of the bone
  40799. */
  40800. adjustRoll: number;
  40801. /**
  40802. * 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)
  40803. */
  40804. slerpAmount: number;
  40805. private _minYaw;
  40806. private _maxYaw;
  40807. private _minPitch;
  40808. private _maxPitch;
  40809. private _minYawSin;
  40810. private _minYawCos;
  40811. private _maxYawSin;
  40812. private _maxYawCos;
  40813. private _midYawConstraint;
  40814. private _minPitchTan;
  40815. private _maxPitchTan;
  40816. private _boneQuat;
  40817. private _slerping;
  40818. private _transformYawPitch;
  40819. private _transformYawPitchInv;
  40820. private _firstFrameSkipped;
  40821. private _yawRange;
  40822. private _fowardAxis;
  40823. /**
  40824. * Gets or sets the minimum yaw angle that the bone can look to
  40825. */
  40826. get minYaw(): number;
  40827. set minYaw(value: number);
  40828. /**
  40829. * Gets or sets the maximum yaw angle that the bone can look to
  40830. */
  40831. get maxYaw(): number;
  40832. set maxYaw(value: number);
  40833. /**
  40834. * Gets or sets the minimum pitch angle that the bone can look to
  40835. */
  40836. get minPitch(): number;
  40837. set minPitch(value: number);
  40838. /**
  40839. * Gets or sets the maximum pitch angle that the bone can look to
  40840. */
  40841. get maxPitch(): number;
  40842. set maxPitch(value: number);
  40843. /**
  40844. * Create a BoneLookController
  40845. * @param mesh the mesh that the bone belongs to
  40846. * @param bone the bone that will be looking to the target
  40847. * @param target the target Vector3 to look at
  40848. * @param options optional settings:
  40849. * * maxYaw: the maximum angle the bone will yaw to
  40850. * * minYaw: the minimum angle the bone will yaw to
  40851. * * maxPitch: the maximum angle the bone will pitch to
  40852. * * minPitch: the minimum angle the bone will yaw to
  40853. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40854. * * upAxis: the up axis of the coordinate system
  40855. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40856. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40857. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40858. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40859. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40860. * * adjustRoll: used to make an adjustment to the roll of the bone
  40861. **/
  40862. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40863. maxYaw?: number;
  40864. minYaw?: number;
  40865. maxPitch?: number;
  40866. minPitch?: number;
  40867. slerpAmount?: number;
  40868. upAxis?: Vector3;
  40869. upAxisSpace?: Space;
  40870. yawAxis?: Vector3;
  40871. pitchAxis?: Vector3;
  40872. adjustYaw?: number;
  40873. adjustPitch?: number;
  40874. adjustRoll?: number;
  40875. });
  40876. /**
  40877. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40878. */
  40879. update(): void;
  40880. private _getAngleDiff;
  40881. private _getAngleBetween;
  40882. private _isAngleBetween;
  40883. }
  40884. }
  40885. declare module "babylonjs/Bones/index" {
  40886. export * from "babylonjs/Bones/bone";
  40887. export * from "babylonjs/Bones/boneIKController";
  40888. export * from "babylonjs/Bones/boneLookController";
  40889. export * from "babylonjs/Bones/skeleton";
  40890. }
  40891. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40892. import { Nullable } from "babylonjs/types";
  40893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40895. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40896. /**
  40897. * Manage the gamepad inputs to control an arc rotate camera.
  40898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40899. */
  40900. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40901. /**
  40902. * Defines the camera the input is attached to.
  40903. */
  40904. camera: ArcRotateCamera;
  40905. /**
  40906. * Defines the gamepad the input is gathering event from.
  40907. */
  40908. gamepad: Nullable<Gamepad>;
  40909. /**
  40910. * Defines the gamepad rotation sensiblity.
  40911. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40912. */
  40913. gamepadRotationSensibility: number;
  40914. /**
  40915. * Defines the gamepad move sensiblity.
  40916. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40917. */
  40918. gamepadMoveSensibility: number;
  40919. private _yAxisScale;
  40920. /**
  40921. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40922. */
  40923. get invertYAxis(): boolean;
  40924. set invertYAxis(value: boolean);
  40925. private _onGamepadConnectedObserver;
  40926. private _onGamepadDisconnectedObserver;
  40927. /**
  40928. * Attach the input controls to a specific dom element to get the input from.
  40929. * @param element Defines the element the controls should be listened from
  40930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40931. */
  40932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40933. /**
  40934. * Detach the current controls from the specified dom element.
  40935. * @param element Defines the element to stop listening the inputs from
  40936. */
  40937. detachControl(element: Nullable<HTMLElement>): void;
  40938. /**
  40939. * Update the current camera state depending on the inputs that have been used this frame.
  40940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40941. */
  40942. checkInputs(): void;
  40943. /**
  40944. * Gets the class name of the current intput.
  40945. * @returns the class name
  40946. */
  40947. getClassName(): string;
  40948. /**
  40949. * Get the friendly name associated with the input class.
  40950. * @returns the input friendly name
  40951. */
  40952. getSimpleName(): string;
  40953. }
  40954. }
  40955. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40956. import { Nullable } from "babylonjs/types";
  40957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40958. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40959. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40960. interface ArcRotateCameraInputsManager {
  40961. /**
  40962. * Add orientation input support to the input manager.
  40963. * @returns the current input manager
  40964. */
  40965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40966. }
  40967. }
  40968. /**
  40969. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40971. */
  40972. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40973. /**
  40974. * Defines the camera the input is attached to.
  40975. */
  40976. camera: ArcRotateCamera;
  40977. /**
  40978. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40979. */
  40980. alphaCorrection: number;
  40981. /**
  40982. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40983. */
  40984. gammaCorrection: number;
  40985. private _alpha;
  40986. private _gamma;
  40987. private _dirty;
  40988. private _deviceOrientationHandler;
  40989. /**
  40990. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40991. */
  40992. constructor();
  40993. /**
  40994. * Attach the input controls to a specific dom element to get the input from.
  40995. * @param element Defines the element the controls should be listened from
  40996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40997. */
  40998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40999. /** @hidden */
  41000. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41001. /**
  41002. * Update the current camera state depending on the inputs that have been used this frame.
  41003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41004. */
  41005. checkInputs(): void;
  41006. /**
  41007. * Detach the current controls from the specified dom element.
  41008. * @param element Defines the element to stop listening the inputs from
  41009. */
  41010. detachControl(element: Nullable<HTMLElement>): void;
  41011. /**
  41012. * Gets the class name of the current intput.
  41013. * @returns the class name
  41014. */
  41015. getClassName(): string;
  41016. /**
  41017. * Get the friendly name associated with the input class.
  41018. * @returns the input friendly name
  41019. */
  41020. getSimpleName(): string;
  41021. }
  41022. }
  41023. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41024. import { Nullable } from "babylonjs/types";
  41025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41026. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41027. /**
  41028. * Listen to mouse events to control the camera.
  41029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41030. */
  41031. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41032. /**
  41033. * Defines the camera the input is attached to.
  41034. */
  41035. camera: FlyCamera;
  41036. /**
  41037. * Defines if touch is enabled. (Default is true.)
  41038. */
  41039. touchEnabled: boolean;
  41040. /**
  41041. * Defines the buttons associated with the input to handle camera rotation.
  41042. */
  41043. buttons: number[];
  41044. /**
  41045. * Assign buttons for Yaw control.
  41046. */
  41047. buttonsYaw: number[];
  41048. /**
  41049. * Assign buttons for Pitch control.
  41050. */
  41051. buttonsPitch: number[];
  41052. /**
  41053. * Assign buttons for Roll control.
  41054. */
  41055. buttonsRoll: number[];
  41056. /**
  41057. * Detect if any button is being pressed while mouse is moved.
  41058. * -1 = Mouse locked.
  41059. * 0 = Left button.
  41060. * 1 = Middle Button.
  41061. * 2 = Right Button.
  41062. */
  41063. activeButton: number;
  41064. /**
  41065. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41066. * Higher values reduce its sensitivity.
  41067. */
  41068. angularSensibility: number;
  41069. private _mousemoveCallback;
  41070. private _observer;
  41071. private _rollObserver;
  41072. private previousPosition;
  41073. private noPreventDefault;
  41074. private element;
  41075. /**
  41076. * Listen to mouse events to control the camera.
  41077. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41079. */
  41080. constructor(touchEnabled?: boolean);
  41081. /**
  41082. * Attach the mouse control to the HTML DOM element.
  41083. * @param element Defines the element that listens to the input events.
  41084. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41085. */
  41086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41087. /**
  41088. * Detach the current controls from the specified dom element.
  41089. * @param element Defines the element to stop listening the inputs from
  41090. */
  41091. detachControl(element: Nullable<HTMLElement>): void;
  41092. /**
  41093. * Gets the class name of the current input.
  41094. * @returns the class name.
  41095. */
  41096. getClassName(): string;
  41097. /**
  41098. * Get the friendly name associated with the input class.
  41099. * @returns the input's friendly name.
  41100. */
  41101. getSimpleName(): string;
  41102. private _pointerInput;
  41103. private _onMouseMove;
  41104. /**
  41105. * Rotate camera by mouse offset.
  41106. */
  41107. private rotateCamera;
  41108. }
  41109. }
  41110. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41111. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41112. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41113. /**
  41114. * Default Inputs manager for the FlyCamera.
  41115. * It groups all the default supported inputs for ease of use.
  41116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41117. */
  41118. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41119. /**
  41120. * Instantiates a new FlyCameraInputsManager.
  41121. * @param camera Defines the camera the inputs belong to.
  41122. */
  41123. constructor(camera: FlyCamera);
  41124. /**
  41125. * Add keyboard input support to the input manager.
  41126. * @returns the new FlyCameraKeyboardMoveInput().
  41127. */
  41128. addKeyboard(): FlyCameraInputsManager;
  41129. /**
  41130. * Add mouse input support to the input manager.
  41131. * @param touchEnabled Enable touch screen support.
  41132. * @returns the new FlyCameraMouseInput().
  41133. */
  41134. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41135. }
  41136. }
  41137. declare module "babylonjs/Cameras/flyCamera" {
  41138. import { Scene } from "babylonjs/scene";
  41139. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41141. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41142. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41143. /**
  41144. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41145. * such as in a 3D Space Shooter or a Flight Simulator.
  41146. */
  41147. export class FlyCamera extends TargetCamera {
  41148. /**
  41149. * Define the collision ellipsoid of the camera.
  41150. * This is helpful for simulating a camera body, like a player's body.
  41151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41152. */
  41153. ellipsoid: Vector3;
  41154. /**
  41155. * Define an offset for the position of the ellipsoid around the camera.
  41156. * This can be helpful if the camera is attached away from the player's body center,
  41157. * such as at its head.
  41158. */
  41159. ellipsoidOffset: Vector3;
  41160. /**
  41161. * Enable or disable collisions of the camera with the rest of the scene objects.
  41162. */
  41163. checkCollisions: boolean;
  41164. /**
  41165. * Enable or disable gravity on the camera.
  41166. */
  41167. applyGravity: boolean;
  41168. /**
  41169. * Define the current direction the camera is moving to.
  41170. */
  41171. cameraDirection: Vector3;
  41172. /**
  41173. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41174. * This overrides and empties cameraRotation.
  41175. */
  41176. rotationQuaternion: Quaternion;
  41177. /**
  41178. * Track Roll to maintain the wanted Rolling when looking around.
  41179. */
  41180. _trackRoll: number;
  41181. /**
  41182. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41183. */
  41184. rollCorrect: number;
  41185. /**
  41186. * Mimic a banked turn, Rolling the camera when Yawing.
  41187. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41188. */
  41189. bankedTurn: boolean;
  41190. /**
  41191. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41192. */
  41193. bankedTurnLimit: number;
  41194. /**
  41195. * Value of 0 disables the banked Roll.
  41196. * Value of 1 is equal to the Yaw angle in radians.
  41197. */
  41198. bankedTurnMultiplier: number;
  41199. /**
  41200. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41201. */
  41202. inputs: FlyCameraInputsManager;
  41203. /**
  41204. * Gets the input sensibility for mouse input.
  41205. * Higher values reduce sensitivity.
  41206. */
  41207. get angularSensibility(): number;
  41208. /**
  41209. * Sets the input sensibility for a mouse input.
  41210. * Higher values reduce sensitivity.
  41211. */
  41212. set angularSensibility(value: number);
  41213. /**
  41214. * Get the keys for camera movement forward.
  41215. */
  41216. get keysForward(): number[];
  41217. /**
  41218. * Set the keys for camera movement forward.
  41219. */
  41220. set keysForward(value: number[]);
  41221. /**
  41222. * Get the keys for camera movement backward.
  41223. */
  41224. get keysBackward(): number[];
  41225. set keysBackward(value: number[]);
  41226. /**
  41227. * Get the keys for camera movement up.
  41228. */
  41229. get keysUp(): number[];
  41230. /**
  41231. * Set the keys for camera movement up.
  41232. */
  41233. set keysUp(value: number[]);
  41234. /**
  41235. * Get the keys for camera movement down.
  41236. */
  41237. get keysDown(): number[];
  41238. /**
  41239. * Set the keys for camera movement down.
  41240. */
  41241. set keysDown(value: number[]);
  41242. /**
  41243. * Get the keys for camera movement left.
  41244. */
  41245. get keysLeft(): number[];
  41246. /**
  41247. * Set the keys for camera movement left.
  41248. */
  41249. set keysLeft(value: number[]);
  41250. /**
  41251. * Set the keys for camera movement right.
  41252. */
  41253. get keysRight(): number[];
  41254. /**
  41255. * Set the keys for camera movement right.
  41256. */
  41257. set keysRight(value: number[]);
  41258. /**
  41259. * Event raised when the camera collides with a mesh in the scene.
  41260. */
  41261. onCollide: (collidedMesh: AbstractMesh) => void;
  41262. private _collider;
  41263. private _needMoveForGravity;
  41264. private _oldPosition;
  41265. private _diffPosition;
  41266. private _newPosition;
  41267. /** @hidden */
  41268. _localDirection: Vector3;
  41269. /** @hidden */
  41270. _transformedDirection: Vector3;
  41271. /**
  41272. * Instantiates a FlyCamera.
  41273. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41274. * such as in a 3D Space Shooter or a Flight Simulator.
  41275. * @param name Define the name of the camera in the scene.
  41276. * @param position Define the starting position of the camera in the scene.
  41277. * @param scene Define the scene the camera belongs to.
  41278. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41279. */
  41280. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41281. /**
  41282. * Attach a control to the HTML DOM element.
  41283. * @param element Defines the element that listens to the input events.
  41284. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41285. */
  41286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41287. /**
  41288. * Detach a control from the HTML DOM element.
  41289. * The camera will stop reacting to that input.
  41290. * @param element Defines the element that listens to the input events.
  41291. */
  41292. detachControl(element: HTMLElement): void;
  41293. private _collisionMask;
  41294. /**
  41295. * Get the mask that the camera ignores in collision events.
  41296. */
  41297. get collisionMask(): number;
  41298. /**
  41299. * Set the mask that the camera ignores in collision events.
  41300. */
  41301. set collisionMask(mask: number);
  41302. /** @hidden */
  41303. _collideWithWorld(displacement: Vector3): void;
  41304. /** @hidden */
  41305. private _onCollisionPositionChange;
  41306. /** @hidden */
  41307. _checkInputs(): void;
  41308. /** @hidden */
  41309. _decideIfNeedsToMove(): boolean;
  41310. /** @hidden */
  41311. _updatePosition(): void;
  41312. /**
  41313. * Restore the Roll to its target value at the rate specified.
  41314. * @param rate - Higher means slower restoring.
  41315. * @hidden
  41316. */
  41317. restoreRoll(rate: number): void;
  41318. /**
  41319. * Destroy the camera and release the current resources held by it.
  41320. */
  41321. dispose(): void;
  41322. /**
  41323. * Get the current object class name.
  41324. * @returns the class name.
  41325. */
  41326. getClassName(): string;
  41327. }
  41328. }
  41329. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41330. import { Nullable } from "babylonjs/types";
  41331. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41332. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41333. /**
  41334. * Listen to keyboard events to control the camera.
  41335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41336. */
  41337. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41338. /**
  41339. * Defines the camera the input is attached to.
  41340. */
  41341. camera: FlyCamera;
  41342. /**
  41343. * The list of keyboard keys used to control the forward move of the camera.
  41344. */
  41345. keysForward: number[];
  41346. /**
  41347. * The list of keyboard keys used to control the backward move of the camera.
  41348. */
  41349. keysBackward: number[];
  41350. /**
  41351. * The list of keyboard keys used to control the forward move of the camera.
  41352. */
  41353. keysUp: number[];
  41354. /**
  41355. * The list of keyboard keys used to control the backward move of the camera.
  41356. */
  41357. keysDown: number[];
  41358. /**
  41359. * The list of keyboard keys used to control the right strafe move of the camera.
  41360. */
  41361. keysRight: number[];
  41362. /**
  41363. * The list of keyboard keys used to control the left strafe move of the camera.
  41364. */
  41365. keysLeft: number[];
  41366. private _keys;
  41367. private _onCanvasBlurObserver;
  41368. private _onKeyboardObserver;
  41369. private _engine;
  41370. private _scene;
  41371. /**
  41372. * Attach the input controls to a specific dom element to get the input from.
  41373. * @param element Defines the element the controls should be listened from
  41374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41375. */
  41376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41377. /**
  41378. * Detach the current controls from the specified dom element.
  41379. * @param element Defines the element to stop listening the inputs from
  41380. */
  41381. detachControl(element: Nullable<HTMLElement>): void;
  41382. /**
  41383. * Gets the class name of the current intput.
  41384. * @returns the class name
  41385. */
  41386. getClassName(): string;
  41387. /** @hidden */
  41388. _onLostFocus(e: FocusEvent): void;
  41389. /**
  41390. * Get the friendly name associated with the input class.
  41391. * @returns the input friendly name
  41392. */
  41393. getSimpleName(): string;
  41394. /**
  41395. * Update the current camera state depending on the inputs that have been used this frame.
  41396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41397. */
  41398. checkInputs(): void;
  41399. }
  41400. }
  41401. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41402. import { Nullable } from "babylonjs/types";
  41403. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41404. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41405. /**
  41406. * Manage the mouse wheel inputs to control a follow camera.
  41407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41408. */
  41409. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41410. /**
  41411. * Defines the camera the input is attached to.
  41412. */
  41413. camera: FollowCamera;
  41414. /**
  41415. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41416. */
  41417. axisControlRadius: boolean;
  41418. /**
  41419. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41420. */
  41421. axisControlHeight: boolean;
  41422. /**
  41423. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41424. */
  41425. axisControlRotation: boolean;
  41426. /**
  41427. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41428. * relation to mouseWheel events.
  41429. */
  41430. wheelPrecision: number;
  41431. /**
  41432. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41433. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41434. */
  41435. wheelDeltaPercentage: number;
  41436. private _wheel;
  41437. private _observer;
  41438. /**
  41439. * Attach the input controls to a specific dom element to get the input from.
  41440. * @param element Defines the element the controls should be listened from
  41441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41442. */
  41443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41444. /**
  41445. * Detach the current controls from the specified dom element.
  41446. * @param element Defines the element to stop listening the inputs from
  41447. */
  41448. detachControl(element: Nullable<HTMLElement>): void;
  41449. /**
  41450. * Gets the class name of the current intput.
  41451. * @returns the class name
  41452. */
  41453. getClassName(): string;
  41454. /**
  41455. * Get the friendly name associated with the input class.
  41456. * @returns the input friendly name
  41457. */
  41458. getSimpleName(): string;
  41459. }
  41460. }
  41461. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41462. import { Nullable } from "babylonjs/types";
  41463. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41464. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41465. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41466. /**
  41467. * Manage the pointers inputs to control an follow camera.
  41468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41469. */
  41470. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41471. /**
  41472. * Defines the camera the input is attached to.
  41473. */
  41474. camera: FollowCamera;
  41475. /**
  41476. * Gets the class name of the current input.
  41477. * @returns the class name
  41478. */
  41479. getClassName(): string;
  41480. /**
  41481. * Defines the pointer angular sensibility along the X axis or how fast is
  41482. * the camera rotating.
  41483. * A negative number will reverse the axis direction.
  41484. */
  41485. angularSensibilityX: number;
  41486. /**
  41487. * Defines the pointer angular sensibility along the Y axis or how fast is
  41488. * the camera rotating.
  41489. * A negative number will reverse the axis direction.
  41490. */
  41491. angularSensibilityY: number;
  41492. /**
  41493. * Defines the pointer pinch precision or how fast is the camera zooming.
  41494. * A negative number will reverse the axis direction.
  41495. */
  41496. pinchPrecision: number;
  41497. /**
  41498. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41499. * from 0.
  41500. * It defines the percentage of current camera.radius to use as delta when
  41501. * pinch zoom is used.
  41502. */
  41503. pinchDeltaPercentage: number;
  41504. /**
  41505. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41506. */
  41507. axisXControlRadius: boolean;
  41508. /**
  41509. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41510. */
  41511. axisXControlHeight: boolean;
  41512. /**
  41513. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41514. */
  41515. axisXControlRotation: boolean;
  41516. /**
  41517. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41518. */
  41519. axisYControlRadius: boolean;
  41520. /**
  41521. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41522. */
  41523. axisYControlHeight: boolean;
  41524. /**
  41525. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41526. */
  41527. axisYControlRotation: boolean;
  41528. /**
  41529. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41530. */
  41531. axisPinchControlRadius: boolean;
  41532. /**
  41533. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41534. */
  41535. axisPinchControlHeight: boolean;
  41536. /**
  41537. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41538. */
  41539. axisPinchControlRotation: boolean;
  41540. /**
  41541. * Log error messages if basic misconfiguration has occurred.
  41542. */
  41543. warningEnable: boolean;
  41544. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41545. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41546. private _warningCounter;
  41547. private _warning;
  41548. }
  41549. }
  41550. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41551. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41552. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41553. /**
  41554. * Default Inputs manager for the FollowCamera.
  41555. * It groups all the default supported inputs for ease of use.
  41556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41557. */
  41558. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41559. /**
  41560. * Instantiates a new FollowCameraInputsManager.
  41561. * @param camera Defines the camera the inputs belong to
  41562. */
  41563. constructor(camera: FollowCamera);
  41564. /**
  41565. * Add keyboard input support to the input manager.
  41566. * @returns the current input manager
  41567. */
  41568. addKeyboard(): FollowCameraInputsManager;
  41569. /**
  41570. * Add mouse wheel input support to the input manager.
  41571. * @returns the current input manager
  41572. */
  41573. addMouseWheel(): FollowCameraInputsManager;
  41574. /**
  41575. * Add pointers input support to the input manager.
  41576. * @returns the current input manager
  41577. */
  41578. addPointers(): FollowCameraInputsManager;
  41579. /**
  41580. * Add orientation input support to the input manager.
  41581. * @returns the current input manager
  41582. */
  41583. addVRDeviceOrientation(): FollowCameraInputsManager;
  41584. }
  41585. }
  41586. declare module "babylonjs/Cameras/followCamera" {
  41587. import { Nullable } from "babylonjs/types";
  41588. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41589. import { Scene } from "babylonjs/scene";
  41590. import { Vector3 } from "babylonjs/Maths/math.vector";
  41591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41592. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41593. /**
  41594. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41595. * an arc rotate version arcFollowCamera are available.
  41596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41597. */
  41598. export class FollowCamera extends TargetCamera {
  41599. /**
  41600. * Distance the follow camera should follow an object at
  41601. */
  41602. radius: number;
  41603. /**
  41604. * Minimum allowed distance of the camera to the axis of rotation
  41605. * (The camera can not get closer).
  41606. * This can help limiting how the Camera is able to move in the scene.
  41607. */
  41608. lowerRadiusLimit: Nullable<number>;
  41609. /**
  41610. * Maximum allowed distance of the camera to the axis of rotation
  41611. * (The camera can not get further).
  41612. * This can help limiting how the Camera is able to move in the scene.
  41613. */
  41614. upperRadiusLimit: Nullable<number>;
  41615. /**
  41616. * Define a rotation offset between the camera and the object it follows
  41617. */
  41618. rotationOffset: number;
  41619. /**
  41620. * Minimum allowed angle to camera position relative to target object.
  41621. * This can help limiting how the Camera is able to move in the scene.
  41622. */
  41623. lowerRotationOffsetLimit: Nullable<number>;
  41624. /**
  41625. * Maximum allowed angle to camera position relative to target object.
  41626. * This can help limiting how the Camera is able to move in the scene.
  41627. */
  41628. upperRotationOffsetLimit: Nullable<number>;
  41629. /**
  41630. * Define a height offset between the camera and the object it follows.
  41631. * It can help following an object from the top (like a car chaing a plane)
  41632. */
  41633. heightOffset: number;
  41634. /**
  41635. * Minimum allowed height of camera position relative to target object.
  41636. * This can help limiting how the Camera is able to move in the scene.
  41637. */
  41638. lowerHeightOffsetLimit: Nullable<number>;
  41639. /**
  41640. * Maximum allowed height of camera position relative to target object.
  41641. * This can help limiting how the Camera is able to move in the scene.
  41642. */
  41643. upperHeightOffsetLimit: Nullable<number>;
  41644. /**
  41645. * Define how fast the camera can accelerate to follow it s target.
  41646. */
  41647. cameraAcceleration: number;
  41648. /**
  41649. * Define the speed limit of the camera following an object.
  41650. */
  41651. maxCameraSpeed: number;
  41652. /**
  41653. * Define the target of the camera.
  41654. */
  41655. lockedTarget: Nullable<AbstractMesh>;
  41656. /**
  41657. * Defines the input associated with the camera.
  41658. */
  41659. inputs: FollowCameraInputsManager;
  41660. /**
  41661. * Instantiates the follow camera.
  41662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41663. * @param name Define the name of the camera in the scene
  41664. * @param position Define the position of the camera
  41665. * @param scene Define the scene the camera belong to
  41666. * @param lockedTarget Define the target of the camera
  41667. */
  41668. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41669. private _follow;
  41670. /**
  41671. * Attached controls to the current camera.
  41672. * @param element Defines the element the controls should be listened from
  41673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41674. */
  41675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41676. /**
  41677. * Detach the current controls from the camera.
  41678. * The camera will stop reacting to inputs.
  41679. * @param element Defines the element to stop listening the inputs from
  41680. */
  41681. detachControl(element: HTMLElement): void;
  41682. /** @hidden */
  41683. _checkInputs(): void;
  41684. private _checkLimits;
  41685. /**
  41686. * Gets the camera class name.
  41687. * @returns the class name
  41688. */
  41689. getClassName(): string;
  41690. }
  41691. /**
  41692. * Arc Rotate version of the follow camera.
  41693. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41694. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41695. */
  41696. export class ArcFollowCamera extends TargetCamera {
  41697. /** The longitudinal angle of the camera */
  41698. alpha: number;
  41699. /** The latitudinal angle of the camera */
  41700. beta: number;
  41701. /** The radius of the camera from its target */
  41702. radius: number;
  41703. /** Define the camera target (the messh it should follow) */
  41704. target: Nullable<AbstractMesh>;
  41705. private _cartesianCoordinates;
  41706. /**
  41707. * Instantiates a new ArcFollowCamera
  41708. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41709. * @param name Define the name of the camera
  41710. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41711. * @param beta Define the rotation angle of the camera around the elevation axis
  41712. * @param radius Define the radius of the camera from its target point
  41713. * @param target Define the target of the camera
  41714. * @param scene Define the scene the camera belongs to
  41715. */
  41716. constructor(name: string,
  41717. /** The longitudinal angle of the camera */
  41718. alpha: number,
  41719. /** The latitudinal angle of the camera */
  41720. beta: number,
  41721. /** The radius of the camera from its target */
  41722. radius: number,
  41723. /** Define the camera target (the messh it should follow) */
  41724. target: Nullable<AbstractMesh>, scene: Scene);
  41725. private _follow;
  41726. /** @hidden */
  41727. _checkInputs(): void;
  41728. /**
  41729. * Returns the class name of the object.
  41730. * It is mostly used internally for serialization purposes.
  41731. */
  41732. getClassName(): string;
  41733. }
  41734. }
  41735. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41737. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41738. import { Nullable } from "babylonjs/types";
  41739. /**
  41740. * Manage the keyboard inputs to control the movement of a follow camera.
  41741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41742. */
  41743. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41744. /**
  41745. * Defines the camera the input is attached to.
  41746. */
  41747. camera: FollowCamera;
  41748. /**
  41749. * Defines the list of key codes associated with the up action (increase heightOffset)
  41750. */
  41751. keysHeightOffsetIncr: number[];
  41752. /**
  41753. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41754. */
  41755. keysHeightOffsetDecr: number[];
  41756. /**
  41757. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41758. */
  41759. keysHeightOffsetModifierAlt: boolean;
  41760. /**
  41761. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41762. */
  41763. keysHeightOffsetModifierCtrl: boolean;
  41764. /**
  41765. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41766. */
  41767. keysHeightOffsetModifierShift: boolean;
  41768. /**
  41769. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41770. */
  41771. keysRotationOffsetIncr: number[];
  41772. /**
  41773. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41774. */
  41775. keysRotationOffsetDecr: number[];
  41776. /**
  41777. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41778. */
  41779. keysRotationOffsetModifierAlt: boolean;
  41780. /**
  41781. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41782. */
  41783. keysRotationOffsetModifierCtrl: boolean;
  41784. /**
  41785. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41786. */
  41787. keysRotationOffsetModifierShift: boolean;
  41788. /**
  41789. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41790. */
  41791. keysRadiusIncr: number[];
  41792. /**
  41793. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41794. */
  41795. keysRadiusDecr: number[];
  41796. /**
  41797. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41798. */
  41799. keysRadiusModifierAlt: boolean;
  41800. /**
  41801. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41802. */
  41803. keysRadiusModifierCtrl: boolean;
  41804. /**
  41805. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41806. */
  41807. keysRadiusModifierShift: boolean;
  41808. /**
  41809. * Defines the rate of change of heightOffset.
  41810. */
  41811. heightSensibility: number;
  41812. /**
  41813. * Defines the rate of change of rotationOffset.
  41814. */
  41815. rotationSensibility: number;
  41816. /**
  41817. * Defines the rate of change of radius.
  41818. */
  41819. radiusSensibility: number;
  41820. private _keys;
  41821. private _ctrlPressed;
  41822. private _altPressed;
  41823. private _shiftPressed;
  41824. private _onCanvasBlurObserver;
  41825. private _onKeyboardObserver;
  41826. private _engine;
  41827. private _scene;
  41828. /**
  41829. * Attach the input controls to a specific dom element to get the input from.
  41830. * @param element Defines the element the controls should be listened from
  41831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41832. */
  41833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41834. /**
  41835. * Detach the current controls from the specified dom element.
  41836. * @param element Defines the element to stop listening the inputs from
  41837. */
  41838. detachControl(element: Nullable<HTMLElement>): void;
  41839. /**
  41840. * Update the current camera state depending on the inputs that have been used this frame.
  41841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41842. */
  41843. checkInputs(): void;
  41844. /**
  41845. * Gets the class name of the current input.
  41846. * @returns the class name
  41847. */
  41848. getClassName(): string;
  41849. /**
  41850. * Get the friendly name associated with the input class.
  41851. * @returns the input friendly name
  41852. */
  41853. getSimpleName(): string;
  41854. /**
  41855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41856. * allow modification of the heightOffset value.
  41857. */
  41858. private _modifierHeightOffset;
  41859. /**
  41860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41861. * allow modification of the rotationOffset value.
  41862. */
  41863. private _modifierRotationOffset;
  41864. /**
  41865. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41866. * allow modification of the radius value.
  41867. */
  41868. private _modifierRadius;
  41869. }
  41870. }
  41871. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41872. import { Nullable } from "babylonjs/types";
  41873. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41874. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41875. import { Observable } from "babylonjs/Misc/observable";
  41876. module "babylonjs/Cameras/freeCameraInputsManager" {
  41877. interface FreeCameraInputsManager {
  41878. /**
  41879. * @hidden
  41880. */
  41881. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41882. /**
  41883. * Add orientation input support to the input manager.
  41884. * @returns the current input manager
  41885. */
  41886. addDeviceOrientation(): FreeCameraInputsManager;
  41887. }
  41888. }
  41889. /**
  41890. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41891. * Screen rotation is taken into account.
  41892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41893. */
  41894. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41895. private _camera;
  41896. private _screenOrientationAngle;
  41897. private _constantTranform;
  41898. private _screenQuaternion;
  41899. private _alpha;
  41900. private _beta;
  41901. private _gamma;
  41902. /**
  41903. * Can be used to detect if a device orientation sensor is available on a device
  41904. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41905. * @returns a promise that will resolve on orientation change
  41906. */
  41907. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41908. /**
  41909. * @hidden
  41910. */
  41911. _onDeviceOrientationChangedObservable: Observable<void>;
  41912. /**
  41913. * Instantiates a new input
  41914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41915. */
  41916. constructor();
  41917. /**
  41918. * Define the camera controlled by the input.
  41919. */
  41920. get camera(): FreeCamera;
  41921. set camera(camera: FreeCamera);
  41922. /**
  41923. * Attach the input controls to a specific dom element to get the input from.
  41924. * @param element Defines the element the controls should be listened from
  41925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41926. */
  41927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41928. private _orientationChanged;
  41929. private _deviceOrientation;
  41930. /**
  41931. * Detach the current controls from the specified dom element.
  41932. * @param element Defines the element to stop listening the inputs from
  41933. */
  41934. detachControl(element: Nullable<HTMLElement>): void;
  41935. /**
  41936. * Update the current camera state depending on the inputs that have been used this frame.
  41937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41938. */
  41939. checkInputs(): void;
  41940. /**
  41941. * Gets the class name of the current intput.
  41942. * @returns the class name
  41943. */
  41944. getClassName(): string;
  41945. /**
  41946. * Get the friendly name associated with the input class.
  41947. * @returns the input friendly name
  41948. */
  41949. getSimpleName(): string;
  41950. }
  41951. }
  41952. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41953. import { Nullable } from "babylonjs/types";
  41954. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41955. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41956. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41957. /**
  41958. * Manage the gamepad inputs to control a free camera.
  41959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41960. */
  41961. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41962. /**
  41963. * Define the camera the input is attached to.
  41964. */
  41965. camera: FreeCamera;
  41966. /**
  41967. * Define the Gamepad controlling the input
  41968. */
  41969. gamepad: Nullable<Gamepad>;
  41970. /**
  41971. * Defines the gamepad rotation sensiblity.
  41972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41973. */
  41974. gamepadAngularSensibility: number;
  41975. /**
  41976. * Defines the gamepad move sensiblity.
  41977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41978. */
  41979. gamepadMoveSensibility: number;
  41980. private _yAxisScale;
  41981. /**
  41982. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41983. */
  41984. get invertYAxis(): boolean;
  41985. set invertYAxis(value: boolean);
  41986. private _onGamepadConnectedObserver;
  41987. private _onGamepadDisconnectedObserver;
  41988. private _cameraTransform;
  41989. private _deltaTransform;
  41990. private _vector3;
  41991. private _vector2;
  41992. /**
  41993. * Attach the input controls to a specific dom element to get the input from.
  41994. * @param element Defines the element the controls should be listened from
  41995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41996. */
  41997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41998. /**
  41999. * Detach the current controls from the specified dom element.
  42000. * @param element Defines the element to stop listening the inputs from
  42001. */
  42002. detachControl(element: Nullable<HTMLElement>): void;
  42003. /**
  42004. * Update the current camera state depending on the inputs that have been used this frame.
  42005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42006. */
  42007. checkInputs(): void;
  42008. /**
  42009. * Gets the class name of the current intput.
  42010. * @returns the class name
  42011. */
  42012. getClassName(): string;
  42013. /**
  42014. * Get the friendly name associated with the input class.
  42015. * @returns the input friendly name
  42016. */
  42017. getSimpleName(): string;
  42018. }
  42019. }
  42020. declare module "babylonjs/Misc/virtualJoystick" {
  42021. import { Nullable } from "babylonjs/types";
  42022. import { Vector3 } from "babylonjs/Maths/math.vector";
  42023. /**
  42024. * Defines the potential axis of a Joystick
  42025. */
  42026. export enum JoystickAxis {
  42027. /** X axis */
  42028. X = 0,
  42029. /** Y axis */
  42030. Y = 1,
  42031. /** Z axis */
  42032. Z = 2
  42033. }
  42034. /**
  42035. * Class used to define virtual joystick (used in touch mode)
  42036. */
  42037. export class VirtualJoystick {
  42038. /**
  42039. * Gets or sets a boolean indicating that left and right values must be inverted
  42040. */
  42041. reverseLeftRight: boolean;
  42042. /**
  42043. * Gets or sets a boolean indicating that up and down values must be inverted
  42044. */
  42045. reverseUpDown: boolean;
  42046. /**
  42047. * Gets the offset value for the position (ie. the change of the position value)
  42048. */
  42049. deltaPosition: Vector3;
  42050. /**
  42051. * Gets a boolean indicating if the virtual joystick was pressed
  42052. */
  42053. pressed: boolean;
  42054. /**
  42055. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42056. */
  42057. static Canvas: Nullable<HTMLCanvasElement>;
  42058. private static _globalJoystickIndex;
  42059. private static vjCanvasContext;
  42060. private static vjCanvasWidth;
  42061. private static vjCanvasHeight;
  42062. private static halfWidth;
  42063. private _action;
  42064. private _axisTargetedByLeftAndRight;
  42065. private _axisTargetedByUpAndDown;
  42066. private _joystickSensibility;
  42067. private _inversedSensibility;
  42068. private _joystickPointerID;
  42069. private _joystickColor;
  42070. private _joystickPointerPos;
  42071. private _joystickPreviousPointerPos;
  42072. private _joystickPointerStartPos;
  42073. private _deltaJoystickVector;
  42074. private _leftJoystick;
  42075. private _touches;
  42076. private _onPointerDownHandlerRef;
  42077. private _onPointerMoveHandlerRef;
  42078. private _onPointerUpHandlerRef;
  42079. private _onResize;
  42080. /**
  42081. * Creates a new virtual joystick
  42082. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42083. */
  42084. constructor(leftJoystick?: boolean);
  42085. /**
  42086. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42087. * @param newJoystickSensibility defines the new sensibility
  42088. */
  42089. setJoystickSensibility(newJoystickSensibility: number): void;
  42090. private _onPointerDown;
  42091. private _onPointerMove;
  42092. private _onPointerUp;
  42093. /**
  42094. * Change the color of the virtual joystick
  42095. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42096. */
  42097. setJoystickColor(newColor: string): void;
  42098. /**
  42099. * Defines a callback to call when the joystick is touched
  42100. * @param action defines the callback
  42101. */
  42102. setActionOnTouch(action: () => any): void;
  42103. /**
  42104. * Defines which axis you'd like to control for left & right
  42105. * @param axis defines the axis to use
  42106. */
  42107. setAxisForLeftRight(axis: JoystickAxis): void;
  42108. /**
  42109. * Defines which axis you'd like to control for up & down
  42110. * @param axis defines the axis to use
  42111. */
  42112. setAxisForUpDown(axis: JoystickAxis): void;
  42113. private _drawVirtualJoystick;
  42114. /**
  42115. * Release internal HTML canvas
  42116. */
  42117. releaseCanvas(): void;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42121. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42122. import { Nullable } from "babylonjs/types";
  42123. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42124. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42125. module "babylonjs/Cameras/freeCameraInputsManager" {
  42126. interface FreeCameraInputsManager {
  42127. /**
  42128. * Add virtual joystick input support to the input manager.
  42129. * @returns the current input manager
  42130. */
  42131. addVirtualJoystick(): FreeCameraInputsManager;
  42132. }
  42133. }
  42134. /**
  42135. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42137. */
  42138. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42139. /**
  42140. * Defines the camera the input is attached to.
  42141. */
  42142. camera: FreeCamera;
  42143. private _leftjoystick;
  42144. private _rightjoystick;
  42145. /**
  42146. * Gets the left stick of the virtual joystick.
  42147. * @returns The virtual Joystick
  42148. */
  42149. getLeftJoystick(): VirtualJoystick;
  42150. /**
  42151. * Gets the right stick of the virtual joystick.
  42152. * @returns The virtual Joystick
  42153. */
  42154. getRightJoystick(): VirtualJoystick;
  42155. /**
  42156. * Update the current camera state depending on the inputs that have been used this frame.
  42157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42158. */
  42159. checkInputs(): void;
  42160. /**
  42161. * Attach the input controls to a specific dom element to get the input from.
  42162. * @param element Defines the element the controls should be listened from
  42163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42164. */
  42165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42166. /**
  42167. * Detach the current controls from the specified dom element.
  42168. * @param element Defines the element to stop listening the inputs from
  42169. */
  42170. detachControl(element: Nullable<HTMLElement>): void;
  42171. /**
  42172. * Gets the class name of the current intput.
  42173. * @returns the class name
  42174. */
  42175. getClassName(): string;
  42176. /**
  42177. * Get the friendly name associated with the input class.
  42178. * @returns the input friendly name
  42179. */
  42180. getSimpleName(): string;
  42181. }
  42182. }
  42183. declare module "babylonjs/Cameras/Inputs/index" {
  42184. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42185. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42186. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42187. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42188. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42189. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42190. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42191. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42192. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42193. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42194. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42195. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42196. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42197. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42198. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42199. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42200. }
  42201. declare module "babylonjs/Cameras/touchCamera" {
  42202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42203. import { Scene } from "babylonjs/scene";
  42204. import { Vector3 } from "babylonjs/Maths/math.vector";
  42205. /**
  42206. * This represents a FPS type of camera controlled by touch.
  42207. * This is like a universal camera minus the Gamepad controls.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. */
  42210. export class TouchCamera extends FreeCamera {
  42211. /**
  42212. * Defines the touch sensibility for rotation.
  42213. * The higher the faster.
  42214. */
  42215. get touchAngularSensibility(): number;
  42216. set touchAngularSensibility(value: number);
  42217. /**
  42218. * Defines the touch sensibility for move.
  42219. * The higher the faster.
  42220. */
  42221. get touchMoveSensibility(): number;
  42222. set touchMoveSensibility(value: number);
  42223. /**
  42224. * Instantiates a new touch camera.
  42225. * This represents a FPS type of camera controlled by touch.
  42226. * This is like a universal camera minus the Gamepad controls.
  42227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42228. * @param name Define the name of the camera in the scene
  42229. * @param position Define the start position of the camera in the scene
  42230. * @param scene Define the scene the camera belongs to
  42231. */
  42232. constructor(name: string, position: Vector3, scene: Scene);
  42233. /**
  42234. * Gets the current object class name.
  42235. * @return the class name
  42236. */
  42237. getClassName(): string;
  42238. /** @hidden */
  42239. _setupInputs(): void;
  42240. }
  42241. }
  42242. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42244. import { Scene } from "babylonjs/scene";
  42245. import { Vector3 } from "babylonjs/Maths/math.vector";
  42246. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42247. import { Axis } from "babylonjs/Maths/math.axis";
  42248. /**
  42249. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42250. * being tilted forward or back and left or right.
  42251. */
  42252. export class DeviceOrientationCamera extends FreeCamera {
  42253. private _initialQuaternion;
  42254. private _quaternionCache;
  42255. private _tmpDragQuaternion;
  42256. private _disablePointerInputWhenUsingDeviceOrientation;
  42257. /**
  42258. * Creates a new device orientation camera
  42259. * @param name The name of the camera
  42260. * @param position The start position camera
  42261. * @param scene The scene the camera belongs to
  42262. */
  42263. constructor(name: string, position: Vector3, scene: Scene);
  42264. /**
  42265. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42266. */
  42267. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42268. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42269. private _dragFactor;
  42270. /**
  42271. * Enabled turning on the y axis when the orientation sensor is active
  42272. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42273. */
  42274. enableHorizontalDragging(dragFactor?: number): void;
  42275. /**
  42276. * Gets the current instance class name ("DeviceOrientationCamera").
  42277. * This helps avoiding instanceof at run time.
  42278. * @returns the class name
  42279. */
  42280. getClassName(): string;
  42281. /**
  42282. * @hidden
  42283. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42284. */
  42285. _checkInputs(): void;
  42286. /**
  42287. * Reset the camera to its default orientation on the specified axis only.
  42288. * @param axis The axis to reset
  42289. */
  42290. resetToCurrentRotation(axis?: Axis): void;
  42291. }
  42292. }
  42293. declare module "babylonjs/Gamepads/xboxGamepad" {
  42294. import { Observable } from "babylonjs/Misc/observable";
  42295. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42296. /**
  42297. * Defines supported buttons for XBox360 compatible gamepads
  42298. */
  42299. export enum Xbox360Button {
  42300. /** A */
  42301. A = 0,
  42302. /** B */
  42303. B = 1,
  42304. /** X */
  42305. X = 2,
  42306. /** Y */
  42307. Y = 3,
  42308. /** Start */
  42309. Start = 4,
  42310. /** Back */
  42311. Back = 5,
  42312. /** Left button */
  42313. LB = 6,
  42314. /** Right button */
  42315. RB = 7,
  42316. /** Left stick */
  42317. LeftStick = 8,
  42318. /** Right stick */
  42319. RightStick = 9
  42320. }
  42321. /** Defines values for XBox360 DPad */
  42322. export enum Xbox360Dpad {
  42323. /** Up */
  42324. Up = 0,
  42325. /** Down */
  42326. Down = 1,
  42327. /** Left */
  42328. Left = 2,
  42329. /** Right */
  42330. Right = 3
  42331. }
  42332. /**
  42333. * Defines a XBox360 gamepad
  42334. */
  42335. export class Xbox360Pad extends Gamepad {
  42336. private _leftTrigger;
  42337. private _rightTrigger;
  42338. private _onlefttriggerchanged;
  42339. private _onrighttriggerchanged;
  42340. private _onbuttondown;
  42341. private _onbuttonup;
  42342. private _ondpaddown;
  42343. private _ondpadup;
  42344. /** Observable raised when a button is pressed */
  42345. onButtonDownObservable: Observable<Xbox360Button>;
  42346. /** Observable raised when a button is released */
  42347. onButtonUpObservable: Observable<Xbox360Button>;
  42348. /** Observable raised when a pad is pressed */
  42349. onPadDownObservable: Observable<Xbox360Dpad>;
  42350. /** Observable raised when a pad is released */
  42351. onPadUpObservable: Observable<Xbox360Dpad>;
  42352. private _buttonA;
  42353. private _buttonB;
  42354. private _buttonX;
  42355. private _buttonY;
  42356. private _buttonBack;
  42357. private _buttonStart;
  42358. private _buttonLB;
  42359. private _buttonRB;
  42360. private _buttonLeftStick;
  42361. private _buttonRightStick;
  42362. private _dPadUp;
  42363. private _dPadDown;
  42364. private _dPadLeft;
  42365. private _dPadRight;
  42366. private _isXboxOnePad;
  42367. /**
  42368. * Creates a new XBox360 gamepad object
  42369. * @param id defines the id of this gamepad
  42370. * @param index defines its index
  42371. * @param gamepad defines the internal HTML gamepad object
  42372. * @param xboxOne defines if it is a XBox One gamepad
  42373. */
  42374. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42375. /**
  42376. * Defines the callback to call when left trigger is pressed
  42377. * @param callback defines the callback to use
  42378. */
  42379. onlefttriggerchanged(callback: (value: number) => void): void;
  42380. /**
  42381. * Defines the callback to call when right trigger is pressed
  42382. * @param callback defines the callback to use
  42383. */
  42384. onrighttriggerchanged(callback: (value: number) => void): void;
  42385. /**
  42386. * Gets the left trigger value
  42387. */
  42388. get leftTrigger(): number;
  42389. /**
  42390. * Sets the left trigger value
  42391. */
  42392. set leftTrigger(newValue: number);
  42393. /**
  42394. * Gets the right trigger value
  42395. */
  42396. get rightTrigger(): number;
  42397. /**
  42398. * Sets the right trigger value
  42399. */
  42400. set rightTrigger(newValue: number);
  42401. /**
  42402. * Defines the callback to call when a button is pressed
  42403. * @param callback defines the callback to use
  42404. */
  42405. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42406. /**
  42407. * Defines the callback to call when a button is released
  42408. * @param callback defines the callback to use
  42409. */
  42410. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42411. /**
  42412. * Defines the callback to call when a pad is pressed
  42413. * @param callback defines the callback to use
  42414. */
  42415. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42416. /**
  42417. * Defines the callback to call when a pad is released
  42418. * @param callback defines the callback to use
  42419. */
  42420. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42421. private _setButtonValue;
  42422. private _setDPadValue;
  42423. /**
  42424. * Gets the value of the `A` button
  42425. */
  42426. get buttonA(): number;
  42427. /**
  42428. * Sets the value of the `A` button
  42429. */
  42430. set buttonA(value: number);
  42431. /**
  42432. * Gets the value of the `B` button
  42433. */
  42434. get buttonB(): number;
  42435. /**
  42436. * Sets the value of the `B` button
  42437. */
  42438. set buttonB(value: number);
  42439. /**
  42440. * Gets the value of the `X` button
  42441. */
  42442. get buttonX(): number;
  42443. /**
  42444. * Sets the value of the `X` button
  42445. */
  42446. set buttonX(value: number);
  42447. /**
  42448. * Gets the value of the `Y` button
  42449. */
  42450. get buttonY(): number;
  42451. /**
  42452. * Sets the value of the `Y` button
  42453. */
  42454. set buttonY(value: number);
  42455. /**
  42456. * Gets the value of the `Start` button
  42457. */
  42458. get buttonStart(): number;
  42459. /**
  42460. * Sets the value of the `Start` button
  42461. */
  42462. set buttonStart(value: number);
  42463. /**
  42464. * Gets the value of the `Back` button
  42465. */
  42466. get buttonBack(): number;
  42467. /**
  42468. * Sets the value of the `Back` button
  42469. */
  42470. set buttonBack(value: number);
  42471. /**
  42472. * Gets the value of the `Left` button
  42473. */
  42474. get buttonLB(): number;
  42475. /**
  42476. * Sets the value of the `Left` button
  42477. */
  42478. set buttonLB(value: number);
  42479. /**
  42480. * Gets the value of the `Right` button
  42481. */
  42482. get buttonRB(): number;
  42483. /**
  42484. * Sets the value of the `Right` button
  42485. */
  42486. set buttonRB(value: number);
  42487. /**
  42488. * Gets the value of the Left joystick
  42489. */
  42490. get buttonLeftStick(): number;
  42491. /**
  42492. * Sets the value of the Left joystick
  42493. */
  42494. set buttonLeftStick(value: number);
  42495. /**
  42496. * Gets the value of the Right joystick
  42497. */
  42498. get buttonRightStick(): number;
  42499. /**
  42500. * Sets the value of the Right joystick
  42501. */
  42502. set buttonRightStick(value: number);
  42503. /**
  42504. * Gets the value of D-pad up
  42505. */
  42506. get dPadUp(): number;
  42507. /**
  42508. * Sets the value of D-pad up
  42509. */
  42510. set dPadUp(value: number);
  42511. /**
  42512. * Gets the value of D-pad down
  42513. */
  42514. get dPadDown(): number;
  42515. /**
  42516. * Sets the value of D-pad down
  42517. */
  42518. set dPadDown(value: number);
  42519. /**
  42520. * Gets the value of D-pad left
  42521. */
  42522. get dPadLeft(): number;
  42523. /**
  42524. * Sets the value of D-pad left
  42525. */
  42526. set dPadLeft(value: number);
  42527. /**
  42528. * Gets the value of D-pad right
  42529. */
  42530. get dPadRight(): number;
  42531. /**
  42532. * Sets the value of D-pad right
  42533. */
  42534. set dPadRight(value: number);
  42535. /**
  42536. * Force the gamepad to synchronize with device values
  42537. */
  42538. update(): void;
  42539. /**
  42540. * Disposes the gamepad
  42541. */
  42542. dispose(): void;
  42543. }
  42544. }
  42545. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42546. import { Observable } from "babylonjs/Misc/observable";
  42547. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42548. /**
  42549. * Defines supported buttons for DualShock compatible gamepads
  42550. */
  42551. export enum DualShockButton {
  42552. /** Cross */
  42553. Cross = 0,
  42554. /** Circle */
  42555. Circle = 1,
  42556. /** Square */
  42557. Square = 2,
  42558. /** Triangle */
  42559. Triangle = 3,
  42560. /** Options */
  42561. Options = 4,
  42562. /** Share */
  42563. Share = 5,
  42564. /** L1 */
  42565. L1 = 6,
  42566. /** R1 */
  42567. R1 = 7,
  42568. /** Left stick */
  42569. LeftStick = 8,
  42570. /** Right stick */
  42571. RightStick = 9
  42572. }
  42573. /** Defines values for DualShock DPad */
  42574. export enum DualShockDpad {
  42575. /** Up */
  42576. Up = 0,
  42577. /** Down */
  42578. Down = 1,
  42579. /** Left */
  42580. Left = 2,
  42581. /** Right */
  42582. Right = 3
  42583. }
  42584. /**
  42585. * Defines a DualShock gamepad
  42586. */
  42587. export class DualShockPad extends Gamepad {
  42588. private _leftTrigger;
  42589. private _rightTrigger;
  42590. private _onlefttriggerchanged;
  42591. private _onrighttriggerchanged;
  42592. private _onbuttondown;
  42593. private _onbuttonup;
  42594. private _ondpaddown;
  42595. private _ondpadup;
  42596. /** Observable raised when a button is pressed */
  42597. onButtonDownObservable: Observable<DualShockButton>;
  42598. /** Observable raised when a button is released */
  42599. onButtonUpObservable: Observable<DualShockButton>;
  42600. /** Observable raised when a pad is pressed */
  42601. onPadDownObservable: Observable<DualShockDpad>;
  42602. /** Observable raised when a pad is released */
  42603. onPadUpObservable: Observable<DualShockDpad>;
  42604. private _buttonCross;
  42605. private _buttonCircle;
  42606. private _buttonSquare;
  42607. private _buttonTriangle;
  42608. private _buttonShare;
  42609. private _buttonOptions;
  42610. private _buttonL1;
  42611. private _buttonR1;
  42612. private _buttonLeftStick;
  42613. private _buttonRightStick;
  42614. private _dPadUp;
  42615. private _dPadDown;
  42616. private _dPadLeft;
  42617. private _dPadRight;
  42618. /**
  42619. * Creates a new DualShock gamepad object
  42620. * @param id defines the id of this gamepad
  42621. * @param index defines its index
  42622. * @param gamepad defines the internal HTML gamepad object
  42623. */
  42624. constructor(id: string, index: number, gamepad: any);
  42625. /**
  42626. * Defines the callback to call when left trigger is pressed
  42627. * @param callback defines the callback to use
  42628. */
  42629. onlefttriggerchanged(callback: (value: number) => void): void;
  42630. /**
  42631. * Defines the callback to call when right trigger is pressed
  42632. * @param callback defines the callback to use
  42633. */
  42634. onrighttriggerchanged(callback: (value: number) => void): void;
  42635. /**
  42636. * Gets the left trigger value
  42637. */
  42638. get leftTrigger(): number;
  42639. /**
  42640. * Sets the left trigger value
  42641. */
  42642. set leftTrigger(newValue: number);
  42643. /**
  42644. * Gets the right trigger value
  42645. */
  42646. get rightTrigger(): number;
  42647. /**
  42648. * Sets the right trigger value
  42649. */
  42650. set rightTrigger(newValue: number);
  42651. /**
  42652. * Defines the callback to call when a button is pressed
  42653. * @param callback defines the callback to use
  42654. */
  42655. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42656. /**
  42657. * Defines the callback to call when a button is released
  42658. * @param callback defines the callback to use
  42659. */
  42660. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42661. /**
  42662. * Defines the callback to call when a pad is pressed
  42663. * @param callback defines the callback to use
  42664. */
  42665. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42666. /**
  42667. * Defines the callback to call when a pad is released
  42668. * @param callback defines the callback to use
  42669. */
  42670. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42671. private _setButtonValue;
  42672. private _setDPadValue;
  42673. /**
  42674. * Gets the value of the `Cross` button
  42675. */
  42676. get buttonCross(): number;
  42677. /**
  42678. * Sets the value of the `Cross` button
  42679. */
  42680. set buttonCross(value: number);
  42681. /**
  42682. * Gets the value of the `Circle` button
  42683. */
  42684. get buttonCircle(): number;
  42685. /**
  42686. * Sets the value of the `Circle` button
  42687. */
  42688. set buttonCircle(value: number);
  42689. /**
  42690. * Gets the value of the `Square` button
  42691. */
  42692. get buttonSquare(): number;
  42693. /**
  42694. * Sets the value of the `Square` button
  42695. */
  42696. set buttonSquare(value: number);
  42697. /**
  42698. * Gets the value of the `Triangle` button
  42699. */
  42700. get buttonTriangle(): number;
  42701. /**
  42702. * Sets the value of the `Triangle` button
  42703. */
  42704. set buttonTriangle(value: number);
  42705. /**
  42706. * Gets the value of the `Options` button
  42707. */
  42708. get buttonOptions(): number;
  42709. /**
  42710. * Sets the value of the `Options` button
  42711. */
  42712. set buttonOptions(value: number);
  42713. /**
  42714. * Gets the value of the `Share` button
  42715. */
  42716. get buttonShare(): number;
  42717. /**
  42718. * Sets the value of the `Share` button
  42719. */
  42720. set buttonShare(value: number);
  42721. /**
  42722. * Gets the value of the `L1` button
  42723. */
  42724. get buttonL1(): number;
  42725. /**
  42726. * Sets the value of the `L1` button
  42727. */
  42728. set buttonL1(value: number);
  42729. /**
  42730. * Gets the value of the `R1` button
  42731. */
  42732. get buttonR1(): number;
  42733. /**
  42734. * Sets the value of the `R1` button
  42735. */
  42736. set buttonR1(value: number);
  42737. /**
  42738. * Gets the value of the Left joystick
  42739. */
  42740. get buttonLeftStick(): number;
  42741. /**
  42742. * Sets the value of the Left joystick
  42743. */
  42744. set buttonLeftStick(value: number);
  42745. /**
  42746. * Gets the value of the Right joystick
  42747. */
  42748. get buttonRightStick(): number;
  42749. /**
  42750. * Sets the value of the Right joystick
  42751. */
  42752. set buttonRightStick(value: number);
  42753. /**
  42754. * Gets the value of D-pad up
  42755. */
  42756. get dPadUp(): number;
  42757. /**
  42758. * Sets the value of D-pad up
  42759. */
  42760. set dPadUp(value: number);
  42761. /**
  42762. * Gets the value of D-pad down
  42763. */
  42764. get dPadDown(): number;
  42765. /**
  42766. * Sets the value of D-pad down
  42767. */
  42768. set dPadDown(value: number);
  42769. /**
  42770. * Gets the value of D-pad left
  42771. */
  42772. get dPadLeft(): number;
  42773. /**
  42774. * Sets the value of D-pad left
  42775. */
  42776. set dPadLeft(value: number);
  42777. /**
  42778. * Gets the value of D-pad right
  42779. */
  42780. get dPadRight(): number;
  42781. /**
  42782. * Sets the value of D-pad right
  42783. */
  42784. set dPadRight(value: number);
  42785. /**
  42786. * Force the gamepad to synchronize with device values
  42787. */
  42788. update(): void;
  42789. /**
  42790. * Disposes the gamepad
  42791. */
  42792. dispose(): void;
  42793. }
  42794. }
  42795. declare module "babylonjs/Gamepads/gamepadManager" {
  42796. import { Observable } from "babylonjs/Misc/observable";
  42797. import { Nullable } from "babylonjs/types";
  42798. import { Scene } from "babylonjs/scene";
  42799. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42800. /**
  42801. * Manager for handling gamepads
  42802. */
  42803. export class GamepadManager {
  42804. private _scene?;
  42805. private _babylonGamepads;
  42806. private _oneGamepadConnected;
  42807. /** @hidden */
  42808. _isMonitoring: boolean;
  42809. private _gamepadEventSupported;
  42810. private _gamepadSupport?;
  42811. /**
  42812. * observable to be triggered when the gamepad controller has been connected
  42813. */
  42814. onGamepadConnectedObservable: Observable<Gamepad>;
  42815. /**
  42816. * observable to be triggered when the gamepad controller has been disconnected
  42817. */
  42818. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42819. private _onGamepadConnectedEvent;
  42820. private _onGamepadDisconnectedEvent;
  42821. /**
  42822. * Initializes the gamepad manager
  42823. * @param _scene BabylonJS scene
  42824. */
  42825. constructor(_scene?: Scene | undefined);
  42826. /**
  42827. * The gamepads in the game pad manager
  42828. */
  42829. get gamepads(): Gamepad[];
  42830. /**
  42831. * Get the gamepad controllers based on type
  42832. * @param type The type of gamepad controller
  42833. * @returns Nullable gamepad
  42834. */
  42835. getGamepadByType(type?: number): Nullable<Gamepad>;
  42836. /**
  42837. * Disposes the gamepad manager
  42838. */
  42839. dispose(): void;
  42840. private _addNewGamepad;
  42841. private _startMonitoringGamepads;
  42842. private _stopMonitoringGamepads;
  42843. /** @hidden */
  42844. _checkGamepadsStatus(): void;
  42845. private _updateGamepadObjects;
  42846. }
  42847. }
  42848. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42849. import { Nullable } from "babylonjs/types";
  42850. import { Scene } from "babylonjs/scene";
  42851. import { ISceneComponent } from "babylonjs/sceneComponent";
  42852. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42853. module "babylonjs/scene" {
  42854. interface Scene {
  42855. /** @hidden */
  42856. _gamepadManager: Nullable<GamepadManager>;
  42857. /**
  42858. * Gets the gamepad manager associated with the scene
  42859. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42860. */
  42861. gamepadManager: GamepadManager;
  42862. }
  42863. }
  42864. module "babylonjs/Cameras/freeCameraInputsManager" {
  42865. /**
  42866. * Interface representing a free camera inputs manager
  42867. */
  42868. interface FreeCameraInputsManager {
  42869. /**
  42870. * Adds gamepad input support to the FreeCameraInputsManager.
  42871. * @returns the FreeCameraInputsManager
  42872. */
  42873. addGamepad(): FreeCameraInputsManager;
  42874. }
  42875. }
  42876. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42877. /**
  42878. * Interface representing an arc rotate camera inputs manager
  42879. */
  42880. interface ArcRotateCameraInputsManager {
  42881. /**
  42882. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42883. * @returns the camera inputs manager
  42884. */
  42885. addGamepad(): ArcRotateCameraInputsManager;
  42886. }
  42887. }
  42888. /**
  42889. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42890. */
  42891. export class GamepadSystemSceneComponent implements ISceneComponent {
  42892. /**
  42893. * The component name helpfull to identify the component in the list of scene components.
  42894. */
  42895. readonly name: string;
  42896. /**
  42897. * The scene the component belongs to.
  42898. */
  42899. scene: Scene;
  42900. /**
  42901. * Creates a new instance of the component for the given scene
  42902. * @param scene Defines the scene to register the component in
  42903. */
  42904. constructor(scene: Scene);
  42905. /**
  42906. * Registers the component in a given scene
  42907. */
  42908. register(): void;
  42909. /**
  42910. * Rebuilds the elements related to this component in case of
  42911. * context lost for instance.
  42912. */
  42913. rebuild(): void;
  42914. /**
  42915. * Disposes the component and the associated ressources
  42916. */
  42917. dispose(): void;
  42918. private _beforeCameraUpdate;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/universalCamera" {
  42922. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42923. import { Scene } from "babylonjs/scene";
  42924. import { Vector3 } from "babylonjs/Maths/math.vector";
  42925. import "babylonjs/Gamepads/gamepadSceneComponent";
  42926. /**
  42927. * 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,
  42928. * which still works and will still be found in many Playgrounds.
  42929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42930. */
  42931. export class UniversalCamera extends TouchCamera {
  42932. /**
  42933. * Defines the gamepad rotation sensiblity.
  42934. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42935. */
  42936. get gamepadAngularSensibility(): number;
  42937. set gamepadAngularSensibility(value: number);
  42938. /**
  42939. * Defines the gamepad move sensiblity.
  42940. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42941. */
  42942. get gamepadMoveSensibility(): number;
  42943. set gamepadMoveSensibility(value: number);
  42944. /**
  42945. * 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,
  42946. * which still works and will still be found in many Playgrounds.
  42947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42948. * @param name Define the name of the camera in the scene
  42949. * @param position Define the start position of the camera in the scene
  42950. * @param scene Define the scene the camera belongs to
  42951. */
  42952. constructor(name: string, position: Vector3, scene: Scene);
  42953. /**
  42954. * Gets the current object class name.
  42955. * @return the class name
  42956. */
  42957. getClassName(): string;
  42958. }
  42959. }
  42960. declare module "babylonjs/Cameras/gamepadCamera" {
  42961. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42962. import { Scene } from "babylonjs/scene";
  42963. import { Vector3 } from "babylonjs/Maths/math.vector";
  42964. /**
  42965. * This represents a FPS type of camera. This is only here for back compat purpose.
  42966. * Please use the UniversalCamera instead as both are identical.
  42967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42968. */
  42969. export class GamepadCamera extends UniversalCamera {
  42970. /**
  42971. * Instantiates a new Gamepad Camera
  42972. * This represents a FPS type of camera. This is only here for back compat purpose.
  42973. * Please use the UniversalCamera instead as both are identical.
  42974. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42975. * @param name Define the name of the camera in the scene
  42976. * @param position Define the start position of the camera in the scene
  42977. * @param scene Define the scene the camera belongs to
  42978. */
  42979. constructor(name: string, position: Vector3, scene: Scene);
  42980. /**
  42981. * Gets the current object class name.
  42982. * @return the class name
  42983. */
  42984. getClassName(): string;
  42985. }
  42986. }
  42987. declare module "babylonjs/Shaders/pass.fragment" {
  42988. /** @hidden */
  42989. export var passPixelShader: {
  42990. name: string;
  42991. shader: string;
  42992. };
  42993. }
  42994. declare module "babylonjs/Shaders/passCube.fragment" {
  42995. /** @hidden */
  42996. export var passCubePixelShader: {
  42997. name: string;
  42998. shader: string;
  42999. };
  43000. }
  43001. declare module "babylonjs/PostProcesses/passPostProcess" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { Camera } from "babylonjs/Cameras/camera";
  43004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43005. import { Engine } from "babylonjs/Engines/engine";
  43006. import "babylonjs/Shaders/pass.fragment";
  43007. import "babylonjs/Shaders/passCube.fragment";
  43008. /**
  43009. * PassPostProcess which produces an output the same as it's input
  43010. */
  43011. export class PassPostProcess extends PostProcess {
  43012. /**
  43013. * Creates the PassPostProcess
  43014. * @param name The name of the effect.
  43015. * @param options The required width/height ratio to downsize to before computing the render pass.
  43016. * @param camera The camera to apply the render pass to.
  43017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43018. * @param engine The engine which the post process will be applied. (default: current engine)
  43019. * @param reusable If the post process can be reused on the same frame. (default: false)
  43020. * @param textureType The type of texture to be used when performing the post processing.
  43021. * @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)
  43022. */
  43023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43024. }
  43025. /**
  43026. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43027. */
  43028. export class PassCubePostProcess extends PostProcess {
  43029. private _face;
  43030. /**
  43031. * Gets or sets the cube face to display.
  43032. * * 0 is +X
  43033. * * 1 is -X
  43034. * * 2 is +Y
  43035. * * 3 is -Y
  43036. * * 4 is +Z
  43037. * * 5 is -Z
  43038. */
  43039. get face(): number;
  43040. set face(value: number);
  43041. /**
  43042. * Creates the PassCubePostProcess
  43043. * @param name The name of the effect.
  43044. * @param options The required width/height ratio to downsize to before computing the render pass.
  43045. * @param camera The camera to apply the render pass to.
  43046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43047. * @param engine The engine which the post process will be applied. (default: current engine)
  43048. * @param reusable If the post process can be reused on the same frame. (default: false)
  43049. * @param textureType The type of texture to be used when performing the post processing.
  43050. * @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)
  43051. */
  43052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43053. }
  43054. }
  43055. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43056. /** @hidden */
  43057. export var anaglyphPixelShader: {
  43058. name: string;
  43059. shader: string;
  43060. };
  43061. }
  43062. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43063. import { Engine } from "babylonjs/Engines/engine";
  43064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43065. import { Camera } from "babylonjs/Cameras/camera";
  43066. import "babylonjs/Shaders/anaglyph.fragment";
  43067. /**
  43068. * Postprocess used to generate anaglyphic rendering
  43069. */
  43070. export class AnaglyphPostProcess extends PostProcess {
  43071. private _passedProcess;
  43072. /**
  43073. * Creates a new AnaglyphPostProcess
  43074. * @param name defines postprocess name
  43075. * @param options defines creation options or target ratio scale
  43076. * @param rigCameras defines cameras using this postprocess
  43077. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43078. * @param engine defines hosting engine
  43079. * @param reusable defines if the postprocess will be reused multiple times per frame
  43080. */
  43081. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43082. }
  43083. }
  43084. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43085. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43086. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43087. import { Scene } from "babylonjs/scene";
  43088. import { Vector3 } from "babylonjs/Maths/math.vector";
  43089. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43090. /**
  43091. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43092. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43093. */
  43094. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43095. /**
  43096. * Creates a new AnaglyphArcRotateCamera
  43097. * @param name defines camera name
  43098. * @param alpha defines alpha angle (in radians)
  43099. * @param beta defines beta angle (in radians)
  43100. * @param radius defines radius
  43101. * @param target defines camera target
  43102. * @param interaxialDistance defines distance between each color axis
  43103. * @param scene defines the hosting scene
  43104. */
  43105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43106. /**
  43107. * Gets camera class name
  43108. * @returns AnaglyphArcRotateCamera
  43109. */
  43110. getClassName(): string;
  43111. }
  43112. }
  43113. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43115. import { Scene } from "babylonjs/scene";
  43116. import { Vector3 } from "babylonjs/Maths/math.vector";
  43117. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43118. /**
  43119. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43120. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43121. */
  43122. export class AnaglyphFreeCamera extends FreeCamera {
  43123. /**
  43124. * Creates a new AnaglyphFreeCamera
  43125. * @param name defines camera name
  43126. * @param position defines initial position
  43127. * @param interaxialDistance defines distance between each color axis
  43128. * @param scene defines the hosting scene
  43129. */
  43130. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43131. /**
  43132. * Gets camera class name
  43133. * @returns AnaglyphFreeCamera
  43134. */
  43135. getClassName(): string;
  43136. }
  43137. }
  43138. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43139. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43140. import { Scene } from "babylonjs/scene";
  43141. import { Vector3 } from "babylonjs/Maths/math.vector";
  43142. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43143. /**
  43144. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43145. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43146. */
  43147. export class AnaglyphGamepadCamera extends GamepadCamera {
  43148. /**
  43149. * Creates a new AnaglyphGamepadCamera
  43150. * @param name defines camera name
  43151. * @param position defines initial position
  43152. * @param interaxialDistance defines distance between each color axis
  43153. * @param scene defines the hosting scene
  43154. */
  43155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43156. /**
  43157. * Gets camera class name
  43158. * @returns AnaglyphGamepadCamera
  43159. */
  43160. getClassName(): string;
  43161. }
  43162. }
  43163. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43164. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43165. import { Scene } from "babylonjs/scene";
  43166. import { Vector3 } from "babylonjs/Maths/math.vector";
  43167. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43168. /**
  43169. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43171. */
  43172. export class AnaglyphUniversalCamera extends UniversalCamera {
  43173. /**
  43174. * Creates a new AnaglyphUniversalCamera
  43175. * @param name defines camera name
  43176. * @param position defines initial position
  43177. * @param interaxialDistance defines distance between each color axis
  43178. * @param scene defines the hosting scene
  43179. */
  43180. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43181. /**
  43182. * Gets camera class name
  43183. * @returns AnaglyphUniversalCamera
  43184. */
  43185. getClassName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43189. /** @hidden */
  43190. export var stereoscopicInterlacePixelShader: {
  43191. name: string;
  43192. shader: string;
  43193. };
  43194. }
  43195. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43196. import { Camera } from "babylonjs/Cameras/camera";
  43197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43198. import { Engine } from "babylonjs/Engines/engine";
  43199. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43200. /**
  43201. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43202. */
  43203. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43204. private _stepSize;
  43205. private _passedProcess;
  43206. /**
  43207. * Initializes a StereoscopicInterlacePostProcessI
  43208. * @param name The name of the effect.
  43209. * @param rigCameras The rig cameras to be appled to the post process
  43210. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43211. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43213. * @param engine The engine which the post process will be applied. (default: current engine)
  43214. * @param reusable If the post process can be reused on the same frame. (default: false)
  43215. */
  43216. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43217. }
  43218. /**
  43219. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43220. */
  43221. export class StereoscopicInterlacePostProcess extends PostProcess {
  43222. private _stepSize;
  43223. private _passedProcess;
  43224. /**
  43225. * Initializes a StereoscopicInterlacePostProcess
  43226. * @param name The name of the effect.
  43227. * @param rigCameras The rig cameras to be appled to the post process
  43228. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43230. * @param engine The engine which the post process will be applied. (default: current engine)
  43231. * @param reusable If the post process can be reused on the same frame. (default: false)
  43232. */
  43233. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43234. }
  43235. }
  43236. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43237. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43238. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43239. import { Scene } from "babylonjs/scene";
  43240. import { Vector3 } from "babylonjs/Maths/math.vector";
  43241. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43242. /**
  43243. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43244. * @see http://doc.babylonjs.com/features/cameras
  43245. */
  43246. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43247. /**
  43248. * Creates a new StereoscopicArcRotateCamera
  43249. * @param name defines camera name
  43250. * @param alpha defines alpha angle (in radians)
  43251. * @param beta defines beta angle (in radians)
  43252. * @param radius defines radius
  43253. * @param target defines camera target
  43254. * @param interaxialDistance defines distance between each color axis
  43255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43256. * @param scene defines the hosting scene
  43257. */
  43258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43259. /**
  43260. * Gets camera class name
  43261. * @returns StereoscopicArcRotateCamera
  43262. */
  43263. getClassName(): string;
  43264. }
  43265. }
  43266. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43267. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43268. import { Scene } from "babylonjs/scene";
  43269. import { Vector3 } from "babylonjs/Maths/math.vector";
  43270. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43271. /**
  43272. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43273. * @see http://doc.babylonjs.com/features/cameras
  43274. */
  43275. export class StereoscopicFreeCamera extends FreeCamera {
  43276. /**
  43277. * Creates a new StereoscopicFreeCamera
  43278. * @param name defines camera name
  43279. * @param position defines initial position
  43280. * @param interaxialDistance defines distance between each color axis
  43281. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43282. * @param scene defines the hosting scene
  43283. */
  43284. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43285. /**
  43286. * Gets camera class name
  43287. * @returns StereoscopicFreeCamera
  43288. */
  43289. getClassName(): string;
  43290. }
  43291. }
  43292. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43293. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43294. import { Scene } from "babylonjs/scene";
  43295. import { Vector3 } from "babylonjs/Maths/math.vector";
  43296. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43297. /**
  43298. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43299. * @see http://doc.babylonjs.com/features/cameras
  43300. */
  43301. export class StereoscopicGamepadCamera extends GamepadCamera {
  43302. /**
  43303. * Creates a new StereoscopicGamepadCamera
  43304. * @param name defines camera name
  43305. * @param position defines initial position
  43306. * @param interaxialDistance defines distance between each color axis
  43307. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43311. /**
  43312. * Gets camera class name
  43313. * @returns StereoscopicGamepadCamera
  43314. */
  43315. getClassName(): string;
  43316. }
  43317. }
  43318. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43319. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43320. import { Scene } from "babylonjs/scene";
  43321. import { Vector3 } from "babylonjs/Maths/math.vector";
  43322. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43323. /**
  43324. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43325. * @see http://doc.babylonjs.com/features/cameras
  43326. */
  43327. export class StereoscopicUniversalCamera extends UniversalCamera {
  43328. /**
  43329. * Creates a new StereoscopicUniversalCamera
  43330. * @param name defines camera name
  43331. * @param position defines initial position
  43332. * @param interaxialDistance defines distance between each color axis
  43333. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43334. * @param scene defines the hosting scene
  43335. */
  43336. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43337. /**
  43338. * Gets camera class name
  43339. * @returns StereoscopicUniversalCamera
  43340. */
  43341. getClassName(): string;
  43342. }
  43343. }
  43344. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43345. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43346. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43347. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43348. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43349. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43350. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43351. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43352. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43353. }
  43354. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43355. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { Vector3 } from "babylonjs/Maths/math.vector";
  43358. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43359. /**
  43360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43364. */
  43365. export class VirtualJoysticksCamera extends FreeCamera {
  43366. /**
  43367. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43371. * @param name Define the name of the camera in the scene
  43372. * @param position Define the start position of the camera in the scene
  43373. * @param scene Define the scene the camera belongs to
  43374. */
  43375. constructor(name: string, position: Vector3, scene: Scene);
  43376. /**
  43377. * Gets the current object class name.
  43378. * @return the class name
  43379. */
  43380. getClassName(): string;
  43381. }
  43382. }
  43383. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43384. import { Matrix } from "babylonjs/Maths/math.vector";
  43385. /**
  43386. * This represents all the required metrics to create a VR camera.
  43387. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43388. */
  43389. export class VRCameraMetrics {
  43390. /**
  43391. * Define the horizontal resolution off the screen.
  43392. */
  43393. hResolution: number;
  43394. /**
  43395. * Define the vertical resolution off the screen.
  43396. */
  43397. vResolution: number;
  43398. /**
  43399. * Define the horizontal screen size.
  43400. */
  43401. hScreenSize: number;
  43402. /**
  43403. * Define the vertical screen size.
  43404. */
  43405. vScreenSize: number;
  43406. /**
  43407. * Define the vertical screen center position.
  43408. */
  43409. vScreenCenter: number;
  43410. /**
  43411. * Define the distance of the eyes to the screen.
  43412. */
  43413. eyeToScreenDistance: number;
  43414. /**
  43415. * Define the distance between both lenses
  43416. */
  43417. lensSeparationDistance: number;
  43418. /**
  43419. * Define the distance between both viewer's eyes.
  43420. */
  43421. interpupillaryDistance: number;
  43422. /**
  43423. * Define the distortion factor of the VR postprocess.
  43424. * Please, touch with care.
  43425. */
  43426. distortionK: number[];
  43427. /**
  43428. * Define the chromatic aberration correction factors for the VR post process.
  43429. */
  43430. chromaAbCorrection: number[];
  43431. /**
  43432. * Define the scale factor of the post process.
  43433. * The smaller the better but the slower.
  43434. */
  43435. postProcessScaleFactor: number;
  43436. /**
  43437. * Define an offset for the lens center.
  43438. */
  43439. lensCenterOffset: number;
  43440. /**
  43441. * Define if the current vr camera should compensate the distortion of the lense or not.
  43442. */
  43443. compensateDistortion: boolean;
  43444. /**
  43445. * Defines if multiview should be enabled when rendering (Default: false)
  43446. */
  43447. multiviewEnabled: boolean;
  43448. /**
  43449. * Gets the rendering aspect ratio based on the provided resolutions.
  43450. */
  43451. get aspectRatio(): number;
  43452. /**
  43453. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43454. */
  43455. get aspectRatioFov(): number;
  43456. /**
  43457. * @hidden
  43458. */
  43459. get leftHMatrix(): Matrix;
  43460. /**
  43461. * @hidden
  43462. */
  43463. get rightHMatrix(): Matrix;
  43464. /**
  43465. * @hidden
  43466. */
  43467. get leftPreViewMatrix(): Matrix;
  43468. /**
  43469. * @hidden
  43470. */
  43471. get rightPreViewMatrix(): Matrix;
  43472. /**
  43473. * Get the default VRMetrics based on the most generic setup.
  43474. * @returns the default vr metrics
  43475. */
  43476. static GetDefault(): VRCameraMetrics;
  43477. }
  43478. }
  43479. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43480. /** @hidden */
  43481. export var vrDistortionCorrectionPixelShader: {
  43482. name: string;
  43483. shader: string;
  43484. };
  43485. }
  43486. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43487. import { Camera } from "babylonjs/Cameras/camera";
  43488. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43490. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43491. /**
  43492. * VRDistortionCorrectionPostProcess used for mobile VR
  43493. */
  43494. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43495. private _isRightEye;
  43496. private _distortionFactors;
  43497. private _postProcessScaleFactor;
  43498. private _lensCenterOffset;
  43499. private _scaleIn;
  43500. private _scaleFactor;
  43501. private _lensCenter;
  43502. /**
  43503. * Initializes the VRDistortionCorrectionPostProcess
  43504. * @param name The name of the effect.
  43505. * @param camera The camera to apply the render pass to.
  43506. * @param isRightEye If this is for the right eye distortion
  43507. * @param vrMetrics All the required metrics for the VR camera
  43508. */
  43509. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43510. }
  43511. }
  43512. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43513. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43514. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43515. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43516. import { Scene } from "babylonjs/scene";
  43517. import { Vector3 } from "babylonjs/Maths/math.vector";
  43518. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43519. import "babylonjs/Cameras/RigModes/vrRigMode";
  43520. /**
  43521. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43522. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43523. */
  43524. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43525. /**
  43526. * Creates a new VRDeviceOrientationArcRotateCamera
  43527. * @param name defines camera name
  43528. * @param alpha defines the camera rotation along the logitudinal axis
  43529. * @param beta defines the camera rotation along the latitudinal axis
  43530. * @param radius defines the camera distance from its target
  43531. * @param target defines the camera target
  43532. * @param scene defines the scene the camera belongs to
  43533. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43534. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43535. */
  43536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43537. /**
  43538. * Gets camera class name
  43539. * @returns VRDeviceOrientationArcRotateCamera
  43540. */
  43541. getClassName(): string;
  43542. }
  43543. }
  43544. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43545. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43546. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { Vector3 } from "babylonjs/Maths/math.vector";
  43549. import "babylonjs/Cameras/RigModes/vrRigMode";
  43550. /**
  43551. * Camera used to simulate VR rendering (based on FreeCamera)
  43552. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43553. */
  43554. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43555. /**
  43556. * Creates a new VRDeviceOrientationFreeCamera
  43557. * @param name defines camera name
  43558. * @param position defines the start position of the camera
  43559. * @param scene defines the scene the camera belongs to
  43560. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43561. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43562. */
  43563. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43564. /**
  43565. * Gets camera class name
  43566. * @returns VRDeviceOrientationFreeCamera
  43567. */
  43568. getClassName(): string;
  43569. }
  43570. }
  43571. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43572. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43573. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43574. import { Scene } from "babylonjs/scene";
  43575. import { Vector3 } from "babylonjs/Maths/math.vector";
  43576. import "babylonjs/Gamepads/gamepadSceneComponent";
  43577. /**
  43578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43580. */
  43581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43582. /**
  43583. * Creates a new VRDeviceOrientationGamepadCamera
  43584. * @param name defines camera name
  43585. * @param position defines the start position of the camera
  43586. * @param scene defines the scene the camera belongs to
  43587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43589. */
  43590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43591. /**
  43592. * Gets camera class name
  43593. * @returns VRDeviceOrientationGamepadCamera
  43594. */
  43595. getClassName(): string;
  43596. }
  43597. }
  43598. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43601. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43602. /** @hidden */
  43603. export var imageProcessingPixelShader: {
  43604. name: string;
  43605. shader: string;
  43606. };
  43607. }
  43608. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43609. import { Nullable } from "babylonjs/types";
  43610. import { Color4 } from "babylonjs/Maths/math.color";
  43611. import { Camera } from "babylonjs/Cameras/camera";
  43612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43613. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43614. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43616. import { Engine } from "babylonjs/Engines/engine";
  43617. import "babylonjs/Shaders/imageProcessing.fragment";
  43618. import "babylonjs/Shaders/postprocess.vertex";
  43619. /**
  43620. * ImageProcessingPostProcess
  43621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43622. */
  43623. export class ImageProcessingPostProcess extends PostProcess {
  43624. /**
  43625. * Default configuration related to image processing available in the PBR Material.
  43626. */
  43627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43628. /**
  43629. * Gets the image processing configuration used either in this material.
  43630. */
  43631. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43632. /**
  43633. * Sets the Default image processing configuration used either in the this material.
  43634. *
  43635. * If sets to null, the scene one is in use.
  43636. */
  43637. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43638. /**
  43639. * Keep track of the image processing observer to allow dispose and replace.
  43640. */
  43641. private _imageProcessingObserver;
  43642. /**
  43643. * Attaches a new image processing configuration to the PBR Material.
  43644. * @param configuration
  43645. */
  43646. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43647. /**
  43648. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43649. */
  43650. get colorCurves(): Nullable<ColorCurves>;
  43651. /**
  43652. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43653. */
  43654. set colorCurves(value: Nullable<ColorCurves>);
  43655. /**
  43656. * Gets wether the color curves effect is enabled.
  43657. */
  43658. get colorCurvesEnabled(): boolean;
  43659. /**
  43660. * Sets wether the color curves effect is enabled.
  43661. */
  43662. set colorCurvesEnabled(value: boolean);
  43663. /**
  43664. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43665. */
  43666. get colorGradingTexture(): Nullable<BaseTexture>;
  43667. /**
  43668. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43669. */
  43670. set colorGradingTexture(value: Nullable<BaseTexture>);
  43671. /**
  43672. * Gets wether the color grading effect is enabled.
  43673. */
  43674. get colorGradingEnabled(): boolean;
  43675. /**
  43676. * Gets wether the color grading effect is enabled.
  43677. */
  43678. set colorGradingEnabled(value: boolean);
  43679. /**
  43680. * Gets exposure used in the effect.
  43681. */
  43682. get exposure(): number;
  43683. /**
  43684. * Sets exposure used in the effect.
  43685. */
  43686. set exposure(value: number);
  43687. /**
  43688. * Gets wether tonemapping is enabled or not.
  43689. */
  43690. get toneMappingEnabled(): boolean;
  43691. /**
  43692. * Sets wether tonemapping is enabled or not
  43693. */
  43694. set toneMappingEnabled(value: boolean);
  43695. /**
  43696. * Gets the type of tone mapping effect.
  43697. */
  43698. get toneMappingType(): number;
  43699. /**
  43700. * Sets the type of tone mapping effect.
  43701. */
  43702. set toneMappingType(value: number);
  43703. /**
  43704. * Gets contrast used in the effect.
  43705. */
  43706. get contrast(): number;
  43707. /**
  43708. * Sets contrast used in the effect.
  43709. */
  43710. set contrast(value: number);
  43711. /**
  43712. * Gets Vignette stretch size.
  43713. */
  43714. get vignetteStretch(): number;
  43715. /**
  43716. * Sets Vignette stretch size.
  43717. */
  43718. set vignetteStretch(value: number);
  43719. /**
  43720. * Gets Vignette centre X Offset.
  43721. */
  43722. get vignetteCentreX(): number;
  43723. /**
  43724. * Sets Vignette centre X Offset.
  43725. */
  43726. set vignetteCentreX(value: number);
  43727. /**
  43728. * Gets Vignette centre Y Offset.
  43729. */
  43730. get vignetteCentreY(): number;
  43731. /**
  43732. * Sets Vignette centre Y Offset.
  43733. */
  43734. set vignetteCentreY(value: number);
  43735. /**
  43736. * Gets Vignette weight or intensity of the vignette effect.
  43737. */
  43738. get vignetteWeight(): number;
  43739. /**
  43740. * Sets Vignette weight or intensity of the vignette effect.
  43741. */
  43742. set vignetteWeight(value: number);
  43743. /**
  43744. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43745. * if vignetteEnabled is set to true.
  43746. */
  43747. get vignetteColor(): Color4;
  43748. /**
  43749. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43750. * if vignetteEnabled is set to true.
  43751. */
  43752. set vignetteColor(value: Color4);
  43753. /**
  43754. * Gets Camera field of view used by the Vignette effect.
  43755. */
  43756. get vignetteCameraFov(): number;
  43757. /**
  43758. * Sets Camera field of view used by the Vignette effect.
  43759. */
  43760. set vignetteCameraFov(value: number);
  43761. /**
  43762. * Gets the vignette blend mode allowing different kind of effect.
  43763. */
  43764. get vignetteBlendMode(): number;
  43765. /**
  43766. * Sets the vignette blend mode allowing different kind of effect.
  43767. */
  43768. set vignetteBlendMode(value: number);
  43769. /**
  43770. * Gets wether the vignette effect is enabled.
  43771. */
  43772. get vignetteEnabled(): boolean;
  43773. /**
  43774. * Sets wether the vignette effect is enabled.
  43775. */
  43776. set vignetteEnabled(value: boolean);
  43777. private _fromLinearSpace;
  43778. /**
  43779. * Gets wether the input of the processing is in Gamma or Linear Space.
  43780. */
  43781. get fromLinearSpace(): boolean;
  43782. /**
  43783. * Sets wether the input of the processing is in Gamma or Linear Space.
  43784. */
  43785. set fromLinearSpace(value: boolean);
  43786. /**
  43787. * Defines cache preventing GC.
  43788. */
  43789. private _defines;
  43790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43791. /**
  43792. * "ImageProcessingPostProcess"
  43793. * @returns "ImageProcessingPostProcess"
  43794. */
  43795. getClassName(): string;
  43796. protected _updateParameters(): void;
  43797. dispose(camera?: Camera): void;
  43798. }
  43799. }
  43800. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43801. import { Scene } from "babylonjs/scene";
  43802. import { Color3 } from "babylonjs/Maths/math.color";
  43803. import { Mesh } from "babylonjs/Meshes/mesh";
  43804. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43805. import { Nullable } from "babylonjs/types";
  43806. /**
  43807. * Class containing static functions to help procedurally build meshes
  43808. */
  43809. export class GroundBuilder {
  43810. /**
  43811. * Creates a ground mesh
  43812. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43813. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43815. * @param name defines the name of the mesh
  43816. * @param options defines the options used to create the mesh
  43817. * @param scene defines the hosting scene
  43818. * @returns the ground mesh
  43819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43820. */
  43821. static CreateGround(name: string, options: {
  43822. width?: number;
  43823. height?: number;
  43824. subdivisions?: number;
  43825. subdivisionsX?: number;
  43826. subdivisionsY?: number;
  43827. updatable?: boolean;
  43828. }, scene: any): Mesh;
  43829. /**
  43830. * Creates a tiled ground mesh
  43831. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43832. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43833. * * 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
  43834. * * 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
  43835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43836. * @param name defines the name of the mesh
  43837. * @param options defines the options used to create the mesh
  43838. * @param scene defines the hosting scene
  43839. * @returns the tiled ground mesh
  43840. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43841. */
  43842. static CreateTiledGround(name: string, options: {
  43843. xmin: number;
  43844. zmin: number;
  43845. xmax: number;
  43846. zmax: number;
  43847. subdivisions?: {
  43848. w: number;
  43849. h: number;
  43850. };
  43851. precision?: {
  43852. w: number;
  43853. h: number;
  43854. };
  43855. updatable?: boolean;
  43856. }, scene?: Nullable<Scene>): Mesh;
  43857. /**
  43858. * Creates a ground mesh from a height map
  43859. * * The parameter `url` sets the URL of the height map image resource.
  43860. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43861. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43862. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43863. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43864. * * 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.
  43865. * * 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).
  43866. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43868. * @param name defines the name of the mesh
  43869. * @param url defines the url to the height map
  43870. * @param options defines the options used to create the mesh
  43871. * @param scene defines the hosting scene
  43872. * @returns the ground mesh
  43873. * @see https://doc.babylonjs.com/babylon101/height_map
  43874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43875. */
  43876. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43877. width?: number;
  43878. height?: number;
  43879. subdivisions?: number;
  43880. minHeight?: number;
  43881. maxHeight?: number;
  43882. colorFilter?: Color3;
  43883. alphaFilter?: number;
  43884. updatable?: boolean;
  43885. onReady?: (mesh: GroundMesh) => void;
  43886. }, scene?: Nullable<Scene>): GroundMesh;
  43887. }
  43888. }
  43889. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43890. import { Vector4 } from "babylonjs/Maths/math.vector";
  43891. import { Mesh } from "babylonjs/Meshes/mesh";
  43892. /**
  43893. * Class containing static functions to help procedurally build meshes
  43894. */
  43895. export class TorusBuilder {
  43896. /**
  43897. * Creates a torus mesh
  43898. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43899. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43900. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43904. * @param name defines the name of the mesh
  43905. * @param options defines the options used to create the mesh
  43906. * @param scene defines the hosting scene
  43907. * @returns the torus mesh
  43908. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43909. */
  43910. static CreateTorus(name: string, options: {
  43911. diameter?: number;
  43912. thickness?: number;
  43913. tessellation?: number;
  43914. updatable?: boolean;
  43915. sideOrientation?: number;
  43916. frontUVs?: Vector4;
  43917. backUVs?: Vector4;
  43918. }, scene: any): Mesh;
  43919. }
  43920. }
  43921. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43922. import { Vector4 } from "babylonjs/Maths/math.vector";
  43923. import { Color4 } from "babylonjs/Maths/math.color";
  43924. import { Mesh } from "babylonjs/Meshes/mesh";
  43925. /**
  43926. * Class containing static functions to help procedurally build meshes
  43927. */
  43928. export class CylinderBuilder {
  43929. /**
  43930. * Creates a cylinder or a cone mesh
  43931. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43932. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43933. * * 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.
  43934. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43935. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43936. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43937. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43938. * * 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).
  43939. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43940. * * 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).
  43941. * * 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
  43942. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43943. * * 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
  43944. * * 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.
  43945. * * If `enclose` is false, a ring surface is one element.
  43946. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43947. * * 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
  43948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43951. * @param name defines the name of the mesh
  43952. * @param options defines the options used to create the mesh
  43953. * @param scene defines the hosting scene
  43954. * @returns the cylinder mesh
  43955. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43956. */
  43957. static CreateCylinder(name: string, options: {
  43958. height?: number;
  43959. diameterTop?: number;
  43960. diameterBottom?: number;
  43961. diameter?: number;
  43962. tessellation?: number;
  43963. subdivisions?: number;
  43964. arc?: number;
  43965. faceColors?: Color4[];
  43966. faceUV?: Vector4[];
  43967. updatable?: boolean;
  43968. hasRings?: boolean;
  43969. enclose?: boolean;
  43970. cap?: number;
  43971. sideOrientation?: number;
  43972. frontUVs?: Vector4;
  43973. backUVs?: Vector4;
  43974. }, scene: any): Mesh;
  43975. }
  43976. }
  43977. declare module "babylonjs/XR/webXRTypes" {
  43978. import { Nullable } from "babylonjs/types";
  43979. import { IDisposable } from "babylonjs/scene";
  43980. /**
  43981. * States of the webXR experience
  43982. */
  43983. export enum WebXRState {
  43984. /**
  43985. * Transitioning to being in XR mode
  43986. */
  43987. ENTERING_XR = 0,
  43988. /**
  43989. * Transitioning to non XR mode
  43990. */
  43991. EXITING_XR = 1,
  43992. /**
  43993. * In XR mode and presenting
  43994. */
  43995. IN_XR = 2,
  43996. /**
  43997. * Not entered XR mode
  43998. */
  43999. NOT_IN_XR = 3
  44000. }
  44001. /**
  44002. * Abstraction of the XR render target
  44003. */
  44004. export interface WebXRRenderTarget extends IDisposable {
  44005. /**
  44006. * xrpresent context of the canvas which can be used to display/mirror xr content
  44007. */
  44008. canvasContext: WebGLRenderingContext;
  44009. /**
  44010. * xr layer for the canvas
  44011. */
  44012. xrLayer: Nullable<XRWebGLLayer>;
  44013. /**
  44014. * Initializes the xr layer for the session
  44015. * @param xrSession xr session
  44016. * @returns a promise that will resolve once the XR Layer has been created
  44017. */
  44018. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44019. }
  44020. }
  44021. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44022. import { Nullable } from "babylonjs/types";
  44023. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44024. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44025. /**
  44026. * COnfiguration object for WebXR output canvas
  44027. */
  44028. export class WebXRManagedOutputCanvasOptions {
  44029. /**
  44030. * Options for this XR Layer output
  44031. */
  44032. canvasOptions?: XRWebGLLayerOptions;
  44033. /**
  44034. * CSS styling for a newly created canvas (if not provided)
  44035. */
  44036. newCanvasCssStyle?: string;
  44037. /**
  44038. * An optional canvas in case you wish to create it yourself and provide it here.
  44039. * If not provided, a new canvas will be created
  44040. */
  44041. canvasElement?: HTMLCanvasElement;
  44042. /**
  44043. * Get the default values of the configuration object
  44044. * @returns default values of this configuration object
  44045. */
  44046. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44047. }
  44048. /**
  44049. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44050. */
  44051. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44052. private _options;
  44053. private _engine;
  44054. private _canvas;
  44055. /**
  44056. * Rendering context of the canvas which can be used to display/mirror xr content
  44057. */
  44058. canvasContext: WebGLRenderingContext;
  44059. /**
  44060. * xr layer for the canvas
  44061. */
  44062. xrLayer: Nullable<XRWebGLLayer>;
  44063. /**
  44064. * Initializes the xr layer for the session
  44065. * @param xrSession xr session
  44066. * @returns a promise that will resolve once the XR Layer has been created
  44067. */
  44068. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44069. /**
  44070. * Initializes the canvas to be added/removed upon entering/exiting xr
  44071. * @param _xrSessionManager The XR Session manager
  44072. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44073. */
  44074. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44075. /**
  44076. * Disposes of the object
  44077. */
  44078. dispose(): void;
  44079. private _setManagedOutputCanvas;
  44080. private _addCanvas;
  44081. private _removeCanvas;
  44082. }
  44083. }
  44084. declare module "babylonjs/XR/webXRSessionManager" {
  44085. import { Observable } from "babylonjs/Misc/observable";
  44086. import { Nullable } from "babylonjs/types";
  44087. import { IDisposable, Scene } from "babylonjs/scene";
  44088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44089. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44090. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44091. /**
  44092. * Manages an XRSession to work with Babylon's engine
  44093. * @see https://doc.babylonjs.com/how_to/webxr
  44094. */
  44095. export class WebXRSessionManager implements IDisposable {
  44096. /** The scene which the session should be created for */
  44097. scene: Scene;
  44098. /**
  44099. * Fires every time a new xrFrame arrives which can be used to update the camera
  44100. */
  44101. onXRFrameObservable: Observable<XRFrame>;
  44102. /**
  44103. * Fires when the xr session is ended either by the device or manually done
  44104. */
  44105. onXRSessionEnded: Observable<any>;
  44106. /**
  44107. * Fires when the xr session is ended either by the device or manually done
  44108. */
  44109. onXRSessionInit: Observable<XRSession>;
  44110. /**
  44111. * Fires when the reference space changed
  44112. */
  44113. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44114. /**
  44115. * Underlying xr session
  44116. */
  44117. session: XRSession;
  44118. /**
  44119. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44120. * or get the offset the player is currently at.
  44121. */
  44122. viewerReferenceSpace: XRReferenceSpace;
  44123. private _referenceSpace;
  44124. /**
  44125. * The current reference space used in this session. This reference space can constantly change!
  44126. * It is mainly used to offset the camera's position.
  44127. */
  44128. get referenceSpace(): XRReferenceSpace;
  44129. /**
  44130. * Set a new reference space and triggers the observable
  44131. */
  44132. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44133. /**
  44134. * The base reference space from which the session started. good if you want to reset your
  44135. * reference space
  44136. */
  44137. baseReferenceSpace: XRReferenceSpace;
  44138. /**
  44139. * Used just in case of a failure to initialize an immersive session.
  44140. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44141. */
  44142. defaultHeightCompensation: number;
  44143. /**
  44144. * Current XR frame
  44145. */
  44146. currentFrame: Nullable<XRFrame>;
  44147. /** WebXR timestamp updated every frame */
  44148. currentTimestamp: number;
  44149. private _xrNavigator;
  44150. private baseLayer;
  44151. private _rttProvider;
  44152. private _sessionEnded;
  44153. /**
  44154. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44155. * @param scene The scene which the session should be created for
  44156. */
  44157. constructor(
  44158. /** The scene which the session should be created for */
  44159. scene: Scene);
  44160. /**
  44161. * Initializes the manager
  44162. * After initialization enterXR can be called to start an XR session
  44163. * @returns Promise which resolves after it is initialized
  44164. */
  44165. initializeAsync(): Promise<void>;
  44166. /**
  44167. * Initializes an xr session
  44168. * @param xrSessionMode mode to initialize
  44169. * @param xrSessionInit defines optional and required values to pass to the session builder
  44170. * @returns a promise which will resolve once the session has been initialized
  44171. */
  44172. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44173. /**
  44174. * Sets the reference space on the xr session
  44175. * @param referenceSpaceType space to set
  44176. * @returns a promise that will resolve once the reference space has been set
  44177. */
  44178. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44179. /**
  44180. * Resets the reference space to the one started the session
  44181. */
  44182. resetReferenceSpace(): void;
  44183. /**
  44184. * Updates the render state of the session
  44185. * @param state state to set
  44186. * @returns a promise that resolves once the render state has been updated
  44187. */
  44188. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44189. /**
  44190. * Starts rendering to the xr layer
  44191. */
  44192. runXRRenderLoop(): void;
  44193. /**
  44194. * Gets the correct render target texture to be rendered this frame for this eye
  44195. * @param eye the eye for which to get the render target
  44196. * @returns the render target for the specified eye
  44197. */
  44198. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44199. /**
  44200. * Stops the xrSession and restores the renderloop
  44201. * @returns Promise which resolves after it exits XR
  44202. */
  44203. exitXRAsync(): Promise<void>;
  44204. /**
  44205. * Checks if a session would be supported for the creation options specified
  44206. * @param sessionMode session mode to check if supported eg. immersive-vr
  44207. * @returns A Promise that resolves to true if supported and false if not
  44208. */
  44209. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44210. /**
  44211. * Creates a WebXRRenderTarget object for the XR session
  44212. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44213. * @param options optional options to provide when creating a new render target
  44214. * @returns a WebXR render target to which the session can render
  44215. */
  44216. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44217. /**
  44218. * @hidden
  44219. * Converts the render layer of xrSession to a render target
  44220. * @param session session to create render target for
  44221. * @param scene scene the new render target should be created for
  44222. * @param baseLayer the webgl layer to create the render target for
  44223. */
  44224. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44225. /**
  44226. * Disposes of the session manager
  44227. */
  44228. dispose(): void;
  44229. /**
  44230. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44231. * @param sessionMode defines the session to test
  44232. * @returns a promise with boolean as final value
  44233. */
  44234. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44235. }
  44236. }
  44237. declare module "babylonjs/XR/webXRCamera" {
  44238. import { Scene } from "babylonjs/scene";
  44239. import { Camera } from "babylonjs/Cameras/camera";
  44240. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44241. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44242. /**
  44243. * WebXR Camera which holds the views for the xrSession
  44244. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44245. */
  44246. export class WebXRCamera extends FreeCamera {
  44247. private _xrSessionManager;
  44248. private _firstFrame;
  44249. private _referenceQuaternion;
  44250. private _referencedPosition;
  44251. private _xrInvPositionCache;
  44252. private _xrInvQuaternionCache;
  44253. /**
  44254. * Should position compensation execute on first frame.
  44255. * This is used when copying the position from a native (non XR) camera
  44256. */
  44257. compensateOnFirstFrame: boolean;
  44258. /**
  44259. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44260. * @param name the name of the camera
  44261. * @param scene the scene to add the camera to
  44262. * @param _xrSessionManager a constructed xr session manager
  44263. */
  44264. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44265. /**
  44266. * Return the user's height, unrelated to the current ground.
  44267. * This will be the y position of this camera, when ground level is 0.
  44268. */
  44269. get realWorldHeight(): number;
  44270. /** @hidden */
  44271. _updateForDualEyeDebugging(): void;
  44272. /**
  44273. * Sets this camera's transformation based on a non-vr camera
  44274. * @param otherCamera the non-vr camera to copy the transformation from
  44275. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44276. */
  44277. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44278. private _updateFromXRSession;
  44279. private _updateNumberOfRigCameras;
  44280. private _updateReferenceSpace;
  44281. private _updateReferenceSpaceOffset;
  44282. }
  44283. }
  44284. declare module "babylonjs/XR/webXRFeaturesManager" {
  44285. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44286. import { IDisposable } from "babylonjs/scene";
  44287. /**
  44288. * Defining the interface required for a (webxr) feature
  44289. */
  44290. export interface IWebXRFeature extends IDisposable {
  44291. /**
  44292. * Is this feature attached
  44293. */
  44294. attached: boolean;
  44295. /**
  44296. * Should auto-attach be disabled?
  44297. */
  44298. disableAutoAttach: boolean;
  44299. /**
  44300. * Attach the feature to the session
  44301. * Will usually be called by the features manager
  44302. *
  44303. * @param force should attachment be forced (even when already attached)
  44304. * @returns true if successful.
  44305. */
  44306. attach(force?: boolean): boolean;
  44307. /**
  44308. * Detach the feature from the session
  44309. * Will usually be called by the features manager
  44310. *
  44311. * @returns true if successful.
  44312. */
  44313. detach(): boolean;
  44314. }
  44315. /**
  44316. * A list of the currently available features without referencing them
  44317. */
  44318. export class WebXRFeatureName {
  44319. /**
  44320. * The name of the hit test feature
  44321. */
  44322. static HIT_TEST: string;
  44323. /**
  44324. * The name of the anchor system feature
  44325. */
  44326. static ANCHOR_SYSTEM: string;
  44327. /**
  44328. * The name of the background remover feature
  44329. */
  44330. static BACKGROUND_REMOVER: string;
  44331. /**
  44332. * The name of the pointer selection feature
  44333. */
  44334. static POINTER_SELECTION: string;
  44335. /**
  44336. * The name of the teleportation feature
  44337. */
  44338. static TELEPORTATION: string;
  44339. /**
  44340. * The name of the plane detection feature
  44341. */
  44342. static PLANE_DETECTION: string;
  44343. /**
  44344. * physics impostors for xr controllers feature
  44345. */
  44346. static PHYSICS_CONTROLLERS: string;
  44347. }
  44348. /**
  44349. * Defining the constructor of a feature. Used to register the modules.
  44350. */
  44351. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44352. /**
  44353. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44354. * It is mainly used in AR sessions.
  44355. *
  44356. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44357. */
  44358. export class WebXRFeaturesManager implements IDisposable {
  44359. private _xrSessionManager;
  44360. private static readonly _AvailableFeatures;
  44361. /**
  44362. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44363. * Mainly used internally.
  44364. *
  44365. * @param featureName the name of the feature to register
  44366. * @param constructorFunction the function used to construct the module
  44367. * @param version the (babylon) version of the module
  44368. * @param stable is that a stable version of this module
  44369. */
  44370. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44371. /**
  44372. * Returns a constructor of a specific feature.
  44373. *
  44374. * @param featureName the name of the feature to construct
  44375. * @param version the version of the feature to load
  44376. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44377. * @param options optional options provided to the module.
  44378. * @returns a function that, when called, will return a new instance of this feature
  44379. */
  44380. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44381. /**
  44382. * Return the latest unstable version of this feature
  44383. * @param featureName the name of the feature to search
  44384. * @returns the version number. if not found will return -1
  44385. */
  44386. static GetLatestVersionOfFeature(featureName: string): number;
  44387. /**
  44388. * Return the latest stable version of this feature
  44389. * @param featureName the name of the feature to search
  44390. * @returns the version number. if not found will return -1
  44391. */
  44392. static GetStableVersionOfFeature(featureName: string): number;
  44393. /**
  44394. * Can be used to return the list of features currently registered
  44395. *
  44396. * @returns an Array of available features
  44397. */
  44398. static GetAvailableFeatures(): string[];
  44399. /**
  44400. * Gets the versions available for a specific feature
  44401. * @param featureName the name of the feature
  44402. * @returns an array with the available versions
  44403. */
  44404. static GetAvailableVersions(featureName: string): string[];
  44405. private _features;
  44406. /**
  44407. * constructs a new features manages.
  44408. *
  44409. * @param _xrSessionManager an instance of WebXRSessionManager
  44410. */
  44411. constructor(_xrSessionManager: WebXRSessionManager);
  44412. /**
  44413. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  44414. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44415. *
  44416. * @param featureName the name of the feature to load or the class of the feature
  44417. * @param version optional version to load. if not provided the latest version will be enabled
  44418. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44419. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44420. * @returns a new constructed feature or throws an error if feature not found.
  44421. */
  44422. enableFeature(featureName: string | {
  44423. Name: string;
  44424. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44425. /**
  44426. * Used to disable an already-enabled feature
  44427. * The feature will be disposed and will be recreated once enabled.
  44428. * @param featureName the feature to disable
  44429. * @returns true if disable was successful
  44430. */
  44431. disableFeature(featureName: string | {
  44432. Name: string;
  44433. }): boolean;
  44434. /**
  44435. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44436. * Can be used during a session to start a feature
  44437. * @param featureName the name of feature to attach
  44438. */
  44439. attachFeature(featureName: string): void;
  44440. /**
  44441. * Can be used inside a session or when the session ends to detach a specific feature
  44442. * @param featureName the name of the feature to detach
  44443. */
  44444. detachFeature(featureName: string): void;
  44445. /**
  44446. * Get the list of enabled features
  44447. * @returns an array of enabled features
  44448. */
  44449. getEnabledFeatures(): string[];
  44450. /**
  44451. * get the implementation of an enabled feature.
  44452. * @param featureName the name of the feature to load
  44453. * @returns the feature class, if found
  44454. */
  44455. getEnabledFeature(featureName: string): IWebXRFeature;
  44456. /**
  44457. * dispose this features manager
  44458. */
  44459. dispose(): void;
  44460. }
  44461. }
  44462. declare module "babylonjs/XR/webXRExperienceHelper" {
  44463. import { Observable } from "babylonjs/Misc/observable";
  44464. import { IDisposable, Scene } from "babylonjs/scene";
  44465. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44466. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44467. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44468. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44469. /**
  44470. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44471. * @see https://doc.babylonjs.com/how_to/webxr
  44472. */
  44473. export class WebXRExperienceHelper implements IDisposable {
  44474. private scene;
  44475. /**
  44476. * Camera used to render xr content
  44477. */
  44478. camera: WebXRCamera;
  44479. /**
  44480. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44481. */
  44482. state: WebXRState;
  44483. private _setState;
  44484. /**
  44485. * Fires when the state of the experience helper has changed
  44486. */
  44487. onStateChangedObservable: Observable<WebXRState>;
  44488. /**
  44489. * Observers registered here will be triggered after the camera's initial transformation is set
  44490. * This can be used to set a different ground level or an extra rotation.
  44491. *
  44492. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44493. * to the position set after this observable is done executing.
  44494. */
  44495. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44496. /** Session manager used to keep track of xr session */
  44497. sessionManager: WebXRSessionManager;
  44498. /** A features manager for this xr session */
  44499. featuresManager: WebXRFeaturesManager;
  44500. private _nonVRCamera;
  44501. private _originalSceneAutoClear;
  44502. private _supported;
  44503. /**
  44504. * Creates the experience helper
  44505. * @param scene the scene to attach the experience helper to
  44506. * @returns a promise for the experience helper
  44507. */
  44508. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44509. /**
  44510. * Creates a WebXRExperienceHelper
  44511. * @param scene The scene the helper should be created in
  44512. */
  44513. private constructor();
  44514. /**
  44515. * Exits XR mode and returns the scene to its original state
  44516. * @returns promise that resolves after xr mode has exited
  44517. */
  44518. exitXRAsync(): Promise<void>;
  44519. /**
  44520. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44521. * @param sessionMode options for the XR session
  44522. * @param referenceSpaceType frame of reference of the XR session
  44523. * @param renderTarget the output canvas that will be used to enter XR mode
  44524. * @returns promise that resolves after xr mode has entered
  44525. */
  44526. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44527. /**
  44528. * Disposes of the experience helper
  44529. */
  44530. dispose(): void;
  44531. private _nonXRToXRCamera;
  44532. }
  44533. }
  44534. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44535. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44536. import { Observable } from "babylonjs/Misc/observable";
  44537. import { IDisposable } from "babylonjs/scene";
  44538. /**
  44539. * X-Y values for axes in WebXR
  44540. */
  44541. export interface IWebXRMotionControllerAxesValue {
  44542. /**
  44543. * The value of the x axis
  44544. */
  44545. x: number;
  44546. /**
  44547. * The value of the y-axis
  44548. */
  44549. y: number;
  44550. }
  44551. /**
  44552. * changed / previous values for the values of this component
  44553. */
  44554. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44555. /**
  44556. * current (this frame) value
  44557. */
  44558. current: T;
  44559. /**
  44560. * previous (last change) value
  44561. */
  44562. previous: T;
  44563. }
  44564. /**
  44565. * Represents changes in the component between current frame and last values recorded
  44566. */
  44567. export interface IWebXRMotionControllerComponentChanges {
  44568. /**
  44569. * will be populated with previous and current values if touched changed
  44570. */
  44571. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44572. /**
  44573. * will be populated with previous and current values if pressed changed
  44574. */
  44575. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44576. /**
  44577. * will be populated with previous and current values if value changed
  44578. */
  44579. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44580. /**
  44581. * will be populated with previous and current values if axes changed
  44582. */
  44583. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44584. }
  44585. /**
  44586. * This class represents a single component (for example button or thumbstick) of a motion controller
  44587. */
  44588. export class WebXRControllerComponent implements IDisposable {
  44589. /**
  44590. * the id of this component
  44591. */
  44592. id: string;
  44593. /**
  44594. * the type of the component
  44595. */
  44596. type: MotionControllerComponentType;
  44597. private _buttonIndex;
  44598. private _axesIndices;
  44599. /**
  44600. * Thumbstick component type
  44601. */
  44602. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44603. /**
  44604. * Touchpad component type
  44605. */
  44606. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44607. /**
  44608. * trigger component type
  44609. */
  44610. static TRIGGER_TYPE: MotionControllerComponentType;
  44611. /**
  44612. * squeeze component type
  44613. */
  44614. static SQUEEZE_TYPE: MotionControllerComponentType;
  44615. /**
  44616. * button component type
  44617. */
  44618. static BUTTON_TYPE: MotionControllerComponentType;
  44619. /**
  44620. * Observers registered here will be triggered when the state of a button changes
  44621. * State change is either pressed / touched / value
  44622. */
  44623. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44624. /**
  44625. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44626. * the axes data changes
  44627. */
  44628. onAxisValueChangedObservable: Observable<{
  44629. x: number;
  44630. y: number;
  44631. }>;
  44632. private _currentValue;
  44633. private _touched;
  44634. private _pressed;
  44635. private _axes;
  44636. private _changes;
  44637. private _hasChanges;
  44638. /**
  44639. * Return whether or not the component changed the last frame
  44640. */
  44641. get hasChanges(): boolean;
  44642. /**
  44643. * Creates a new component for a motion controller.
  44644. * It is created by the motion controller itself
  44645. *
  44646. * @param id the id of this component
  44647. * @param type the type of the component
  44648. * @param _buttonIndex index in the buttons array of the gamepad
  44649. * @param _axesIndices indices of the values in the axes array of the gamepad
  44650. */
  44651. constructor(
  44652. /**
  44653. * the id of this component
  44654. */
  44655. id: string,
  44656. /**
  44657. * the type of the component
  44658. */
  44659. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44660. /**
  44661. * Get the current value of this component
  44662. */
  44663. get value(): number;
  44664. /**
  44665. * is the button currently pressed
  44666. */
  44667. get pressed(): boolean;
  44668. /**
  44669. * is the button currently touched
  44670. */
  44671. get touched(): boolean;
  44672. /**
  44673. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44674. */
  44675. get axes(): IWebXRMotionControllerAxesValue;
  44676. /**
  44677. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44678. */
  44679. get changes(): IWebXRMotionControllerComponentChanges;
  44680. /**
  44681. * Is this component a button (hence - pressable)
  44682. * @returns true if can be pressed
  44683. */
  44684. isButton(): boolean;
  44685. /**
  44686. * Are there axes correlating to this component
  44687. * @return true is axes data is available
  44688. */
  44689. isAxes(): boolean;
  44690. /**
  44691. * update this component using the gamepad object it is in. Called on every frame
  44692. * @param nativeController the native gamepad controller object
  44693. */
  44694. update(nativeController: IMinimalMotionControllerObject): void;
  44695. /**
  44696. * Dispose this component
  44697. */
  44698. dispose(): void;
  44699. }
  44700. }
  44701. declare module "babylonjs/Loading/sceneLoader" {
  44702. import { Observable } from "babylonjs/Misc/observable";
  44703. import { Nullable } from "babylonjs/types";
  44704. import { Scene } from "babylonjs/scene";
  44705. import { Engine } from "babylonjs/Engines/engine";
  44706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44707. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44708. import { AssetContainer } from "babylonjs/assetContainer";
  44709. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44710. import { Skeleton } from "babylonjs/Bones/skeleton";
  44711. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44712. import { WebRequest } from "babylonjs/Misc/webRequest";
  44713. /**
  44714. * Class used to represent data loading progression
  44715. */
  44716. export class SceneLoaderProgressEvent {
  44717. /** defines if data length to load can be evaluated */
  44718. readonly lengthComputable: boolean;
  44719. /** defines the loaded data length */
  44720. readonly loaded: number;
  44721. /** defines the data length to load */
  44722. readonly total: number;
  44723. /**
  44724. * Create a new progress event
  44725. * @param lengthComputable defines if data length to load can be evaluated
  44726. * @param loaded defines the loaded data length
  44727. * @param total defines the data length to load
  44728. */
  44729. constructor(
  44730. /** defines if data length to load can be evaluated */
  44731. lengthComputable: boolean,
  44732. /** defines the loaded data length */
  44733. loaded: number,
  44734. /** defines the data length to load */
  44735. total: number);
  44736. /**
  44737. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44738. * @param event defines the source event
  44739. * @returns a new SceneLoaderProgressEvent
  44740. */
  44741. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44742. }
  44743. /**
  44744. * Interface used by SceneLoader plugins to define supported file extensions
  44745. */
  44746. export interface ISceneLoaderPluginExtensions {
  44747. /**
  44748. * Defines the list of supported extensions
  44749. */
  44750. [extension: string]: {
  44751. isBinary: boolean;
  44752. };
  44753. }
  44754. /**
  44755. * Interface used by SceneLoader plugin factory
  44756. */
  44757. export interface ISceneLoaderPluginFactory {
  44758. /**
  44759. * Defines the name of the factory
  44760. */
  44761. name: string;
  44762. /**
  44763. * Function called to create a new plugin
  44764. * @return the new plugin
  44765. */
  44766. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44767. /**
  44768. * The callback that returns true if the data can be directly loaded.
  44769. * @param data string containing the file data
  44770. * @returns if the data can be loaded directly
  44771. */
  44772. canDirectLoad?(data: string): boolean;
  44773. }
  44774. /**
  44775. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44776. */
  44777. export interface ISceneLoaderPluginBase {
  44778. /**
  44779. * The friendly name of this plugin.
  44780. */
  44781. name: string;
  44782. /**
  44783. * The file extensions supported by this plugin.
  44784. */
  44785. extensions: string | ISceneLoaderPluginExtensions;
  44786. /**
  44787. * The callback called when loading from a url.
  44788. * @param scene scene loading this url
  44789. * @param url url to load
  44790. * @param onSuccess callback called when the file successfully loads
  44791. * @param onProgress callback called while file is loading (if the server supports this mode)
  44792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44793. * @param onError callback called when the file fails to load
  44794. * @returns a file request object
  44795. */
  44796. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44797. /**
  44798. * The callback called when loading from a file object.
  44799. * @param scene scene loading this file
  44800. * @param file defines the file to load
  44801. * @param onSuccess defines the callback to call when data is loaded
  44802. * @param onProgress defines the callback to call during loading process
  44803. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44804. * @param onError defines the callback to call when an error occurs
  44805. * @returns a file request object
  44806. */
  44807. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44808. /**
  44809. * The callback that returns true if the data can be directly loaded.
  44810. * @param data string containing the file data
  44811. * @returns if the data can be loaded directly
  44812. */
  44813. canDirectLoad?(data: string): boolean;
  44814. /**
  44815. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44816. * @param scene scene loading this data
  44817. * @param data string containing the data
  44818. * @returns data to pass to the plugin
  44819. */
  44820. directLoad?(scene: Scene, data: string): any;
  44821. /**
  44822. * The callback that allows custom handling of the root url based on the response url.
  44823. * @param rootUrl the original root url
  44824. * @param responseURL the response url if available
  44825. * @returns the new root url
  44826. */
  44827. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44828. }
  44829. /**
  44830. * Interface used to define a SceneLoader plugin
  44831. */
  44832. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44833. /**
  44834. * Import meshes into a scene.
  44835. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44836. * @param scene The scene to import into
  44837. * @param data The data to import
  44838. * @param rootUrl The root url for scene and resources
  44839. * @param meshes The meshes array to import into
  44840. * @param particleSystems The particle systems array to import into
  44841. * @param skeletons The skeletons array to import into
  44842. * @param onError The callback when import fails
  44843. * @returns True if successful or false otherwise
  44844. */
  44845. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44846. /**
  44847. * Load into a scene.
  44848. * @param scene The scene to load into
  44849. * @param data The data to import
  44850. * @param rootUrl The root url for scene and resources
  44851. * @param onError The callback when import fails
  44852. * @returns True if successful or false otherwise
  44853. */
  44854. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44855. /**
  44856. * Load into an asset container.
  44857. * @param scene The scene to load into
  44858. * @param data The data to import
  44859. * @param rootUrl The root url for scene and resources
  44860. * @param onError The callback when import fails
  44861. * @returns The loaded asset container
  44862. */
  44863. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44864. }
  44865. /**
  44866. * Interface used to define an async SceneLoader plugin
  44867. */
  44868. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44869. /**
  44870. * Import meshes into a scene.
  44871. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44872. * @param scene The scene to import into
  44873. * @param data The data to import
  44874. * @param rootUrl The root url for scene and resources
  44875. * @param onProgress The callback when the load progresses
  44876. * @param fileName Defines the name of the file to load
  44877. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44878. */
  44879. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44880. meshes: AbstractMesh[];
  44881. particleSystems: IParticleSystem[];
  44882. skeletons: Skeleton[];
  44883. animationGroups: AnimationGroup[];
  44884. }>;
  44885. /**
  44886. * Load into a scene.
  44887. * @param scene The scene to load into
  44888. * @param data The data to import
  44889. * @param rootUrl The root url for scene and resources
  44890. * @param onProgress The callback when the load progresses
  44891. * @param fileName Defines the name of the file to load
  44892. * @returns Nothing
  44893. */
  44894. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44895. /**
  44896. * Load into an asset container.
  44897. * @param scene The scene to load into
  44898. * @param data The data to import
  44899. * @param rootUrl The root url for scene and resources
  44900. * @param onProgress The callback when the load progresses
  44901. * @param fileName Defines the name of the file to load
  44902. * @returns The loaded asset container
  44903. */
  44904. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44905. }
  44906. /**
  44907. * Mode that determines how to handle old animation groups before loading new ones.
  44908. */
  44909. export enum SceneLoaderAnimationGroupLoadingMode {
  44910. /**
  44911. * Reset all old animations to initial state then dispose them.
  44912. */
  44913. Clean = 0,
  44914. /**
  44915. * Stop all old animations.
  44916. */
  44917. Stop = 1,
  44918. /**
  44919. * Restart old animations from first frame.
  44920. */
  44921. Sync = 2,
  44922. /**
  44923. * Old animations remains untouched.
  44924. */
  44925. NoSync = 3
  44926. }
  44927. /**
  44928. * Class used to load scene from various file formats using registered plugins
  44929. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44930. */
  44931. export class SceneLoader {
  44932. /**
  44933. * No logging while loading
  44934. */
  44935. static readonly NO_LOGGING: number;
  44936. /**
  44937. * Minimal logging while loading
  44938. */
  44939. static readonly MINIMAL_LOGGING: number;
  44940. /**
  44941. * Summary logging while loading
  44942. */
  44943. static readonly SUMMARY_LOGGING: number;
  44944. /**
  44945. * Detailled logging while loading
  44946. */
  44947. static readonly DETAILED_LOGGING: number;
  44948. /**
  44949. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44950. */
  44951. static get ForceFullSceneLoadingForIncremental(): boolean;
  44952. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44953. /**
  44954. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44955. */
  44956. static get ShowLoadingScreen(): boolean;
  44957. static set ShowLoadingScreen(value: boolean);
  44958. /**
  44959. * Defines the current logging level (while loading the scene)
  44960. * @ignorenaming
  44961. */
  44962. static get loggingLevel(): number;
  44963. static set loggingLevel(value: number);
  44964. /**
  44965. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44966. */
  44967. static get CleanBoneMatrixWeights(): boolean;
  44968. static set CleanBoneMatrixWeights(value: boolean);
  44969. /**
  44970. * Event raised when a plugin is used to load a scene
  44971. */
  44972. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44973. private static _registeredPlugins;
  44974. private static _getDefaultPlugin;
  44975. private static _getPluginForExtension;
  44976. private static _getPluginForDirectLoad;
  44977. private static _getPluginForFilename;
  44978. private static _getDirectLoad;
  44979. private static _loadData;
  44980. private static _getFileInfo;
  44981. /**
  44982. * Gets a plugin that can load the given extension
  44983. * @param extension defines the extension to load
  44984. * @returns a plugin or null if none works
  44985. */
  44986. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44987. /**
  44988. * Gets a boolean indicating that the given extension can be loaded
  44989. * @param extension defines the extension to load
  44990. * @returns true if the extension is supported
  44991. */
  44992. static IsPluginForExtensionAvailable(extension: string): boolean;
  44993. /**
  44994. * Adds a new plugin to the list of registered plugins
  44995. * @param plugin defines the plugin to add
  44996. */
  44997. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44998. /**
  44999. * Import meshes into a scene
  45000. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45001. * @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)
  45002. * @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)
  45003. * @param scene the instance of BABYLON.Scene to append to
  45004. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45005. * @param onProgress a callback with a progress event for each file being loaded
  45006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45007. * @param pluginExtension the extension used to determine the plugin
  45008. * @returns The loaded plugin
  45009. */
  45010. 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>;
  45011. /**
  45012. * Import meshes into a scene
  45013. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45014. * @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)
  45015. * @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)
  45016. * @param scene the instance of BABYLON.Scene to append to
  45017. * @param onProgress a callback with a progress event for each file being loaded
  45018. * @param pluginExtension the extension used to determine the plugin
  45019. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45020. */
  45021. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45022. meshes: AbstractMesh[];
  45023. particleSystems: IParticleSystem[];
  45024. skeletons: Skeleton[];
  45025. animationGroups: AnimationGroup[];
  45026. }>;
  45027. /**
  45028. * Load a scene
  45029. * @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)
  45030. * @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)
  45031. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45032. * @param onSuccess a callback with the scene when import succeeds
  45033. * @param onProgress a callback with a progress event for each file being loaded
  45034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45035. * @param pluginExtension the extension used to determine the plugin
  45036. * @returns The loaded plugin
  45037. */
  45038. 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>;
  45039. /**
  45040. * Load a scene
  45041. * @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)
  45042. * @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)
  45043. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45044. * @param onProgress a callback with a progress event for each file being loaded
  45045. * @param pluginExtension the extension used to determine the plugin
  45046. * @returns The loaded scene
  45047. */
  45048. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45049. /**
  45050. * Append a scene
  45051. * @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)
  45052. * @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)
  45053. * @param scene is the instance of BABYLON.Scene to append to
  45054. * @param onSuccess a callback with the scene when import succeeds
  45055. * @param onProgress a callback with a progress event for each file being loaded
  45056. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45057. * @param pluginExtension the extension used to determine the plugin
  45058. * @returns The loaded plugin
  45059. */
  45060. 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>;
  45061. /**
  45062. * Append a scene
  45063. * @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)
  45064. * @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)
  45065. * @param scene is the instance of BABYLON.Scene to append to
  45066. * @param onProgress a callback with a progress event for each file being loaded
  45067. * @param pluginExtension the extension used to determine the plugin
  45068. * @returns The given scene
  45069. */
  45070. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45071. /**
  45072. * Load a scene into an asset container
  45073. * @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)
  45074. * @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)
  45075. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45076. * @param onSuccess a callback with the scene when import succeeds
  45077. * @param onProgress a callback with a progress event for each file being loaded
  45078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45079. * @param pluginExtension the extension used to determine the plugin
  45080. * @returns The loaded plugin
  45081. */
  45082. 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>;
  45083. /**
  45084. * Load a scene into an asset container
  45085. * @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)
  45086. * @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)
  45087. * @param scene is the instance of Scene to append to
  45088. * @param onProgress a callback with a progress event for each file being loaded
  45089. * @param pluginExtension the extension used to determine the plugin
  45090. * @returns The loaded asset container
  45091. */
  45092. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45093. /**
  45094. * Import animations from a file into a scene
  45095. * @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)
  45096. * @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)
  45097. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45098. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45099. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45100. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45101. * @param onSuccess a callback with the scene when import succeeds
  45102. * @param onProgress a callback with a progress event for each file being loaded
  45103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45104. */
  45105. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45106. /**
  45107. * Import animations from a file into a scene
  45108. * @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)
  45109. * @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)
  45110. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45111. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45112. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45113. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45114. * @param onSuccess a callback with the scene when import succeeds
  45115. * @param onProgress a callback with a progress event for each file being loaded
  45116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45117. * @returns the updated scene with imported animations
  45118. */
  45119. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45120. }
  45121. }
  45122. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45123. import { IDisposable, Scene } from "babylonjs/scene";
  45124. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45125. import { Observable } from "babylonjs/Misc/observable";
  45126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45127. import { Nullable } from "babylonjs/types";
  45128. /**
  45129. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45130. */
  45131. export type MotionControllerHandness = "none" | "left" | "right";
  45132. /**
  45133. * The type of components available in motion controllers.
  45134. * This is not the name of the component.
  45135. */
  45136. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45137. /**
  45138. * The state of a controller component
  45139. */
  45140. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45141. /**
  45142. * The schema of motion controller layout.
  45143. * No object will be initialized using this interface
  45144. * This is used just to define the profile.
  45145. */
  45146. export interface IMotionControllerLayout {
  45147. /**
  45148. * Defines the main button component id
  45149. */
  45150. selectComponentId: string;
  45151. /**
  45152. * Available components (unsorted)
  45153. */
  45154. components: {
  45155. /**
  45156. * A map of component Ids
  45157. */
  45158. [componentId: string]: {
  45159. /**
  45160. * The type of input the component outputs
  45161. */
  45162. type: MotionControllerComponentType;
  45163. /**
  45164. * The indices of this component in the gamepad object
  45165. */
  45166. gamepadIndices: {
  45167. /**
  45168. * Index of button
  45169. */
  45170. button?: number;
  45171. /**
  45172. * If available, index of x-axis
  45173. */
  45174. xAxis?: number;
  45175. /**
  45176. * If available, index of y-axis
  45177. */
  45178. yAxis?: number;
  45179. };
  45180. /**
  45181. * The mesh's root node name
  45182. */
  45183. rootNodeName: string;
  45184. /**
  45185. * Animation definitions for this model
  45186. */
  45187. visualResponses: {
  45188. [stateKey: string]: {
  45189. /**
  45190. * What property will be animated
  45191. */
  45192. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45193. /**
  45194. * What states influence this visual reponse
  45195. */
  45196. states: MotionControllerComponentStateType[];
  45197. /**
  45198. * Type of animation - movement or visibility
  45199. */
  45200. valueNodeProperty: "transform" | "visibility";
  45201. /**
  45202. * Base node name to move. Its position will be calculated according to the min and max nodes
  45203. */
  45204. valueNodeName?: string;
  45205. /**
  45206. * Minimum movement node
  45207. */
  45208. minNodeName?: string;
  45209. /**
  45210. * Max movement node
  45211. */
  45212. maxNodeName?: string;
  45213. };
  45214. };
  45215. /**
  45216. * If touch enabled, what is the name of node to display user feedback
  45217. */
  45218. touchPointNodeName?: string;
  45219. };
  45220. };
  45221. /**
  45222. * Is it xr standard mapping or not
  45223. */
  45224. gamepadMapping: "" | "xr-standard";
  45225. /**
  45226. * Base root node of this entire model
  45227. */
  45228. rootNodeName: string;
  45229. /**
  45230. * Path to load the assets. Usually relative to the base path
  45231. */
  45232. assetPath: string;
  45233. }
  45234. /**
  45235. * A definition for the layout map in the input profile
  45236. */
  45237. export interface IMotionControllerLayoutMap {
  45238. /**
  45239. * Layouts with handness type as a key
  45240. */
  45241. [handness: string]: IMotionControllerLayout;
  45242. }
  45243. /**
  45244. * The XR Input profile schema
  45245. * Profiles can be found here:
  45246. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45247. */
  45248. export interface IMotionControllerProfile {
  45249. /**
  45250. * The id of this profile
  45251. * correlates to the profile(s) in the xrInput.profiles array
  45252. */
  45253. profileId: string;
  45254. /**
  45255. * fallback profiles for this profileId
  45256. */
  45257. fallbackProfileIds: string[];
  45258. /**
  45259. * The layout map, with handness as key
  45260. */
  45261. layouts: IMotionControllerLayoutMap;
  45262. }
  45263. /**
  45264. * A helper-interface for the 3 meshes needed for controller button animation
  45265. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45266. */
  45267. export interface IMotionControllerButtonMeshMap {
  45268. /**
  45269. * The mesh that will be changed when value changes
  45270. */
  45271. valueMesh: AbstractMesh;
  45272. /**
  45273. * the mesh that defines the pressed value mesh position.
  45274. * This is used to find the max-position of this button
  45275. */
  45276. pressedMesh: AbstractMesh;
  45277. /**
  45278. * the mesh that defines the unpressed value mesh position.
  45279. * This is used to find the min (or initial) position of this button
  45280. */
  45281. unpressedMesh: AbstractMesh;
  45282. }
  45283. /**
  45284. * A helper-interface for the 3 meshes needed for controller axis animation.
  45285. * This will be expanded when touchpad animations are fully supported
  45286. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45287. */
  45288. export interface IMotionControllerMeshMap {
  45289. /**
  45290. * The mesh that will be changed when axis value changes
  45291. */
  45292. valueMesh: AbstractMesh;
  45293. /**
  45294. * the mesh that defines the minimum value mesh position.
  45295. */
  45296. minMesh?: AbstractMesh;
  45297. /**
  45298. * the mesh that defines the maximum value mesh position.
  45299. */
  45300. maxMesh?: AbstractMesh;
  45301. }
  45302. /**
  45303. * The elements needed for change-detection of the gamepad objects in motion controllers
  45304. */
  45305. export interface IMinimalMotionControllerObject {
  45306. /**
  45307. * An array of available buttons
  45308. */
  45309. buttons: Array<{
  45310. /**
  45311. * Value of the button/trigger
  45312. */
  45313. value: number;
  45314. /**
  45315. * If the button/trigger is currently touched
  45316. */
  45317. touched: boolean;
  45318. /**
  45319. * If the button/trigger is currently pressed
  45320. */
  45321. pressed: boolean;
  45322. }>;
  45323. /**
  45324. * Available axes of this controller
  45325. */
  45326. axes: number[];
  45327. }
  45328. /**
  45329. * An Abstract Motion controller
  45330. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45331. * Each component has an observable to check for changes in value and state
  45332. */
  45333. export abstract class WebXRAbstractMotionController implements IDisposable {
  45334. protected scene: Scene;
  45335. protected layout: IMotionControllerLayout;
  45336. /**
  45337. * The gamepad object correlating to this controller
  45338. */
  45339. gamepadObject: IMinimalMotionControllerObject;
  45340. /**
  45341. * handness (left/right/none) of this controller
  45342. */
  45343. handness: MotionControllerHandness;
  45344. /**
  45345. * The profile id of this motion controller
  45346. */
  45347. abstract profileId: string;
  45348. /**
  45349. * A map of components (WebXRControllerComponent) in this motion controller
  45350. * Components have a ComponentType and can also have both button and axis definitions
  45351. */
  45352. readonly components: {
  45353. [id: string]: WebXRControllerComponent;
  45354. };
  45355. /**
  45356. * Observers registered here will be triggered when the model of this controller is done loading
  45357. */
  45358. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45359. /**
  45360. * The root mesh of the model. It is null if the model was not yet initialized
  45361. */
  45362. rootMesh: Nullable<AbstractMesh>;
  45363. /**
  45364. * Disable the model's animation. Can be set at any time.
  45365. */
  45366. disableAnimation: boolean;
  45367. private _modelReady;
  45368. /**
  45369. * constructs a new abstract motion controller
  45370. * @param scene the scene to which the model of the controller will be added
  45371. * @param layout The profile layout to load
  45372. * @param gamepadObject The gamepad object correlating to this controller
  45373. * @param handness handness (left/right/none) of this controller
  45374. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45375. */
  45376. constructor(scene: Scene, layout: IMotionControllerLayout,
  45377. /**
  45378. * The gamepad object correlating to this controller
  45379. */
  45380. gamepadObject: IMinimalMotionControllerObject,
  45381. /**
  45382. * handness (left/right/none) of this controller
  45383. */
  45384. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45385. private _initComponent;
  45386. /**
  45387. * Update this model using the current XRFrame
  45388. * @param xrFrame the current xr frame to use and update the model
  45389. */
  45390. updateFromXRFrame(xrFrame: XRFrame): void;
  45391. /**
  45392. * Get the list of components available in this motion controller
  45393. * @returns an array of strings correlating to available components
  45394. */
  45395. getComponentIds(): string[];
  45396. /**
  45397. * Get the main (Select) component of this controller as defined in the layout
  45398. * @returns the main component of this controller
  45399. */
  45400. getMainComponent(): WebXRControllerComponent;
  45401. /**
  45402. * get a component based an its component id as defined in layout.components
  45403. * @param id the id of the component
  45404. * @returns the component correlates to the id or undefined if not found
  45405. */
  45406. getComponent(id: string): WebXRControllerComponent;
  45407. /**
  45408. * Get the first component of specific type
  45409. * @param type type of component to find
  45410. * @return a controller component or null if not found
  45411. */
  45412. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45413. /**
  45414. * Returns all components of specific type
  45415. * @param type the type to search for
  45416. * @return an array of components with this type
  45417. */
  45418. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45419. /**
  45420. * Loads the model correlating to this controller
  45421. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45422. * @returns A promise fulfilled with the result of the model loading
  45423. */
  45424. loadModel(): Promise<boolean>;
  45425. /**
  45426. * Update the model itself with the current frame data
  45427. * @param xrFrame the frame to use for updating the model mesh
  45428. */
  45429. protected updateModel(xrFrame: XRFrame): void;
  45430. /**
  45431. * Moves the axis on the controller mesh based on its current state
  45432. * @param axis the index of the axis
  45433. * @param axisValue the value of the axis which determines the meshes new position
  45434. * @hidden
  45435. */
  45436. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45437. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45438. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45439. private _getGenericFilenameAndPath;
  45440. private _getGenericParentMesh;
  45441. /**
  45442. * Get the filename and path for this controller's model
  45443. * @returns a map of filename and path
  45444. */
  45445. protected abstract _getFilenameAndPath(): {
  45446. filename: string;
  45447. path: string;
  45448. };
  45449. /**
  45450. * This function will be called after the model was successfully loaded and can be used
  45451. * for mesh transformations before it is available for the user
  45452. * @param meshes the loaded meshes
  45453. */
  45454. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45455. /**
  45456. * Set the root mesh for this controller. Important for the WebXR controller class
  45457. * @param meshes the loaded meshes
  45458. */
  45459. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45460. /**
  45461. * A function executed each frame that updates the mesh (if needed)
  45462. * @param xrFrame the current xrFrame
  45463. */
  45464. protected abstract _updateModel(xrFrame: XRFrame): void;
  45465. /**
  45466. * This function is called before the mesh is loaded. It checks for loading constraints.
  45467. * For example, this function can check if the GLB loader is available
  45468. * If this function returns false, the generic controller will be loaded instead
  45469. * @returns Is the client ready to load the mesh
  45470. */
  45471. protected abstract _getModelLoadingConstraints(): boolean;
  45472. /**
  45473. * Dispose this controller, the model mesh and all its components
  45474. */
  45475. dispose(): void;
  45476. }
  45477. }
  45478. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45479. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45481. import { Scene } from "babylonjs/scene";
  45482. /**
  45483. * A generic trigger-only motion controller for WebXR
  45484. */
  45485. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45486. /**
  45487. * Static version of the profile id of this controller
  45488. */
  45489. static ProfileId: string;
  45490. profileId: string;
  45491. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45492. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45493. protected _updateModel(): void;
  45494. protected _getFilenameAndPath(): {
  45495. filename: string;
  45496. path: string;
  45497. };
  45498. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45499. protected _getModelLoadingConstraints(): boolean;
  45500. }
  45501. }
  45502. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45503. import { Vector4 } from "babylonjs/Maths/math.vector";
  45504. import { Mesh } from "babylonjs/Meshes/mesh";
  45505. import { Scene } from "babylonjs/scene";
  45506. import { Nullable } from "babylonjs/types";
  45507. /**
  45508. * Class containing static functions to help procedurally build meshes
  45509. */
  45510. export class SphereBuilder {
  45511. /**
  45512. * Creates a sphere mesh
  45513. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45514. * * 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`)
  45515. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45516. * * 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
  45517. * * 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)
  45518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45521. * @param name defines the name of the mesh
  45522. * @param options defines the options used to create the mesh
  45523. * @param scene defines the hosting scene
  45524. * @returns the sphere mesh
  45525. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45526. */
  45527. static CreateSphere(name: string, options: {
  45528. segments?: number;
  45529. diameter?: number;
  45530. diameterX?: number;
  45531. diameterY?: number;
  45532. diameterZ?: number;
  45533. arc?: number;
  45534. slice?: number;
  45535. sideOrientation?: number;
  45536. frontUVs?: Vector4;
  45537. backUVs?: Vector4;
  45538. updatable?: boolean;
  45539. }, scene?: Nullable<Scene>): Mesh;
  45540. }
  45541. }
  45542. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45544. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45545. import { Scene } from "babylonjs/scene";
  45546. /**
  45547. * A profiled motion controller has its profile loaded from an online repository.
  45548. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45549. */
  45550. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45551. private _repositoryUrl;
  45552. /**
  45553. * The profile ID of this controller. Will be populated when the controller initializes.
  45554. */
  45555. profileId: string;
  45556. private _buttonMeshMapping;
  45557. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45558. protected _getFilenameAndPath(): {
  45559. filename: string;
  45560. path: string;
  45561. };
  45562. private _touchDots;
  45563. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45564. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45565. protected _updateModel(_xrFrame: XRFrame): void;
  45566. protected _getModelLoadingConstraints(): boolean;
  45567. dispose(): void;
  45568. }
  45569. }
  45570. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45571. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45572. import { Scene } from "babylonjs/scene";
  45573. /**
  45574. * A construction function type to create a new controller based on an xrInput object
  45575. */
  45576. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45577. /**
  45578. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45579. *
  45580. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45581. * it should be replaced with auto-loaded controllers.
  45582. *
  45583. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45584. */
  45585. export class WebXRMotionControllerManager {
  45586. /**
  45587. * The base URL of the online controller repository. Can be changed at any time.
  45588. */
  45589. static BaseRepositoryUrl: string;
  45590. /**
  45591. * Use the online repository, or use only locally-defined controllers
  45592. */
  45593. static UseOnlineRepository: boolean;
  45594. /**
  45595. * Which repository gets priority - local or online
  45596. */
  45597. static PrioritizeOnlineRepository: boolean;
  45598. private static _AvailableControllers;
  45599. private static _Fallbacks;
  45600. /**
  45601. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45602. *
  45603. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45604. *
  45605. * @param type the profile type to register
  45606. * @param constructFunction the function to be called when loading this profile
  45607. */
  45608. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45609. /**
  45610. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45611. * The order of search:
  45612. *
  45613. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45614. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45615. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45616. * 4) return the generic trigger controller if none were found
  45617. *
  45618. * @param xrInput the xrInput to which a new controller is initialized
  45619. * @param scene the scene to which the model will be added
  45620. * @param forceProfile force a certain profile for this controller
  45621. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45622. */
  45623. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45624. private static _LoadProfilesFromAvailableControllers;
  45625. private static _ProfilesList;
  45626. private static _ProfileLoadingPromises;
  45627. private static _LoadProfileFromRepository;
  45628. /**
  45629. * Clear the cache used for profile loading and reload when requested again
  45630. */
  45631. static ClearProfilesCache(): void;
  45632. /**
  45633. * Will update the list of profiles available in the repository
  45634. * @return a promise that resolves to a map of profiles available online
  45635. */
  45636. static UpdateProfilesList(): Promise<{
  45637. [profile: string]: string;
  45638. }>;
  45639. /**
  45640. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45641. * @param profileId the profile to which a fallback needs to be found
  45642. * @return an array with corresponding fallback profiles
  45643. */
  45644. static FindFallbackWithProfileId(profileId: string): string[];
  45645. /**
  45646. * Register a fallback to a specific profile.
  45647. * @param profileId the profileId that will receive the fallbacks
  45648. * @param fallbacks A list of fallback profiles
  45649. */
  45650. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45651. /**
  45652. * Register the default fallbacks.
  45653. * This function is called automatically when this file is imported.
  45654. */
  45655. static DefaultFallbacks(): void;
  45656. }
  45657. }
  45658. declare module "babylonjs/XR/webXRInputSource" {
  45659. import { Observable } from "babylonjs/Misc/observable";
  45660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45661. import { Ray } from "babylonjs/Culling/ray";
  45662. import { Scene } from "babylonjs/scene";
  45663. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45664. /**
  45665. * Configuration options for the WebXR controller creation
  45666. */
  45667. export interface IWebXRControllerOptions {
  45668. /**
  45669. * Force a specific controller type for this controller.
  45670. * This can be used when creating your own profile or when testing different controllers
  45671. */
  45672. forceControllerProfile?: string;
  45673. /**
  45674. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45675. */
  45676. doNotLoadControllerMesh?: boolean;
  45677. /**
  45678. * Should the controller mesh be animated when a user interacts with it
  45679. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45680. */
  45681. disableMotionControllerAnimation?: boolean;
  45682. }
  45683. /**
  45684. * Represents an XR controller
  45685. */
  45686. export class WebXRInputSource {
  45687. private _scene;
  45688. /** The underlying input source for the controller */
  45689. inputSource: XRInputSource;
  45690. private _options;
  45691. /**
  45692. * 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
  45693. */
  45694. grip?: AbstractMesh;
  45695. /**
  45696. * Pointer which can be used to select objects or attach a visible laser to
  45697. */
  45698. pointer: AbstractMesh;
  45699. /**
  45700. * If available, this is the gamepad object related to this controller.
  45701. * Using this object it is possible to get click events and trackpad changes of the
  45702. * webxr controller that is currently being used.
  45703. */
  45704. motionController?: WebXRAbstractMotionController;
  45705. /**
  45706. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45707. */
  45708. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45709. /**
  45710. * Will be triggered when the mesh associated with the motion controller is done loading.
  45711. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45712. * A shortened version of controller -> motion controller -> on mesh loaded.
  45713. */
  45714. onMeshLoadedObservable: Observable<AbstractMesh>;
  45715. /**
  45716. * Event that fires when the controller is removed/disposed.
  45717. * The object provided as event data is this controller, after associated assets were disposed.
  45718. * uniqueId is still available.
  45719. */
  45720. onDisposeObservable: Observable<WebXRInputSource>;
  45721. private _tmpQuaternion;
  45722. private _tmpVector;
  45723. private _uniqueId;
  45724. /**
  45725. * Creates the controller
  45726. * @see https://doc.babylonjs.com/how_to/webxr
  45727. * @param _scene the scene which the controller should be associated to
  45728. * @param inputSource the underlying input source for the controller
  45729. * @param _options options for this controller creation
  45730. */
  45731. constructor(_scene: Scene,
  45732. /** The underlying input source for the controller */
  45733. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45734. /**
  45735. * Get this controllers unique id
  45736. */
  45737. get uniqueId(): string;
  45738. /**
  45739. * Updates the controller pose based on the given XRFrame
  45740. * @param xrFrame xr frame to update the pose with
  45741. * @param referenceSpace reference space to use
  45742. */
  45743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45744. /**
  45745. * Gets a world space ray coming from the pointer or grip
  45746. * @param result the resulting ray
  45747. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45748. */
  45749. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45750. /**
  45751. * Disposes of the object
  45752. */
  45753. dispose(): void;
  45754. }
  45755. }
  45756. declare module "babylonjs/XR/webXRInput" {
  45757. import { Observable } from "babylonjs/Misc/observable";
  45758. import { IDisposable } from "babylonjs/scene";
  45759. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45760. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45761. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45762. /**
  45763. * The schema for initialization options of the XR Input class
  45764. */
  45765. export interface IWebXRInputOptions {
  45766. /**
  45767. * If set to true no model will be automatically loaded
  45768. */
  45769. doNotLoadControllerMeshes?: boolean;
  45770. /**
  45771. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45772. * If not found, the xr input profile data will be used.
  45773. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45774. */
  45775. forceInputProfile?: string;
  45776. /**
  45777. * Do not send a request to the controlle repository to load the profile.
  45778. *
  45779. * Instead, use the controllers available in babylon itself.
  45780. */
  45781. disableOnlineControllerRepository?: boolean;
  45782. /**
  45783. * A custom URL for the controllers repository
  45784. */
  45785. customControllersRepositoryURL?: string;
  45786. /**
  45787. * Should the controller model's components not move according to the user input
  45788. */
  45789. disableControllerAnimation?: boolean;
  45790. }
  45791. /**
  45792. * XR input used to track XR inputs such as controllers/rays
  45793. */
  45794. export class WebXRInput implements IDisposable {
  45795. /**
  45796. * the xr session manager for this session
  45797. */
  45798. xrSessionManager: WebXRSessionManager;
  45799. /**
  45800. * the WebXR camera for this session. Mainly used for teleportation
  45801. */
  45802. xrCamera: WebXRCamera;
  45803. private readonly options;
  45804. /**
  45805. * XR controllers being tracked
  45806. */
  45807. controllers: Array<WebXRInputSource>;
  45808. private _frameObserver;
  45809. private _sessionEndedObserver;
  45810. private _sessionInitObserver;
  45811. /**
  45812. * Event when a controller has been connected/added
  45813. */
  45814. onControllerAddedObservable: Observable<WebXRInputSource>;
  45815. /**
  45816. * Event when a controller has been removed/disconnected
  45817. */
  45818. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45819. /**
  45820. * Initializes the WebXRInput
  45821. * @param xrSessionManager the xr session manager for this session
  45822. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45823. * @param options = initialization options for this xr input
  45824. */
  45825. constructor(
  45826. /**
  45827. * the xr session manager for this session
  45828. */
  45829. xrSessionManager: WebXRSessionManager,
  45830. /**
  45831. * the WebXR camera for this session. Mainly used for teleportation
  45832. */
  45833. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45834. private _onInputSourcesChange;
  45835. private _addAndRemoveControllers;
  45836. /**
  45837. * Disposes of the object
  45838. */
  45839. dispose(): void;
  45840. }
  45841. }
  45842. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45843. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45844. import { Observable, EventState } from "babylonjs/Misc/observable";
  45845. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45846. /**
  45847. * This is the base class for all WebXR features.
  45848. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45849. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45850. */
  45851. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45852. protected _xrSessionManager: WebXRSessionManager;
  45853. /**
  45854. * Construct a new (abstract) webxr feature
  45855. * @param _xrSessionManager the xr session manager for this feature
  45856. */
  45857. constructor(_xrSessionManager: WebXRSessionManager);
  45858. private _attached;
  45859. private _removeOnDetach;
  45860. /**
  45861. * Is this feature attached
  45862. */
  45863. get attached(): boolean;
  45864. /**
  45865. * Should auto-attach be disabled?
  45866. */
  45867. disableAutoAttach: boolean;
  45868. /**
  45869. * attach this feature
  45870. *
  45871. * @param force should attachment be forced (even when already attached)
  45872. * @returns true if successful, false is failed or already attached
  45873. */
  45874. attach(force?: boolean): boolean;
  45875. /**
  45876. * detach this feature.
  45877. *
  45878. * @returns true if successful, false if failed or already detached
  45879. */
  45880. detach(): boolean;
  45881. /**
  45882. * Dispose this feature and all of the resources attached
  45883. */
  45884. dispose(): void;
  45885. /**
  45886. * Code in this function will be executed on each xrFrame received from the browser.
  45887. * This function will not execute after the feature is detached.
  45888. * @param _xrFrame the current frame
  45889. */
  45890. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45891. /**
  45892. * This is used to register callbacks that will automatically be removed when detach is called.
  45893. * @param observable the observable to which the observer will be attached
  45894. * @param callback the callback to register
  45895. */
  45896. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45897. }
  45898. }
  45899. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45900. import { IDisposable, Scene } from "babylonjs/scene";
  45901. import { Nullable } from "babylonjs/types";
  45902. import { Observable } from "babylonjs/Misc/observable";
  45903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45904. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45905. import { Camera } from "babylonjs/Cameras/camera";
  45906. /**
  45907. * Renders a layer on top of an existing scene
  45908. */
  45909. export class UtilityLayerRenderer implements IDisposable {
  45910. /** the original scene that will be rendered on top of */
  45911. originalScene: Scene;
  45912. private _pointerCaptures;
  45913. private _lastPointerEvents;
  45914. private static _DefaultUtilityLayer;
  45915. private static _DefaultKeepDepthUtilityLayer;
  45916. private _sharedGizmoLight;
  45917. private _renderCamera;
  45918. /**
  45919. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45920. * @returns the camera that is used when rendering the utility layer
  45921. */
  45922. getRenderCamera(): Camera;
  45923. /**
  45924. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45925. * @param cam the camera that should be used when rendering the utility layer
  45926. */
  45927. setRenderCamera(cam: Nullable<Camera>): void;
  45928. /**
  45929. * @hidden
  45930. * Light which used by gizmos to get light shading
  45931. */
  45932. _getSharedGizmoLight(): HemisphericLight;
  45933. /**
  45934. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45935. */
  45936. pickUtilitySceneFirst: boolean;
  45937. /**
  45938. * 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)
  45939. */
  45940. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45941. /**
  45942. * 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)
  45943. */
  45944. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45945. /**
  45946. * The scene that is rendered on top of the original scene
  45947. */
  45948. utilityLayerScene: Scene;
  45949. /**
  45950. * If the utility layer should automatically be rendered on top of existing scene
  45951. */
  45952. shouldRender: boolean;
  45953. /**
  45954. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45955. */
  45956. onlyCheckPointerDownEvents: boolean;
  45957. /**
  45958. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45959. */
  45960. processAllEvents: boolean;
  45961. /**
  45962. * Observable raised when the pointer move from the utility layer scene to the main scene
  45963. */
  45964. onPointerOutObservable: Observable<number>;
  45965. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45966. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45967. private _afterRenderObserver;
  45968. private _sceneDisposeObserver;
  45969. private _originalPointerObserver;
  45970. /**
  45971. * Instantiates a UtilityLayerRenderer
  45972. * @param originalScene the original scene that will be rendered on top of
  45973. * @param handleEvents boolean indicating if the utility layer should handle events
  45974. */
  45975. constructor(
  45976. /** the original scene that will be rendered on top of */
  45977. originalScene: Scene, handleEvents?: boolean);
  45978. private _notifyObservers;
  45979. /**
  45980. * Renders the utility layers scene on top of the original scene
  45981. */
  45982. render(): void;
  45983. /**
  45984. * Disposes of the renderer
  45985. */
  45986. dispose(): void;
  45987. private _updateCamera;
  45988. }
  45989. }
  45990. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45991. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45993. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45994. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45995. import { Scene } from "babylonjs/scene";
  45996. import { Nullable } from "babylonjs/types";
  45997. import { Color3 } from "babylonjs/Maths/math.color";
  45998. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45999. /**
  46000. * Options interface for the pointer selection module
  46001. */
  46002. export interface IWebXRControllerPointerSelectionOptions {
  46003. /**
  46004. * the xr input to use with this pointer selection
  46005. */
  46006. xrInput: WebXRInput;
  46007. /**
  46008. * Different button type to use instead of the main component
  46009. */
  46010. overrideButtonId?: string;
  46011. /**
  46012. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46013. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46014. * 3000 means 3 seconds between pointing at something and selecting it
  46015. */
  46016. timeToSelect?: number;
  46017. /**
  46018. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  46019. * If not disabled, the last picked point will be used to execute a pointer up event
  46020. * If disabled, pointer up event will be triggered right after the pointer down event.
  46021. * Used in screen and gaze target ray mode only
  46022. */
  46023. disablePointerUpOnTouchOut: boolean;
  46024. /**
  46025. * For gaze mode (time to select instead of press)
  46026. */
  46027. forceGazeMode: boolean;
  46028. /**
  46029. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  46030. * to start a new countdown to the pointer down event.
  46031. * Defaults to 1.
  46032. */
  46033. gazeModePointerMovedFactor?: number;
  46034. /**
  46035. * Should meshes created here be added to a utility layer or the main scene
  46036. */
  46037. useUtilityLayer?: boolean;
  46038. /**
  46039. * if provided, this scene will be used to render meshes.
  46040. */
  46041. customUtilityLayerScene?: Scene;
  46042. /**
  46043. * use this rendering group id for the meshes (optional)
  46044. */
  46045. renderingGroupId?: number;
  46046. }
  46047. /**
  46048. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46049. */
  46050. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46051. private readonly _options;
  46052. /**
  46053. * The module's name
  46054. */
  46055. static readonly Name: string;
  46056. /**
  46057. * The (Babylon) version of this module.
  46058. * This is an integer representing the implementation version.
  46059. * This number does not correspond to the webxr specs version
  46060. */
  46061. static readonly Version: number;
  46062. /**
  46063. * This color will be set to the laser pointer when selection is triggered
  46064. */
  46065. laserPointerPickedColor: Color3;
  46066. /**
  46067. * This color will be applied to the selection ring when selection is triggered
  46068. */
  46069. selectionMeshPickedColor: Color3;
  46070. /**
  46071. * default color of the selection ring
  46072. */
  46073. selectionMeshDefaultColor: Color3;
  46074. /**
  46075. * Default color of the laser pointer
  46076. */
  46077. lasterPointerDefaultColor: Color3;
  46078. /**
  46079. * Should the laser pointer be displayed
  46080. */
  46081. displayLaserPointer: boolean;
  46082. /**
  46083. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46084. */
  46085. displaySelectionMesh: boolean;
  46086. /**
  46087. * Disable lighting on the laser pointer (so it will always be visible)
  46088. */
  46089. disablePointerLighting: boolean;
  46090. /**
  46091. * Disable lighting on the selection mesh (so it will always be visible)
  46092. */
  46093. disableSelectionMeshLighting: boolean;
  46094. private static _idCounter;
  46095. private _controllers;
  46096. private _scene;
  46097. /**
  46098. * constructs a new background remover module
  46099. * @param _xrSessionManager the session manager for this module
  46100. * @param _options read-only options to be used in this module
  46101. */
  46102. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46103. /**
  46104. * attach this feature
  46105. * Will usually be called by the features manager
  46106. *
  46107. * @returns true if successful.
  46108. */
  46109. attach(): boolean;
  46110. /**
  46111. * detach this feature.
  46112. * Will usually be called by the features manager
  46113. *
  46114. * @returns true if successful.
  46115. */
  46116. detach(): boolean;
  46117. /**
  46118. * Get the xr controller that correlates to the pointer id in the pointer event
  46119. *
  46120. * @param id the pointer id to search for
  46121. * @returns the controller that correlates to this id or null if not found
  46122. */
  46123. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46124. /**
  46125. * Will get the mesh under a specific pointer.
  46126. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46127. * @param controllerId the controllerId to check
  46128. * @returns The mesh under pointer or null if no mesh is under the pointer
  46129. */
  46130. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46131. protected _onXRFrame(_xrFrame: XRFrame): void;
  46132. private _attachController;
  46133. private _attachScreenRayMode;
  46134. private _attachGazeMode;
  46135. private _tmpVectorForPickCompare;
  46136. private _pickingMoved;
  46137. private _attachTrackedPointerRayMode;
  46138. private _detachController;
  46139. private _generateNewMeshPair;
  46140. private _convertNormalToDirectionOfRay;
  46141. private _updatePointerDistance;
  46142. }
  46143. }
  46144. declare module "babylonjs/XR/webXREnterExitUI" {
  46145. import { Nullable } from "babylonjs/types";
  46146. import { Observable } from "babylonjs/Misc/observable";
  46147. import { IDisposable, Scene } from "babylonjs/scene";
  46148. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46149. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46150. /**
  46151. * Button which can be used to enter a different mode of XR
  46152. */
  46153. export class WebXREnterExitUIButton {
  46154. /** button element */
  46155. element: HTMLElement;
  46156. /** XR initialization options for the button */
  46157. sessionMode: XRSessionMode;
  46158. /** Reference space type */
  46159. referenceSpaceType: XRReferenceSpaceType;
  46160. /**
  46161. * Creates a WebXREnterExitUIButton
  46162. * @param element button element
  46163. * @param sessionMode XR initialization session mode
  46164. * @param referenceSpaceType the type of reference space to be used
  46165. */
  46166. constructor(
  46167. /** button element */
  46168. element: HTMLElement,
  46169. /** XR initialization options for the button */
  46170. sessionMode: XRSessionMode,
  46171. /** Reference space type */
  46172. referenceSpaceType: XRReferenceSpaceType);
  46173. /**
  46174. * Overwritable function which can be used to update the button's visuals when the state changes
  46175. * @param activeButton the current active button in the UI
  46176. */
  46177. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46178. }
  46179. /**
  46180. * Options to create the webXR UI
  46181. */
  46182. export class WebXREnterExitUIOptions {
  46183. /**
  46184. * Context to enter xr with
  46185. */
  46186. renderTarget?: Nullable<WebXRRenderTarget>;
  46187. /**
  46188. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46189. */
  46190. customButtons?: Array<WebXREnterExitUIButton>;
  46191. /**
  46192. * A session mode to use when creating the default button.
  46193. * Default is immersive-vr
  46194. */
  46195. sessionMode?: XRSessionMode;
  46196. /**
  46197. * A reference space type to use when creating the default button.
  46198. * Default is local-floor
  46199. */
  46200. referenceSpaceType?: XRReferenceSpaceType;
  46201. }
  46202. /**
  46203. * UI to allow the user to enter/exit XR mode
  46204. */
  46205. export class WebXREnterExitUI implements IDisposable {
  46206. private scene;
  46207. /** version of the options passed to this UI */
  46208. options: WebXREnterExitUIOptions;
  46209. private _overlay;
  46210. private _buttons;
  46211. private _activeButton;
  46212. /**
  46213. * Fired every time the active button is changed.
  46214. *
  46215. * When xr is entered via a button that launches xr that button will be the callback parameter
  46216. *
  46217. * When exiting xr the callback parameter will be null)
  46218. */
  46219. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46220. /**
  46221. * Creates UI to allow the user to enter/exit XR mode
  46222. * @param scene the scene to add the ui to
  46223. * @param helper the xr experience helper to enter/exit xr with
  46224. * @param options options to configure the UI
  46225. * @returns the created ui
  46226. */
  46227. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46228. /**
  46229. *
  46230. * @param scene babylon scene object to use
  46231. * @param options (read-only) version of the options passed to this UI
  46232. */
  46233. private constructor();
  46234. private _updateButtons;
  46235. /**
  46236. * Disposes of the object
  46237. */
  46238. dispose(): void;
  46239. }
  46240. }
  46241. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46242. import { Vector3 } from "babylonjs/Maths/math.vector";
  46243. import { Color4 } from "babylonjs/Maths/math.color";
  46244. import { Nullable } from "babylonjs/types";
  46245. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46246. import { Scene } from "babylonjs/scene";
  46247. /**
  46248. * Class containing static functions to help procedurally build meshes
  46249. */
  46250. export class LinesBuilder {
  46251. /**
  46252. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46253. * * 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
  46254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46255. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46256. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46257. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46259. * * 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
  46260. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46263. * @param name defines the name of the new line system
  46264. * @param options defines the options used to create the line system
  46265. * @param scene defines the hosting scene
  46266. * @returns a new line system mesh
  46267. */
  46268. static CreateLineSystem(name: string, options: {
  46269. lines: Vector3[][];
  46270. updatable?: boolean;
  46271. instance?: Nullable<LinesMesh>;
  46272. colors?: Nullable<Color4[][]>;
  46273. useVertexAlpha?: boolean;
  46274. }, scene: Nullable<Scene>): LinesMesh;
  46275. /**
  46276. * Creates a line mesh
  46277. * 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
  46278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46279. * * The parameter `points` is an array successive Vector3
  46280. * * 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
  46281. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46283. * * When updating an instance, remember that only point positions can change, not the number of points
  46284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46286. * @param name defines the name of the new line system
  46287. * @param options defines the options used to create the line system
  46288. * @param scene defines the hosting scene
  46289. * @returns a new line mesh
  46290. */
  46291. static CreateLines(name: string, options: {
  46292. points: Vector3[];
  46293. updatable?: boolean;
  46294. instance?: Nullable<LinesMesh>;
  46295. colors?: Color4[];
  46296. useVertexAlpha?: boolean;
  46297. }, scene?: Nullable<Scene>): LinesMesh;
  46298. /**
  46299. * Creates a dashed line mesh
  46300. * * 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
  46301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46302. * * The parameter `points` is an array successive Vector3
  46303. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46304. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46305. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46306. * * 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
  46307. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46308. * * When updating an instance, remember that only point positions can change, not the number of points
  46309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46310. * @param name defines the name of the mesh
  46311. * @param options defines the options used to create the mesh
  46312. * @param scene defines the hosting scene
  46313. * @returns the dashed line mesh
  46314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46315. */
  46316. static CreateDashedLines(name: string, options: {
  46317. points: Vector3[];
  46318. dashSize?: number;
  46319. gapSize?: number;
  46320. dashNb?: number;
  46321. updatable?: boolean;
  46322. instance?: LinesMesh;
  46323. useVertexAlpha?: boolean;
  46324. }, scene?: Nullable<Scene>): LinesMesh;
  46325. }
  46326. }
  46327. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46328. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46329. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46330. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46332. import { Vector3 } from "babylonjs/Maths/math.vector";
  46333. import { Material } from "babylonjs/Materials/material";
  46334. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46335. import { Scene } from "babylonjs/scene";
  46336. /**
  46337. * The options container for the teleportation module
  46338. */
  46339. export interface IWebXRTeleportationOptions {
  46340. /**
  46341. * Babylon XR Input class for controller
  46342. */
  46343. xrInput: WebXRInput;
  46344. /**
  46345. * A list of meshes to use as floor meshes.
  46346. * Meshes can be added and removed after initializing the feature using the
  46347. * addFloorMesh and removeFloorMesh functions
  46348. * If empty, rotation will still work
  46349. */
  46350. floorMeshes?: AbstractMesh[];
  46351. /**
  46352. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46353. * If you want to support rotation, make sure your mesh has a direction indicator.
  46354. *
  46355. * When left untouched, the default mesh will be initialized.
  46356. */
  46357. teleportationTargetMesh?: AbstractMesh;
  46358. /**
  46359. * An array of points to which the teleportation will snap to.
  46360. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46361. */
  46362. snapPositions?: Vector3[];
  46363. /**
  46364. * How close should the teleportation ray be in order to snap to position.
  46365. * Default to 0.8 units (meters)
  46366. */
  46367. snapToPositionRadius?: number;
  46368. /**
  46369. * Should teleportation move only to snap points
  46370. */
  46371. snapPointsOnly?: boolean;
  46372. /**
  46373. * Values to configure the default target mesh
  46374. */
  46375. defaultTargetMeshOptions?: {
  46376. /**
  46377. * Fill color of the teleportation area
  46378. */
  46379. teleportationFillColor?: string;
  46380. /**
  46381. * Border color for the teleportation area
  46382. */
  46383. teleportationBorderColor?: string;
  46384. /**
  46385. * Disable the mesh's animation sequence
  46386. */
  46387. disableAnimation?: boolean;
  46388. /**
  46389. * Disable lighting on the material or the ring and arrow
  46390. */
  46391. disableLighting?: boolean;
  46392. /**
  46393. * Override the default material of the torus and arrow
  46394. */
  46395. torusArrowMaterial?: Material;
  46396. };
  46397. /**
  46398. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46399. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46400. */
  46401. useMainComponentOnly?: boolean;
  46402. /**
  46403. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46404. */
  46405. timeToTeleport?: number;
  46406. /**
  46407. * Should meshes created here be added to a utility layer or the main scene
  46408. */
  46409. useUtilityLayer?: boolean;
  46410. /**
  46411. * if provided, this scene will be used to render meshes.
  46412. */
  46413. customUtilityLayerScene?: Scene;
  46414. /**
  46415. * use this rendering group id for the meshes (optional)
  46416. */
  46417. renderingGroupId?: number;
  46418. }
  46419. /**
  46420. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46421. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46422. * the input of the attached controllers.
  46423. */
  46424. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46425. private _options;
  46426. /**
  46427. * The module's name
  46428. */
  46429. static readonly Name: string;
  46430. /**
  46431. * The (Babylon) version of this module.
  46432. * This is an integer representing the implementation version.
  46433. * This number does not correspond to the webxr specs version
  46434. */
  46435. static readonly Version: number;
  46436. /**
  46437. * Is rotation enabled when moving forward?
  46438. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46439. */
  46440. rotationEnabled: boolean;
  46441. /**
  46442. * Should the module support parabolic ray on top of direct ray
  46443. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46444. * Very helpful when moving between floors / different heights
  46445. */
  46446. parabolicRayEnabled: boolean;
  46447. /**
  46448. * The distance from the user to the inspection point in the direction of the controller
  46449. * A higher number will allow the user to move further
  46450. * defaults to 5 (meters, in xr units)
  46451. */
  46452. parabolicCheckRadius: number;
  46453. /**
  46454. * How much rotation should be applied when rotating right and left
  46455. */
  46456. rotationAngle: number;
  46457. /**
  46458. * Is movement backwards enabled
  46459. */
  46460. backwardsMovementEnabled: boolean;
  46461. /**
  46462. * Distance to travel when moving backwards
  46463. */
  46464. backwardsTeleportationDistance: number;
  46465. /**
  46466. * Add a new mesh to the floor meshes array
  46467. * @param mesh the mesh to use as floor mesh
  46468. */
  46469. addFloorMesh(mesh: AbstractMesh): void;
  46470. /**
  46471. * Remove a mesh from the floor meshes array
  46472. * @param mesh the mesh to remove
  46473. */
  46474. removeFloorMesh(mesh: AbstractMesh): void;
  46475. /**
  46476. * Remove a mesh from the floor meshes array using its name
  46477. * @param name the mesh name to remove
  46478. */
  46479. removeFloorMeshByName(name: string): void;
  46480. private _tmpRay;
  46481. private _tmpVector;
  46482. private _floorMeshes;
  46483. private _snapToPositions;
  46484. private _controllers;
  46485. /**
  46486. * constructs a new anchor system
  46487. * @param _xrSessionManager an instance of WebXRSessionManager
  46488. * @param _options configuration object for this feature
  46489. */
  46490. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46491. private _selectionFeature;
  46492. private _snappedToPoint;
  46493. private _teleportationRingMaterial?;
  46494. /**
  46495. * Get the snapPointsOnly flag
  46496. */
  46497. get snapPointsOnly(): boolean;
  46498. /**
  46499. * Sets the snapPointsOnly flag
  46500. * @param snapToPoints should teleportation be exclusively to snap points
  46501. */
  46502. set snapPointsOnly(snapToPoints: boolean);
  46503. /**
  46504. * Add a new snap-to point to fix teleportation to this position
  46505. * @param newSnapPoint The new Snap-To point
  46506. */
  46507. addSnapPoint(newSnapPoint: Vector3): void;
  46508. /**
  46509. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  46510. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46511. * @returns was the point found and removed or not
  46512. */
  46513. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46514. /**
  46515. * This function sets a selection feature that will be disabled when
  46516. * the forward ray is shown and will be reattached when hidden.
  46517. * This is used to remove the selection rays when moving.
  46518. * @param selectionFeature the feature to disable when forward movement is enabled
  46519. */
  46520. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46521. attach(): boolean;
  46522. detach(): boolean;
  46523. dispose(): void;
  46524. protected _onXRFrame(_xrFrame: XRFrame): void;
  46525. private _currentTeleportationControllerId;
  46526. private _attachController;
  46527. private _teleportForward;
  46528. private _detachController;
  46529. private _createDefaultTargetMesh;
  46530. private _setTargetMeshVisibility;
  46531. private _setTargetMeshPosition;
  46532. private _quadraticBezierCurve;
  46533. private _showParabolicPath;
  46534. private _findClosestSnapPointWithRadius;
  46535. }
  46536. }
  46537. declare module "babylonjs/XR/webXRDefaultExperience" {
  46538. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46539. import { Scene } from "babylonjs/scene";
  46540. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46541. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46542. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46543. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46546. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46547. /**
  46548. * Options for the default xr helper
  46549. */
  46550. export class WebXRDefaultExperienceOptions {
  46551. /**
  46552. * Floor meshes that will be used for teleporting
  46553. */
  46554. floorMeshes?: Array<AbstractMesh>;
  46555. /**
  46556. * Enable or disable default UI to enter XR
  46557. */
  46558. disableDefaultUI?: boolean;
  46559. /**
  46560. * optional configuration for the output canvas
  46561. */
  46562. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46563. /**
  46564. * optional UI options. This can be used among other to change session mode and reference space type
  46565. */
  46566. uiOptions?: WebXREnterExitUIOptions;
  46567. /**
  46568. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46569. */
  46570. inputOptions?: IWebXRInputOptions;
  46571. /**
  46572. * Should teleportation not initialize. defaults to false.
  46573. */
  46574. disableTeleportation?: boolean;
  46575. /**
  46576. * If set to true, the first frame will not be used to reset position
  46577. * The first frame is mainly used when copying transformation from the old camera
  46578. * Mainly used in AR
  46579. */
  46580. ignoreNativeCameraTransformation?: boolean;
  46581. /**
  46582. * When loading teleportation and pointer select, use stable versions instead of latest.
  46583. */
  46584. useStablePlugins?: boolean;
  46585. }
  46586. /**
  46587. * Default experience which provides a similar setup to the previous webVRExperience
  46588. */
  46589. export class WebXRDefaultExperience {
  46590. /**
  46591. * Base experience
  46592. */
  46593. baseExperience: WebXRExperienceHelper;
  46594. /**
  46595. * Input experience extension
  46596. */
  46597. input: WebXRInput;
  46598. /**
  46599. * Enables laser pointer and selection
  46600. */
  46601. pointerSelection: WebXRControllerPointerSelection;
  46602. /**
  46603. * Enables teleportation
  46604. */
  46605. teleportation: WebXRMotionControllerTeleportation;
  46606. /**
  46607. * Enables ui for entering/exiting xr
  46608. */
  46609. enterExitUI: WebXREnterExitUI;
  46610. /**
  46611. * Default target xr should render to
  46612. */
  46613. renderTarget: WebXRRenderTarget;
  46614. /**
  46615. * Creates the default xr experience
  46616. * @param scene scene
  46617. * @param options options for basic configuration
  46618. * @returns resulting WebXRDefaultExperience
  46619. */
  46620. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46621. private constructor();
  46622. /**
  46623. * DIsposes of the experience helper
  46624. */
  46625. dispose(): void;
  46626. }
  46627. }
  46628. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46629. import { Observable } from "babylonjs/Misc/observable";
  46630. import { Nullable } from "babylonjs/types";
  46631. import { Camera } from "babylonjs/Cameras/camera";
  46632. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46633. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46634. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46635. import { Scene } from "babylonjs/scene";
  46636. import { Vector3 } from "babylonjs/Maths/math.vector";
  46637. import { Color3 } from "babylonjs/Maths/math.color";
  46638. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46640. import { Mesh } from "babylonjs/Meshes/mesh";
  46641. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46642. import { EasingFunction } from "babylonjs/Animations/easing";
  46643. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46644. import "babylonjs/Meshes/Builders/groundBuilder";
  46645. import "babylonjs/Meshes/Builders/torusBuilder";
  46646. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46647. import "babylonjs/Gamepads/gamepadSceneComponent";
  46648. import "babylonjs/Animations/animatable";
  46649. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46650. /**
  46651. * Options to modify the vr teleportation behavior.
  46652. */
  46653. export interface VRTeleportationOptions {
  46654. /**
  46655. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46656. */
  46657. floorMeshName?: string;
  46658. /**
  46659. * A list of meshes to be used as the teleportation floor. (default: empty)
  46660. */
  46661. floorMeshes?: Mesh[];
  46662. /**
  46663. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46664. */
  46665. teleportationMode?: number;
  46666. /**
  46667. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46668. */
  46669. teleportationTime?: number;
  46670. /**
  46671. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46672. */
  46673. teleportationSpeed?: number;
  46674. /**
  46675. * The easing function used in the animation or null for Linear. (default CircleEase)
  46676. */
  46677. easingFunction?: EasingFunction;
  46678. }
  46679. /**
  46680. * Options to modify the vr experience helper's behavior.
  46681. */
  46682. export interface VRExperienceHelperOptions extends WebVROptions {
  46683. /**
  46684. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46685. */
  46686. createDeviceOrientationCamera?: boolean;
  46687. /**
  46688. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46689. */
  46690. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46691. /**
  46692. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46693. */
  46694. laserToggle?: boolean;
  46695. /**
  46696. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46697. */
  46698. floorMeshes?: Mesh[];
  46699. /**
  46700. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46701. */
  46702. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46703. /**
  46704. * Defines if WebXR should be used instead of WebVR (if available)
  46705. */
  46706. useXR?: boolean;
  46707. }
  46708. /**
  46709. * Event containing information after VR has been entered
  46710. */
  46711. export class OnAfterEnteringVRObservableEvent {
  46712. /**
  46713. * If entering vr was successful
  46714. */
  46715. success: boolean;
  46716. }
  46717. /**
  46718. * Helps to quickly add VR support to an existing scene.
  46719. * See http://doc.babylonjs.com/how_to/webvr_helper
  46720. */
  46721. export class VRExperienceHelper {
  46722. /** Options to modify the vr experience helper's behavior. */
  46723. webVROptions: VRExperienceHelperOptions;
  46724. private _scene;
  46725. private _position;
  46726. private _btnVR;
  46727. private _btnVRDisplayed;
  46728. private _webVRsupported;
  46729. private _webVRready;
  46730. private _webVRrequesting;
  46731. private _webVRpresenting;
  46732. private _hasEnteredVR;
  46733. private _fullscreenVRpresenting;
  46734. private _inputElement;
  46735. private _webVRCamera;
  46736. private _vrDeviceOrientationCamera;
  46737. private _deviceOrientationCamera;
  46738. private _existingCamera;
  46739. private _onKeyDown;
  46740. private _onVrDisplayPresentChange;
  46741. private _onVRDisplayChanged;
  46742. private _onVRRequestPresentStart;
  46743. private _onVRRequestPresentComplete;
  46744. /**
  46745. * 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)
  46746. */
  46747. enableGazeEvenWhenNoPointerLock: boolean;
  46748. /**
  46749. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46750. */
  46751. exitVROnDoubleTap: boolean;
  46752. /**
  46753. * Observable raised right before entering VR.
  46754. */
  46755. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46756. /**
  46757. * Observable raised when entering VR has completed.
  46758. */
  46759. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46760. /**
  46761. * Observable raised when exiting VR.
  46762. */
  46763. onExitingVRObservable: Observable<VRExperienceHelper>;
  46764. /**
  46765. * Observable raised when controller mesh is loaded.
  46766. */
  46767. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46768. /** Return this.onEnteringVRObservable
  46769. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46770. */
  46771. get onEnteringVR(): Observable<VRExperienceHelper>;
  46772. /** Return this.onExitingVRObservable
  46773. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46774. */
  46775. get onExitingVR(): Observable<VRExperienceHelper>;
  46776. /** Return this.onControllerMeshLoadedObservable
  46777. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46778. */
  46779. get onControllerMeshLoaded(): Observable<WebVRController>;
  46780. private _rayLength;
  46781. private _useCustomVRButton;
  46782. private _teleportationRequested;
  46783. private _teleportActive;
  46784. private _floorMeshName;
  46785. private _floorMeshesCollection;
  46786. private _teleportationMode;
  46787. private _teleportationTime;
  46788. private _teleportationSpeed;
  46789. private _teleportationEasing;
  46790. private _rotationAllowed;
  46791. private _teleportBackwardsVector;
  46792. private _teleportationTarget;
  46793. private _isDefaultTeleportationTarget;
  46794. private _postProcessMove;
  46795. private _teleportationFillColor;
  46796. private _teleportationBorderColor;
  46797. private _rotationAngle;
  46798. private _haloCenter;
  46799. private _cameraGazer;
  46800. private _padSensibilityUp;
  46801. private _padSensibilityDown;
  46802. private _leftController;
  46803. private _rightController;
  46804. private _gazeColor;
  46805. private _laserColor;
  46806. private _pickedLaserColor;
  46807. private _pickedGazeColor;
  46808. /**
  46809. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46810. */
  46811. onNewMeshSelected: Observable<AbstractMesh>;
  46812. /**
  46813. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46814. * This observable will provide the mesh and the controller used to select the mesh
  46815. */
  46816. onMeshSelectedWithController: Observable<{
  46817. mesh: AbstractMesh;
  46818. controller: WebVRController;
  46819. }>;
  46820. /**
  46821. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46822. */
  46823. onNewMeshPicked: Observable<PickingInfo>;
  46824. private _circleEase;
  46825. /**
  46826. * Observable raised before camera teleportation
  46827. */
  46828. onBeforeCameraTeleport: Observable<Vector3>;
  46829. /**
  46830. * Observable raised after camera teleportation
  46831. */
  46832. onAfterCameraTeleport: Observable<Vector3>;
  46833. /**
  46834. * Observable raised when current selected mesh gets unselected
  46835. */
  46836. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46837. private _raySelectionPredicate;
  46838. /**
  46839. * To be optionaly changed by user to define custom ray selection
  46840. */
  46841. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46842. /**
  46843. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46844. */
  46845. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46846. /**
  46847. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46848. */
  46849. teleportationEnabled: boolean;
  46850. private _defaultHeight;
  46851. private _teleportationInitialized;
  46852. private _interactionsEnabled;
  46853. private _interactionsRequested;
  46854. private _displayGaze;
  46855. private _displayLaserPointer;
  46856. /**
  46857. * The mesh used to display where the user is going to teleport.
  46858. */
  46859. get teleportationTarget(): Mesh;
  46860. /**
  46861. * Sets the mesh to be used to display where the user is going to teleport.
  46862. */
  46863. set teleportationTarget(value: Mesh);
  46864. /**
  46865. * 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
  46866. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46867. * See http://doc.babylonjs.com/resources/baking_transformations
  46868. */
  46869. get gazeTrackerMesh(): Mesh;
  46870. set gazeTrackerMesh(value: Mesh);
  46871. /**
  46872. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46873. */
  46874. updateGazeTrackerScale: boolean;
  46875. /**
  46876. * If the gaze trackers color should be updated when selecting meshes
  46877. */
  46878. updateGazeTrackerColor: boolean;
  46879. /**
  46880. * If the controller laser color should be updated when selecting meshes
  46881. */
  46882. updateControllerLaserColor: boolean;
  46883. /**
  46884. * The gaze tracking mesh corresponding to the left controller
  46885. */
  46886. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46887. /**
  46888. * The gaze tracking mesh corresponding to the right controller
  46889. */
  46890. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46891. /**
  46892. * If the ray of the gaze should be displayed.
  46893. */
  46894. get displayGaze(): boolean;
  46895. /**
  46896. * Sets if the ray of the gaze should be displayed.
  46897. */
  46898. set displayGaze(value: boolean);
  46899. /**
  46900. * If the ray of the LaserPointer should be displayed.
  46901. */
  46902. get displayLaserPointer(): boolean;
  46903. /**
  46904. * Sets if the ray of the LaserPointer should be displayed.
  46905. */
  46906. set displayLaserPointer(value: boolean);
  46907. /**
  46908. * The deviceOrientationCamera used as the camera when not in VR.
  46909. */
  46910. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46911. /**
  46912. * Based on the current WebVR support, returns the current VR camera used.
  46913. */
  46914. get currentVRCamera(): Nullable<Camera>;
  46915. /**
  46916. * The webVRCamera which is used when in VR.
  46917. */
  46918. get webVRCamera(): WebVRFreeCamera;
  46919. /**
  46920. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46921. */
  46922. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46923. /**
  46924. * The html button that is used to trigger entering into VR.
  46925. */
  46926. get vrButton(): Nullable<HTMLButtonElement>;
  46927. private get _teleportationRequestInitiated();
  46928. /**
  46929. * Defines whether or not Pointer lock should be requested when switching to
  46930. * full screen.
  46931. */
  46932. requestPointerLockOnFullScreen: boolean;
  46933. /**
  46934. * If asking to force XR, this will be populated with the default xr experience
  46935. */
  46936. xr: WebXRDefaultExperience;
  46937. /**
  46938. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46939. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46940. */
  46941. xrTestDone: boolean;
  46942. /**
  46943. * Instantiates a VRExperienceHelper.
  46944. * Helps to quickly add VR support to an existing scene.
  46945. * @param scene The scene the VRExperienceHelper belongs to.
  46946. * @param webVROptions Options to modify the vr experience helper's behavior.
  46947. */
  46948. constructor(scene: Scene,
  46949. /** Options to modify the vr experience helper's behavior. */
  46950. webVROptions?: VRExperienceHelperOptions);
  46951. private completeVRInit;
  46952. private _onDefaultMeshLoaded;
  46953. private _onResize;
  46954. private _onFullscreenChange;
  46955. /**
  46956. * Gets a value indicating if we are currently in VR mode.
  46957. */
  46958. get isInVRMode(): boolean;
  46959. private onVrDisplayPresentChange;
  46960. private onVRDisplayChanged;
  46961. private moveButtonToBottomRight;
  46962. private displayVRButton;
  46963. private updateButtonVisibility;
  46964. private _cachedAngularSensibility;
  46965. /**
  46966. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46967. * Otherwise, will use the fullscreen API.
  46968. */
  46969. enterVR(): void;
  46970. /**
  46971. * Attempt to exit VR, or fullscreen.
  46972. */
  46973. exitVR(): void;
  46974. /**
  46975. * The position of the vr experience helper.
  46976. */
  46977. get position(): Vector3;
  46978. /**
  46979. * Sets the position of the vr experience helper.
  46980. */
  46981. set position(value: Vector3);
  46982. /**
  46983. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46984. */
  46985. enableInteractions(): void;
  46986. private get _noControllerIsActive();
  46987. private beforeRender;
  46988. private _isTeleportationFloor;
  46989. /**
  46990. * Adds a floor mesh to be used for teleportation.
  46991. * @param floorMesh the mesh to be used for teleportation.
  46992. */
  46993. addFloorMesh(floorMesh: Mesh): void;
  46994. /**
  46995. * Removes a floor mesh from being used for teleportation.
  46996. * @param floorMesh the mesh to be removed.
  46997. */
  46998. removeFloorMesh(floorMesh: Mesh): void;
  46999. /**
  47000. * Enables interactions and teleportation using the VR controllers and gaze.
  47001. * @param vrTeleportationOptions options to modify teleportation behavior.
  47002. */
  47003. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47004. private _onNewGamepadConnected;
  47005. private _tryEnableInteractionOnController;
  47006. private _onNewGamepadDisconnected;
  47007. private _enableInteractionOnController;
  47008. private _checkTeleportWithRay;
  47009. private _checkRotate;
  47010. private _checkTeleportBackwards;
  47011. private _enableTeleportationOnController;
  47012. private _createTeleportationCircles;
  47013. private _displayTeleportationTarget;
  47014. private _hideTeleportationTarget;
  47015. private _rotateCamera;
  47016. private _moveTeleportationSelectorTo;
  47017. private _workingVector;
  47018. private _workingQuaternion;
  47019. private _workingMatrix;
  47020. /**
  47021. * Time Constant Teleportation Mode
  47022. */
  47023. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47024. /**
  47025. * Speed Constant Teleportation Mode
  47026. */
  47027. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47028. /**
  47029. * Teleports the users feet to the desired location
  47030. * @param location The location where the user's feet should be placed
  47031. */
  47032. teleportCamera(location: Vector3): void;
  47033. private _convertNormalToDirectionOfRay;
  47034. private _castRayAndSelectObject;
  47035. private _notifySelectedMeshUnselected;
  47036. /**
  47037. * Permanently set new colors for the laser pointer
  47038. * @param color the new laser color
  47039. * @param pickedColor the new laser color when picked mesh detected
  47040. */
  47041. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47042. /**
  47043. * Set lighting enabled / disabled on the laser pointer of both controllers
  47044. * @param enabled should the lighting be enabled on the laser pointer
  47045. */
  47046. setLaserLightingState(enabled?: boolean): void;
  47047. /**
  47048. * Permanently set new colors for the gaze pointer
  47049. * @param color the new gaze color
  47050. * @param pickedColor the new gaze color when picked mesh detected
  47051. */
  47052. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47053. /**
  47054. * Sets the color of the laser ray from the vr controllers.
  47055. * @param color new color for the ray.
  47056. */
  47057. changeLaserColor(color: Color3): void;
  47058. /**
  47059. * Sets the color of the ray from the vr headsets gaze.
  47060. * @param color new color for the ray.
  47061. */
  47062. changeGazeColor(color: Color3): void;
  47063. /**
  47064. * Exits VR and disposes of the vr experience helper
  47065. */
  47066. dispose(): void;
  47067. /**
  47068. * Gets the name of the VRExperienceHelper class
  47069. * @returns "VRExperienceHelper"
  47070. */
  47071. getClassName(): string;
  47072. }
  47073. }
  47074. declare module "babylonjs/Cameras/VR/index" {
  47075. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47076. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47077. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47078. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47079. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47080. export * from "babylonjs/Cameras/VR/webVRCamera";
  47081. }
  47082. declare module "babylonjs/Cameras/RigModes/index" {
  47083. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47084. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47085. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47086. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47087. }
  47088. declare module "babylonjs/Cameras/index" {
  47089. export * from "babylonjs/Cameras/Inputs/index";
  47090. export * from "babylonjs/Cameras/cameraInputsManager";
  47091. export * from "babylonjs/Cameras/camera";
  47092. export * from "babylonjs/Cameras/targetCamera";
  47093. export * from "babylonjs/Cameras/freeCamera";
  47094. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47095. export * from "babylonjs/Cameras/touchCamera";
  47096. export * from "babylonjs/Cameras/arcRotateCamera";
  47097. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47098. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47099. export * from "babylonjs/Cameras/flyCamera";
  47100. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47101. export * from "babylonjs/Cameras/followCamera";
  47102. export * from "babylonjs/Cameras/followCameraInputsManager";
  47103. export * from "babylonjs/Cameras/gamepadCamera";
  47104. export * from "babylonjs/Cameras/Stereoscopic/index";
  47105. export * from "babylonjs/Cameras/universalCamera";
  47106. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47107. export * from "babylonjs/Cameras/VR/index";
  47108. export * from "babylonjs/Cameras/RigModes/index";
  47109. }
  47110. declare module "babylonjs/Collisions/index" {
  47111. export * from "babylonjs/Collisions/collider";
  47112. export * from "babylonjs/Collisions/collisionCoordinator";
  47113. export * from "babylonjs/Collisions/pickingInfo";
  47114. export * from "babylonjs/Collisions/intersectionInfo";
  47115. export * from "babylonjs/Collisions/meshCollisionData";
  47116. }
  47117. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47118. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47119. import { Vector3 } from "babylonjs/Maths/math.vector";
  47120. import { Ray } from "babylonjs/Culling/ray";
  47121. import { Plane } from "babylonjs/Maths/math.plane";
  47122. /**
  47123. * Contains an array of blocks representing the octree
  47124. */
  47125. export interface IOctreeContainer<T> {
  47126. /**
  47127. * Blocks within the octree
  47128. */
  47129. blocks: Array<OctreeBlock<T>>;
  47130. }
  47131. /**
  47132. * Class used to store a cell in an octree
  47133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47134. */
  47135. export class OctreeBlock<T> {
  47136. /**
  47137. * Gets the content of the current block
  47138. */
  47139. entries: T[];
  47140. /**
  47141. * Gets the list of block children
  47142. */
  47143. blocks: Array<OctreeBlock<T>>;
  47144. private _depth;
  47145. private _maxDepth;
  47146. private _capacity;
  47147. private _minPoint;
  47148. private _maxPoint;
  47149. private _boundingVectors;
  47150. private _creationFunc;
  47151. /**
  47152. * Creates a new block
  47153. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47154. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47155. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47156. * @param depth defines the current depth of this block in the octree
  47157. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47158. * @param creationFunc defines a callback to call when an element is added to the block
  47159. */
  47160. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47161. /**
  47162. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47163. */
  47164. get capacity(): number;
  47165. /**
  47166. * Gets the minimum vector (in world space) of the block's bounding box
  47167. */
  47168. get minPoint(): Vector3;
  47169. /**
  47170. * Gets the maximum vector (in world space) of the block's bounding box
  47171. */
  47172. get maxPoint(): Vector3;
  47173. /**
  47174. * Add a new element to this block
  47175. * @param entry defines the element to add
  47176. */
  47177. addEntry(entry: T): void;
  47178. /**
  47179. * Remove an element from this block
  47180. * @param entry defines the element to remove
  47181. */
  47182. removeEntry(entry: T): void;
  47183. /**
  47184. * Add an array of elements to this block
  47185. * @param entries defines the array of elements to add
  47186. */
  47187. addEntries(entries: T[]): void;
  47188. /**
  47189. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47190. * @param frustumPlanes defines the frustum planes to test
  47191. * @param selection defines the array to store current content if selection is positive
  47192. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47193. */
  47194. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47195. /**
  47196. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47197. * @param sphereCenter defines the bounding sphere center
  47198. * @param sphereRadius defines the bounding sphere radius
  47199. * @param selection defines the array to store current content if selection is positive
  47200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47201. */
  47202. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47203. /**
  47204. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47205. * @param ray defines the ray to test with
  47206. * @param selection defines the array to store current content if selection is positive
  47207. */
  47208. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47209. /**
  47210. * Subdivide the content into child blocks (this block will then be empty)
  47211. */
  47212. createInnerBlocks(): void;
  47213. /**
  47214. * @hidden
  47215. */
  47216. 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;
  47217. }
  47218. }
  47219. declare module "babylonjs/Culling/Octrees/octree" {
  47220. import { SmartArray } from "babylonjs/Misc/smartArray";
  47221. import { Vector3 } from "babylonjs/Maths/math.vector";
  47222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47224. import { Ray } from "babylonjs/Culling/ray";
  47225. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47226. import { Plane } from "babylonjs/Maths/math.plane";
  47227. /**
  47228. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47230. */
  47231. export class Octree<T> {
  47232. /** 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.) */
  47233. maxDepth: number;
  47234. /**
  47235. * Blocks within the octree containing objects
  47236. */
  47237. blocks: Array<OctreeBlock<T>>;
  47238. /**
  47239. * Content stored in the octree
  47240. */
  47241. dynamicContent: T[];
  47242. private _maxBlockCapacity;
  47243. private _selectionContent;
  47244. private _creationFunc;
  47245. /**
  47246. * Creates a octree
  47247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47248. * @param creationFunc function to be used to instatiate the octree
  47249. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47250. * @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.)
  47251. */
  47252. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47253. /** 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.) */
  47254. maxDepth?: number);
  47255. /**
  47256. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47257. * @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);
  47258. * @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);
  47259. * @param entries meshes to be added to the octree blocks
  47260. */
  47261. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47262. /**
  47263. * Adds a mesh to the octree
  47264. * @param entry Mesh to add to the octree
  47265. */
  47266. addMesh(entry: T): void;
  47267. /**
  47268. * Remove an element from the octree
  47269. * @param entry defines the element to remove
  47270. */
  47271. removeMesh(entry: T): void;
  47272. /**
  47273. * Selects an array of meshes within the frustum
  47274. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47275. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47276. * @returns array of meshes within the frustum
  47277. */
  47278. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47279. /**
  47280. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47281. * @param sphereCenter defines the bounding sphere center
  47282. * @param sphereRadius defines the bounding sphere radius
  47283. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47284. * @returns an array of objects that intersect the sphere
  47285. */
  47286. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47287. /**
  47288. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47289. * @param ray defines the ray to test with
  47290. * @returns array of intersected objects
  47291. */
  47292. intersectsRay(ray: Ray): SmartArray<T>;
  47293. /**
  47294. * Adds a mesh into the octree block if it intersects the block
  47295. */
  47296. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47297. /**
  47298. * Adds a submesh into the octree block if it intersects the block
  47299. */
  47300. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47301. }
  47302. }
  47303. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47304. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47305. import { Scene } from "babylonjs/scene";
  47306. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47308. import { Ray } from "babylonjs/Culling/ray";
  47309. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47310. import { Collider } from "babylonjs/Collisions/collider";
  47311. module "babylonjs/scene" {
  47312. interface Scene {
  47313. /**
  47314. * @hidden
  47315. * Backing Filed
  47316. */
  47317. _selectionOctree: Octree<AbstractMesh>;
  47318. /**
  47319. * Gets the octree used to boost mesh selection (picking)
  47320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47321. */
  47322. selectionOctree: Octree<AbstractMesh>;
  47323. /**
  47324. * Creates or updates the octree used to boost selection (picking)
  47325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47326. * @param maxCapacity defines the maximum capacity per leaf
  47327. * @param maxDepth defines the maximum depth of the octree
  47328. * @returns an octree of AbstractMesh
  47329. */
  47330. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47331. }
  47332. }
  47333. module "babylonjs/Meshes/abstractMesh" {
  47334. interface AbstractMesh {
  47335. /**
  47336. * @hidden
  47337. * Backing Field
  47338. */
  47339. _submeshesOctree: Octree<SubMesh>;
  47340. /**
  47341. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47342. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47343. * @param maxCapacity defines the maximum size of each block (64 by default)
  47344. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47345. * @returns the new octree
  47346. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47348. */
  47349. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47350. }
  47351. }
  47352. /**
  47353. * Defines the octree scene component responsible to manage any octrees
  47354. * in a given scene.
  47355. */
  47356. export class OctreeSceneComponent {
  47357. /**
  47358. * The component name help to identify the component in the list of scene components.
  47359. */
  47360. readonly name: string;
  47361. /**
  47362. * The scene the component belongs to.
  47363. */
  47364. scene: Scene;
  47365. /**
  47366. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47367. */
  47368. readonly checksIsEnabled: boolean;
  47369. /**
  47370. * Creates a new instance of the component for the given scene
  47371. * @param scene Defines the scene to register the component in
  47372. */
  47373. constructor(scene: Scene);
  47374. /**
  47375. * Registers the component in a given scene
  47376. */
  47377. register(): void;
  47378. /**
  47379. * Return the list of active meshes
  47380. * @returns the list of active meshes
  47381. */
  47382. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47383. /**
  47384. * Return the list of active sub meshes
  47385. * @param mesh The mesh to get the candidates sub meshes from
  47386. * @returns the list of active sub meshes
  47387. */
  47388. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47389. private _tempRay;
  47390. /**
  47391. * Return the list of sub meshes intersecting with a given local ray
  47392. * @param mesh defines the mesh to find the submesh for
  47393. * @param localRay defines the ray in local space
  47394. * @returns the list of intersecting sub meshes
  47395. */
  47396. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47397. /**
  47398. * Return the list of sub meshes colliding with a collider
  47399. * @param mesh defines the mesh to find the submesh for
  47400. * @param collider defines the collider to evaluate the collision against
  47401. * @returns the list of colliding sub meshes
  47402. */
  47403. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47404. /**
  47405. * Rebuilds the elements related to this component in case of
  47406. * context lost for instance.
  47407. */
  47408. rebuild(): void;
  47409. /**
  47410. * Disposes the component and the associated ressources.
  47411. */
  47412. dispose(): void;
  47413. }
  47414. }
  47415. declare module "babylonjs/Culling/Octrees/index" {
  47416. export * from "babylonjs/Culling/Octrees/octree";
  47417. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47418. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47419. }
  47420. declare module "babylonjs/Culling/index" {
  47421. export * from "babylonjs/Culling/boundingBox";
  47422. export * from "babylonjs/Culling/boundingInfo";
  47423. export * from "babylonjs/Culling/boundingSphere";
  47424. export * from "babylonjs/Culling/Octrees/index";
  47425. export * from "babylonjs/Culling/ray";
  47426. }
  47427. declare module "babylonjs/Gizmos/gizmo" {
  47428. import { Nullable } from "babylonjs/types";
  47429. import { IDisposable } from "babylonjs/scene";
  47430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47431. import { Mesh } from "babylonjs/Meshes/mesh";
  47432. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47433. /**
  47434. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47435. */
  47436. export class Gizmo implements IDisposable {
  47437. /** The utility layer the gizmo will be added to */
  47438. gizmoLayer: UtilityLayerRenderer;
  47439. /**
  47440. * The root mesh of the gizmo
  47441. */
  47442. _rootMesh: Mesh;
  47443. private _attachedMesh;
  47444. /**
  47445. * Ratio for the scale of the gizmo (Default: 1)
  47446. */
  47447. scaleRatio: number;
  47448. /**
  47449. * If a custom mesh has been set (Default: false)
  47450. */
  47451. protected _customMeshSet: boolean;
  47452. /**
  47453. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47454. * * When set, interactions will be enabled
  47455. */
  47456. get attachedMesh(): Nullable<AbstractMesh>;
  47457. set attachedMesh(value: Nullable<AbstractMesh>);
  47458. /**
  47459. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47460. * @param mesh The mesh to replace the default mesh of the gizmo
  47461. */
  47462. setCustomMesh(mesh: Mesh): void;
  47463. /**
  47464. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47465. */
  47466. updateGizmoRotationToMatchAttachedMesh: boolean;
  47467. /**
  47468. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47469. */
  47470. updateGizmoPositionToMatchAttachedMesh: boolean;
  47471. /**
  47472. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47473. */
  47474. updateScale: boolean;
  47475. protected _interactionsEnabled: boolean;
  47476. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47477. private _beforeRenderObserver;
  47478. private _tempVector;
  47479. /**
  47480. * Creates a gizmo
  47481. * @param gizmoLayer The utility layer the gizmo will be added to
  47482. */
  47483. constructor(
  47484. /** The utility layer the gizmo will be added to */
  47485. gizmoLayer?: UtilityLayerRenderer);
  47486. /**
  47487. * Updates the gizmo to match the attached mesh's position/rotation
  47488. */
  47489. protected _update(): void;
  47490. /**
  47491. * Disposes of the gizmo
  47492. */
  47493. dispose(): void;
  47494. }
  47495. }
  47496. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47497. import { Observable } from "babylonjs/Misc/observable";
  47498. import { Nullable } from "babylonjs/types";
  47499. import { Vector3 } from "babylonjs/Maths/math.vector";
  47500. import { Color3 } from "babylonjs/Maths/math.color";
  47501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47503. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47504. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47505. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47506. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47507. import { Scene } from "babylonjs/scene";
  47508. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47509. /**
  47510. * Single plane drag gizmo
  47511. */
  47512. export class PlaneDragGizmo extends Gizmo {
  47513. /**
  47514. * Drag behavior responsible for the gizmos dragging interactions
  47515. */
  47516. dragBehavior: PointerDragBehavior;
  47517. private _pointerObserver;
  47518. /**
  47519. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47520. */
  47521. snapDistance: number;
  47522. /**
  47523. * Event that fires each time the gizmo snaps to a new location.
  47524. * * snapDistance is the the change in distance
  47525. */
  47526. onSnapObservable: Observable<{
  47527. snapDistance: number;
  47528. }>;
  47529. private _plane;
  47530. private _coloredMaterial;
  47531. private _hoverMaterial;
  47532. private _isEnabled;
  47533. private _parent;
  47534. /** @hidden */
  47535. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47536. /** @hidden */
  47537. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47538. /**
  47539. * Creates a PlaneDragGizmo
  47540. * @param gizmoLayer The utility layer the gizmo will be added to
  47541. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47542. * @param color The color of the gizmo
  47543. */
  47544. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47545. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47546. /**
  47547. * If the gizmo is enabled
  47548. */
  47549. set isEnabled(value: boolean);
  47550. get isEnabled(): boolean;
  47551. /**
  47552. * Disposes of the gizmo
  47553. */
  47554. dispose(): void;
  47555. }
  47556. }
  47557. declare module "babylonjs/Gizmos/positionGizmo" {
  47558. import { Observable } from "babylonjs/Misc/observable";
  47559. import { Nullable } from "babylonjs/types";
  47560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47561. import { Mesh } from "babylonjs/Meshes/mesh";
  47562. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47563. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47564. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47565. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47566. /**
  47567. * Gizmo that enables dragging a mesh along 3 axis
  47568. */
  47569. export class PositionGizmo extends Gizmo {
  47570. /**
  47571. * Internal gizmo used for interactions on the x axis
  47572. */
  47573. xGizmo: AxisDragGizmo;
  47574. /**
  47575. * Internal gizmo used for interactions on the y axis
  47576. */
  47577. yGizmo: AxisDragGizmo;
  47578. /**
  47579. * Internal gizmo used for interactions on the z axis
  47580. */
  47581. zGizmo: AxisDragGizmo;
  47582. /**
  47583. * Internal gizmo used for interactions on the yz plane
  47584. */
  47585. xPlaneGizmo: PlaneDragGizmo;
  47586. /**
  47587. * Internal gizmo used for interactions on the xz plane
  47588. */
  47589. yPlaneGizmo: PlaneDragGizmo;
  47590. /**
  47591. * Internal gizmo used for interactions on the xy plane
  47592. */
  47593. zPlaneGizmo: PlaneDragGizmo;
  47594. /**
  47595. * private variables
  47596. */
  47597. private _meshAttached;
  47598. private _updateGizmoRotationToMatchAttachedMesh;
  47599. private _snapDistance;
  47600. private _scaleRatio;
  47601. /** Fires an event when any of it's sub gizmos are dragged */
  47602. onDragStartObservable: Observable<unknown>;
  47603. /** Fires an event when any of it's sub gizmos are released from dragging */
  47604. onDragEndObservable: Observable<unknown>;
  47605. /**
  47606. * If set to true, planar drag is enabled
  47607. */
  47608. private _planarGizmoEnabled;
  47609. get attachedMesh(): Nullable<AbstractMesh>;
  47610. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47611. /**
  47612. * Creates a PositionGizmo
  47613. * @param gizmoLayer The utility layer the gizmo will be added to
  47614. */
  47615. constructor(gizmoLayer?: UtilityLayerRenderer);
  47616. /**
  47617. * If the planar drag gizmo is enabled
  47618. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47619. */
  47620. set planarGizmoEnabled(value: boolean);
  47621. get planarGizmoEnabled(): boolean;
  47622. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47623. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47624. /**
  47625. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47626. */
  47627. set snapDistance(value: number);
  47628. get snapDistance(): number;
  47629. /**
  47630. * Ratio for the scale of the gizmo (Default: 1)
  47631. */
  47632. set scaleRatio(value: number);
  47633. get scaleRatio(): number;
  47634. /**
  47635. * Disposes of the gizmo
  47636. */
  47637. dispose(): void;
  47638. /**
  47639. * CustomMeshes are not supported by this gizmo
  47640. * @param mesh The mesh to replace the default mesh of the gizmo
  47641. */
  47642. setCustomMesh(mesh: Mesh): void;
  47643. }
  47644. }
  47645. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47646. import { Observable } from "babylonjs/Misc/observable";
  47647. import { Nullable } from "babylonjs/types";
  47648. import { Vector3 } from "babylonjs/Maths/math.vector";
  47649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47651. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47652. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47653. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47654. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47655. import { Scene } from "babylonjs/scene";
  47656. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47657. import { Color3 } from "babylonjs/Maths/math.color";
  47658. /**
  47659. * Single axis drag gizmo
  47660. */
  47661. export class AxisDragGizmo extends Gizmo {
  47662. /**
  47663. * Drag behavior responsible for the gizmos dragging interactions
  47664. */
  47665. dragBehavior: PointerDragBehavior;
  47666. private _pointerObserver;
  47667. /**
  47668. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47669. */
  47670. snapDistance: number;
  47671. /**
  47672. * Event that fires each time the gizmo snaps to a new location.
  47673. * * snapDistance is the the change in distance
  47674. */
  47675. onSnapObservable: Observable<{
  47676. snapDistance: number;
  47677. }>;
  47678. private _isEnabled;
  47679. private _parent;
  47680. private _arrow;
  47681. private _coloredMaterial;
  47682. private _hoverMaterial;
  47683. /** @hidden */
  47684. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47685. /** @hidden */
  47686. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47687. /**
  47688. * Creates an AxisDragGizmo
  47689. * @param gizmoLayer The utility layer the gizmo will be added to
  47690. * @param dragAxis The axis which the gizmo will be able to drag on
  47691. * @param color The color of the gizmo
  47692. */
  47693. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47695. /**
  47696. * If the gizmo is enabled
  47697. */
  47698. set isEnabled(value: boolean);
  47699. get isEnabled(): boolean;
  47700. /**
  47701. * Disposes of the gizmo
  47702. */
  47703. dispose(): void;
  47704. }
  47705. }
  47706. declare module "babylonjs/Debug/axesViewer" {
  47707. import { Vector3 } from "babylonjs/Maths/math.vector";
  47708. import { Nullable } from "babylonjs/types";
  47709. import { Scene } from "babylonjs/scene";
  47710. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47711. /**
  47712. * The Axes viewer will show 3 axes in a specific point in space
  47713. */
  47714. export class AxesViewer {
  47715. private _xAxis;
  47716. private _yAxis;
  47717. private _zAxis;
  47718. private _scaleLinesFactor;
  47719. private _instanced;
  47720. /**
  47721. * Gets the hosting scene
  47722. */
  47723. scene: Scene;
  47724. /**
  47725. * Gets or sets a number used to scale line length
  47726. */
  47727. scaleLines: number;
  47728. /** Gets the node hierarchy used to render x-axis */
  47729. get xAxis(): TransformNode;
  47730. /** Gets the node hierarchy used to render y-axis */
  47731. get yAxis(): TransformNode;
  47732. /** Gets the node hierarchy used to render z-axis */
  47733. get zAxis(): TransformNode;
  47734. /**
  47735. * Creates a new AxesViewer
  47736. * @param scene defines the hosting scene
  47737. * @param scaleLines defines a number used to scale line length (1 by default)
  47738. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47739. * @param xAxis defines the node hierarchy used to render the x-axis
  47740. * @param yAxis defines the node hierarchy used to render the y-axis
  47741. * @param zAxis defines the node hierarchy used to render the z-axis
  47742. */
  47743. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47744. /**
  47745. * Force the viewer to update
  47746. * @param position defines the position of the viewer
  47747. * @param xaxis defines the x axis of the viewer
  47748. * @param yaxis defines the y axis of the viewer
  47749. * @param zaxis defines the z axis of the viewer
  47750. */
  47751. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47752. /**
  47753. * Creates an instance of this axes viewer.
  47754. * @returns a new axes viewer with instanced meshes
  47755. */
  47756. createInstance(): AxesViewer;
  47757. /** Releases resources */
  47758. dispose(): void;
  47759. private static _SetRenderingGroupId;
  47760. }
  47761. }
  47762. declare module "babylonjs/Debug/boneAxesViewer" {
  47763. import { Nullable } from "babylonjs/types";
  47764. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47765. import { Vector3 } from "babylonjs/Maths/math.vector";
  47766. import { Mesh } from "babylonjs/Meshes/mesh";
  47767. import { Bone } from "babylonjs/Bones/bone";
  47768. import { Scene } from "babylonjs/scene";
  47769. /**
  47770. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47771. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47772. */
  47773. export class BoneAxesViewer extends AxesViewer {
  47774. /**
  47775. * Gets or sets the target mesh where to display the axes viewer
  47776. */
  47777. mesh: Nullable<Mesh>;
  47778. /**
  47779. * Gets or sets the target bone where to display the axes viewer
  47780. */
  47781. bone: Nullable<Bone>;
  47782. /** Gets current position */
  47783. pos: Vector3;
  47784. /** Gets direction of X axis */
  47785. xaxis: Vector3;
  47786. /** Gets direction of Y axis */
  47787. yaxis: Vector3;
  47788. /** Gets direction of Z axis */
  47789. zaxis: Vector3;
  47790. /**
  47791. * Creates a new BoneAxesViewer
  47792. * @param scene defines the hosting scene
  47793. * @param bone defines the target bone
  47794. * @param mesh defines the target mesh
  47795. * @param scaleLines defines a scaling factor for line length (1 by default)
  47796. */
  47797. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47798. /**
  47799. * Force the viewer to update
  47800. */
  47801. update(): void;
  47802. /** Releases resources */
  47803. dispose(): void;
  47804. }
  47805. }
  47806. declare module "babylonjs/Debug/debugLayer" {
  47807. import { Scene } from "babylonjs/scene";
  47808. /**
  47809. * Interface used to define scene explorer extensibility option
  47810. */
  47811. export interface IExplorerExtensibilityOption {
  47812. /**
  47813. * Define the option label
  47814. */
  47815. label: string;
  47816. /**
  47817. * Defines the action to execute on click
  47818. */
  47819. action: (entity: any) => void;
  47820. }
  47821. /**
  47822. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47823. */
  47824. export interface IExplorerExtensibilityGroup {
  47825. /**
  47826. * Defines a predicate to test if a given type mut be extended
  47827. */
  47828. predicate: (entity: any) => boolean;
  47829. /**
  47830. * Gets the list of options added to a type
  47831. */
  47832. entries: IExplorerExtensibilityOption[];
  47833. }
  47834. /**
  47835. * Interface used to define the options to use to create the Inspector
  47836. */
  47837. export interface IInspectorOptions {
  47838. /**
  47839. * Display in overlay mode (default: false)
  47840. */
  47841. overlay?: boolean;
  47842. /**
  47843. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47844. */
  47845. globalRoot?: HTMLElement;
  47846. /**
  47847. * Display the Scene explorer
  47848. */
  47849. showExplorer?: boolean;
  47850. /**
  47851. * Display the property inspector
  47852. */
  47853. showInspector?: boolean;
  47854. /**
  47855. * Display in embed mode (both panes on the right)
  47856. */
  47857. embedMode?: boolean;
  47858. /**
  47859. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47860. */
  47861. handleResize?: boolean;
  47862. /**
  47863. * Allow the panes to popup (default: true)
  47864. */
  47865. enablePopup?: boolean;
  47866. /**
  47867. * Allow the panes to be closed by users (default: true)
  47868. */
  47869. enableClose?: boolean;
  47870. /**
  47871. * Optional list of extensibility entries
  47872. */
  47873. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47874. /**
  47875. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47876. */
  47877. inspectorURL?: string;
  47878. /**
  47879. * Optional initial tab (default to DebugLayerTab.Properties)
  47880. */
  47881. initialTab?: DebugLayerTab;
  47882. }
  47883. module "babylonjs/scene" {
  47884. interface Scene {
  47885. /**
  47886. * @hidden
  47887. * Backing field
  47888. */
  47889. _debugLayer: DebugLayer;
  47890. /**
  47891. * Gets the debug layer (aka Inspector) associated with the scene
  47892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47893. */
  47894. debugLayer: DebugLayer;
  47895. }
  47896. }
  47897. /**
  47898. * Enum of inspector action tab
  47899. */
  47900. export enum DebugLayerTab {
  47901. /**
  47902. * Properties tag (default)
  47903. */
  47904. Properties = 0,
  47905. /**
  47906. * Debug tab
  47907. */
  47908. Debug = 1,
  47909. /**
  47910. * Statistics tab
  47911. */
  47912. Statistics = 2,
  47913. /**
  47914. * Tools tab
  47915. */
  47916. Tools = 3,
  47917. /**
  47918. * Settings tab
  47919. */
  47920. Settings = 4
  47921. }
  47922. /**
  47923. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47924. * what is happening in your scene
  47925. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47926. */
  47927. export class DebugLayer {
  47928. /**
  47929. * Define the url to get the inspector script from.
  47930. * By default it uses the babylonjs CDN.
  47931. * @ignoreNaming
  47932. */
  47933. static InspectorURL: string;
  47934. private _scene;
  47935. private BJSINSPECTOR;
  47936. private _onPropertyChangedObservable?;
  47937. /**
  47938. * Observable triggered when a property is changed through the inspector.
  47939. */
  47940. get onPropertyChangedObservable(): any;
  47941. /**
  47942. * Instantiates a new debug layer.
  47943. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47944. * what is happening in your scene
  47945. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47946. * @param scene Defines the scene to inspect
  47947. */
  47948. constructor(scene: Scene);
  47949. /** Creates the inspector window. */
  47950. private _createInspector;
  47951. /**
  47952. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47953. * @param entity defines the entity to select
  47954. * @param lineContainerTitle defines the specific block to highlight
  47955. */
  47956. select(entity: any, lineContainerTitle?: string): void;
  47957. /** Get the inspector from bundle or global */
  47958. private _getGlobalInspector;
  47959. /**
  47960. * Get if the inspector is visible or not.
  47961. * @returns true if visible otherwise, false
  47962. */
  47963. isVisible(): boolean;
  47964. /**
  47965. * Hide the inspector and close its window.
  47966. */
  47967. hide(): void;
  47968. /**
  47969. * Launch the debugLayer.
  47970. * @param config Define the configuration of the inspector
  47971. * @return a promise fulfilled when the debug layer is visible
  47972. */
  47973. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47974. }
  47975. }
  47976. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47977. import { Nullable } from "babylonjs/types";
  47978. import { Scene } from "babylonjs/scene";
  47979. import { Vector4 } from "babylonjs/Maths/math.vector";
  47980. import { Color4 } from "babylonjs/Maths/math.color";
  47981. import { Mesh } from "babylonjs/Meshes/mesh";
  47982. /**
  47983. * Class containing static functions to help procedurally build meshes
  47984. */
  47985. export class BoxBuilder {
  47986. /**
  47987. * Creates a box mesh
  47988. * * The parameter `size` sets the size (float) of each box side (default 1)
  47989. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47990. * * 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)
  47991. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47995. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47996. * @param name defines the name of the mesh
  47997. * @param options defines the options used to create the mesh
  47998. * @param scene defines the hosting scene
  47999. * @returns the box mesh
  48000. */
  48001. static CreateBox(name: string, options: {
  48002. size?: number;
  48003. width?: number;
  48004. height?: number;
  48005. depth?: number;
  48006. faceUV?: Vector4[];
  48007. faceColors?: Color4[];
  48008. sideOrientation?: number;
  48009. frontUVs?: Vector4;
  48010. backUVs?: Vector4;
  48011. wrap?: boolean;
  48012. topBaseAt?: number;
  48013. bottomBaseAt?: number;
  48014. updatable?: boolean;
  48015. }, scene?: Nullable<Scene>): Mesh;
  48016. }
  48017. }
  48018. declare module "babylonjs/Debug/physicsViewer" {
  48019. import { Nullable } from "babylonjs/types";
  48020. import { Scene } from "babylonjs/scene";
  48021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48022. import { Mesh } from "babylonjs/Meshes/mesh";
  48023. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48024. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48025. /**
  48026. * Used to show the physics impostor around the specific mesh
  48027. */
  48028. export class PhysicsViewer {
  48029. /** @hidden */
  48030. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48031. /** @hidden */
  48032. protected _meshes: Array<Nullable<AbstractMesh>>;
  48033. /** @hidden */
  48034. protected _scene: Nullable<Scene>;
  48035. /** @hidden */
  48036. protected _numMeshes: number;
  48037. /** @hidden */
  48038. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48039. private _renderFunction;
  48040. private _utilityLayer;
  48041. private _debugBoxMesh;
  48042. private _debugSphereMesh;
  48043. private _debugCylinderMesh;
  48044. private _debugMaterial;
  48045. private _debugMeshMeshes;
  48046. /**
  48047. * Creates a new PhysicsViewer
  48048. * @param scene defines the hosting scene
  48049. */
  48050. constructor(scene: Scene);
  48051. /** @hidden */
  48052. protected _updateDebugMeshes(): void;
  48053. /**
  48054. * Renders a specified physic impostor
  48055. * @param impostor defines the impostor to render
  48056. * @param targetMesh defines the mesh represented by the impostor
  48057. * @returns the new debug mesh used to render the impostor
  48058. */
  48059. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48060. /**
  48061. * Hides a specified physic impostor
  48062. * @param impostor defines the impostor to hide
  48063. */
  48064. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48065. private _getDebugMaterial;
  48066. private _getDebugBoxMesh;
  48067. private _getDebugSphereMesh;
  48068. private _getDebugCylinderMesh;
  48069. private _getDebugMeshMesh;
  48070. private _getDebugMesh;
  48071. /** Releases all resources */
  48072. dispose(): void;
  48073. }
  48074. }
  48075. declare module "babylonjs/Debug/rayHelper" {
  48076. import { Nullable } from "babylonjs/types";
  48077. import { Ray } from "babylonjs/Culling/ray";
  48078. import { Vector3 } from "babylonjs/Maths/math.vector";
  48079. import { Color3 } from "babylonjs/Maths/math.color";
  48080. import { Scene } from "babylonjs/scene";
  48081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48082. import "babylonjs/Meshes/Builders/linesBuilder";
  48083. /**
  48084. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48085. * in order to better appreciate the issue one might have.
  48086. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48087. */
  48088. export class RayHelper {
  48089. /**
  48090. * Defines the ray we are currently tryin to visualize.
  48091. */
  48092. ray: Nullable<Ray>;
  48093. private _renderPoints;
  48094. private _renderLine;
  48095. private _renderFunction;
  48096. private _scene;
  48097. private _updateToMeshFunction;
  48098. private _attachedToMesh;
  48099. private _meshSpaceDirection;
  48100. private _meshSpaceOrigin;
  48101. /**
  48102. * Helper function to create a colored helper in a scene in one line.
  48103. * @param ray Defines the ray we are currently tryin to visualize
  48104. * @param scene Defines the scene the ray is used in
  48105. * @param color Defines the color we want to see the ray in
  48106. * @returns The newly created ray helper.
  48107. */
  48108. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48109. /**
  48110. * Instantiate a new ray helper.
  48111. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48112. * in order to better appreciate the issue one might have.
  48113. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48114. * @param ray Defines the ray we are currently tryin to visualize
  48115. */
  48116. constructor(ray: Ray);
  48117. /**
  48118. * Shows the ray we are willing to debug.
  48119. * @param scene Defines the scene the ray needs to be rendered in
  48120. * @param color Defines the color the ray needs to be rendered in
  48121. */
  48122. show(scene: Scene, color?: Color3): void;
  48123. /**
  48124. * Hides the ray we are debugging.
  48125. */
  48126. hide(): void;
  48127. private _render;
  48128. /**
  48129. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48130. * @param mesh Defines the mesh we want the helper attached to
  48131. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48132. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48133. * @param length Defines the length of the ray
  48134. */
  48135. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48136. /**
  48137. * Detach the ray helper from the mesh it has previously been attached to.
  48138. */
  48139. detachFromMesh(): void;
  48140. private _updateToMesh;
  48141. /**
  48142. * Dispose the helper and release its associated resources.
  48143. */
  48144. dispose(): void;
  48145. }
  48146. }
  48147. declare module "babylonjs/Debug/skeletonViewer" {
  48148. import { Color3 } from "babylonjs/Maths/math.color";
  48149. import { Scene } from "babylonjs/scene";
  48150. import { Nullable } from "babylonjs/types";
  48151. import { Skeleton } from "babylonjs/Bones/skeleton";
  48152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48153. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48154. /**
  48155. * Class used to render a debug view of a given skeleton
  48156. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48157. */
  48158. export class SkeletonViewer {
  48159. /** defines the skeleton to render */
  48160. skeleton: Skeleton;
  48161. /** defines the mesh attached to the skeleton */
  48162. mesh: AbstractMesh;
  48163. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48164. autoUpdateBonesMatrices: boolean;
  48165. /** defines the rendering group id to use with the viewer */
  48166. renderingGroupId: number;
  48167. /** Gets or sets the color used to render the skeleton */
  48168. color: Color3;
  48169. private _scene;
  48170. private _debugLines;
  48171. private _debugMesh;
  48172. private _isEnabled;
  48173. private _renderFunction;
  48174. private _utilityLayer;
  48175. /**
  48176. * Returns the mesh used to render the bones
  48177. */
  48178. get debugMesh(): Nullable<LinesMesh>;
  48179. /**
  48180. * Creates a new SkeletonViewer
  48181. * @param skeleton defines the skeleton to render
  48182. * @param mesh defines the mesh attached to the skeleton
  48183. * @param scene defines the hosting scene
  48184. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48185. * @param renderingGroupId defines the rendering group id to use with the viewer
  48186. */
  48187. constructor(
  48188. /** defines the skeleton to render */
  48189. skeleton: Skeleton,
  48190. /** defines the mesh attached to the skeleton */
  48191. mesh: AbstractMesh, scene: Scene,
  48192. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48193. autoUpdateBonesMatrices?: boolean,
  48194. /** defines the rendering group id to use with the viewer */
  48195. renderingGroupId?: number);
  48196. /** Gets or sets a boolean indicating if the viewer is enabled */
  48197. set isEnabled(value: boolean);
  48198. get isEnabled(): boolean;
  48199. private _getBonePosition;
  48200. private _getLinesForBonesWithLength;
  48201. private _getLinesForBonesNoLength;
  48202. /** Update the viewer to sync with current skeleton state */
  48203. update(): void;
  48204. /** Release associated resources */
  48205. dispose(): void;
  48206. }
  48207. }
  48208. declare module "babylonjs/Debug/index" {
  48209. export * from "babylonjs/Debug/axesViewer";
  48210. export * from "babylonjs/Debug/boneAxesViewer";
  48211. export * from "babylonjs/Debug/debugLayer";
  48212. export * from "babylonjs/Debug/physicsViewer";
  48213. export * from "babylonjs/Debug/rayHelper";
  48214. export * from "babylonjs/Debug/skeletonViewer";
  48215. }
  48216. declare module "babylonjs/Engines/nullEngine" {
  48217. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48218. import { Scene } from "babylonjs/scene";
  48219. import { Engine } from "babylonjs/Engines/engine";
  48220. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48221. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48222. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48223. import { Effect } from "babylonjs/Materials/effect";
  48224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48226. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48227. /**
  48228. * Options to create the null engine
  48229. */
  48230. export class NullEngineOptions {
  48231. /**
  48232. * Render width (Default: 512)
  48233. */
  48234. renderWidth: number;
  48235. /**
  48236. * Render height (Default: 256)
  48237. */
  48238. renderHeight: number;
  48239. /**
  48240. * Texture size (Default: 512)
  48241. */
  48242. textureSize: number;
  48243. /**
  48244. * If delta time between frames should be constant
  48245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48246. */
  48247. deterministicLockstep: boolean;
  48248. /**
  48249. * Maximum about of steps between frames (Default: 4)
  48250. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48251. */
  48252. lockstepMaxSteps: number;
  48253. }
  48254. /**
  48255. * The null engine class provides support for headless version of babylon.js.
  48256. * This can be used in server side scenario or for testing purposes
  48257. */
  48258. export class NullEngine extends Engine {
  48259. private _options;
  48260. /**
  48261. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48263. * @returns true if engine is in deterministic lock step mode
  48264. */
  48265. isDeterministicLockStep(): boolean;
  48266. /**
  48267. * Gets the max steps when engine is running in deterministic lock step
  48268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48269. * @returns the max steps
  48270. */
  48271. getLockstepMaxSteps(): number;
  48272. /**
  48273. * Gets the current hardware scaling level.
  48274. * By default the hardware scaling level is computed from the window device ratio.
  48275. * 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.
  48276. * @returns a number indicating the current hardware scaling level
  48277. */
  48278. getHardwareScalingLevel(): number;
  48279. constructor(options?: NullEngineOptions);
  48280. /**
  48281. * Creates a vertex buffer
  48282. * @param vertices the data for the vertex buffer
  48283. * @returns the new WebGL static buffer
  48284. */
  48285. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48286. /**
  48287. * Creates a new index buffer
  48288. * @param indices defines the content of the index buffer
  48289. * @param updatable defines if the index buffer must be updatable
  48290. * @returns a new webGL buffer
  48291. */
  48292. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48293. /**
  48294. * Clear the current render buffer or the current render target (if any is set up)
  48295. * @param color defines the color to use
  48296. * @param backBuffer defines if the back buffer must be cleared
  48297. * @param depth defines if the depth buffer must be cleared
  48298. * @param stencil defines if the stencil buffer must be cleared
  48299. */
  48300. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48301. /**
  48302. * Gets the current render width
  48303. * @param useScreen defines if screen size must be used (or the current render target if any)
  48304. * @returns a number defining the current render width
  48305. */
  48306. getRenderWidth(useScreen?: boolean): number;
  48307. /**
  48308. * Gets the current render height
  48309. * @param useScreen defines if screen size must be used (or the current render target if any)
  48310. * @returns a number defining the current render height
  48311. */
  48312. getRenderHeight(useScreen?: boolean): number;
  48313. /**
  48314. * Set the WebGL's viewport
  48315. * @param viewport defines the viewport element to be used
  48316. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48317. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48318. */
  48319. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48320. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48321. /**
  48322. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48323. * @param pipelineContext defines the pipeline context to use
  48324. * @param uniformsNames defines the list of uniform names
  48325. * @returns an array of webGL uniform locations
  48326. */
  48327. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48328. /**
  48329. * Gets the lsit of active attributes for a given webGL program
  48330. * @param pipelineContext defines the pipeline context to use
  48331. * @param attributesNames defines the list of attribute names to get
  48332. * @returns an array of indices indicating the offset of each attribute
  48333. */
  48334. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48335. /**
  48336. * Binds an effect to the webGL context
  48337. * @param effect defines the effect to bind
  48338. */
  48339. bindSamplers(effect: Effect): void;
  48340. /**
  48341. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48342. * @param effect defines the effect to activate
  48343. */
  48344. enableEffect(effect: Effect): void;
  48345. /**
  48346. * Set various states to the webGL context
  48347. * @param culling defines backface culling state
  48348. * @param zOffset defines the value to apply to zOffset (0 by default)
  48349. * @param force defines if states must be applied even if cache is up to date
  48350. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48351. */
  48352. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48353. /**
  48354. * Set the value of an uniform to an array of int32
  48355. * @param uniform defines the webGL uniform location where to store the value
  48356. * @param array defines the array of int32 to store
  48357. */
  48358. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48359. /**
  48360. * Set the value of an uniform to an array of int32 (stored as vec2)
  48361. * @param uniform defines the webGL uniform location where to store the value
  48362. * @param array defines the array of int32 to store
  48363. */
  48364. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48365. /**
  48366. * Set the value of an uniform to an array of int32 (stored as vec3)
  48367. * @param uniform defines the webGL uniform location where to store the value
  48368. * @param array defines the array of int32 to store
  48369. */
  48370. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48371. /**
  48372. * Set the value of an uniform to an array of int32 (stored as vec4)
  48373. * @param uniform defines the webGL uniform location where to store the value
  48374. * @param array defines the array of int32 to store
  48375. */
  48376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48377. /**
  48378. * Set the value of an uniform to an array of float32
  48379. * @param uniform defines the webGL uniform location where to store the value
  48380. * @param array defines the array of float32 to store
  48381. */
  48382. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48383. /**
  48384. * Set the value of an uniform to an array of float32 (stored as vec2)
  48385. * @param uniform defines the webGL uniform location where to store the value
  48386. * @param array defines the array of float32 to store
  48387. */
  48388. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48389. /**
  48390. * Set the value of an uniform to an array of float32 (stored as vec3)
  48391. * @param uniform defines the webGL uniform location where to store the value
  48392. * @param array defines the array of float32 to store
  48393. */
  48394. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48395. /**
  48396. * Set the value of an uniform to an array of float32 (stored as vec4)
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param array defines the array of float32 to store
  48399. */
  48400. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48401. /**
  48402. * Set the value of an uniform to an array of number
  48403. * @param uniform defines the webGL uniform location where to store the value
  48404. * @param array defines the array of number to store
  48405. */
  48406. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48407. /**
  48408. * Set the value of an uniform to an array of number (stored as vec2)
  48409. * @param uniform defines the webGL uniform location where to store the value
  48410. * @param array defines the array of number to store
  48411. */
  48412. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48413. /**
  48414. * Set the value of an uniform to an array of number (stored as vec3)
  48415. * @param uniform defines the webGL uniform location where to store the value
  48416. * @param array defines the array of number to store
  48417. */
  48418. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48419. /**
  48420. * Set the value of an uniform to an array of number (stored as vec4)
  48421. * @param uniform defines the webGL uniform location where to store the value
  48422. * @param array defines the array of number to store
  48423. */
  48424. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48425. /**
  48426. * Set the value of an uniform to an array of float32 (stored as matrices)
  48427. * @param uniform defines the webGL uniform location where to store the value
  48428. * @param matrices defines the array of float32 to store
  48429. */
  48430. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48431. /**
  48432. * Set the value of an uniform to a matrix (3x3)
  48433. * @param uniform defines the webGL uniform location where to store the value
  48434. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48435. */
  48436. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48437. /**
  48438. * Set the value of an uniform to a matrix (2x2)
  48439. * @param uniform defines the webGL uniform location where to store the value
  48440. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48441. */
  48442. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48443. /**
  48444. * Set the value of an uniform to a number (float)
  48445. * @param uniform defines the webGL uniform location where to store the value
  48446. * @param value defines the float number to store
  48447. */
  48448. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48449. /**
  48450. * Set the value of an uniform to a vec2
  48451. * @param uniform defines the webGL uniform location where to store the value
  48452. * @param x defines the 1st component of the value
  48453. * @param y defines the 2nd component of the value
  48454. */
  48455. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48456. /**
  48457. * Set the value of an uniform to a vec3
  48458. * @param uniform defines the webGL uniform location where to store the value
  48459. * @param x defines the 1st component of the value
  48460. * @param y defines the 2nd component of the value
  48461. * @param z defines the 3rd component of the value
  48462. */
  48463. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48464. /**
  48465. * Set the value of an uniform to a boolean
  48466. * @param uniform defines the webGL uniform location where to store the value
  48467. * @param bool defines the boolean to store
  48468. */
  48469. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48470. /**
  48471. * Set the value of an uniform to a vec4
  48472. * @param uniform defines the webGL uniform location where to store the value
  48473. * @param x defines the 1st component of the value
  48474. * @param y defines the 2nd component of the value
  48475. * @param z defines the 3rd component of the value
  48476. * @param w defines the 4th component of the value
  48477. */
  48478. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48479. /**
  48480. * Sets the current alpha mode
  48481. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48482. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48483. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48484. */
  48485. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48486. /**
  48487. * Bind webGl buffers directly to the webGL context
  48488. * @param vertexBuffers defines the vertex buffer to bind
  48489. * @param indexBuffer defines the index buffer to bind
  48490. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48491. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48492. * @param effect defines the effect associated with the vertex buffer
  48493. */
  48494. bindBuffers(vertexBuffers: {
  48495. [key: string]: VertexBuffer;
  48496. }, indexBuffer: DataBuffer, effect: Effect): void;
  48497. /**
  48498. * Force the entire cache to be cleared
  48499. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48500. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48501. */
  48502. wipeCaches(bruteForce?: boolean): void;
  48503. /**
  48504. * Send a draw order
  48505. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48506. * @param indexStart defines the starting index
  48507. * @param indexCount defines the number of index to draw
  48508. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48509. */
  48510. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48511. /**
  48512. * Draw a list of indexed primitives
  48513. * @param fillMode defines the primitive to use
  48514. * @param indexStart defines the starting index
  48515. * @param indexCount defines the number of index to draw
  48516. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48517. */
  48518. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48519. /**
  48520. * Draw a list of unindexed primitives
  48521. * @param fillMode defines the primitive to use
  48522. * @param verticesStart defines the index of first vertex to draw
  48523. * @param verticesCount defines the count of vertices to draw
  48524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48525. */
  48526. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48527. /** @hidden */
  48528. _createTexture(): WebGLTexture;
  48529. /** @hidden */
  48530. _releaseTexture(texture: InternalTexture): void;
  48531. /**
  48532. * Usually called from Texture.ts.
  48533. * Passed information to create a WebGLTexture
  48534. * @param urlArg defines a value which contains one of the following:
  48535. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48536. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48537. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48538. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48539. * @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)
  48540. * @param scene needed for loading to the correct scene
  48541. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48542. * @param onLoad optional callback to be called upon successful completion
  48543. * @param onError optional callback to be called upon failure
  48544. * @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
  48545. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48546. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48547. * @param forcedExtension defines the extension to use to pick the right loader
  48548. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48549. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48550. */
  48551. 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;
  48552. /**
  48553. * Creates a new render target texture
  48554. * @param size defines the size of the texture
  48555. * @param options defines the options used to create the texture
  48556. * @returns a new render target texture stored in an InternalTexture
  48557. */
  48558. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48559. /**
  48560. * Update the sampling mode of a given texture
  48561. * @param samplingMode defines the required sampling mode
  48562. * @param texture defines the texture to update
  48563. */
  48564. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48565. /**
  48566. * Binds the frame buffer to the specified texture.
  48567. * @param texture The texture to render to or null for the default canvas
  48568. * @param faceIndex The face of the texture to render to in case of cube texture
  48569. * @param requiredWidth The width of the target to render to
  48570. * @param requiredHeight The height of the target to render to
  48571. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48572. * @param lodLevel defines le lod level to bind to the frame buffer
  48573. */
  48574. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48575. /**
  48576. * Unbind the current render target texture from the webGL context
  48577. * @param texture defines the render target texture to unbind
  48578. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48579. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48580. */
  48581. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48582. /**
  48583. * Creates a dynamic vertex buffer
  48584. * @param vertices the data for the dynamic vertex buffer
  48585. * @returns the new WebGL dynamic buffer
  48586. */
  48587. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48588. /**
  48589. * Update the content of a dynamic texture
  48590. * @param texture defines the texture to update
  48591. * @param canvas defines the canvas containing the source
  48592. * @param invertY defines if data must be stored with Y axis inverted
  48593. * @param premulAlpha defines if alpha is stored as premultiplied
  48594. * @param format defines the format of the data
  48595. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48596. */
  48597. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48598. /**
  48599. * Gets a boolean indicating if all created effects are ready
  48600. * @returns true if all effects are ready
  48601. */
  48602. areAllEffectsReady(): boolean;
  48603. /**
  48604. * @hidden
  48605. * Get the current error code of the webGL context
  48606. * @returns the error code
  48607. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48608. */
  48609. getError(): number;
  48610. /** @hidden */
  48611. _getUnpackAlignement(): number;
  48612. /** @hidden */
  48613. _unpackFlipY(value: boolean): void;
  48614. /**
  48615. * Update a dynamic index buffer
  48616. * @param indexBuffer defines the target index buffer
  48617. * @param indices defines the data to update
  48618. * @param offset defines the offset in the target index buffer where update should start
  48619. */
  48620. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48621. /**
  48622. * Updates a dynamic vertex buffer.
  48623. * @param vertexBuffer the vertex buffer to update
  48624. * @param vertices the data used to update the vertex buffer
  48625. * @param byteOffset the byte offset of the data (optional)
  48626. * @param byteLength the byte length of the data (optional)
  48627. */
  48628. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48629. /** @hidden */
  48630. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48631. /** @hidden */
  48632. _bindTexture(channel: number, texture: InternalTexture): void;
  48633. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48634. /**
  48635. * 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
  48636. */
  48637. releaseEffects(): void;
  48638. displayLoadingUI(): void;
  48639. hideLoadingUI(): void;
  48640. /** @hidden */
  48641. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48642. /** @hidden */
  48643. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48644. /** @hidden */
  48645. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48646. /** @hidden */
  48647. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48648. }
  48649. }
  48650. declare module "babylonjs/Instrumentation/timeToken" {
  48651. import { Nullable } from "babylonjs/types";
  48652. /**
  48653. * @hidden
  48654. **/
  48655. export class _TimeToken {
  48656. _startTimeQuery: Nullable<WebGLQuery>;
  48657. _endTimeQuery: Nullable<WebGLQuery>;
  48658. _timeElapsedQuery: Nullable<WebGLQuery>;
  48659. _timeElapsedQueryEnded: boolean;
  48660. }
  48661. }
  48662. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48663. import { Nullable, int } from "babylonjs/types";
  48664. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48665. /** @hidden */
  48666. export class _OcclusionDataStorage {
  48667. /** @hidden */
  48668. occlusionInternalRetryCounter: number;
  48669. /** @hidden */
  48670. isOcclusionQueryInProgress: boolean;
  48671. /** @hidden */
  48672. isOccluded: boolean;
  48673. /** @hidden */
  48674. occlusionRetryCount: number;
  48675. /** @hidden */
  48676. occlusionType: number;
  48677. /** @hidden */
  48678. occlusionQueryAlgorithmType: number;
  48679. }
  48680. module "babylonjs/Engines/engine" {
  48681. interface Engine {
  48682. /**
  48683. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48684. * @return the new query
  48685. */
  48686. createQuery(): WebGLQuery;
  48687. /**
  48688. * Delete and release a webGL query
  48689. * @param query defines the query to delete
  48690. * @return the current engine
  48691. */
  48692. deleteQuery(query: WebGLQuery): Engine;
  48693. /**
  48694. * Check if a given query has resolved and got its value
  48695. * @param query defines the query to check
  48696. * @returns true if the query got its value
  48697. */
  48698. isQueryResultAvailable(query: WebGLQuery): boolean;
  48699. /**
  48700. * Gets the value of a given query
  48701. * @param query defines the query to check
  48702. * @returns the value of the query
  48703. */
  48704. getQueryResult(query: WebGLQuery): number;
  48705. /**
  48706. * Initiates an occlusion query
  48707. * @param algorithmType defines the algorithm to use
  48708. * @param query defines the query to use
  48709. * @returns the current engine
  48710. * @see http://doc.babylonjs.com/features/occlusionquery
  48711. */
  48712. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48713. /**
  48714. * Ends an occlusion query
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. * @param algorithmType defines the algorithm to use
  48717. * @returns the current engine
  48718. */
  48719. endOcclusionQuery(algorithmType: number): Engine;
  48720. /**
  48721. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48722. * Please note that only one query can be issued at a time
  48723. * @returns a time token used to track the time span
  48724. */
  48725. startTimeQuery(): Nullable<_TimeToken>;
  48726. /**
  48727. * Ends a time query
  48728. * @param token defines the token used to measure the time span
  48729. * @returns the time spent (in ns)
  48730. */
  48731. endTimeQuery(token: _TimeToken): int;
  48732. /** @hidden */
  48733. _currentNonTimestampToken: Nullable<_TimeToken>;
  48734. /** @hidden */
  48735. _createTimeQuery(): WebGLQuery;
  48736. /** @hidden */
  48737. _deleteTimeQuery(query: WebGLQuery): void;
  48738. /** @hidden */
  48739. _getGlAlgorithmType(algorithmType: number): number;
  48740. /** @hidden */
  48741. _getTimeQueryResult(query: WebGLQuery): any;
  48742. /** @hidden */
  48743. _getTimeQueryAvailability(query: WebGLQuery): any;
  48744. }
  48745. }
  48746. module "babylonjs/Meshes/abstractMesh" {
  48747. interface AbstractMesh {
  48748. /**
  48749. * Backing filed
  48750. * @hidden
  48751. */
  48752. __occlusionDataStorage: _OcclusionDataStorage;
  48753. /**
  48754. * Access property
  48755. * @hidden
  48756. */
  48757. _occlusionDataStorage: _OcclusionDataStorage;
  48758. /**
  48759. * 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.
  48760. * The default value is -1 which means don't break the query and wait till the result
  48761. * @see http://doc.babylonjs.com/features/occlusionquery
  48762. */
  48763. occlusionRetryCount: number;
  48764. /**
  48765. * 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:
  48766. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48767. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48768. * * 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.
  48769. * @see http://doc.babylonjs.com/features/occlusionquery
  48770. */
  48771. occlusionType: number;
  48772. /**
  48773. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48774. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48775. * * 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.
  48776. * @see http://doc.babylonjs.com/features/occlusionquery
  48777. */
  48778. occlusionQueryAlgorithmType: number;
  48779. /**
  48780. * 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
  48781. * @see http://doc.babylonjs.com/features/occlusionquery
  48782. */
  48783. isOccluded: boolean;
  48784. /**
  48785. * Flag to check the progress status of the query
  48786. * @see http://doc.babylonjs.com/features/occlusionquery
  48787. */
  48788. isOcclusionQueryInProgress: boolean;
  48789. }
  48790. }
  48791. }
  48792. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48793. import { Nullable } from "babylonjs/types";
  48794. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48795. /** @hidden */
  48796. export var _forceTransformFeedbackToBundle: boolean;
  48797. module "babylonjs/Engines/engine" {
  48798. interface Engine {
  48799. /**
  48800. * Creates a webGL transform feedback object
  48801. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48802. * @returns the webGL transform feedback object
  48803. */
  48804. createTransformFeedback(): WebGLTransformFeedback;
  48805. /**
  48806. * Delete a webGL transform feedback object
  48807. * @param value defines the webGL transform feedback object to delete
  48808. */
  48809. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48810. /**
  48811. * Bind a webGL transform feedback object to the webgl context
  48812. * @param value defines the webGL transform feedback object to bind
  48813. */
  48814. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48815. /**
  48816. * Begins a transform feedback operation
  48817. * @param usePoints defines if points or triangles must be used
  48818. */
  48819. beginTransformFeedback(usePoints: boolean): void;
  48820. /**
  48821. * Ends a transform feedback operation
  48822. */
  48823. endTransformFeedback(): void;
  48824. /**
  48825. * Specify the varyings to use with transform feedback
  48826. * @param program defines the associated webGL program
  48827. * @param value defines the list of strings representing the varying names
  48828. */
  48829. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48830. /**
  48831. * Bind a webGL buffer for a transform feedback operation
  48832. * @param value defines the webGL buffer to bind
  48833. */
  48834. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48835. }
  48836. }
  48837. }
  48838. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48839. import { Scene } from "babylonjs/scene";
  48840. import { Engine } from "babylonjs/Engines/engine";
  48841. import { Texture } from "babylonjs/Materials/Textures/texture";
  48842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48843. import "babylonjs/Engines/Extensions/engine.multiRender";
  48844. /**
  48845. * Creation options of the multi render target texture.
  48846. */
  48847. export interface IMultiRenderTargetOptions {
  48848. /**
  48849. * Define if the texture needs to create mip maps after render.
  48850. */
  48851. generateMipMaps?: boolean;
  48852. /**
  48853. * Define the types of all the draw buffers we want to create
  48854. */
  48855. types?: number[];
  48856. /**
  48857. * Define the sampling modes of all the draw buffers we want to create
  48858. */
  48859. samplingModes?: number[];
  48860. /**
  48861. * Define if a depth buffer is required
  48862. */
  48863. generateDepthBuffer?: boolean;
  48864. /**
  48865. * Define if a stencil buffer is required
  48866. */
  48867. generateStencilBuffer?: boolean;
  48868. /**
  48869. * Define if a depth texture is required instead of a depth buffer
  48870. */
  48871. generateDepthTexture?: boolean;
  48872. /**
  48873. * Define the number of desired draw buffers
  48874. */
  48875. textureCount?: number;
  48876. /**
  48877. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48878. */
  48879. doNotChangeAspectRatio?: boolean;
  48880. /**
  48881. * Define the default type of the buffers we are creating
  48882. */
  48883. defaultType?: number;
  48884. }
  48885. /**
  48886. * A multi render target, like a render target provides the ability to render to a texture.
  48887. * Unlike the render target, it can render to several draw buffers in one draw.
  48888. * This is specially interesting in deferred rendering or for any effects requiring more than
  48889. * just one color from a single pass.
  48890. */
  48891. export class MultiRenderTarget extends RenderTargetTexture {
  48892. private _internalTextures;
  48893. private _textures;
  48894. private _multiRenderTargetOptions;
  48895. /**
  48896. * Get if draw buffers are currently supported by the used hardware and browser.
  48897. */
  48898. get isSupported(): boolean;
  48899. /**
  48900. * Get the list of textures generated by the multi render target.
  48901. */
  48902. get textures(): Texture[];
  48903. /**
  48904. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48905. */
  48906. get depthTexture(): Texture;
  48907. /**
  48908. * Set the wrapping mode on U of all the textures we are rendering to.
  48909. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48910. */
  48911. set wrapU(wrap: number);
  48912. /**
  48913. * Set the wrapping mode on V of all the textures we are rendering to.
  48914. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48915. */
  48916. set wrapV(wrap: number);
  48917. /**
  48918. * Instantiate a new multi render target texture.
  48919. * A multi render target, like a render target provides the ability to render to a texture.
  48920. * Unlike the render target, it can render to several draw buffers in one draw.
  48921. * This is specially interesting in deferred rendering or for any effects requiring more than
  48922. * just one color from a single pass.
  48923. * @param name Define the name of the texture
  48924. * @param size Define the size of the buffers to render to
  48925. * @param count Define the number of target we are rendering into
  48926. * @param scene Define the scene the texture belongs to
  48927. * @param options Define the options used to create the multi render target
  48928. */
  48929. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48930. /** @hidden */
  48931. _rebuild(): void;
  48932. private _createInternalTextures;
  48933. private _createTextures;
  48934. /**
  48935. * Define the number of samples used if MSAA is enabled.
  48936. */
  48937. get samples(): number;
  48938. set samples(value: number);
  48939. /**
  48940. * Resize all the textures in the multi render target.
  48941. * Be carrefull as it will recreate all the data in the new texture.
  48942. * @param size Define the new size
  48943. */
  48944. resize(size: any): void;
  48945. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48946. /**
  48947. * Dispose the render targets and their associated resources
  48948. */
  48949. dispose(): void;
  48950. /**
  48951. * Release all the underlying texture used as draw buffers.
  48952. */
  48953. releaseInternalTextures(): void;
  48954. }
  48955. }
  48956. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48958. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48959. import { Nullable } from "babylonjs/types";
  48960. module "babylonjs/Engines/thinEngine" {
  48961. interface ThinEngine {
  48962. /**
  48963. * Unbind a list of render target textures from the webGL context
  48964. * This is used only when drawBuffer extension or webGL2 are active
  48965. * @param textures defines the render target textures to unbind
  48966. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48967. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48968. */
  48969. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48970. /**
  48971. * Create a multi render target texture
  48972. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48973. * @param size defines the size of the texture
  48974. * @param options defines the creation options
  48975. * @returns the cube texture as an InternalTexture
  48976. */
  48977. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48978. /**
  48979. * Update the sample count for a given multiple render target texture
  48980. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48981. * @param textures defines the textures to update
  48982. * @param samples defines the sample count to set
  48983. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48984. */
  48985. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48986. }
  48987. }
  48988. }
  48989. declare module "babylonjs/Engines/Extensions/engine.views" {
  48990. import { Camera } from "babylonjs/Cameras/camera";
  48991. import { Nullable } from "babylonjs/types";
  48992. /**
  48993. * Class used to define an additional view for the engine
  48994. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48995. */
  48996. export class EngineView {
  48997. /** Defines the canvas where to render the view */
  48998. target: HTMLCanvasElement;
  48999. /** Defines an optional camera used to render the view (will use active camera else) */
  49000. camera?: Camera;
  49001. }
  49002. module "babylonjs/Engines/engine" {
  49003. interface Engine {
  49004. /**
  49005. * Gets or sets the HTML element to use for attaching events
  49006. */
  49007. inputElement: Nullable<HTMLElement>;
  49008. /**
  49009. * Gets the current engine view
  49010. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49011. */
  49012. activeView: Nullable<EngineView>;
  49013. /** Gets or sets the list of views */
  49014. views: EngineView[];
  49015. /**
  49016. * Register a new child canvas
  49017. * @param canvas defines the canvas to register
  49018. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49019. * @returns the associated view
  49020. */
  49021. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49022. /**
  49023. * Remove a registered child canvas
  49024. * @param canvas defines the canvas to remove
  49025. * @returns the current engine
  49026. */
  49027. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49028. }
  49029. }
  49030. }
  49031. declare module "babylonjs/Engines/Extensions/index" {
  49032. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49033. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49034. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49035. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49036. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49037. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49038. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49039. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49040. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49041. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49042. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49043. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49044. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49045. export * from "babylonjs/Engines/Extensions/engine.views";
  49046. }
  49047. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49048. import { Nullable } from "babylonjs/types";
  49049. /**
  49050. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49051. */
  49052. export interface CubeMapInfo {
  49053. /**
  49054. * The pixel array for the front face.
  49055. * This is stored in format, left to right, up to down format.
  49056. */
  49057. front: Nullable<ArrayBufferView>;
  49058. /**
  49059. * The pixel array for the back face.
  49060. * This is stored in format, left to right, up to down format.
  49061. */
  49062. back: Nullable<ArrayBufferView>;
  49063. /**
  49064. * The pixel array for the left face.
  49065. * This is stored in format, left to right, up to down format.
  49066. */
  49067. left: Nullable<ArrayBufferView>;
  49068. /**
  49069. * The pixel array for the right face.
  49070. * This is stored in format, left to right, up to down format.
  49071. */
  49072. right: Nullable<ArrayBufferView>;
  49073. /**
  49074. * The pixel array for the up face.
  49075. * This is stored in format, left to right, up to down format.
  49076. */
  49077. up: Nullable<ArrayBufferView>;
  49078. /**
  49079. * The pixel array for the down face.
  49080. * This is stored in format, left to right, up to down format.
  49081. */
  49082. down: Nullable<ArrayBufferView>;
  49083. /**
  49084. * The size of the cubemap stored.
  49085. *
  49086. * Each faces will be size * size pixels.
  49087. */
  49088. size: number;
  49089. /**
  49090. * The format of the texture.
  49091. *
  49092. * RGBA, RGB.
  49093. */
  49094. format: number;
  49095. /**
  49096. * The type of the texture data.
  49097. *
  49098. * UNSIGNED_INT, FLOAT.
  49099. */
  49100. type: number;
  49101. /**
  49102. * Specifies whether the texture is in gamma space.
  49103. */
  49104. gammaSpace: boolean;
  49105. }
  49106. /**
  49107. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49108. */
  49109. export class PanoramaToCubeMapTools {
  49110. private static FACE_FRONT;
  49111. private static FACE_BACK;
  49112. private static FACE_RIGHT;
  49113. private static FACE_LEFT;
  49114. private static FACE_DOWN;
  49115. private static FACE_UP;
  49116. /**
  49117. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49118. *
  49119. * @param float32Array The source data.
  49120. * @param inputWidth The width of the input panorama.
  49121. * @param inputHeight The height of the input panorama.
  49122. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49123. * @return The cubemap data
  49124. */
  49125. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49126. private static CreateCubemapTexture;
  49127. private static CalcProjectionSpherical;
  49128. }
  49129. }
  49130. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49131. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49133. import { Nullable } from "babylonjs/types";
  49134. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49135. /**
  49136. * Helper class dealing with the extraction of spherical polynomial dataArray
  49137. * from a cube map.
  49138. */
  49139. export class CubeMapToSphericalPolynomialTools {
  49140. private static FileFaces;
  49141. /**
  49142. * Converts a texture to the according Spherical Polynomial data.
  49143. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49144. *
  49145. * @param texture The texture to extract the information from.
  49146. * @return The Spherical Polynomial data.
  49147. */
  49148. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49149. /**
  49150. * Converts a cubemap to the according Spherical Polynomial data.
  49151. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49152. *
  49153. * @param cubeInfo The Cube map to extract the information from.
  49154. * @return The Spherical Polynomial data.
  49155. */
  49156. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49157. }
  49158. }
  49159. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49160. import { Nullable } from "babylonjs/types";
  49161. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49162. module "babylonjs/Materials/Textures/baseTexture" {
  49163. interface BaseTexture {
  49164. /**
  49165. * Get the polynomial representation of the texture data.
  49166. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49167. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49168. */
  49169. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49170. }
  49171. }
  49172. }
  49173. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49174. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49175. /** @hidden */
  49176. export var rgbdEncodePixelShader: {
  49177. name: string;
  49178. shader: string;
  49179. };
  49180. }
  49181. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49182. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49183. /** @hidden */
  49184. export var rgbdDecodePixelShader: {
  49185. name: string;
  49186. shader: string;
  49187. };
  49188. }
  49189. declare module "babylonjs/Misc/environmentTextureTools" {
  49190. import { Nullable } from "babylonjs/types";
  49191. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49193. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49194. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49195. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49196. import "babylonjs/Shaders/rgbdEncode.fragment";
  49197. import "babylonjs/Shaders/rgbdDecode.fragment";
  49198. /**
  49199. * Raw texture data and descriptor sufficient for WebGL texture upload
  49200. */
  49201. export interface EnvironmentTextureInfo {
  49202. /**
  49203. * Version of the environment map
  49204. */
  49205. version: number;
  49206. /**
  49207. * Width of image
  49208. */
  49209. width: number;
  49210. /**
  49211. * Irradiance information stored in the file.
  49212. */
  49213. irradiance: any;
  49214. /**
  49215. * Specular information stored in the file.
  49216. */
  49217. specular: any;
  49218. }
  49219. /**
  49220. * Defines One Image in the file. It requires only the position in the file
  49221. * as well as the length.
  49222. */
  49223. interface BufferImageData {
  49224. /**
  49225. * Length of the image data.
  49226. */
  49227. length: number;
  49228. /**
  49229. * Position of the data from the null terminator delimiting the end of the JSON.
  49230. */
  49231. position: number;
  49232. }
  49233. /**
  49234. * Defines the specular data enclosed in the file.
  49235. * This corresponds to the version 1 of the data.
  49236. */
  49237. export interface EnvironmentTextureSpecularInfoV1 {
  49238. /**
  49239. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49240. */
  49241. specularDataPosition?: number;
  49242. /**
  49243. * This contains all the images data needed to reconstruct the cubemap.
  49244. */
  49245. mipmaps: Array<BufferImageData>;
  49246. /**
  49247. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49248. */
  49249. lodGenerationScale: number;
  49250. }
  49251. /**
  49252. * Sets of helpers addressing the serialization and deserialization of environment texture
  49253. * stored in a BabylonJS env file.
  49254. * Those files are usually stored as .env files.
  49255. */
  49256. export class EnvironmentTextureTools {
  49257. /**
  49258. * Magic number identifying the env file.
  49259. */
  49260. private static _MagicBytes;
  49261. /**
  49262. * Gets the environment info from an env file.
  49263. * @param data The array buffer containing the .env bytes.
  49264. * @returns the environment file info (the json header) if successfully parsed.
  49265. */
  49266. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49267. /**
  49268. * Creates an environment texture from a loaded cube texture.
  49269. * @param texture defines the cube texture to convert in env file
  49270. * @return a promise containing the environment data if succesfull.
  49271. */
  49272. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49273. /**
  49274. * Creates a JSON representation of the spherical data.
  49275. * @param texture defines the texture containing the polynomials
  49276. * @return the JSON representation of the spherical info
  49277. */
  49278. private static _CreateEnvTextureIrradiance;
  49279. /**
  49280. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49281. * @param data the image data
  49282. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49283. * @return the views described by info providing access to the underlying buffer
  49284. */
  49285. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49286. /**
  49287. * Uploads the texture info contained in the env file to the GPU.
  49288. * @param texture defines the internal texture to upload to
  49289. * @param data defines the data to load
  49290. * @param info defines the texture info retrieved through the GetEnvInfo method
  49291. * @returns a promise
  49292. */
  49293. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49294. private static _OnImageReadyAsync;
  49295. /**
  49296. * Uploads the levels of image data to the GPU.
  49297. * @param texture defines the internal texture to upload to
  49298. * @param imageData defines the array buffer views of image data [mipmap][face]
  49299. * @returns a promise
  49300. */
  49301. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49302. /**
  49303. * Uploads spherical polynomials information to the texture.
  49304. * @param texture defines the texture we are trying to upload the information to
  49305. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49306. */
  49307. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49308. /** @hidden */
  49309. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49310. }
  49311. }
  49312. declare module "babylonjs/Maths/math.vertexFormat" {
  49313. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49314. /**
  49315. * Contains position and normal vectors for a vertex
  49316. */
  49317. export class PositionNormalVertex {
  49318. /** the position of the vertex (defaut: 0,0,0) */
  49319. position: Vector3;
  49320. /** the normal of the vertex (defaut: 0,1,0) */
  49321. normal: Vector3;
  49322. /**
  49323. * Creates a PositionNormalVertex
  49324. * @param position the position of the vertex (defaut: 0,0,0)
  49325. * @param normal the normal of the vertex (defaut: 0,1,0)
  49326. */
  49327. constructor(
  49328. /** the position of the vertex (defaut: 0,0,0) */
  49329. position?: Vector3,
  49330. /** the normal of the vertex (defaut: 0,1,0) */
  49331. normal?: Vector3);
  49332. /**
  49333. * Clones the PositionNormalVertex
  49334. * @returns the cloned PositionNormalVertex
  49335. */
  49336. clone(): PositionNormalVertex;
  49337. }
  49338. /**
  49339. * Contains position, normal and uv vectors for a vertex
  49340. */
  49341. export class PositionNormalTextureVertex {
  49342. /** the position of the vertex (defaut: 0,0,0) */
  49343. position: Vector3;
  49344. /** the normal of the vertex (defaut: 0,1,0) */
  49345. normal: Vector3;
  49346. /** the uv of the vertex (default: 0,0) */
  49347. uv: Vector2;
  49348. /**
  49349. * Creates a PositionNormalTextureVertex
  49350. * @param position the position of the vertex (defaut: 0,0,0)
  49351. * @param normal the normal of the vertex (defaut: 0,1,0)
  49352. * @param uv the uv of the vertex (default: 0,0)
  49353. */
  49354. constructor(
  49355. /** the position of the vertex (defaut: 0,0,0) */
  49356. position?: Vector3,
  49357. /** the normal of the vertex (defaut: 0,1,0) */
  49358. normal?: Vector3,
  49359. /** the uv of the vertex (default: 0,0) */
  49360. uv?: Vector2);
  49361. /**
  49362. * Clones the PositionNormalTextureVertex
  49363. * @returns the cloned PositionNormalTextureVertex
  49364. */
  49365. clone(): PositionNormalTextureVertex;
  49366. }
  49367. }
  49368. declare module "babylonjs/Maths/math" {
  49369. export * from "babylonjs/Maths/math.axis";
  49370. export * from "babylonjs/Maths/math.color";
  49371. export * from "babylonjs/Maths/math.constants";
  49372. export * from "babylonjs/Maths/math.frustum";
  49373. export * from "babylonjs/Maths/math.path";
  49374. export * from "babylonjs/Maths/math.plane";
  49375. export * from "babylonjs/Maths/math.size";
  49376. export * from "babylonjs/Maths/math.vector";
  49377. export * from "babylonjs/Maths/math.vertexFormat";
  49378. export * from "babylonjs/Maths/math.viewport";
  49379. }
  49380. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49381. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49382. /** @hidden */
  49383. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49384. private _genericAttributeLocation;
  49385. private _varyingLocationCount;
  49386. private _varyingLocationMap;
  49387. private _replacements;
  49388. private _textureCount;
  49389. private _uniforms;
  49390. lineProcessor(line: string): string;
  49391. attributeProcessor(attribute: string): string;
  49392. varyingProcessor(varying: string, isFragment: boolean): string;
  49393. uniformProcessor(uniform: string): string;
  49394. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49395. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49396. }
  49397. }
  49398. declare module "babylonjs/Engines/nativeEngine" {
  49399. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49400. import { Engine } from "babylonjs/Engines/engine";
  49401. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49402. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49404. import { Effect } from "babylonjs/Materials/effect";
  49405. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49406. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49407. import { IColor4Like } from "babylonjs/Maths/math.like";
  49408. import { Scene } from "babylonjs/scene";
  49409. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49410. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49411. /**
  49412. * Container for accessors for natively-stored mesh data buffers.
  49413. */
  49414. class NativeDataBuffer extends DataBuffer {
  49415. /**
  49416. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49417. */
  49418. nativeIndexBuffer?: any;
  49419. /**
  49420. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49421. */
  49422. nativeVertexBuffer?: any;
  49423. }
  49424. /** @hidden */
  49425. class NativeTexture extends InternalTexture {
  49426. getInternalTexture(): InternalTexture;
  49427. getViewCount(): number;
  49428. }
  49429. /** @hidden */
  49430. export class NativeEngine extends Engine {
  49431. private readonly _native;
  49432. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49433. private readonly INVALID_HANDLE;
  49434. getHardwareScalingLevel(): number;
  49435. constructor();
  49436. /**
  49437. * Can be used to override the current requestAnimationFrame requester.
  49438. * @hidden
  49439. */
  49440. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49441. /**
  49442. * Override default engine behavior.
  49443. * @param color
  49444. * @param backBuffer
  49445. * @param depth
  49446. * @param stencil
  49447. */
  49448. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49449. /**
  49450. * Gets host document
  49451. * @returns the host document object
  49452. */
  49453. getHostDocument(): Nullable<Document>;
  49454. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49455. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49456. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49457. recordVertexArrayObject(vertexBuffers: {
  49458. [key: string]: VertexBuffer;
  49459. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49460. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49461. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49462. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49463. /**
  49464. * Draw a list of indexed primitives
  49465. * @param fillMode defines the primitive to use
  49466. * @param indexStart defines the starting index
  49467. * @param indexCount defines the number of index to draw
  49468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49469. */
  49470. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49471. /**
  49472. * Draw a list of unindexed primitives
  49473. * @param fillMode defines the primitive to use
  49474. * @param verticesStart defines the index of first vertex to draw
  49475. * @param verticesCount defines the count of vertices to draw
  49476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49477. */
  49478. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49479. createPipelineContext(): IPipelineContext;
  49480. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49481. /** @hidden */
  49482. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49483. /** @hidden */
  49484. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49485. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49486. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49487. protected _setProgram(program: WebGLProgram): void;
  49488. _releaseEffect(effect: Effect): void;
  49489. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49490. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49491. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49492. bindSamplers(effect: Effect): void;
  49493. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49494. getRenderWidth(useScreen?: boolean): number;
  49495. getRenderHeight(useScreen?: boolean): number;
  49496. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49497. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49498. /**
  49499. * Set the z offset to apply to current rendering
  49500. * @param value defines the offset to apply
  49501. */
  49502. setZOffset(value: number): void;
  49503. /**
  49504. * Gets the current value of the zOffset
  49505. * @returns the current zOffset state
  49506. */
  49507. getZOffset(): number;
  49508. /**
  49509. * Enable or disable depth buffering
  49510. * @param enable defines the state to set
  49511. */
  49512. setDepthBuffer(enable: boolean): void;
  49513. /**
  49514. * Gets a boolean indicating if depth writing is enabled
  49515. * @returns the current depth writing state
  49516. */
  49517. getDepthWrite(): boolean;
  49518. /**
  49519. * Enable or disable depth writing
  49520. * @param enable defines the state to set
  49521. */
  49522. setDepthWrite(enable: boolean): void;
  49523. /**
  49524. * Enable or disable color writing
  49525. * @param enable defines the state to set
  49526. */
  49527. setColorWrite(enable: boolean): void;
  49528. /**
  49529. * Gets a boolean indicating if color writing is enabled
  49530. * @returns the current color writing state
  49531. */
  49532. getColorWrite(): boolean;
  49533. /**
  49534. * Sets alpha constants used by some alpha blending modes
  49535. * @param r defines the red component
  49536. * @param g defines the green component
  49537. * @param b defines the blue component
  49538. * @param a defines the alpha component
  49539. */
  49540. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49541. /**
  49542. * Sets the current alpha mode
  49543. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49544. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49545. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49546. */
  49547. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49548. /**
  49549. * Gets the current alpha mode
  49550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49551. * @returns the current alpha mode
  49552. */
  49553. getAlphaMode(): number;
  49554. setInt(uniform: WebGLUniformLocation, int: number): void;
  49555. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49556. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49557. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49558. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49559. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49560. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49561. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49562. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49563. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49564. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49565. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49566. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49567. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49568. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49569. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49570. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49571. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49572. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49573. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49574. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49575. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49576. wipeCaches(bruteForce?: boolean): void;
  49577. _createTexture(): WebGLTexture;
  49578. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49579. /**
  49580. * Usually called from BABYLON.Texture.ts.
  49581. * Passed information to create a WebGLTexture
  49582. * @param urlArg defines a value which contains one of the following:
  49583. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49584. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49585. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49587. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49588. * @param scene needed for loading to the correct scene
  49589. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49590. * @param onLoad optional callback to be called upon successful completion
  49591. * @param onError optional callback to be called upon failure
  49592. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49593. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49594. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49595. * @param forcedExtension defines the extension to use to pick the right loader
  49596. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49597. */
  49598. 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;
  49599. /**
  49600. * Creates a cube texture
  49601. * @param rootUrl defines the url where the files to load is located
  49602. * @param scene defines the current scene
  49603. * @param files defines the list of files to load (1 per face)
  49604. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49605. * @param onLoad defines an optional callback raised when the texture is loaded
  49606. * @param onError defines an optional callback raised if there is an issue to load the texture
  49607. * @param format defines the format of the data
  49608. * @param forcedExtension defines the extension to use to pick the right loader
  49609. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49612. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49613. * @returns the cube texture as an InternalTexture
  49614. */
  49615. 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;
  49616. private _getSamplingFilter;
  49617. private static _GetNativeTextureFormat;
  49618. createRenderTargetTexture(size: number | {
  49619. width: number;
  49620. height: number;
  49621. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49622. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49623. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49624. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49625. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49626. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49627. /**
  49628. * Updates a dynamic vertex buffer.
  49629. * @param vertexBuffer the vertex buffer to update
  49630. * @param data the data used to update the vertex buffer
  49631. * @param byteOffset the byte offset of the data (optional)
  49632. * @param byteLength the byte length of the data (optional)
  49633. */
  49634. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49635. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49636. private _updateAnisotropicLevel;
  49637. private _getAddressMode;
  49638. /** @hidden */
  49639. _bindTexture(channel: number, texture: InternalTexture): void;
  49640. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49641. releaseEffects(): void;
  49642. /** @hidden */
  49643. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49644. /** @hidden */
  49645. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49646. /** @hidden */
  49647. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49648. /** @hidden */
  49649. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49650. }
  49651. }
  49652. declare module "babylonjs/Engines/index" {
  49653. export * from "babylonjs/Engines/constants";
  49654. export * from "babylonjs/Engines/engineCapabilities";
  49655. export * from "babylonjs/Engines/instancingAttributeInfo";
  49656. export * from "babylonjs/Engines/thinEngine";
  49657. export * from "babylonjs/Engines/engine";
  49658. export * from "babylonjs/Engines/engineStore";
  49659. export * from "babylonjs/Engines/nullEngine";
  49660. export * from "babylonjs/Engines/Extensions/index";
  49661. export * from "babylonjs/Engines/IPipelineContext";
  49662. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49663. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49664. export * from "babylonjs/Engines/nativeEngine";
  49665. }
  49666. declare module "babylonjs/Events/clipboardEvents" {
  49667. /**
  49668. * Gather the list of clipboard event types as constants.
  49669. */
  49670. export class ClipboardEventTypes {
  49671. /**
  49672. * The clipboard event is fired when a copy command is active (pressed).
  49673. */
  49674. static readonly COPY: number;
  49675. /**
  49676. * The clipboard event is fired when a cut command is active (pressed).
  49677. */
  49678. static readonly CUT: number;
  49679. /**
  49680. * The clipboard event is fired when a paste command is active (pressed).
  49681. */
  49682. static readonly PASTE: number;
  49683. }
  49684. /**
  49685. * This class is used to store clipboard related info for the onClipboardObservable event.
  49686. */
  49687. export class ClipboardInfo {
  49688. /**
  49689. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49690. */
  49691. type: number;
  49692. /**
  49693. * Defines the related dom event
  49694. */
  49695. event: ClipboardEvent;
  49696. /**
  49697. *Creates an instance of ClipboardInfo.
  49698. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49699. * @param event Defines the related dom event
  49700. */
  49701. constructor(
  49702. /**
  49703. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49704. */
  49705. type: number,
  49706. /**
  49707. * Defines the related dom event
  49708. */
  49709. event: ClipboardEvent);
  49710. /**
  49711. * Get the clipboard event's type from the keycode.
  49712. * @param keyCode Defines the keyCode for the current keyboard event.
  49713. * @return {number}
  49714. */
  49715. static GetTypeFromCharacter(keyCode: number): number;
  49716. }
  49717. }
  49718. declare module "babylonjs/Events/index" {
  49719. export * from "babylonjs/Events/keyboardEvents";
  49720. export * from "babylonjs/Events/pointerEvents";
  49721. export * from "babylonjs/Events/clipboardEvents";
  49722. }
  49723. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49724. import { Scene } from "babylonjs/scene";
  49725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49726. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49727. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49728. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49729. /**
  49730. * Google Daydream controller
  49731. */
  49732. export class DaydreamController extends WebVRController {
  49733. /**
  49734. * Base Url for the controller model.
  49735. */
  49736. static MODEL_BASE_URL: string;
  49737. /**
  49738. * File name for the controller model.
  49739. */
  49740. static MODEL_FILENAME: string;
  49741. /**
  49742. * Gamepad Id prefix used to identify Daydream Controller.
  49743. */
  49744. static readonly GAMEPAD_ID_PREFIX: string;
  49745. /**
  49746. * Creates a new DaydreamController from a gamepad
  49747. * @param vrGamepad the gamepad that the controller should be created from
  49748. */
  49749. constructor(vrGamepad: any);
  49750. /**
  49751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49752. * @param scene scene in which to add meshes
  49753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49754. */
  49755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49756. /**
  49757. * Called once for each button that changed state since the last frame
  49758. * @param buttonIdx Which button index changed
  49759. * @param state New state of the button
  49760. * @param changes Which properties on the state changed since last frame
  49761. */
  49762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49763. }
  49764. }
  49765. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49766. import { Scene } from "babylonjs/scene";
  49767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49768. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49769. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49770. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49771. /**
  49772. * Gear VR Controller
  49773. */
  49774. export class GearVRController extends WebVRController {
  49775. /**
  49776. * Base Url for the controller model.
  49777. */
  49778. static MODEL_BASE_URL: string;
  49779. /**
  49780. * File name for the controller model.
  49781. */
  49782. static MODEL_FILENAME: string;
  49783. /**
  49784. * Gamepad Id prefix used to identify this controller.
  49785. */
  49786. static readonly GAMEPAD_ID_PREFIX: string;
  49787. private readonly _buttonIndexToObservableNameMap;
  49788. /**
  49789. * Creates a new GearVRController from a gamepad
  49790. * @param vrGamepad the gamepad that the controller should be created from
  49791. */
  49792. constructor(vrGamepad: any);
  49793. /**
  49794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49795. * @param scene scene in which to add meshes
  49796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49797. */
  49798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49799. /**
  49800. * Called once for each button that changed state since the last frame
  49801. * @param buttonIdx Which button index changed
  49802. * @param state New state of the button
  49803. * @param changes Which properties on the state changed since last frame
  49804. */
  49805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49806. }
  49807. }
  49808. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49809. import { Scene } from "babylonjs/scene";
  49810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49811. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49812. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49813. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49814. /**
  49815. * Generic Controller
  49816. */
  49817. export class GenericController extends WebVRController {
  49818. /**
  49819. * Base Url for the controller model.
  49820. */
  49821. static readonly MODEL_BASE_URL: string;
  49822. /**
  49823. * File name for the controller model.
  49824. */
  49825. static readonly MODEL_FILENAME: string;
  49826. /**
  49827. * Creates a new GenericController from a gamepad
  49828. * @param vrGamepad the gamepad that the controller should be created from
  49829. */
  49830. constructor(vrGamepad: any);
  49831. /**
  49832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49833. * @param scene scene in which to add meshes
  49834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49835. */
  49836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49837. /**
  49838. * Called once for each button that changed state since the last frame
  49839. * @param buttonIdx Which button index changed
  49840. * @param state New state of the button
  49841. * @param changes Which properties on the state changed since last frame
  49842. */
  49843. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49844. }
  49845. }
  49846. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49847. import { Observable } from "babylonjs/Misc/observable";
  49848. import { Scene } from "babylonjs/scene";
  49849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49850. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49851. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49852. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49853. /**
  49854. * Oculus Touch Controller
  49855. */
  49856. export class OculusTouchController extends WebVRController {
  49857. /**
  49858. * Base Url for the controller model.
  49859. */
  49860. static MODEL_BASE_URL: string;
  49861. /**
  49862. * File name for the left controller model.
  49863. */
  49864. static MODEL_LEFT_FILENAME: string;
  49865. /**
  49866. * File name for the right controller model.
  49867. */
  49868. static MODEL_RIGHT_FILENAME: string;
  49869. /**
  49870. * Base Url for the Quest controller model.
  49871. */
  49872. static QUEST_MODEL_BASE_URL: string;
  49873. /**
  49874. * @hidden
  49875. * If the controllers are running on a device that needs the updated Quest controller models
  49876. */
  49877. static _IsQuest: boolean;
  49878. /**
  49879. * Fired when the secondary trigger on this controller is modified
  49880. */
  49881. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49882. /**
  49883. * Fired when the thumb rest on this controller is modified
  49884. */
  49885. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49886. /**
  49887. * Creates a new OculusTouchController from a gamepad
  49888. * @param vrGamepad the gamepad that the controller should be created from
  49889. */
  49890. constructor(vrGamepad: any);
  49891. /**
  49892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49893. * @param scene scene in which to add meshes
  49894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49895. */
  49896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49897. /**
  49898. * Fired when the A button on this controller is modified
  49899. */
  49900. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49901. /**
  49902. * Fired when the B button on this controller is modified
  49903. */
  49904. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49905. /**
  49906. * Fired when the X button on this controller is modified
  49907. */
  49908. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49909. /**
  49910. * Fired when the Y button on this controller is modified
  49911. */
  49912. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49913. /**
  49914. * Called once for each button that changed state since the last frame
  49915. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49916. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49917. * 2) secondary trigger (same)
  49918. * 3) A (right) X (left), touch, pressed = value
  49919. * 4) B / Y
  49920. * 5) thumb rest
  49921. * @param buttonIdx Which button index changed
  49922. * @param state New state of the button
  49923. * @param changes Which properties on the state changed since last frame
  49924. */
  49925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49926. }
  49927. }
  49928. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49929. import { Scene } from "babylonjs/scene";
  49930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49931. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49932. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49933. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49934. import { Observable } from "babylonjs/Misc/observable";
  49935. /**
  49936. * Vive Controller
  49937. */
  49938. export class ViveController extends WebVRController {
  49939. /**
  49940. * Base Url for the controller model.
  49941. */
  49942. static MODEL_BASE_URL: string;
  49943. /**
  49944. * File name for the controller model.
  49945. */
  49946. static MODEL_FILENAME: string;
  49947. /**
  49948. * Creates a new ViveController from a gamepad
  49949. * @param vrGamepad the gamepad that the controller should be created from
  49950. */
  49951. constructor(vrGamepad: any);
  49952. /**
  49953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49954. * @param scene scene in which to add meshes
  49955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49956. */
  49957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49958. /**
  49959. * Fired when the left button on this controller is modified
  49960. */
  49961. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49962. /**
  49963. * Fired when the right button on this controller is modified
  49964. */
  49965. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49966. /**
  49967. * Fired when the menu button on this controller is modified
  49968. */
  49969. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49970. /**
  49971. * Called once for each button that changed state since the last frame
  49972. * Vive mapping:
  49973. * 0: touchpad
  49974. * 1: trigger
  49975. * 2: left AND right buttons
  49976. * 3: menu button
  49977. * @param buttonIdx Which button index changed
  49978. * @param state New state of the button
  49979. * @param changes Which properties on the state changed since last frame
  49980. */
  49981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49982. }
  49983. }
  49984. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49985. import { Observable } from "babylonjs/Misc/observable";
  49986. import { Scene } from "babylonjs/scene";
  49987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49988. import { Ray } from "babylonjs/Culling/ray";
  49989. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49990. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49991. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49992. /**
  49993. * Defines the WindowsMotionController object that the state of the windows motion controller
  49994. */
  49995. export class WindowsMotionController extends WebVRController {
  49996. /**
  49997. * The base url used to load the left and right controller models
  49998. */
  49999. static MODEL_BASE_URL: string;
  50000. /**
  50001. * The name of the left controller model file
  50002. */
  50003. static MODEL_LEFT_FILENAME: string;
  50004. /**
  50005. * The name of the right controller model file
  50006. */
  50007. static MODEL_RIGHT_FILENAME: string;
  50008. /**
  50009. * The controller name prefix for this controller type
  50010. */
  50011. static readonly GAMEPAD_ID_PREFIX: string;
  50012. /**
  50013. * The controller id pattern for this controller type
  50014. */
  50015. private static readonly GAMEPAD_ID_PATTERN;
  50016. private _loadedMeshInfo;
  50017. protected readonly _mapping: {
  50018. buttons: string[];
  50019. buttonMeshNames: {
  50020. 'trigger': string;
  50021. 'menu': string;
  50022. 'grip': string;
  50023. 'thumbstick': string;
  50024. 'trackpad': string;
  50025. };
  50026. buttonObservableNames: {
  50027. 'trigger': string;
  50028. 'menu': string;
  50029. 'grip': string;
  50030. 'thumbstick': string;
  50031. 'trackpad': string;
  50032. };
  50033. axisMeshNames: string[];
  50034. pointingPoseMeshName: string;
  50035. };
  50036. /**
  50037. * Fired when the trackpad on this controller is clicked
  50038. */
  50039. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50040. /**
  50041. * Fired when the trackpad on this controller is modified
  50042. */
  50043. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50044. /**
  50045. * The current x and y values of this controller's trackpad
  50046. */
  50047. trackpad: StickValues;
  50048. /**
  50049. * Creates a new WindowsMotionController from a gamepad
  50050. * @param vrGamepad the gamepad that the controller should be created from
  50051. */
  50052. constructor(vrGamepad: any);
  50053. /**
  50054. * Fired when the trigger on this controller is modified
  50055. */
  50056. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50057. /**
  50058. * Fired when the menu button on this controller is modified
  50059. */
  50060. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50061. /**
  50062. * Fired when the grip button on this controller is modified
  50063. */
  50064. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50065. /**
  50066. * Fired when the thumbstick button on this controller is modified
  50067. */
  50068. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50069. /**
  50070. * Fired when the touchpad button on this controller is modified
  50071. */
  50072. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50073. /**
  50074. * Fired when the touchpad values on this controller are modified
  50075. */
  50076. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50077. protected _updateTrackpad(): void;
  50078. /**
  50079. * Called once per frame by the engine.
  50080. */
  50081. update(): void;
  50082. /**
  50083. * Called once for each button that changed state since the last frame
  50084. * @param buttonIdx Which button index changed
  50085. * @param state New state of the button
  50086. * @param changes Which properties on the state changed since last frame
  50087. */
  50088. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50089. /**
  50090. * Moves the buttons on the controller mesh based on their current state
  50091. * @param buttonName the name of the button to move
  50092. * @param buttonValue the value of the button which determines the buttons new position
  50093. */
  50094. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50095. /**
  50096. * Moves the axis on the controller mesh based on its current state
  50097. * @param axis the index of the axis
  50098. * @param axisValue the value of the axis which determines the meshes new position
  50099. * @hidden
  50100. */
  50101. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50102. /**
  50103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50104. * @param scene scene in which to add meshes
  50105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50106. */
  50107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50108. /**
  50109. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50110. * can be transformed by button presses and axes values, based on this._mapping.
  50111. *
  50112. * @param scene scene in which the meshes exist
  50113. * @param meshes list of meshes that make up the controller model to process
  50114. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50115. */
  50116. private processModel;
  50117. private createMeshInfo;
  50118. /**
  50119. * Gets the ray of the controller in the direction the controller is pointing
  50120. * @param length the length the resulting ray should be
  50121. * @returns a ray in the direction the controller is pointing
  50122. */
  50123. getForwardRay(length?: number): Ray;
  50124. /**
  50125. * Disposes of the controller
  50126. */
  50127. dispose(): void;
  50128. }
  50129. /**
  50130. * This class represents a new windows motion controller in XR.
  50131. */
  50132. export class XRWindowsMotionController extends WindowsMotionController {
  50133. /**
  50134. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50135. */
  50136. protected readonly _mapping: {
  50137. buttons: string[];
  50138. buttonMeshNames: {
  50139. 'trigger': string;
  50140. 'menu': string;
  50141. 'grip': string;
  50142. 'thumbstick': string;
  50143. 'trackpad': string;
  50144. };
  50145. buttonObservableNames: {
  50146. 'trigger': string;
  50147. 'menu': string;
  50148. 'grip': string;
  50149. 'thumbstick': string;
  50150. 'trackpad': string;
  50151. };
  50152. axisMeshNames: string[];
  50153. pointingPoseMeshName: string;
  50154. };
  50155. /**
  50156. * Construct a new XR-Based windows motion controller
  50157. *
  50158. * @param gamepadInfo the gamepad object from the browser
  50159. */
  50160. constructor(gamepadInfo: any);
  50161. /**
  50162. * holds the thumbstick values (X,Y)
  50163. */
  50164. thumbstickValues: StickValues;
  50165. /**
  50166. * Fired when the thumbstick on this controller is clicked
  50167. */
  50168. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50169. /**
  50170. * Fired when the thumbstick on this controller is modified
  50171. */
  50172. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50173. /**
  50174. * Fired when the touchpad button on this controller is modified
  50175. */
  50176. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50177. /**
  50178. * Fired when the touchpad values on this controller are modified
  50179. */
  50180. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50181. /**
  50182. * Fired when the thumbstick button on this controller is modified
  50183. * here to prevent breaking changes
  50184. */
  50185. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50186. /**
  50187. * updating the thumbstick(!) and not the trackpad.
  50188. * This is named this way due to the difference between WebVR and XR and to avoid
  50189. * changing the parent class.
  50190. */
  50191. protected _updateTrackpad(): void;
  50192. /**
  50193. * Disposes the class with joy
  50194. */
  50195. dispose(): void;
  50196. }
  50197. }
  50198. declare module "babylonjs/Gamepads/Controllers/index" {
  50199. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50200. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50201. export * from "babylonjs/Gamepads/Controllers/genericController";
  50202. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50203. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50204. export * from "babylonjs/Gamepads/Controllers/viveController";
  50205. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50206. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50207. }
  50208. declare module "babylonjs/Gamepads/index" {
  50209. export * from "babylonjs/Gamepads/Controllers/index";
  50210. export * from "babylonjs/Gamepads/gamepad";
  50211. export * from "babylonjs/Gamepads/gamepadManager";
  50212. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50213. export * from "babylonjs/Gamepads/xboxGamepad";
  50214. export * from "babylonjs/Gamepads/dualShockGamepad";
  50215. }
  50216. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50217. import { Scene } from "babylonjs/scene";
  50218. import { Vector4 } from "babylonjs/Maths/math.vector";
  50219. import { Color4 } from "babylonjs/Maths/math.color";
  50220. import { Mesh } from "babylonjs/Meshes/mesh";
  50221. import { Nullable } from "babylonjs/types";
  50222. /**
  50223. * Class containing static functions to help procedurally build meshes
  50224. */
  50225. export class PolyhedronBuilder {
  50226. /**
  50227. * Creates a polyhedron mesh
  50228. * * 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
  50229. * * The parameter `size` (positive float, default 1) sets the polygon size
  50230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50231. * * 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`
  50232. * * 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
  50233. * * 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)`)
  50234. * * 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
  50235. * * 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
  50236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50239. * @param name defines the name of the mesh
  50240. * @param options defines the options used to create the mesh
  50241. * @param scene defines the hosting scene
  50242. * @returns the polyhedron mesh
  50243. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50244. */
  50245. static CreatePolyhedron(name: string, options: {
  50246. type?: number;
  50247. size?: number;
  50248. sizeX?: number;
  50249. sizeY?: number;
  50250. sizeZ?: number;
  50251. custom?: any;
  50252. faceUV?: Vector4[];
  50253. faceColors?: Color4[];
  50254. flat?: boolean;
  50255. updatable?: boolean;
  50256. sideOrientation?: number;
  50257. frontUVs?: Vector4;
  50258. backUVs?: Vector4;
  50259. }, scene?: Nullable<Scene>): Mesh;
  50260. }
  50261. }
  50262. declare module "babylonjs/Gizmos/scaleGizmo" {
  50263. import { Observable } from "babylonjs/Misc/observable";
  50264. import { Nullable } from "babylonjs/types";
  50265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50266. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50267. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50269. /**
  50270. * Gizmo that enables scaling a mesh along 3 axis
  50271. */
  50272. export class ScaleGizmo extends Gizmo {
  50273. /**
  50274. * Internal gizmo used for interactions on the x axis
  50275. */
  50276. xGizmo: AxisScaleGizmo;
  50277. /**
  50278. * Internal gizmo used for interactions on the y axis
  50279. */
  50280. yGizmo: AxisScaleGizmo;
  50281. /**
  50282. * Internal gizmo used for interactions on the z axis
  50283. */
  50284. zGizmo: AxisScaleGizmo;
  50285. /**
  50286. * Internal gizmo used to scale all axis equally
  50287. */
  50288. uniformScaleGizmo: AxisScaleGizmo;
  50289. private _meshAttached;
  50290. private _updateGizmoRotationToMatchAttachedMesh;
  50291. private _snapDistance;
  50292. private _scaleRatio;
  50293. private _uniformScalingMesh;
  50294. private _octahedron;
  50295. private _sensitivity;
  50296. /** Fires an event when any of it's sub gizmos are dragged */
  50297. onDragStartObservable: Observable<unknown>;
  50298. /** Fires an event when any of it's sub gizmos are released from dragging */
  50299. onDragEndObservable: Observable<unknown>;
  50300. get attachedMesh(): Nullable<AbstractMesh>;
  50301. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50302. /**
  50303. * Creates a ScaleGizmo
  50304. * @param gizmoLayer The utility layer the gizmo will be added to
  50305. */
  50306. constructor(gizmoLayer?: UtilityLayerRenderer);
  50307. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50308. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50309. /**
  50310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50311. */
  50312. set snapDistance(value: number);
  50313. get snapDistance(): number;
  50314. /**
  50315. * Ratio for the scale of the gizmo (Default: 1)
  50316. */
  50317. set scaleRatio(value: number);
  50318. get scaleRatio(): number;
  50319. /**
  50320. * Sensitivity factor for dragging (Default: 1)
  50321. */
  50322. set sensitivity(value: number);
  50323. get sensitivity(): number;
  50324. /**
  50325. * Disposes of the gizmo
  50326. */
  50327. dispose(): void;
  50328. }
  50329. }
  50330. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50331. import { Observable } from "babylonjs/Misc/observable";
  50332. import { Nullable } from "babylonjs/types";
  50333. import { Vector3 } from "babylonjs/Maths/math.vector";
  50334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50335. import { Mesh } from "babylonjs/Meshes/mesh";
  50336. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50337. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50339. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50340. import { Color3 } from "babylonjs/Maths/math.color";
  50341. /**
  50342. * Single axis scale gizmo
  50343. */
  50344. export class AxisScaleGizmo extends Gizmo {
  50345. /**
  50346. * Drag behavior responsible for the gizmos dragging interactions
  50347. */
  50348. dragBehavior: PointerDragBehavior;
  50349. private _pointerObserver;
  50350. /**
  50351. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50352. */
  50353. snapDistance: number;
  50354. /**
  50355. * Event that fires each time the gizmo snaps to a new location.
  50356. * * snapDistance is the the change in distance
  50357. */
  50358. onSnapObservable: Observable<{
  50359. snapDistance: number;
  50360. }>;
  50361. /**
  50362. * If the scaling operation should be done on all axis (default: false)
  50363. */
  50364. uniformScaling: boolean;
  50365. /**
  50366. * Custom sensitivity value for the drag strength
  50367. */
  50368. sensitivity: number;
  50369. private _isEnabled;
  50370. private _parent;
  50371. private _arrow;
  50372. private _coloredMaterial;
  50373. private _hoverMaterial;
  50374. /**
  50375. * Creates an AxisScaleGizmo
  50376. * @param gizmoLayer The utility layer the gizmo will be added to
  50377. * @param dragAxis The axis which the gizmo will be able to scale on
  50378. * @param color The color of the gizmo
  50379. */
  50380. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50381. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50382. /**
  50383. * If the gizmo is enabled
  50384. */
  50385. set isEnabled(value: boolean);
  50386. get isEnabled(): boolean;
  50387. /**
  50388. * Disposes of the gizmo
  50389. */
  50390. dispose(): void;
  50391. /**
  50392. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50393. * @param mesh The mesh to replace the default mesh of the gizmo
  50394. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50395. */
  50396. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50397. }
  50398. }
  50399. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50400. import { Observable } from "babylonjs/Misc/observable";
  50401. import { Nullable } from "babylonjs/types";
  50402. import { Vector3 } from "babylonjs/Maths/math.vector";
  50403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50404. import { Mesh } from "babylonjs/Meshes/mesh";
  50405. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50406. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50407. import { Color3 } from "babylonjs/Maths/math.color";
  50408. import "babylonjs/Meshes/Builders/boxBuilder";
  50409. /**
  50410. * Bounding box gizmo
  50411. */
  50412. export class BoundingBoxGizmo extends Gizmo {
  50413. private _lineBoundingBox;
  50414. private _rotateSpheresParent;
  50415. private _scaleBoxesParent;
  50416. private _boundingDimensions;
  50417. private _renderObserver;
  50418. private _pointerObserver;
  50419. private _scaleDragSpeed;
  50420. private _tmpQuaternion;
  50421. private _tmpVector;
  50422. private _tmpRotationMatrix;
  50423. /**
  50424. * 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)
  50425. */
  50426. ignoreChildren: boolean;
  50427. /**
  50428. * 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)
  50429. */
  50430. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50431. /**
  50432. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50433. */
  50434. rotationSphereSize: number;
  50435. /**
  50436. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50437. */
  50438. scaleBoxSize: number;
  50439. /**
  50440. * 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)
  50441. */
  50442. fixedDragMeshScreenSize: boolean;
  50443. /**
  50444. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50445. */
  50446. fixedDragMeshScreenSizeDistanceFactor: number;
  50447. /**
  50448. * Fired when a rotation sphere or scale box is dragged
  50449. */
  50450. onDragStartObservable: Observable<{}>;
  50451. /**
  50452. * Fired when a scale box is dragged
  50453. */
  50454. onScaleBoxDragObservable: Observable<{}>;
  50455. /**
  50456. * Fired when a scale box drag is ended
  50457. */
  50458. onScaleBoxDragEndObservable: Observable<{}>;
  50459. /**
  50460. * Fired when a rotation sphere is dragged
  50461. */
  50462. onRotationSphereDragObservable: Observable<{}>;
  50463. /**
  50464. * Fired when a rotation sphere drag is ended
  50465. */
  50466. onRotationSphereDragEndObservable: Observable<{}>;
  50467. /**
  50468. * 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)
  50469. */
  50470. scalePivot: Nullable<Vector3>;
  50471. /**
  50472. * Mesh used as a pivot to rotate the attached mesh
  50473. */
  50474. private _anchorMesh;
  50475. private _existingMeshScale;
  50476. private _dragMesh;
  50477. private pointerDragBehavior;
  50478. private coloredMaterial;
  50479. private hoverColoredMaterial;
  50480. /**
  50481. * Sets the color of the bounding box gizmo
  50482. * @param color the color to set
  50483. */
  50484. setColor(color: Color3): void;
  50485. /**
  50486. * Creates an BoundingBoxGizmo
  50487. * @param gizmoLayer The utility layer the gizmo will be added to
  50488. * @param color The color of the gizmo
  50489. */
  50490. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50492. private _selectNode;
  50493. /**
  50494. * Updates the bounding box information for the Gizmo
  50495. */
  50496. updateBoundingBox(): void;
  50497. private _updateRotationSpheres;
  50498. private _updateScaleBoxes;
  50499. /**
  50500. * Enables rotation on the specified axis and disables rotation on the others
  50501. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50502. */
  50503. setEnabledRotationAxis(axis: string): void;
  50504. /**
  50505. * Enables/disables scaling
  50506. * @param enable if scaling should be enabled
  50507. */
  50508. setEnabledScaling(enable: boolean): void;
  50509. private _updateDummy;
  50510. /**
  50511. * Enables a pointer drag behavior on the bounding box of the gizmo
  50512. */
  50513. enableDragBehavior(): void;
  50514. /**
  50515. * Disposes of the gizmo
  50516. */
  50517. dispose(): void;
  50518. /**
  50519. * 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)
  50520. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50521. * @returns the bounding box mesh with the passed in mesh as a child
  50522. */
  50523. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50524. /**
  50525. * CustomMeshes are not supported by this gizmo
  50526. * @param mesh The mesh to replace the default mesh of the gizmo
  50527. */
  50528. setCustomMesh(mesh: Mesh): void;
  50529. }
  50530. }
  50531. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50532. import { Observable } from "babylonjs/Misc/observable";
  50533. import { Nullable } from "babylonjs/types";
  50534. import { Vector3 } from "babylonjs/Maths/math.vector";
  50535. import { Color3 } from "babylonjs/Maths/math.color";
  50536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50537. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50538. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50539. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50540. import "babylonjs/Meshes/Builders/linesBuilder";
  50541. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50542. /**
  50543. * Single plane rotation gizmo
  50544. */
  50545. export class PlaneRotationGizmo extends Gizmo {
  50546. /**
  50547. * Drag behavior responsible for the gizmos dragging interactions
  50548. */
  50549. dragBehavior: PointerDragBehavior;
  50550. private _pointerObserver;
  50551. /**
  50552. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50553. */
  50554. snapDistance: number;
  50555. /**
  50556. * Event that fires each time the gizmo snaps to a new location.
  50557. * * snapDistance is the the change in distance
  50558. */
  50559. onSnapObservable: Observable<{
  50560. snapDistance: number;
  50561. }>;
  50562. private _isEnabled;
  50563. private _parent;
  50564. /**
  50565. * Creates a PlaneRotationGizmo
  50566. * @param gizmoLayer The utility layer the gizmo will be added to
  50567. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50568. * @param color The color of the gizmo
  50569. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50570. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50571. */
  50572. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50573. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50574. /**
  50575. * If the gizmo is enabled
  50576. */
  50577. set isEnabled(value: boolean);
  50578. get isEnabled(): boolean;
  50579. /**
  50580. * Disposes of the gizmo
  50581. */
  50582. dispose(): void;
  50583. }
  50584. }
  50585. declare module "babylonjs/Gizmos/rotationGizmo" {
  50586. import { Observable } from "babylonjs/Misc/observable";
  50587. import { Nullable } from "babylonjs/types";
  50588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50589. import { Mesh } from "babylonjs/Meshes/mesh";
  50590. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50591. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50592. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50593. /**
  50594. * Gizmo that enables rotating a mesh along 3 axis
  50595. */
  50596. export class RotationGizmo extends Gizmo {
  50597. /**
  50598. * Internal gizmo used for interactions on the x axis
  50599. */
  50600. xGizmo: PlaneRotationGizmo;
  50601. /**
  50602. * Internal gizmo used for interactions on the y axis
  50603. */
  50604. yGizmo: PlaneRotationGizmo;
  50605. /**
  50606. * Internal gizmo used for interactions on the z axis
  50607. */
  50608. zGizmo: PlaneRotationGizmo;
  50609. /** Fires an event when any of it's sub gizmos are dragged */
  50610. onDragStartObservable: Observable<unknown>;
  50611. /** Fires an event when any of it's sub gizmos are released from dragging */
  50612. onDragEndObservable: Observable<unknown>;
  50613. private _meshAttached;
  50614. get attachedMesh(): Nullable<AbstractMesh>;
  50615. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50616. /**
  50617. * Creates a RotationGizmo
  50618. * @param gizmoLayer The utility layer the gizmo will be added to
  50619. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50620. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50621. */
  50622. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50623. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50624. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50625. /**
  50626. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50627. */
  50628. set snapDistance(value: number);
  50629. get snapDistance(): number;
  50630. /**
  50631. * Ratio for the scale of the gizmo (Default: 1)
  50632. */
  50633. set scaleRatio(value: number);
  50634. get scaleRatio(): number;
  50635. /**
  50636. * Disposes of the gizmo
  50637. */
  50638. dispose(): void;
  50639. /**
  50640. * CustomMeshes are not supported by this gizmo
  50641. * @param mesh The mesh to replace the default mesh of the gizmo
  50642. */
  50643. setCustomMesh(mesh: Mesh): void;
  50644. }
  50645. }
  50646. declare module "babylonjs/Gizmos/gizmoManager" {
  50647. import { Observable } from "babylonjs/Misc/observable";
  50648. import { Nullable } from "babylonjs/types";
  50649. import { Scene, IDisposable } from "babylonjs/scene";
  50650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50651. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50652. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50653. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50654. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50655. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50656. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50657. /**
  50658. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50659. */
  50660. export class GizmoManager implements IDisposable {
  50661. private scene;
  50662. /**
  50663. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50664. */
  50665. gizmos: {
  50666. positionGizmo: Nullable<PositionGizmo>;
  50667. rotationGizmo: Nullable<RotationGizmo>;
  50668. scaleGizmo: Nullable<ScaleGizmo>;
  50669. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50670. };
  50671. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50672. clearGizmoOnEmptyPointerEvent: boolean;
  50673. /** Fires an event when the manager is attached to a mesh */
  50674. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50675. private _gizmosEnabled;
  50676. private _pointerObserver;
  50677. private _attachedMesh;
  50678. private _boundingBoxColor;
  50679. private _defaultUtilityLayer;
  50680. private _defaultKeepDepthUtilityLayer;
  50681. /**
  50682. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50683. */
  50684. boundingBoxDragBehavior: SixDofDragBehavior;
  50685. /**
  50686. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50687. */
  50688. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50689. /**
  50690. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50691. */
  50692. usePointerToAttachGizmos: boolean;
  50693. /**
  50694. * Utility layer that the bounding box gizmo belongs to
  50695. */
  50696. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50697. /**
  50698. * Utility layer that all gizmos besides bounding box belong to
  50699. */
  50700. get utilityLayer(): UtilityLayerRenderer;
  50701. /**
  50702. * Instatiates a gizmo manager
  50703. * @param scene the scene to overlay the gizmos on top of
  50704. */
  50705. constructor(scene: Scene);
  50706. /**
  50707. * Attaches a set of gizmos to the specified mesh
  50708. * @param mesh The mesh the gizmo's should be attached to
  50709. */
  50710. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50711. /**
  50712. * If the position gizmo is enabled
  50713. */
  50714. set positionGizmoEnabled(value: boolean);
  50715. get positionGizmoEnabled(): boolean;
  50716. /**
  50717. * If the rotation gizmo is enabled
  50718. */
  50719. set rotationGizmoEnabled(value: boolean);
  50720. get rotationGizmoEnabled(): boolean;
  50721. /**
  50722. * If the scale gizmo is enabled
  50723. */
  50724. set scaleGizmoEnabled(value: boolean);
  50725. get scaleGizmoEnabled(): boolean;
  50726. /**
  50727. * If the boundingBox gizmo is enabled
  50728. */
  50729. set boundingBoxGizmoEnabled(value: boolean);
  50730. get boundingBoxGizmoEnabled(): boolean;
  50731. /**
  50732. * Disposes of the gizmo manager
  50733. */
  50734. dispose(): void;
  50735. }
  50736. }
  50737. declare module "babylonjs/Lights/directionalLight" {
  50738. import { Camera } from "babylonjs/Cameras/camera";
  50739. import { Scene } from "babylonjs/scene";
  50740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50742. import { Light } from "babylonjs/Lights/light";
  50743. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50744. import { Effect } from "babylonjs/Materials/effect";
  50745. /**
  50746. * A directional light is defined by a direction (what a surprise!).
  50747. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50748. * 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.
  50749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50750. */
  50751. export class DirectionalLight extends ShadowLight {
  50752. private _shadowFrustumSize;
  50753. /**
  50754. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50755. */
  50756. get shadowFrustumSize(): number;
  50757. /**
  50758. * Specifies a fix frustum size for the shadow generation.
  50759. */
  50760. set shadowFrustumSize(value: number);
  50761. private _shadowOrthoScale;
  50762. /**
  50763. * Gets the shadow projection scale against the optimal computed one.
  50764. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50765. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50766. */
  50767. get shadowOrthoScale(): number;
  50768. /**
  50769. * Sets the shadow projection scale against the optimal computed one.
  50770. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50771. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50772. */
  50773. set shadowOrthoScale(value: number);
  50774. /**
  50775. * Automatically compute the projection matrix to best fit (including all the casters)
  50776. * on each frame.
  50777. */
  50778. autoUpdateExtends: boolean;
  50779. /**
  50780. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50781. * on each frame. autoUpdateExtends must be set to true for this to work
  50782. */
  50783. autoCalcShadowZBounds: boolean;
  50784. private _orthoLeft;
  50785. private _orthoRight;
  50786. private _orthoTop;
  50787. private _orthoBottom;
  50788. /**
  50789. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50790. * The directional light is emitted from everywhere in the given direction.
  50791. * It can cast shadows.
  50792. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50793. * @param name The friendly name of the light
  50794. * @param direction The direction of the light
  50795. * @param scene The scene the light belongs to
  50796. */
  50797. constructor(name: string, direction: Vector3, scene: Scene);
  50798. /**
  50799. * Returns the string "DirectionalLight".
  50800. * @return The class name
  50801. */
  50802. getClassName(): string;
  50803. /**
  50804. * Returns the integer 1.
  50805. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50806. */
  50807. getTypeID(): number;
  50808. /**
  50809. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50810. * Returns the DirectionalLight Shadow projection matrix.
  50811. */
  50812. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50813. /**
  50814. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50815. * Returns the DirectionalLight Shadow projection matrix.
  50816. */
  50817. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50818. /**
  50819. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50820. * Returns the DirectionalLight Shadow projection matrix.
  50821. */
  50822. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50823. protected _buildUniformLayout(): void;
  50824. /**
  50825. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50826. * @param effect The effect to update
  50827. * @param lightIndex The index of the light in the effect to update
  50828. * @returns The directional light
  50829. */
  50830. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50831. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50832. /**
  50833. * Gets the minZ used for shadow according to both the scene and the light.
  50834. *
  50835. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50836. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50837. * @param activeCamera The camera we are returning the min for
  50838. * @returns the depth min z
  50839. */
  50840. getDepthMinZ(activeCamera: Camera): number;
  50841. /**
  50842. * Gets the maxZ used for shadow according to both the scene and the light.
  50843. *
  50844. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50845. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50846. * @param activeCamera The camera we are returning the max for
  50847. * @returns the depth max z
  50848. */
  50849. getDepthMaxZ(activeCamera: Camera): number;
  50850. /**
  50851. * Prepares the list of defines specific to the light type.
  50852. * @param defines the list of defines
  50853. * @param lightIndex defines the index of the light for the effect
  50854. */
  50855. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50856. }
  50857. }
  50858. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50859. import { Mesh } from "babylonjs/Meshes/mesh";
  50860. /**
  50861. * Class containing static functions to help procedurally build meshes
  50862. */
  50863. export class HemisphereBuilder {
  50864. /**
  50865. * Creates a hemisphere mesh
  50866. * @param name defines the name of the mesh
  50867. * @param options defines the options used to create the mesh
  50868. * @param scene defines the hosting scene
  50869. * @returns the hemisphere mesh
  50870. */
  50871. static CreateHemisphere(name: string, options: {
  50872. segments?: number;
  50873. diameter?: number;
  50874. sideOrientation?: number;
  50875. }, scene: any): Mesh;
  50876. }
  50877. }
  50878. declare module "babylonjs/Lights/spotLight" {
  50879. import { Nullable } from "babylonjs/types";
  50880. import { Scene } from "babylonjs/scene";
  50881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50883. import { Effect } from "babylonjs/Materials/effect";
  50884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50885. import { Light } from "babylonjs/Lights/light";
  50886. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50887. /**
  50888. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50889. * These values define a cone of light starting from the position, emitting toward the direction.
  50890. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50891. * and the exponent defines the speed of the decay of the light with distance (reach).
  50892. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50893. */
  50894. export class SpotLight extends ShadowLight {
  50895. private _angle;
  50896. private _innerAngle;
  50897. private _cosHalfAngle;
  50898. private _lightAngleScale;
  50899. private _lightAngleOffset;
  50900. /**
  50901. * Gets the cone angle of the spot light in Radians.
  50902. */
  50903. get angle(): number;
  50904. /**
  50905. * Sets the cone angle of the spot light in Radians.
  50906. */
  50907. set angle(value: number);
  50908. /**
  50909. * Only used in gltf falloff mode, this defines the angle where
  50910. * the directional falloff will start before cutting at angle which could be seen
  50911. * as outer angle.
  50912. */
  50913. get innerAngle(): number;
  50914. /**
  50915. * Only used in gltf falloff mode, this defines the angle where
  50916. * the directional falloff will start before cutting at angle which could be seen
  50917. * as outer angle.
  50918. */
  50919. set innerAngle(value: number);
  50920. private _shadowAngleScale;
  50921. /**
  50922. * Allows scaling the angle of the light for shadow generation only.
  50923. */
  50924. get shadowAngleScale(): number;
  50925. /**
  50926. * Allows scaling the angle of the light for shadow generation only.
  50927. */
  50928. set shadowAngleScale(value: number);
  50929. /**
  50930. * The light decay speed with the distance from the emission spot.
  50931. */
  50932. exponent: number;
  50933. private _projectionTextureMatrix;
  50934. /**
  50935. * Allows reading the projecton texture
  50936. */
  50937. get projectionTextureMatrix(): Matrix;
  50938. protected _projectionTextureLightNear: number;
  50939. /**
  50940. * Gets the near clip of the Spotlight for texture projection.
  50941. */
  50942. get projectionTextureLightNear(): number;
  50943. /**
  50944. * Sets the near clip of the Spotlight for texture projection.
  50945. */
  50946. set projectionTextureLightNear(value: number);
  50947. protected _projectionTextureLightFar: number;
  50948. /**
  50949. * Gets the far clip of the Spotlight for texture projection.
  50950. */
  50951. get projectionTextureLightFar(): number;
  50952. /**
  50953. * Sets the far clip of the Spotlight for texture projection.
  50954. */
  50955. set projectionTextureLightFar(value: number);
  50956. protected _projectionTextureUpDirection: Vector3;
  50957. /**
  50958. * Gets the Up vector of the Spotlight for texture projection.
  50959. */
  50960. get projectionTextureUpDirection(): Vector3;
  50961. /**
  50962. * Sets the Up vector of the Spotlight for texture projection.
  50963. */
  50964. set projectionTextureUpDirection(value: Vector3);
  50965. private _projectionTexture;
  50966. /**
  50967. * Gets the projection texture of the light.
  50968. */
  50969. get projectionTexture(): Nullable<BaseTexture>;
  50970. /**
  50971. * Sets the projection texture of the light.
  50972. */
  50973. set projectionTexture(value: Nullable<BaseTexture>);
  50974. private _projectionTextureViewLightDirty;
  50975. private _projectionTextureProjectionLightDirty;
  50976. private _projectionTextureDirty;
  50977. private _projectionTextureViewTargetVector;
  50978. private _projectionTextureViewLightMatrix;
  50979. private _projectionTextureProjectionLightMatrix;
  50980. private _projectionTextureScalingMatrix;
  50981. /**
  50982. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50983. * It can cast shadows.
  50984. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50985. * @param name The light friendly name
  50986. * @param position The position of the spot light in the scene
  50987. * @param direction The direction of the light in the scene
  50988. * @param angle The cone angle of the light in Radians
  50989. * @param exponent The light decay speed with the distance from the emission spot
  50990. * @param scene The scene the lights belongs to
  50991. */
  50992. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50993. /**
  50994. * Returns the string "SpotLight".
  50995. * @returns the class name
  50996. */
  50997. getClassName(): string;
  50998. /**
  50999. * Returns the integer 2.
  51000. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51001. */
  51002. getTypeID(): number;
  51003. /**
  51004. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51005. */
  51006. protected _setDirection(value: Vector3): void;
  51007. /**
  51008. * Overrides the position setter to recompute the projection texture view light Matrix.
  51009. */
  51010. protected _setPosition(value: Vector3): void;
  51011. /**
  51012. * 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.
  51013. * Returns the SpotLight.
  51014. */
  51015. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51016. protected _computeProjectionTextureViewLightMatrix(): void;
  51017. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51018. /**
  51019. * Main function for light texture projection matrix computing.
  51020. */
  51021. protected _computeProjectionTextureMatrix(): void;
  51022. protected _buildUniformLayout(): void;
  51023. private _computeAngleValues;
  51024. /**
  51025. * Sets the passed Effect "effect" with the Light textures.
  51026. * @param effect The effect to update
  51027. * @param lightIndex The index of the light in the effect to update
  51028. * @returns The light
  51029. */
  51030. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51031. /**
  51032. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51033. * @param effect The effect to update
  51034. * @param lightIndex The index of the light in the effect to update
  51035. * @returns The spot light
  51036. */
  51037. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51038. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51039. /**
  51040. * Disposes the light and the associated resources.
  51041. */
  51042. dispose(): void;
  51043. /**
  51044. * Prepares the list of defines specific to the light type.
  51045. * @param defines the list of defines
  51046. * @param lightIndex defines the index of the light for the effect
  51047. */
  51048. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51049. }
  51050. }
  51051. declare module "babylonjs/Gizmos/lightGizmo" {
  51052. import { Nullable } from "babylonjs/types";
  51053. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51054. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51055. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51056. import { Light } from "babylonjs/Lights/light";
  51057. /**
  51058. * Gizmo that enables viewing a light
  51059. */
  51060. export class LightGizmo extends Gizmo {
  51061. private _lightMesh;
  51062. private _material;
  51063. private _cachedPosition;
  51064. private _cachedForward;
  51065. private _attachedMeshParent;
  51066. /**
  51067. * Creates a LightGizmo
  51068. * @param gizmoLayer The utility layer the gizmo will be added to
  51069. */
  51070. constructor(gizmoLayer?: UtilityLayerRenderer);
  51071. private _light;
  51072. /**
  51073. * The light that the gizmo is attached to
  51074. */
  51075. set light(light: Nullable<Light>);
  51076. get light(): Nullable<Light>;
  51077. /**
  51078. * Gets the material used to render the light gizmo
  51079. */
  51080. get material(): StandardMaterial;
  51081. /**
  51082. * @hidden
  51083. * Updates the gizmo to match the attached mesh's position/rotation
  51084. */
  51085. protected _update(): void;
  51086. private static _Scale;
  51087. /**
  51088. * Creates the lines for a light mesh
  51089. */
  51090. private static _CreateLightLines;
  51091. /**
  51092. * Disposes of the light gizmo
  51093. */
  51094. dispose(): void;
  51095. private static _CreateHemisphericLightMesh;
  51096. private static _CreatePointLightMesh;
  51097. private static _CreateSpotLightMesh;
  51098. private static _CreateDirectionalLightMesh;
  51099. }
  51100. }
  51101. declare module "babylonjs/Gizmos/index" {
  51102. export * from "babylonjs/Gizmos/axisDragGizmo";
  51103. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51104. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51105. export * from "babylonjs/Gizmos/gizmo";
  51106. export * from "babylonjs/Gizmos/gizmoManager";
  51107. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51108. export * from "babylonjs/Gizmos/positionGizmo";
  51109. export * from "babylonjs/Gizmos/rotationGizmo";
  51110. export * from "babylonjs/Gizmos/scaleGizmo";
  51111. export * from "babylonjs/Gizmos/lightGizmo";
  51112. export * from "babylonjs/Gizmos/planeDragGizmo";
  51113. }
  51114. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51115. /** @hidden */
  51116. export var backgroundFragmentDeclaration: {
  51117. name: string;
  51118. shader: string;
  51119. };
  51120. }
  51121. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51122. /** @hidden */
  51123. export var backgroundUboDeclaration: {
  51124. name: string;
  51125. shader: string;
  51126. };
  51127. }
  51128. declare module "babylonjs/Shaders/background.fragment" {
  51129. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51130. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51131. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51132. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51133. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51134. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51135. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51136. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51137. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51138. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51139. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51140. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51141. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51142. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51143. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51144. /** @hidden */
  51145. export var backgroundPixelShader: {
  51146. name: string;
  51147. shader: string;
  51148. };
  51149. }
  51150. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51151. /** @hidden */
  51152. export var backgroundVertexDeclaration: {
  51153. name: string;
  51154. shader: string;
  51155. };
  51156. }
  51157. declare module "babylonjs/Shaders/background.vertex" {
  51158. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51159. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51160. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51161. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51162. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51164. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51165. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51166. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51167. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51168. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51169. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51170. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51171. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51172. /** @hidden */
  51173. export var backgroundVertexShader: {
  51174. name: string;
  51175. shader: string;
  51176. };
  51177. }
  51178. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51179. import { Nullable, int, float } from "babylonjs/types";
  51180. import { Scene } from "babylonjs/scene";
  51181. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51182. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51184. import { Mesh } from "babylonjs/Meshes/mesh";
  51185. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51186. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51187. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51189. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51190. import { Color3 } from "babylonjs/Maths/math.color";
  51191. import "babylonjs/Shaders/background.fragment";
  51192. import "babylonjs/Shaders/background.vertex";
  51193. /**
  51194. * Background material used to create an efficient environement around your scene.
  51195. */
  51196. export class BackgroundMaterial extends PushMaterial {
  51197. /**
  51198. * Standard reflectance value at parallel view angle.
  51199. */
  51200. static StandardReflectance0: number;
  51201. /**
  51202. * Standard reflectance value at grazing angle.
  51203. */
  51204. static StandardReflectance90: number;
  51205. protected _primaryColor: Color3;
  51206. /**
  51207. * Key light Color (multiply against the environement texture)
  51208. */
  51209. primaryColor: Color3;
  51210. protected __perceptualColor: Nullable<Color3>;
  51211. /**
  51212. * Experimental Internal Use Only.
  51213. *
  51214. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51215. * This acts as a helper to set the primary color to a more "human friendly" value.
  51216. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51217. * output color as close as possible from the chosen value.
  51218. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51219. * part of lighting setup.)
  51220. */
  51221. get _perceptualColor(): Nullable<Color3>;
  51222. set _perceptualColor(value: Nullable<Color3>);
  51223. protected _primaryColorShadowLevel: float;
  51224. /**
  51225. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51226. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51227. */
  51228. get primaryColorShadowLevel(): float;
  51229. set primaryColorShadowLevel(value: float);
  51230. protected _primaryColorHighlightLevel: float;
  51231. /**
  51232. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51233. * The primary color is used at the level chosen to define what the white area would look.
  51234. */
  51235. get primaryColorHighlightLevel(): float;
  51236. set primaryColorHighlightLevel(value: float);
  51237. protected _reflectionTexture: Nullable<BaseTexture>;
  51238. /**
  51239. * Reflection Texture used in the material.
  51240. * Should be author in a specific way for the best result (refer to the documentation).
  51241. */
  51242. reflectionTexture: Nullable<BaseTexture>;
  51243. protected _reflectionBlur: float;
  51244. /**
  51245. * Reflection Texture level of blur.
  51246. *
  51247. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51248. * texture twice.
  51249. */
  51250. reflectionBlur: float;
  51251. protected _diffuseTexture: Nullable<BaseTexture>;
  51252. /**
  51253. * Diffuse Texture used in the material.
  51254. * Should be author in a specific way for the best result (refer to the documentation).
  51255. */
  51256. diffuseTexture: Nullable<BaseTexture>;
  51257. protected _shadowLights: Nullable<IShadowLight[]>;
  51258. /**
  51259. * Specify the list of lights casting shadow on the material.
  51260. * All scene shadow lights will be included if null.
  51261. */
  51262. shadowLights: Nullable<IShadowLight[]>;
  51263. protected _shadowLevel: float;
  51264. /**
  51265. * Helps adjusting the shadow to a softer level if required.
  51266. * 0 means black shadows and 1 means no shadows.
  51267. */
  51268. shadowLevel: float;
  51269. protected _sceneCenter: Vector3;
  51270. /**
  51271. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51272. * It is usually zero but might be interesting to modify according to your setup.
  51273. */
  51274. sceneCenter: Vector3;
  51275. protected _opacityFresnel: boolean;
  51276. /**
  51277. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51278. * This helps ensuring a nice transition when the camera goes under the ground.
  51279. */
  51280. opacityFresnel: boolean;
  51281. protected _reflectionFresnel: boolean;
  51282. /**
  51283. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51284. * This helps adding a mirror texture on the ground.
  51285. */
  51286. reflectionFresnel: boolean;
  51287. protected _reflectionFalloffDistance: number;
  51288. /**
  51289. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51290. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51291. */
  51292. reflectionFalloffDistance: number;
  51293. protected _reflectionAmount: number;
  51294. /**
  51295. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51296. */
  51297. reflectionAmount: number;
  51298. protected _reflectionReflectance0: number;
  51299. /**
  51300. * This specifies the weight of the reflection at grazing angle.
  51301. */
  51302. reflectionReflectance0: number;
  51303. protected _reflectionReflectance90: number;
  51304. /**
  51305. * This specifies the weight of the reflection at a perpendicular point of view.
  51306. */
  51307. reflectionReflectance90: number;
  51308. /**
  51309. * Sets the reflection reflectance fresnel values according to the default standard
  51310. * empirically know to work well :-)
  51311. */
  51312. set reflectionStandardFresnelWeight(value: number);
  51313. protected _useRGBColor: boolean;
  51314. /**
  51315. * Helps to directly use the maps channels instead of their level.
  51316. */
  51317. useRGBColor: boolean;
  51318. protected _enableNoise: boolean;
  51319. /**
  51320. * This helps reducing the banding effect that could occur on the background.
  51321. */
  51322. enableNoise: boolean;
  51323. /**
  51324. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51325. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51326. * Recommended to be keep at 1.0 except for special cases.
  51327. */
  51328. get fovMultiplier(): number;
  51329. set fovMultiplier(value: number);
  51330. private _fovMultiplier;
  51331. /**
  51332. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51333. */
  51334. useEquirectangularFOV: boolean;
  51335. private _maxSimultaneousLights;
  51336. /**
  51337. * Number of Simultaneous lights allowed on the material.
  51338. */
  51339. maxSimultaneousLights: int;
  51340. /**
  51341. * Default configuration related to image processing available in the Background Material.
  51342. */
  51343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51344. /**
  51345. * Keep track of the image processing observer to allow dispose and replace.
  51346. */
  51347. private _imageProcessingObserver;
  51348. /**
  51349. * Attaches a new image processing configuration to the PBR Material.
  51350. * @param configuration (if null the scene configuration will be use)
  51351. */
  51352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51353. /**
  51354. * Gets the image processing configuration used either in this material.
  51355. */
  51356. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51357. /**
  51358. * Sets the Default image processing configuration used either in the this material.
  51359. *
  51360. * If sets to null, the scene one is in use.
  51361. */
  51362. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51363. /**
  51364. * Gets wether the color curves effect is enabled.
  51365. */
  51366. get cameraColorCurvesEnabled(): boolean;
  51367. /**
  51368. * Sets wether the color curves effect is enabled.
  51369. */
  51370. set cameraColorCurvesEnabled(value: boolean);
  51371. /**
  51372. * Gets wether the color grading effect is enabled.
  51373. */
  51374. get cameraColorGradingEnabled(): boolean;
  51375. /**
  51376. * Gets wether the color grading effect is enabled.
  51377. */
  51378. set cameraColorGradingEnabled(value: boolean);
  51379. /**
  51380. * Gets wether tonemapping is enabled or not.
  51381. */
  51382. get cameraToneMappingEnabled(): boolean;
  51383. /**
  51384. * Sets wether tonemapping is enabled or not
  51385. */
  51386. set cameraToneMappingEnabled(value: boolean);
  51387. /**
  51388. * The camera exposure used on this material.
  51389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51390. * This corresponds to a photographic exposure.
  51391. */
  51392. get cameraExposure(): float;
  51393. /**
  51394. * The camera exposure used on this material.
  51395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51396. * This corresponds to a photographic exposure.
  51397. */
  51398. set cameraExposure(value: float);
  51399. /**
  51400. * Gets The camera contrast used on this material.
  51401. */
  51402. get cameraContrast(): float;
  51403. /**
  51404. * Sets The camera contrast used on this material.
  51405. */
  51406. set cameraContrast(value: float);
  51407. /**
  51408. * Gets the Color Grading 2D Lookup Texture.
  51409. */
  51410. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51411. /**
  51412. * Sets the Color Grading 2D Lookup Texture.
  51413. */
  51414. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51415. /**
  51416. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51417. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51418. * 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;
  51419. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51420. */
  51421. get cameraColorCurves(): Nullable<ColorCurves>;
  51422. /**
  51423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51425. * 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;
  51426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51427. */
  51428. set cameraColorCurves(value: Nullable<ColorCurves>);
  51429. /**
  51430. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51431. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51432. */
  51433. switchToBGR: boolean;
  51434. private _renderTargets;
  51435. private _reflectionControls;
  51436. private _white;
  51437. private _primaryShadowColor;
  51438. private _primaryHighlightColor;
  51439. /**
  51440. * Instantiates a Background Material in the given scene
  51441. * @param name The friendly name of the material
  51442. * @param scene The scene to add the material to
  51443. */
  51444. constructor(name: string, scene: Scene);
  51445. /**
  51446. * Gets a boolean indicating that current material needs to register RTT
  51447. */
  51448. get hasRenderTargetTextures(): boolean;
  51449. /**
  51450. * The entire material has been created in order to prevent overdraw.
  51451. * @returns false
  51452. */
  51453. needAlphaTesting(): boolean;
  51454. /**
  51455. * The entire material has been created in order to prevent overdraw.
  51456. * @returns true if blending is enable
  51457. */
  51458. needAlphaBlending(): boolean;
  51459. /**
  51460. * Checks wether the material is ready to be rendered for a given mesh.
  51461. * @param mesh The mesh to render
  51462. * @param subMesh The submesh to check against
  51463. * @param useInstances Specify wether or not the material is used with instances
  51464. * @returns true if all the dependencies are ready (Textures, Effects...)
  51465. */
  51466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51467. /**
  51468. * Compute the primary color according to the chosen perceptual color.
  51469. */
  51470. private _computePrimaryColorFromPerceptualColor;
  51471. /**
  51472. * Compute the highlights and shadow colors according to their chosen levels.
  51473. */
  51474. private _computePrimaryColors;
  51475. /**
  51476. * Build the uniform buffer used in the material.
  51477. */
  51478. buildUniformLayout(): void;
  51479. /**
  51480. * Unbind the material.
  51481. */
  51482. unbind(): void;
  51483. /**
  51484. * Bind only the world matrix to the material.
  51485. * @param world The world matrix to bind.
  51486. */
  51487. bindOnlyWorldMatrix(world: Matrix): void;
  51488. /**
  51489. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51490. * @param world The world matrix to bind.
  51491. * @param subMesh The submesh to bind for.
  51492. */
  51493. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51494. /**
  51495. * Checks to see if a texture is used in the material.
  51496. * @param texture - Base texture to use.
  51497. * @returns - Boolean specifying if a texture is used in the material.
  51498. */
  51499. hasTexture(texture: BaseTexture): boolean;
  51500. /**
  51501. * Dispose the material.
  51502. * @param forceDisposeEffect Force disposal of the associated effect.
  51503. * @param forceDisposeTextures Force disposal of the associated textures.
  51504. */
  51505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51506. /**
  51507. * Clones the material.
  51508. * @param name The cloned name.
  51509. * @returns The cloned material.
  51510. */
  51511. clone(name: string): BackgroundMaterial;
  51512. /**
  51513. * Serializes the current material to its JSON representation.
  51514. * @returns The JSON representation.
  51515. */
  51516. serialize(): any;
  51517. /**
  51518. * Gets the class name of the material
  51519. * @returns "BackgroundMaterial"
  51520. */
  51521. getClassName(): string;
  51522. /**
  51523. * Parse a JSON input to create back a background material.
  51524. * @param source The JSON data to parse
  51525. * @param scene The scene to create the parsed material in
  51526. * @param rootUrl The root url of the assets the material depends upon
  51527. * @returns the instantiated BackgroundMaterial.
  51528. */
  51529. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51530. }
  51531. }
  51532. declare module "babylonjs/Helpers/environmentHelper" {
  51533. import { Observable } from "babylonjs/Misc/observable";
  51534. import { Nullable } from "babylonjs/types";
  51535. import { Scene } from "babylonjs/scene";
  51536. import { Vector3 } from "babylonjs/Maths/math.vector";
  51537. import { Color3 } from "babylonjs/Maths/math.color";
  51538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51539. import { Mesh } from "babylonjs/Meshes/mesh";
  51540. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51541. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51542. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51543. import "babylonjs/Meshes/Builders/planeBuilder";
  51544. import "babylonjs/Meshes/Builders/boxBuilder";
  51545. /**
  51546. * Represents the different options available during the creation of
  51547. * a Environment helper.
  51548. *
  51549. * This can control the default ground, skybox and image processing setup of your scene.
  51550. */
  51551. export interface IEnvironmentHelperOptions {
  51552. /**
  51553. * Specifies whether or not to create a ground.
  51554. * True by default.
  51555. */
  51556. createGround: boolean;
  51557. /**
  51558. * Specifies the ground size.
  51559. * 15 by default.
  51560. */
  51561. groundSize: number;
  51562. /**
  51563. * The texture used on the ground for the main color.
  51564. * Comes from the BabylonJS CDN by default.
  51565. *
  51566. * Remarks: Can be either a texture or a url.
  51567. */
  51568. groundTexture: string | BaseTexture;
  51569. /**
  51570. * The color mixed in the ground texture by default.
  51571. * BabylonJS clearColor by default.
  51572. */
  51573. groundColor: Color3;
  51574. /**
  51575. * Specifies the ground opacity.
  51576. * 1 by default.
  51577. */
  51578. groundOpacity: number;
  51579. /**
  51580. * Enables the ground to receive shadows.
  51581. * True by default.
  51582. */
  51583. enableGroundShadow: boolean;
  51584. /**
  51585. * Helps preventing the shadow to be fully black on the ground.
  51586. * 0.5 by default.
  51587. */
  51588. groundShadowLevel: number;
  51589. /**
  51590. * Creates a mirror texture attach to the ground.
  51591. * false by default.
  51592. */
  51593. enableGroundMirror: boolean;
  51594. /**
  51595. * Specifies the ground mirror size ratio.
  51596. * 0.3 by default as the default kernel is 64.
  51597. */
  51598. groundMirrorSizeRatio: number;
  51599. /**
  51600. * Specifies the ground mirror blur kernel size.
  51601. * 64 by default.
  51602. */
  51603. groundMirrorBlurKernel: number;
  51604. /**
  51605. * Specifies the ground mirror visibility amount.
  51606. * 1 by default
  51607. */
  51608. groundMirrorAmount: number;
  51609. /**
  51610. * Specifies the ground mirror reflectance weight.
  51611. * This uses the standard weight of the background material to setup the fresnel effect
  51612. * of the mirror.
  51613. * 1 by default.
  51614. */
  51615. groundMirrorFresnelWeight: number;
  51616. /**
  51617. * Specifies the ground mirror Falloff distance.
  51618. * This can helps reducing the size of the reflection.
  51619. * 0 by Default.
  51620. */
  51621. groundMirrorFallOffDistance: number;
  51622. /**
  51623. * Specifies the ground mirror texture type.
  51624. * Unsigned Int by Default.
  51625. */
  51626. groundMirrorTextureType: number;
  51627. /**
  51628. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51629. * the shown objects.
  51630. */
  51631. groundYBias: number;
  51632. /**
  51633. * Specifies whether or not to create a skybox.
  51634. * True by default.
  51635. */
  51636. createSkybox: boolean;
  51637. /**
  51638. * Specifies the skybox size.
  51639. * 20 by default.
  51640. */
  51641. skyboxSize: number;
  51642. /**
  51643. * The texture used on the skybox for the main color.
  51644. * Comes from the BabylonJS CDN by default.
  51645. *
  51646. * Remarks: Can be either a texture or a url.
  51647. */
  51648. skyboxTexture: string | BaseTexture;
  51649. /**
  51650. * The color mixed in the skybox texture by default.
  51651. * BabylonJS clearColor by default.
  51652. */
  51653. skyboxColor: Color3;
  51654. /**
  51655. * The background rotation around the Y axis of the scene.
  51656. * This helps aligning the key lights of your scene with the background.
  51657. * 0 by default.
  51658. */
  51659. backgroundYRotation: number;
  51660. /**
  51661. * Compute automatically the size of the elements to best fit with the scene.
  51662. */
  51663. sizeAuto: boolean;
  51664. /**
  51665. * Default position of the rootMesh if autoSize is not true.
  51666. */
  51667. rootPosition: Vector3;
  51668. /**
  51669. * Sets up the image processing in the scene.
  51670. * true by default.
  51671. */
  51672. setupImageProcessing: boolean;
  51673. /**
  51674. * The texture used as your environment texture in the scene.
  51675. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51676. *
  51677. * Remarks: Can be either a texture or a url.
  51678. */
  51679. environmentTexture: string | BaseTexture;
  51680. /**
  51681. * The value of the exposure to apply to the scene.
  51682. * 0.6 by default if setupImageProcessing is true.
  51683. */
  51684. cameraExposure: number;
  51685. /**
  51686. * The value of the contrast to apply to the scene.
  51687. * 1.6 by default if setupImageProcessing is true.
  51688. */
  51689. cameraContrast: number;
  51690. /**
  51691. * Specifies whether or not tonemapping should be enabled in the scene.
  51692. * true by default if setupImageProcessing is true.
  51693. */
  51694. toneMappingEnabled: boolean;
  51695. }
  51696. /**
  51697. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51698. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51699. * It also helps with the default setup of your imageProcessing configuration.
  51700. */
  51701. export class EnvironmentHelper {
  51702. /**
  51703. * Default ground texture URL.
  51704. */
  51705. private static _groundTextureCDNUrl;
  51706. /**
  51707. * Default skybox texture URL.
  51708. */
  51709. private static _skyboxTextureCDNUrl;
  51710. /**
  51711. * Default environment texture URL.
  51712. */
  51713. private static _environmentTextureCDNUrl;
  51714. /**
  51715. * Creates the default options for the helper.
  51716. */
  51717. private static _getDefaultOptions;
  51718. private _rootMesh;
  51719. /**
  51720. * Gets the root mesh created by the helper.
  51721. */
  51722. get rootMesh(): Mesh;
  51723. private _skybox;
  51724. /**
  51725. * Gets the skybox created by the helper.
  51726. */
  51727. get skybox(): Nullable<Mesh>;
  51728. private _skyboxTexture;
  51729. /**
  51730. * Gets the skybox texture created by the helper.
  51731. */
  51732. get skyboxTexture(): Nullable<BaseTexture>;
  51733. private _skyboxMaterial;
  51734. /**
  51735. * Gets the skybox material created by the helper.
  51736. */
  51737. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51738. private _ground;
  51739. /**
  51740. * Gets the ground mesh created by the helper.
  51741. */
  51742. get ground(): Nullable<Mesh>;
  51743. private _groundTexture;
  51744. /**
  51745. * Gets the ground texture created by the helper.
  51746. */
  51747. get groundTexture(): Nullable<BaseTexture>;
  51748. private _groundMirror;
  51749. /**
  51750. * Gets the ground mirror created by the helper.
  51751. */
  51752. get groundMirror(): Nullable<MirrorTexture>;
  51753. /**
  51754. * Gets the ground mirror render list to helps pushing the meshes
  51755. * you wish in the ground reflection.
  51756. */
  51757. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51758. private _groundMaterial;
  51759. /**
  51760. * Gets the ground material created by the helper.
  51761. */
  51762. get groundMaterial(): Nullable<BackgroundMaterial>;
  51763. /**
  51764. * Stores the creation options.
  51765. */
  51766. private readonly _scene;
  51767. private _options;
  51768. /**
  51769. * This observable will be notified with any error during the creation of the environment,
  51770. * mainly texture creation errors.
  51771. */
  51772. onErrorObservable: Observable<{
  51773. message?: string;
  51774. exception?: any;
  51775. }>;
  51776. /**
  51777. * constructor
  51778. * @param options Defines the options we want to customize the helper
  51779. * @param scene The scene to add the material to
  51780. */
  51781. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51782. /**
  51783. * Updates the background according to the new options
  51784. * @param options
  51785. */
  51786. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51787. /**
  51788. * Sets the primary color of all the available elements.
  51789. * @param color the main color to affect to the ground and the background
  51790. */
  51791. setMainColor(color: Color3): void;
  51792. /**
  51793. * Setup the image processing according to the specified options.
  51794. */
  51795. private _setupImageProcessing;
  51796. /**
  51797. * Setup the environment texture according to the specified options.
  51798. */
  51799. private _setupEnvironmentTexture;
  51800. /**
  51801. * Setup the background according to the specified options.
  51802. */
  51803. private _setupBackground;
  51804. /**
  51805. * Get the scene sizes according to the setup.
  51806. */
  51807. private _getSceneSize;
  51808. /**
  51809. * Setup the ground according to the specified options.
  51810. */
  51811. private _setupGround;
  51812. /**
  51813. * Setup the ground material according to the specified options.
  51814. */
  51815. private _setupGroundMaterial;
  51816. /**
  51817. * Setup the ground diffuse texture according to the specified options.
  51818. */
  51819. private _setupGroundDiffuseTexture;
  51820. /**
  51821. * Setup the ground mirror texture according to the specified options.
  51822. */
  51823. private _setupGroundMirrorTexture;
  51824. /**
  51825. * Setup the ground to receive the mirror texture.
  51826. */
  51827. private _setupMirrorInGroundMaterial;
  51828. /**
  51829. * Setup the skybox according to the specified options.
  51830. */
  51831. private _setupSkybox;
  51832. /**
  51833. * Setup the skybox material according to the specified options.
  51834. */
  51835. private _setupSkyboxMaterial;
  51836. /**
  51837. * Setup the skybox reflection texture according to the specified options.
  51838. */
  51839. private _setupSkyboxReflectionTexture;
  51840. private _errorHandler;
  51841. /**
  51842. * Dispose all the elements created by the Helper.
  51843. */
  51844. dispose(): void;
  51845. }
  51846. }
  51847. declare module "babylonjs/Helpers/photoDome" {
  51848. import { Observable } from "babylonjs/Misc/observable";
  51849. import { Nullable } from "babylonjs/types";
  51850. import { Scene } from "babylonjs/scene";
  51851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51852. import { Mesh } from "babylonjs/Meshes/mesh";
  51853. import { Texture } from "babylonjs/Materials/Textures/texture";
  51854. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51855. import "babylonjs/Meshes/Builders/sphereBuilder";
  51856. /**
  51857. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51858. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51859. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51860. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51861. */
  51862. export class PhotoDome extends TransformNode {
  51863. /**
  51864. * Define the image as a Monoscopic panoramic 360 image.
  51865. */
  51866. static readonly MODE_MONOSCOPIC: number;
  51867. /**
  51868. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51869. */
  51870. static readonly MODE_TOPBOTTOM: number;
  51871. /**
  51872. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51873. */
  51874. static readonly MODE_SIDEBYSIDE: number;
  51875. private _useDirectMapping;
  51876. /**
  51877. * The texture being displayed on the sphere
  51878. */
  51879. protected _photoTexture: Texture;
  51880. /**
  51881. * Gets or sets the texture being displayed on the sphere
  51882. */
  51883. get photoTexture(): Texture;
  51884. set photoTexture(value: Texture);
  51885. /**
  51886. * Observable raised when an error occured while loading the 360 image
  51887. */
  51888. onLoadErrorObservable: Observable<string>;
  51889. /**
  51890. * The skybox material
  51891. */
  51892. protected _material: BackgroundMaterial;
  51893. /**
  51894. * The surface used for the skybox
  51895. */
  51896. protected _mesh: Mesh;
  51897. /**
  51898. * Gets the mesh used for the skybox.
  51899. */
  51900. get mesh(): Mesh;
  51901. /**
  51902. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51903. * Also see the options.resolution property.
  51904. */
  51905. get fovMultiplier(): number;
  51906. set fovMultiplier(value: number);
  51907. private _imageMode;
  51908. /**
  51909. * Gets or set the current video mode for the video. It can be:
  51910. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51911. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51912. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51913. */
  51914. get imageMode(): number;
  51915. set imageMode(value: number);
  51916. /**
  51917. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51918. * @param name Element's name, child elements will append suffixes for their own names.
  51919. * @param urlsOfPhoto defines the url of the photo to display
  51920. * @param options defines an object containing optional or exposed sub element properties
  51921. * @param onError defines a callback called when an error occured while loading the texture
  51922. */
  51923. constructor(name: string, urlOfPhoto: string, options: {
  51924. resolution?: number;
  51925. size?: number;
  51926. useDirectMapping?: boolean;
  51927. faceForward?: boolean;
  51928. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51929. private _onBeforeCameraRenderObserver;
  51930. private _changeImageMode;
  51931. /**
  51932. * Releases resources associated with this node.
  51933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51935. */
  51936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51937. }
  51938. }
  51939. declare module "babylonjs/Misc/rgbdTextureTools" {
  51940. import "babylonjs/Shaders/rgbdDecode.fragment";
  51941. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51942. import { Texture } from "babylonjs/Materials/Textures/texture";
  51943. /**
  51944. * Class used to host RGBD texture specific utilities
  51945. */
  51946. export class RGBDTextureTools {
  51947. /**
  51948. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51949. * @param texture the texture to expand.
  51950. */
  51951. static ExpandRGBDTexture(texture: Texture): void;
  51952. }
  51953. }
  51954. declare module "babylonjs/Misc/brdfTextureTools" {
  51955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51956. import { Scene } from "babylonjs/scene";
  51957. /**
  51958. * Class used to host texture specific utilities
  51959. */
  51960. export class BRDFTextureTools {
  51961. /**
  51962. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51963. * @param scene defines the hosting scene
  51964. * @returns the environment BRDF texture
  51965. */
  51966. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51967. private static _environmentBRDFBase64Texture;
  51968. }
  51969. }
  51970. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51971. import { Nullable } from "babylonjs/types";
  51972. import { Color3 } from "babylonjs/Maths/math.color";
  51973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51974. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51975. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51976. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51977. import { Engine } from "babylonjs/Engines/engine";
  51978. import { Scene } from "babylonjs/scene";
  51979. /**
  51980. * @hidden
  51981. */
  51982. export interface IMaterialClearCoatDefines {
  51983. CLEARCOAT: boolean;
  51984. CLEARCOAT_DEFAULTIOR: boolean;
  51985. CLEARCOAT_TEXTURE: boolean;
  51986. CLEARCOAT_TEXTUREDIRECTUV: number;
  51987. CLEARCOAT_BUMP: boolean;
  51988. CLEARCOAT_BUMPDIRECTUV: number;
  51989. CLEARCOAT_TINT: boolean;
  51990. CLEARCOAT_TINT_TEXTURE: boolean;
  51991. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51992. /** @hidden */
  51993. _areTexturesDirty: boolean;
  51994. }
  51995. /**
  51996. * Define the code related to the clear coat parameters of the pbr material.
  51997. */
  51998. export class PBRClearCoatConfiguration {
  51999. /**
  52000. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52001. * The default fits with a polyurethane material.
  52002. */
  52003. private static readonly _DefaultIndexOfRefraction;
  52004. private _isEnabled;
  52005. /**
  52006. * Defines if the clear coat is enabled in the material.
  52007. */
  52008. isEnabled: boolean;
  52009. /**
  52010. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52011. */
  52012. intensity: number;
  52013. /**
  52014. * Defines the clear coat layer roughness.
  52015. */
  52016. roughness: number;
  52017. private _indexOfRefraction;
  52018. /**
  52019. * Defines the index of refraction of the clear coat.
  52020. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52021. * The default fits with a polyurethane material.
  52022. * Changing the default value is more performance intensive.
  52023. */
  52024. indexOfRefraction: number;
  52025. private _texture;
  52026. /**
  52027. * Stores the clear coat values in a texture.
  52028. */
  52029. texture: Nullable<BaseTexture>;
  52030. private _bumpTexture;
  52031. /**
  52032. * Define the clear coat specific bump texture.
  52033. */
  52034. bumpTexture: Nullable<BaseTexture>;
  52035. private _isTintEnabled;
  52036. /**
  52037. * Defines if the clear coat tint is enabled in the material.
  52038. */
  52039. isTintEnabled: boolean;
  52040. /**
  52041. * Defines the clear coat tint of the material.
  52042. * This is only use if tint is enabled
  52043. */
  52044. tintColor: Color3;
  52045. /**
  52046. * Defines the distance at which the tint color should be found in the
  52047. * clear coat media.
  52048. * This is only use if tint is enabled
  52049. */
  52050. tintColorAtDistance: number;
  52051. /**
  52052. * Defines the clear coat layer thickness.
  52053. * This is only use if tint is enabled
  52054. */
  52055. tintThickness: number;
  52056. private _tintTexture;
  52057. /**
  52058. * Stores the clear tint values in a texture.
  52059. * rgb is tint
  52060. * a is a thickness factor
  52061. */
  52062. tintTexture: Nullable<BaseTexture>;
  52063. /** @hidden */
  52064. private _internalMarkAllSubMeshesAsTexturesDirty;
  52065. /** @hidden */
  52066. _markAllSubMeshesAsTexturesDirty(): void;
  52067. /**
  52068. * Instantiate a new istance of clear coat configuration.
  52069. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52070. */
  52071. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52072. /**
  52073. * Gets wehter the submesh is ready to be used or not.
  52074. * @param defines the list of "defines" to update.
  52075. * @param scene defines the scene the material belongs to.
  52076. * @param engine defines the engine the material belongs to.
  52077. * @param disableBumpMap defines wether the material disables bump or not.
  52078. * @returns - boolean indicating that the submesh is ready or not.
  52079. */
  52080. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52081. /**
  52082. * Checks to see if a texture is used in the material.
  52083. * @param defines the list of "defines" to update.
  52084. * @param scene defines the scene to the material belongs to.
  52085. */
  52086. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52087. /**
  52088. * Binds the material data.
  52089. * @param uniformBuffer defines the Uniform buffer to fill in.
  52090. * @param scene defines the scene the material belongs to.
  52091. * @param engine defines the engine the material belongs to.
  52092. * @param disableBumpMap defines wether the material disables bump or not.
  52093. * @param isFrozen defines wether the material is frozen or not.
  52094. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52095. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52096. */
  52097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52098. /**
  52099. * Checks to see if a texture is used in the material.
  52100. * @param texture - Base texture to use.
  52101. * @returns - Boolean specifying if a texture is used in the material.
  52102. */
  52103. hasTexture(texture: BaseTexture): boolean;
  52104. /**
  52105. * Returns an array of the actively used textures.
  52106. * @param activeTextures Array of BaseTextures
  52107. */
  52108. getActiveTextures(activeTextures: BaseTexture[]): void;
  52109. /**
  52110. * Returns the animatable textures.
  52111. * @param animatables Array of animatable textures.
  52112. */
  52113. getAnimatables(animatables: IAnimatable[]): void;
  52114. /**
  52115. * Disposes the resources of the material.
  52116. * @param forceDisposeTextures - Forces the disposal of all textures.
  52117. */
  52118. dispose(forceDisposeTextures?: boolean): void;
  52119. /**
  52120. * Get the current class name of the texture useful for serialization or dynamic coding.
  52121. * @returns "PBRClearCoatConfiguration"
  52122. */
  52123. getClassName(): string;
  52124. /**
  52125. * Add fallbacks to the effect fallbacks list.
  52126. * @param defines defines the Base texture to use.
  52127. * @param fallbacks defines the current fallback list.
  52128. * @param currentRank defines the current fallback rank.
  52129. * @returns the new fallback rank.
  52130. */
  52131. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52132. /**
  52133. * Add the required uniforms to the current list.
  52134. * @param uniforms defines the current uniform list.
  52135. */
  52136. static AddUniforms(uniforms: string[]): void;
  52137. /**
  52138. * Add the required samplers to the current list.
  52139. * @param samplers defines the current sampler list.
  52140. */
  52141. static AddSamplers(samplers: string[]): void;
  52142. /**
  52143. * Add the required uniforms to the current buffer.
  52144. * @param uniformBuffer defines the current uniform buffer.
  52145. */
  52146. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52147. /**
  52148. * Makes a duplicate of the current configuration into another one.
  52149. * @param clearCoatConfiguration define the config where to copy the info
  52150. */
  52151. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52152. /**
  52153. * Serializes this clear coat configuration.
  52154. * @returns - An object with the serialized config.
  52155. */
  52156. serialize(): any;
  52157. /**
  52158. * Parses a anisotropy Configuration from a serialized object.
  52159. * @param source - Serialized object.
  52160. * @param scene Defines the scene we are parsing for
  52161. * @param rootUrl Defines the rootUrl to load from
  52162. */
  52163. parse(source: any, scene: Scene, rootUrl: string): void;
  52164. }
  52165. }
  52166. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52167. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52169. import { Vector2 } from "babylonjs/Maths/math.vector";
  52170. import { Scene } from "babylonjs/scene";
  52171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52172. import { Nullable } from "babylonjs/types";
  52173. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52174. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52175. /**
  52176. * @hidden
  52177. */
  52178. export interface IMaterialAnisotropicDefines {
  52179. ANISOTROPIC: boolean;
  52180. ANISOTROPIC_TEXTURE: boolean;
  52181. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52182. MAINUV1: boolean;
  52183. _areTexturesDirty: boolean;
  52184. _needUVs: boolean;
  52185. }
  52186. /**
  52187. * Define the code related to the anisotropic parameters of the pbr material.
  52188. */
  52189. export class PBRAnisotropicConfiguration {
  52190. private _isEnabled;
  52191. /**
  52192. * Defines if the anisotropy is enabled in the material.
  52193. */
  52194. isEnabled: boolean;
  52195. /**
  52196. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52197. */
  52198. intensity: number;
  52199. /**
  52200. * Defines if the effect is along the tangents, bitangents or in between.
  52201. * By default, the effect is "strectching" the highlights along the tangents.
  52202. */
  52203. direction: Vector2;
  52204. private _texture;
  52205. /**
  52206. * Stores the anisotropy values in a texture.
  52207. * rg is direction (like normal from -1 to 1)
  52208. * b is a intensity
  52209. */
  52210. texture: Nullable<BaseTexture>;
  52211. /** @hidden */
  52212. private _internalMarkAllSubMeshesAsTexturesDirty;
  52213. /** @hidden */
  52214. _markAllSubMeshesAsTexturesDirty(): void;
  52215. /**
  52216. * Instantiate a new istance of anisotropy configuration.
  52217. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52218. */
  52219. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52220. /**
  52221. * Specifies that the submesh is ready to be used.
  52222. * @param defines the list of "defines" to update.
  52223. * @param scene defines the scene the material belongs to.
  52224. * @returns - boolean indicating that the submesh is ready or not.
  52225. */
  52226. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52227. /**
  52228. * Checks to see if a texture is used in the material.
  52229. * @param defines the list of "defines" to update.
  52230. * @param mesh the mesh we are preparing the defines for.
  52231. * @param scene defines the scene the material belongs to.
  52232. */
  52233. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52234. /**
  52235. * Binds the material data.
  52236. * @param uniformBuffer defines the Uniform buffer to fill in.
  52237. * @param scene defines the scene the material belongs to.
  52238. * @param isFrozen defines wether the material is frozen or not.
  52239. */
  52240. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52241. /**
  52242. * Checks to see if a texture is used in the material.
  52243. * @param texture - Base texture to use.
  52244. * @returns - Boolean specifying if a texture is used in the material.
  52245. */
  52246. hasTexture(texture: BaseTexture): boolean;
  52247. /**
  52248. * Returns an array of the actively used textures.
  52249. * @param activeTextures Array of BaseTextures
  52250. */
  52251. getActiveTextures(activeTextures: BaseTexture[]): void;
  52252. /**
  52253. * Returns the animatable textures.
  52254. * @param animatables Array of animatable textures.
  52255. */
  52256. getAnimatables(animatables: IAnimatable[]): void;
  52257. /**
  52258. * Disposes the resources of the material.
  52259. * @param forceDisposeTextures - Forces the disposal of all textures.
  52260. */
  52261. dispose(forceDisposeTextures?: boolean): void;
  52262. /**
  52263. * Get the current class name of the texture useful for serialization or dynamic coding.
  52264. * @returns "PBRAnisotropicConfiguration"
  52265. */
  52266. getClassName(): string;
  52267. /**
  52268. * Add fallbacks to the effect fallbacks list.
  52269. * @param defines defines the Base texture to use.
  52270. * @param fallbacks defines the current fallback list.
  52271. * @param currentRank defines the current fallback rank.
  52272. * @returns the new fallback rank.
  52273. */
  52274. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52275. /**
  52276. * Add the required uniforms to the current list.
  52277. * @param uniforms defines the current uniform list.
  52278. */
  52279. static AddUniforms(uniforms: string[]): void;
  52280. /**
  52281. * Add the required uniforms to the current buffer.
  52282. * @param uniformBuffer defines the current uniform buffer.
  52283. */
  52284. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52285. /**
  52286. * Add the required samplers to the current list.
  52287. * @param samplers defines the current sampler list.
  52288. */
  52289. static AddSamplers(samplers: string[]): void;
  52290. /**
  52291. * Makes a duplicate of the current configuration into another one.
  52292. * @param anisotropicConfiguration define the config where to copy the info
  52293. */
  52294. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52295. /**
  52296. * Serializes this anisotropy configuration.
  52297. * @returns - An object with the serialized config.
  52298. */
  52299. serialize(): any;
  52300. /**
  52301. * Parses a anisotropy Configuration from a serialized object.
  52302. * @param source - Serialized object.
  52303. * @param scene Defines the scene we are parsing for
  52304. * @param rootUrl Defines the rootUrl to load from
  52305. */
  52306. parse(source: any, scene: Scene, rootUrl: string): void;
  52307. }
  52308. }
  52309. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52310. import { Scene } from "babylonjs/scene";
  52311. /**
  52312. * @hidden
  52313. */
  52314. export interface IMaterialBRDFDefines {
  52315. BRDF_V_HEIGHT_CORRELATED: boolean;
  52316. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52317. SPHERICAL_HARMONICS: boolean;
  52318. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52319. /** @hidden */
  52320. _areMiscDirty: boolean;
  52321. }
  52322. /**
  52323. * Define the code related to the BRDF parameters of the pbr material.
  52324. */
  52325. export class PBRBRDFConfiguration {
  52326. /**
  52327. * Default value used for the energy conservation.
  52328. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52329. */
  52330. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52331. /**
  52332. * Default value used for the Smith Visibility Height Correlated mode.
  52333. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52334. */
  52335. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52336. /**
  52337. * Default value used for the IBL diffuse part.
  52338. * This can help switching back to the polynomials mode globally which is a tiny bit
  52339. * less GPU intensive at the drawback of a lower quality.
  52340. */
  52341. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52342. /**
  52343. * Default value used for activating energy conservation for the specular workflow.
  52344. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52345. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52346. */
  52347. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52348. private _useEnergyConservation;
  52349. /**
  52350. * Defines if the material uses energy conservation.
  52351. */
  52352. useEnergyConservation: boolean;
  52353. private _useSmithVisibilityHeightCorrelated;
  52354. /**
  52355. * LEGACY Mode set to false
  52356. * Defines if the material uses height smith correlated visibility term.
  52357. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52358. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52359. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52360. * Not relying on height correlated will also disable energy conservation.
  52361. */
  52362. useSmithVisibilityHeightCorrelated: boolean;
  52363. private _useSphericalHarmonics;
  52364. /**
  52365. * LEGACY Mode set to false
  52366. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52367. * diffuse part of the IBL.
  52368. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52369. * to the ground truth.
  52370. */
  52371. useSphericalHarmonics: boolean;
  52372. private _useSpecularGlossinessInputEnergyConservation;
  52373. /**
  52374. * Defines if the material uses energy conservation, when the specular workflow is active.
  52375. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52376. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52377. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52378. */
  52379. useSpecularGlossinessInputEnergyConservation: boolean;
  52380. /** @hidden */
  52381. private _internalMarkAllSubMeshesAsMiscDirty;
  52382. /** @hidden */
  52383. _markAllSubMeshesAsMiscDirty(): void;
  52384. /**
  52385. * Instantiate a new istance of clear coat configuration.
  52386. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52387. */
  52388. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52389. /**
  52390. * Checks to see if a texture is used in the material.
  52391. * @param defines the list of "defines" to update.
  52392. */
  52393. prepareDefines(defines: IMaterialBRDFDefines): void;
  52394. /**
  52395. * Get the current class name of the texture useful for serialization or dynamic coding.
  52396. * @returns "PBRClearCoatConfiguration"
  52397. */
  52398. getClassName(): string;
  52399. /**
  52400. * Makes a duplicate of the current configuration into another one.
  52401. * @param brdfConfiguration define the config where to copy the info
  52402. */
  52403. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52404. /**
  52405. * Serializes this BRDF configuration.
  52406. * @returns - An object with the serialized config.
  52407. */
  52408. serialize(): any;
  52409. /**
  52410. * Parses a anisotropy Configuration from a serialized object.
  52411. * @param source - Serialized object.
  52412. * @param scene Defines the scene we are parsing for
  52413. * @param rootUrl Defines the rootUrl to load from
  52414. */
  52415. parse(source: any, scene: Scene, rootUrl: string): void;
  52416. }
  52417. }
  52418. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52419. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52420. import { Color3 } from "babylonjs/Maths/math.color";
  52421. import { Scene } from "babylonjs/scene";
  52422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52423. import { Nullable } from "babylonjs/types";
  52424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52425. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52426. /**
  52427. * @hidden
  52428. */
  52429. export interface IMaterialSheenDefines {
  52430. SHEEN: boolean;
  52431. SHEEN_TEXTURE: boolean;
  52432. SHEEN_TEXTUREDIRECTUV: number;
  52433. SHEEN_LINKWITHALBEDO: boolean;
  52434. /** @hidden */
  52435. _areTexturesDirty: boolean;
  52436. }
  52437. /**
  52438. * Define the code related to the Sheen parameters of the pbr material.
  52439. */
  52440. export class PBRSheenConfiguration {
  52441. private _isEnabled;
  52442. /**
  52443. * Defines if the material uses sheen.
  52444. */
  52445. isEnabled: boolean;
  52446. private _linkSheenWithAlbedo;
  52447. /**
  52448. * Defines if the sheen is linked to the sheen color.
  52449. */
  52450. linkSheenWithAlbedo: boolean;
  52451. /**
  52452. * Defines the sheen intensity.
  52453. */
  52454. intensity: number;
  52455. /**
  52456. * Defines the sheen color.
  52457. */
  52458. color: Color3;
  52459. private _texture;
  52460. /**
  52461. * Stores the sheen tint values in a texture.
  52462. * rgb is tint
  52463. * a is a intensity
  52464. */
  52465. texture: Nullable<BaseTexture>;
  52466. /** @hidden */
  52467. private _internalMarkAllSubMeshesAsTexturesDirty;
  52468. /** @hidden */
  52469. _markAllSubMeshesAsTexturesDirty(): void;
  52470. /**
  52471. * Instantiate a new istance of clear coat configuration.
  52472. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52473. */
  52474. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52475. /**
  52476. * Specifies that the submesh is ready to be used.
  52477. * @param defines the list of "defines" to update.
  52478. * @param scene defines the scene the material belongs to.
  52479. * @returns - boolean indicating that the submesh is ready or not.
  52480. */
  52481. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52482. /**
  52483. * Checks to see if a texture is used in the material.
  52484. * @param defines the list of "defines" to update.
  52485. * @param scene defines the scene the material belongs to.
  52486. */
  52487. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52488. /**
  52489. * Binds the material data.
  52490. * @param uniformBuffer defines the Uniform buffer to fill in.
  52491. * @param scene defines the scene the material belongs to.
  52492. * @param isFrozen defines wether the material is frozen or not.
  52493. */
  52494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52495. /**
  52496. * Checks to see if a texture is used in the material.
  52497. * @param texture - Base texture to use.
  52498. * @returns - Boolean specifying if a texture is used in the material.
  52499. */
  52500. hasTexture(texture: BaseTexture): boolean;
  52501. /**
  52502. * Returns an array of the actively used textures.
  52503. * @param activeTextures Array of BaseTextures
  52504. */
  52505. getActiveTextures(activeTextures: BaseTexture[]): void;
  52506. /**
  52507. * Returns the animatable textures.
  52508. * @param animatables Array of animatable textures.
  52509. */
  52510. getAnimatables(animatables: IAnimatable[]): void;
  52511. /**
  52512. * Disposes the resources of the material.
  52513. * @param forceDisposeTextures - Forces the disposal of all textures.
  52514. */
  52515. dispose(forceDisposeTextures?: boolean): void;
  52516. /**
  52517. * Get the current class name of the texture useful for serialization or dynamic coding.
  52518. * @returns "PBRSheenConfiguration"
  52519. */
  52520. getClassName(): string;
  52521. /**
  52522. * Add fallbacks to the effect fallbacks list.
  52523. * @param defines defines the Base texture to use.
  52524. * @param fallbacks defines the current fallback list.
  52525. * @param currentRank defines the current fallback rank.
  52526. * @returns the new fallback rank.
  52527. */
  52528. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52529. /**
  52530. * Add the required uniforms to the current list.
  52531. * @param uniforms defines the current uniform list.
  52532. */
  52533. static AddUniforms(uniforms: string[]): void;
  52534. /**
  52535. * Add the required uniforms to the current buffer.
  52536. * @param uniformBuffer defines the current uniform buffer.
  52537. */
  52538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52539. /**
  52540. * Add the required samplers to the current list.
  52541. * @param samplers defines the current sampler list.
  52542. */
  52543. static AddSamplers(samplers: string[]): void;
  52544. /**
  52545. * Makes a duplicate of the current configuration into another one.
  52546. * @param sheenConfiguration define the config where to copy the info
  52547. */
  52548. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52549. /**
  52550. * Serializes this BRDF configuration.
  52551. * @returns - An object with the serialized config.
  52552. */
  52553. serialize(): any;
  52554. /**
  52555. * Parses a anisotropy Configuration from a serialized object.
  52556. * @param source - Serialized object.
  52557. * @param scene Defines the scene we are parsing for
  52558. * @param rootUrl Defines the rootUrl to load from
  52559. */
  52560. parse(source: any, scene: Scene, rootUrl: string): void;
  52561. }
  52562. }
  52563. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52564. import { Nullable } from "babylonjs/types";
  52565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52566. import { Color3 } from "babylonjs/Maths/math.color";
  52567. import { SmartArray } from "babylonjs/Misc/smartArray";
  52568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52570. import { Effect } from "babylonjs/Materials/effect";
  52571. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52572. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52573. import { Engine } from "babylonjs/Engines/engine";
  52574. import { Scene } from "babylonjs/scene";
  52575. /**
  52576. * @hidden
  52577. */
  52578. export interface IMaterialSubSurfaceDefines {
  52579. SUBSURFACE: boolean;
  52580. SS_REFRACTION: boolean;
  52581. SS_TRANSLUCENCY: boolean;
  52582. SS_SCATERRING: boolean;
  52583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52585. SS_REFRACTIONMAP_3D: boolean;
  52586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52587. SS_LODINREFRACTIONALPHA: boolean;
  52588. SS_GAMMAREFRACTION: boolean;
  52589. SS_RGBDREFRACTION: boolean;
  52590. SS_LINEARSPECULARREFRACTION: boolean;
  52591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52592. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52593. /** @hidden */
  52594. _areTexturesDirty: boolean;
  52595. }
  52596. /**
  52597. * Define the code related to the sub surface parameters of the pbr material.
  52598. */
  52599. export class PBRSubSurfaceConfiguration {
  52600. private _isRefractionEnabled;
  52601. /**
  52602. * Defines if the refraction is enabled in the material.
  52603. */
  52604. isRefractionEnabled: boolean;
  52605. private _isTranslucencyEnabled;
  52606. /**
  52607. * Defines if the translucency is enabled in the material.
  52608. */
  52609. isTranslucencyEnabled: boolean;
  52610. private _isScatteringEnabled;
  52611. /**
  52612. * Defines the refraction intensity of the material.
  52613. * The refraction when enabled replaces the Diffuse part of the material.
  52614. * The intensity helps transitionning between diffuse and refraction.
  52615. */
  52616. refractionIntensity: number;
  52617. /**
  52618. * Defines the translucency intensity of the material.
  52619. * When translucency has been enabled, this defines how much of the "translucency"
  52620. * is addded to the diffuse part of the material.
  52621. */
  52622. translucencyIntensity: number;
  52623. /**
  52624. * Defines the scattering intensity of the material.
  52625. * When scattering has been enabled, this defines how much of the "scattered light"
  52626. * is addded to the diffuse part of the material.
  52627. */
  52628. scatteringIntensity: number;
  52629. private _thicknessTexture;
  52630. /**
  52631. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52632. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52633. * 0 would mean minimumThickness
  52634. * 1 would mean maximumThickness
  52635. * The other channels might be use as a mask to vary the different effects intensity.
  52636. */
  52637. thicknessTexture: Nullable<BaseTexture>;
  52638. private _refractionTexture;
  52639. /**
  52640. * Defines the texture to use for refraction.
  52641. */
  52642. refractionTexture: Nullable<BaseTexture>;
  52643. private _indexOfRefraction;
  52644. /**
  52645. * Defines the index of refraction used in the material.
  52646. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52647. */
  52648. indexOfRefraction: number;
  52649. private _invertRefractionY;
  52650. /**
  52651. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52652. */
  52653. invertRefractionY: boolean;
  52654. private _linkRefractionWithTransparency;
  52655. /**
  52656. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52657. * Materials half opaque for instance using refraction could benefit from this control.
  52658. */
  52659. linkRefractionWithTransparency: boolean;
  52660. /**
  52661. * Defines the minimum thickness stored in the thickness map.
  52662. * If no thickness map is defined, this value will be used to simulate thickness.
  52663. */
  52664. minimumThickness: number;
  52665. /**
  52666. * Defines the maximum thickness stored in the thickness map.
  52667. */
  52668. maximumThickness: number;
  52669. /**
  52670. * Defines the volume tint of the material.
  52671. * This is used for both translucency and scattering.
  52672. */
  52673. tintColor: Color3;
  52674. /**
  52675. * Defines the distance at which the tint color should be found in the media.
  52676. * This is used for refraction only.
  52677. */
  52678. tintColorAtDistance: number;
  52679. /**
  52680. * Defines how far each channel transmit through the media.
  52681. * It is defined as a color to simplify it selection.
  52682. */
  52683. diffusionDistance: Color3;
  52684. private _useMaskFromThicknessTexture;
  52685. /**
  52686. * Stores the intensity of the different subsurface effects in the thickness texture.
  52687. * * the green channel is the translucency intensity.
  52688. * * the blue channel is the scattering intensity.
  52689. * * the alpha channel is the refraction intensity.
  52690. */
  52691. useMaskFromThicknessTexture: boolean;
  52692. /** @hidden */
  52693. private _internalMarkAllSubMeshesAsTexturesDirty;
  52694. /** @hidden */
  52695. _markAllSubMeshesAsTexturesDirty(): void;
  52696. /**
  52697. * Instantiate a new istance of sub surface configuration.
  52698. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52699. */
  52700. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52701. /**
  52702. * Gets wehter the submesh is ready to be used or not.
  52703. * @param defines the list of "defines" to update.
  52704. * @param scene defines the scene the material belongs to.
  52705. * @returns - boolean indicating that the submesh is ready or not.
  52706. */
  52707. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52708. /**
  52709. * Checks to see if a texture is used in the material.
  52710. * @param defines the list of "defines" to update.
  52711. * @param scene defines the scene to the material belongs to.
  52712. */
  52713. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52714. /**
  52715. * Binds the material data.
  52716. * @param uniformBuffer defines the Uniform buffer to fill in.
  52717. * @param scene defines the scene the material belongs to.
  52718. * @param engine defines the engine the material belongs to.
  52719. * @param isFrozen defines wether the material is frozen or not.
  52720. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52721. */
  52722. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52723. /**
  52724. * Unbinds the material from the mesh.
  52725. * @param activeEffect defines the effect that should be unbound from.
  52726. * @returns true if unbound, otherwise false
  52727. */
  52728. unbind(activeEffect: Effect): boolean;
  52729. /**
  52730. * Returns the texture used for refraction or null if none is used.
  52731. * @param scene defines the scene the material belongs to.
  52732. * @returns - Refraction texture if present. If no refraction texture and refraction
  52733. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52734. */
  52735. private _getRefractionTexture;
  52736. /**
  52737. * Returns true if alpha blending should be disabled.
  52738. */
  52739. get disableAlphaBlending(): boolean;
  52740. /**
  52741. * Fills the list of render target textures.
  52742. * @param renderTargets the list of render targets to update
  52743. */
  52744. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52745. /**
  52746. * Checks to see if a texture is used in the material.
  52747. * @param texture - Base texture to use.
  52748. * @returns - Boolean specifying if a texture is used in the material.
  52749. */
  52750. hasTexture(texture: BaseTexture): boolean;
  52751. /**
  52752. * Gets a boolean indicating that current material needs to register RTT
  52753. * @returns true if this uses a render target otherwise false.
  52754. */
  52755. hasRenderTargetTextures(): boolean;
  52756. /**
  52757. * Returns an array of the actively used textures.
  52758. * @param activeTextures Array of BaseTextures
  52759. */
  52760. getActiveTextures(activeTextures: BaseTexture[]): void;
  52761. /**
  52762. * Returns the animatable textures.
  52763. * @param animatables Array of animatable textures.
  52764. */
  52765. getAnimatables(animatables: IAnimatable[]): void;
  52766. /**
  52767. * Disposes the resources of the material.
  52768. * @param forceDisposeTextures - Forces the disposal of all textures.
  52769. */
  52770. dispose(forceDisposeTextures?: boolean): void;
  52771. /**
  52772. * Get the current class name of the texture useful for serialization or dynamic coding.
  52773. * @returns "PBRSubSurfaceConfiguration"
  52774. */
  52775. getClassName(): string;
  52776. /**
  52777. * Add fallbacks to the effect fallbacks list.
  52778. * @param defines defines the Base texture to use.
  52779. * @param fallbacks defines the current fallback list.
  52780. * @param currentRank defines the current fallback rank.
  52781. * @returns the new fallback rank.
  52782. */
  52783. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52784. /**
  52785. * Add the required uniforms to the current list.
  52786. * @param uniforms defines the current uniform list.
  52787. */
  52788. static AddUniforms(uniforms: string[]): void;
  52789. /**
  52790. * Add the required samplers to the current list.
  52791. * @param samplers defines the current sampler list.
  52792. */
  52793. static AddSamplers(samplers: string[]): void;
  52794. /**
  52795. * Add the required uniforms to the current buffer.
  52796. * @param uniformBuffer defines the current uniform buffer.
  52797. */
  52798. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52799. /**
  52800. * Makes a duplicate of the current configuration into another one.
  52801. * @param configuration define the config where to copy the info
  52802. */
  52803. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52804. /**
  52805. * Serializes this Sub Surface configuration.
  52806. * @returns - An object with the serialized config.
  52807. */
  52808. serialize(): any;
  52809. /**
  52810. * Parses a anisotropy Configuration from a serialized object.
  52811. * @param source - Serialized object.
  52812. * @param scene Defines the scene we are parsing for
  52813. * @param rootUrl Defines the rootUrl to load from
  52814. */
  52815. parse(source: any, scene: Scene, rootUrl: string): void;
  52816. }
  52817. }
  52818. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52819. /** @hidden */
  52820. export var pbrFragmentDeclaration: {
  52821. name: string;
  52822. shader: string;
  52823. };
  52824. }
  52825. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52826. /** @hidden */
  52827. export var pbrUboDeclaration: {
  52828. name: string;
  52829. shader: string;
  52830. };
  52831. }
  52832. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52833. /** @hidden */
  52834. export var pbrFragmentExtraDeclaration: {
  52835. name: string;
  52836. shader: string;
  52837. };
  52838. }
  52839. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52840. /** @hidden */
  52841. export var pbrFragmentSamplersDeclaration: {
  52842. name: string;
  52843. shader: string;
  52844. };
  52845. }
  52846. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52847. /** @hidden */
  52848. export var pbrHelperFunctions: {
  52849. name: string;
  52850. shader: string;
  52851. };
  52852. }
  52853. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52854. /** @hidden */
  52855. export var harmonicsFunctions: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52861. /** @hidden */
  52862. export var pbrDirectLightingSetupFunctions: {
  52863. name: string;
  52864. shader: string;
  52865. };
  52866. }
  52867. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52868. /** @hidden */
  52869. export var pbrDirectLightingFalloffFunctions: {
  52870. name: string;
  52871. shader: string;
  52872. };
  52873. }
  52874. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52875. /** @hidden */
  52876. export var pbrBRDFFunctions: {
  52877. name: string;
  52878. shader: string;
  52879. };
  52880. }
  52881. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52882. /** @hidden */
  52883. export var pbrDirectLightingFunctions: {
  52884. name: string;
  52885. shader: string;
  52886. };
  52887. }
  52888. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52889. /** @hidden */
  52890. export var pbrIBLFunctions: {
  52891. name: string;
  52892. shader: string;
  52893. };
  52894. }
  52895. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52896. /** @hidden */
  52897. export var pbrDebug: {
  52898. name: string;
  52899. shader: string;
  52900. };
  52901. }
  52902. declare module "babylonjs/Shaders/pbr.fragment" {
  52903. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52908. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52909. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52910. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52911. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52912. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52913. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52914. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52915. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52916. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52917. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52918. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52919. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52920. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52921. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52922. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52923. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52924. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52925. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52926. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52927. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52928. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52929. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52930. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52931. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52932. /** @hidden */
  52933. export var pbrPixelShader: {
  52934. name: string;
  52935. shader: string;
  52936. };
  52937. }
  52938. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52939. /** @hidden */
  52940. export var pbrVertexDeclaration: {
  52941. name: string;
  52942. shader: string;
  52943. };
  52944. }
  52945. declare module "babylonjs/Shaders/pbr.vertex" {
  52946. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52947. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52948. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52949. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52950. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52951. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52952. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52953. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52954. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52955. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52956. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52959. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52961. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52962. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52963. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52965. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52966. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52967. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52968. /** @hidden */
  52969. export var pbrVertexShader: {
  52970. name: string;
  52971. shader: string;
  52972. };
  52973. }
  52974. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52975. import { Nullable } from "babylonjs/types";
  52976. import { Scene } from "babylonjs/scene";
  52977. import { Matrix } from "babylonjs/Maths/math.vector";
  52978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52980. import { Mesh } from "babylonjs/Meshes/mesh";
  52981. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52982. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52983. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52984. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52985. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52986. import { Color3 } from "babylonjs/Maths/math.color";
  52987. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52988. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52989. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52990. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52992. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52993. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52994. import "babylonjs/Shaders/pbr.fragment";
  52995. import "babylonjs/Shaders/pbr.vertex";
  52996. /**
  52997. * Manages the defines for the PBR Material.
  52998. * @hidden
  52999. */
  53000. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53001. PBR: boolean;
  53002. MAINUV1: boolean;
  53003. MAINUV2: boolean;
  53004. UV1: boolean;
  53005. UV2: boolean;
  53006. ALBEDO: boolean;
  53007. ALBEDODIRECTUV: number;
  53008. VERTEXCOLOR: boolean;
  53009. AMBIENT: boolean;
  53010. AMBIENTDIRECTUV: number;
  53011. AMBIENTINGRAYSCALE: boolean;
  53012. OPACITY: boolean;
  53013. VERTEXALPHA: boolean;
  53014. OPACITYDIRECTUV: number;
  53015. OPACITYRGB: boolean;
  53016. ALPHATEST: boolean;
  53017. DEPTHPREPASS: boolean;
  53018. ALPHABLEND: boolean;
  53019. ALPHAFROMALBEDO: boolean;
  53020. ALPHATESTVALUE: string;
  53021. SPECULAROVERALPHA: boolean;
  53022. RADIANCEOVERALPHA: boolean;
  53023. ALPHAFRESNEL: boolean;
  53024. LINEARALPHAFRESNEL: boolean;
  53025. PREMULTIPLYALPHA: boolean;
  53026. EMISSIVE: boolean;
  53027. EMISSIVEDIRECTUV: number;
  53028. REFLECTIVITY: boolean;
  53029. REFLECTIVITYDIRECTUV: number;
  53030. SPECULARTERM: boolean;
  53031. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53032. MICROSURFACEAUTOMATIC: boolean;
  53033. LODBASEDMICROSFURACE: boolean;
  53034. MICROSURFACEMAP: boolean;
  53035. MICROSURFACEMAPDIRECTUV: number;
  53036. METALLICWORKFLOW: boolean;
  53037. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53038. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53039. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53040. AOSTOREINMETALMAPRED: boolean;
  53041. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53042. ENVIRONMENTBRDF: boolean;
  53043. ENVIRONMENTBRDF_RGBD: boolean;
  53044. NORMAL: boolean;
  53045. TANGENT: boolean;
  53046. BUMP: boolean;
  53047. BUMPDIRECTUV: number;
  53048. OBJECTSPACE_NORMALMAP: boolean;
  53049. PARALLAX: boolean;
  53050. PARALLAXOCCLUSION: boolean;
  53051. NORMALXYSCALE: boolean;
  53052. LIGHTMAP: boolean;
  53053. LIGHTMAPDIRECTUV: number;
  53054. USELIGHTMAPASSHADOWMAP: boolean;
  53055. GAMMALIGHTMAP: boolean;
  53056. RGBDLIGHTMAP: boolean;
  53057. REFLECTION: boolean;
  53058. REFLECTIONMAP_3D: boolean;
  53059. REFLECTIONMAP_SPHERICAL: boolean;
  53060. REFLECTIONMAP_PLANAR: boolean;
  53061. REFLECTIONMAP_CUBIC: boolean;
  53062. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53063. REFLECTIONMAP_PROJECTION: boolean;
  53064. REFLECTIONMAP_SKYBOX: boolean;
  53065. REFLECTIONMAP_EXPLICIT: boolean;
  53066. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53067. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53068. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53069. INVERTCUBICMAP: boolean;
  53070. USESPHERICALFROMREFLECTIONMAP: boolean;
  53071. USEIRRADIANCEMAP: boolean;
  53072. SPHERICAL_HARMONICS: boolean;
  53073. USESPHERICALINVERTEX: boolean;
  53074. REFLECTIONMAP_OPPOSITEZ: boolean;
  53075. LODINREFLECTIONALPHA: boolean;
  53076. GAMMAREFLECTION: boolean;
  53077. RGBDREFLECTION: boolean;
  53078. LINEARSPECULARREFLECTION: boolean;
  53079. RADIANCEOCCLUSION: boolean;
  53080. HORIZONOCCLUSION: boolean;
  53081. INSTANCES: boolean;
  53082. NUM_BONE_INFLUENCERS: number;
  53083. BonesPerMesh: number;
  53084. BONETEXTURE: boolean;
  53085. NONUNIFORMSCALING: boolean;
  53086. MORPHTARGETS: boolean;
  53087. MORPHTARGETS_NORMAL: boolean;
  53088. MORPHTARGETS_TANGENT: boolean;
  53089. MORPHTARGETS_UV: boolean;
  53090. NUM_MORPH_INFLUENCERS: number;
  53091. IMAGEPROCESSING: boolean;
  53092. VIGNETTE: boolean;
  53093. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53094. VIGNETTEBLENDMODEOPAQUE: boolean;
  53095. TONEMAPPING: boolean;
  53096. TONEMAPPING_ACES: boolean;
  53097. CONTRAST: boolean;
  53098. COLORCURVES: boolean;
  53099. COLORGRADING: boolean;
  53100. COLORGRADING3D: boolean;
  53101. SAMPLER3DGREENDEPTH: boolean;
  53102. SAMPLER3DBGRMAP: boolean;
  53103. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53104. EXPOSURE: boolean;
  53105. MULTIVIEW: boolean;
  53106. USEPHYSICALLIGHTFALLOFF: boolean;
  53107. USEGLTFLIGHTFALLOFF: boolean;
  53108. TWOSIDEDLIGHTING: boolean;
  53109. SHADOWFLOAT: boolean;
  53110. CLIPPLANE: boolean;
  53111. CLIPPLANE2: boolean;
  53112. CLIPPLANE3: boolean;
  53113. CLIPPLANE4: boolean;
  53114. CLIPPLANE5: boolean;
  53115. CLIPPLANE6: boolean;
  53116. POINTSIZE: boolean;
  53117. FOG: boolean;
  53118. LOGARITHMICDEPTH: boolean;
  53119. FORCENORMALFORWARD: boolean;
  53120. SPECULARAA: boolean;
  53121. CLEARCOAT: boolean;
  53122. CLEARCOAT_DEFAULTIOR: boolean;
  53123. CLEARCOAT_TEXTURE: boolean;
  53124. CLEARCOAT_TEXTUREDIRECTUV: number;
  53125. CLEARCOAT_BUMP: boolean;
  53126. CLEARCOAT_BUMPDIRECTUV: number;
  53127. CLEARCOAT_TINT: boolean;
  53128. CLEARCOAT_TINT_TEXTURE: boolean;
  53129. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53130. ANISOTROPIC: boolean;
  53131. ANISOTROPIC_TEXTURE: boolean;
  53132. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53133. BRDF_V_HEIGHT_CORRELATED: boolean;
  53134. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53135. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53136. SHEEN: boolean;
  53137. SHEEN_TEXTURE: boolean;
  53138. SHEEN_TEXTUREDIRECTUV: number;
  53139. SHEEN_LINKWITHALBEDO: boolean;
  53140. SUBSURFACE: boolean;
  53141. SS_REFRACTION: boolean;
  53142. SS_TRANSLUCENCY: boolean;
  53143. SS_SCATERRING: boolean;
  53144. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53145. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53146. SS_REFRACTIONMAP_3D: boolean;
  53147. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53148. SS_LODINREFRACTIONALPHA: boolean;
  53149. SS_GAMMAREFRACTION: boolean;
  53150. SS_RGBDREFRACTION: boolean;
  53151. SS_LINEARSPECULARREFRACTION: boolean;
  53152. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53153. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53154. UNLIT: boolean;
  53155. DEBUGMODE: number;
  53156. /**
  53157. * Initializes the PBR Material defines.
  53158. */
  53159. constructor();
  53160. /**
  53161. * Resets the PBR Material defines.
  53162. */
  53163. reset(): void;
  53164. }
  53165. /**
  53166. * The Physically based material base class of BJS.
  53167. *
  53168. * This offers the main features of a standard PBR material.
  53169. * For more information, please refer to the documentation :
  53170. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53171. */
  53172. export abstract class PBRBaseMaterial extends PushMaterial {
  53173. /**
  53174. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53175. */
  53176. static readonly PBRMATERIAL_OPAQUE: number;
  53177. /**
  53178. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53179. */
  53180. static readonly PBRMATERIAL_ALPHATEST: number;
  53181. /**
  53182. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53183. */
  53184. static readonly PBRMATERIAL_ALPHABLEND: number;
  53185. /**
  53186. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53187. * They are also discarded below the alpha cutoff threshold to improve performances.
  53188. */
  53189. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53190. /**
  53191. * Defines the default value of how much AO map is occluding the analytical lights
  53192. * (point spot...).
  53193. */
  53194. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53195. /**
  53196. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53197. */
  53198. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53199. /**
  53200. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53201. * to enhance interoperability with other engines.
  53202. */
  53203. static readonly LIGHTFALLOFF_GLTF: number;
  53204. /**
  53205. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53206. * to enhance interoperability with other materials.
  53207. */
  53208. static readonly LIGHTFALLOFF_STANDARD: number;
  53209. /**
  53210. * Intensity of the direct lights e.g. the four lights available in your scene.
  53211. * This impacts both the direct diffuse and specular highlights.
  53212. */
  53213. protected _directIntensity: number;
  53214. /**
  53215. * Intensity of the emissive part of the material.
  53216. * This helps controlling the emissive effect without modifying the emissive color.
  53217. */
  53218. protected _emissiveIntensity: number;
  53219. /**
  53220. * Intensity of the environment e.g. how much the environment will light the object
  53221. * either through harmonics for rough material or through the refelction for shiny ones.
  53222. */
  53223. protected _environmentIntensity: number;
  53224. /**
  53225. * This is a special control allowing the reduction of the specular highlights coming from the
  53226. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53227. */
  53228. protected _specularIntensity: number;
  53229. /**
  53230. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53231. */
  53232. private _lightingInfos;
  53233. /**
  53234. * Debug Control allowing disabling the bump map on this material.
  53235. */
  53236. protected _disableBumpMap: boolean;
  53237. /**
  53238. * AKA Diffuse Texture in standard nomenclature.
  53239. */
  53240. protected _albedoTexture: Nullable<BaseTexture>;
  53241. /**
  53242. * AKA Occlusion Texture in other nomenclature.
  53243. */
  53244. protected _ambientTexture: Nullable<BaseTexture>;
  53245. /**
  53246. * AKA Occlusion Texture Intensity in other nomenclature.
  53247. */
  53248. protected _ambientTextureStrength: number;
  53249. /**
  53250. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53251. * 1 means it completely occludes it
  53252. * 0 mean it has no impact
  53253. */
  53254. protected _ambientTextureImpactOnAnalyticalLights: number;
  53255. /**
  53256. * Stores the alpha values in a texture.
  53257. */
  53258. protected _opacityTexture: Nullable<BaseTexture>;
  53259. /**
  53260. * Stores the reflection values in a texture.
  53261. */
  53262. protected _reflectionTexture: Nullable<BaseTexture>;
  53263. /**
  53264. * Stores the emissive values in a texture.
  53265. */
  53266. protected _emissiveTexture: Nullable<BaseTexture>;
  53267. /**
  53268. * AKA Specular texture in other nomenclature.
  53269. */
  53270. protected _reflectivityTexture: Nullable<BaseTexture>;
  53271. /**
  53272. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53273. */
  53274. protected _metallicTexture: Nullable<BaseTexture>;
  53275. /**
  53276. * Specifies the metallic scalar of the metallic/roughness workflow.
  53277. * Can also be used to scale the metalness values of the metallic texture.
  53278. */
  53279. protected _metallic: Nullable<number>;
  53280. /**
  53281. * Specifies the roughness scalar of the metallic/roughness workflow.
  53282. * Can also be used to scale the roughness values of the metallic texture.
  53283. */
  53284. protected _roughness: Nullable<number>;
  53285. /**
  53286. * Specifies the an F0 factor to help configuring the material F0.
  53287. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53288. * to 0.5 the previously hard coded value stays the same.
  53289. * Can also be used to scale the F0 values of the metallic texture.
  53290. */
  53291. protected _metallicF0Factor: number;
  53292. /**
  53293. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53294. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53295. * your expectation as it multiplies with the texture data.
  53296. */
  53297. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53298. /**
  53299. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53300. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53301. */
  53302. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53303. /**
  53304. * Stores surface normal data used to displace a mesh in a texture.
  53305. */
  53306. protected _bumpTexture: Nullable<BaseTexture>;
  53307. /**
  53308. * Stores the pre-calculated light information of a mesh in a texture.
  53309. */
  53310. protected _lightmapTexture: Nullable<BaseTexture>;
  53311. /**
  53312. * The color of a material in ambient lighting.
  53313. */
  53314. protected _ambientColor: Color3;
  53315. /**
  53316. * AKA Diffuse Color in other nomenclature.
  53317. */
  53318. protected _albedoColor: Color3;
  53319. /**
  53320. * AKA Specular Color in other nomenclature.
  53321. */
  53322. protected _reflectivityColor: Color3;
  53323. /**
  53324. * The color applied when light is reflected from a material.
  53325. */
  53326. protected _reflectionColor: Color3;
  53327. /**
  53328. * The color applied when light is emitted from a material.
  53329. */
  53330. protected _emissiveColor: Color3;
  53331. /**
  53332. * AKA Glossiness in other nomenclature.
  53333. */
  53334. protected _microSurface: number;
  53335. /**
  53336. * Specifies that the material will use the light map as a show map.
  53337. */
  53338. protected _useLightmapAsShadowmap: boolean;
  53339. /**
  53340. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53341. * makes the reflect vector face the model (under horizon).
  53342. */
  53343. protected _useHorizonOcclusion: boolean;
  53344. /**
  53345. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53346. * too much the area relying on ambient texture to define their ambient occlusion.
  53347. */
  53348. protected _useRadianceOcclusion: boolean;
  53349. /**
  53350. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53351. */
  53352. protected _useAlphaFromAlbedoTexture: boolean;
  53353. /**
  53354. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53355. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53356. */
  53357. protected _useSpecularOverAlpha: boolean;
  53358. /**
  53359. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53360. */
  53361. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53362. /**
  53363. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53364. */
  53365. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53366. /**
  53367. * Specifies if the metallic texture contains the roughness information in its green channel.
  53368. */
  53369. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53370. /**
  53371. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53372. */
  53373. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53374. /**
  53375. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53376. */
  53377. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53378. /**
  53379. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53380. */
  53381. protected _useAmbientInGrayScale: boolean;
  53382. /**
  53383. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53384. * The material will try to infer what glossiness each pixel should be.
  53385. */
  53386. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53387. /**
  53388. * Defines the falloff type used in this material.
  53389. * It by default is Physical.
  53390. */
  53391. protected _lightFalloff: number;
  53392. /**
  53393. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53394. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53395. */
  53396. protected _useRadianceOverAlpha: boolean;
  53397. /**
  53398. * Allows using an object space normal map (instead of tangent space).
  53399. */
  53400. protected _useObjectSpaceNormalMap: boolean;
  53401. /**
  53402. * Allows using the bump map in parallax mode.
  53403. */
  53404. protected _useParallax: boolean;
  53405. /**
  53406. * Allows using the bump map in parallax occlusion mode.
  53407. */
  53408. protected _useParallaxOcclusion: boolean;
  53409. /**
  53410. * Controls the scale bias of the parallax mode.
  53411. */
  53412. protected _parallaxScaleBias: number;
  53413. /**
  53414. * If sets to true, disables all the lights affecting the material.
  53415. */
  53416. protected _disableLighting: boolean;
  53417. /**
  53418. * Number of Simultaneous lights allowed on the material.
  53419. */
  53420. protected _maxSimultaneousLights: number;
  53421. /**
  53422. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53423. */
  53424. protected _invertNormalMapX: boolean;
  53425. /**
  53426. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53427. */
  53428. protected _invertNormalMapY: boolean;
  53429. /**
  53430. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53431. */
  53432. protected _twoSidedLighting: boolean;
  53433. /**
  53434. * Defines the alpha limits in alpha test mode.
  53435. */
  53436. protected _alphaCutOff: number;
  53437. /**
  53438. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53439. */
  53440. protected _forceAlphaTest: boolean;
  53441. /**
  53442. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53443. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53444. */
  53445. protected _useAlphaFresnel: boolean;
  53446. /**
  53447. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53448. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53449. */
  53450. protected _useLinearAlphaFresnel: boolean;
  53451. /**
  53452. * The transparency mode of the material.
  53453. */
  53454. protected _transparencyMode: Nullable<number>;
  53455. /**
  53456. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53457. * from cos thetav and roughness:
  53458. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53459. */
  53460. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53461. /**
  53462. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53463. */
  53464. protected _forceIrradianceInFragment: boolean;
  53465. /**
  53466. * Force normal to face away from face.
  53467. */
  53468. protected _forceNormalForward: boolean;
  53469. /**
  53470. * Enables specular anti aliasing in the PBR shader.
  53471. * It will both interacts on the Geometry for analytical and IBL lighting.
  53472. * It also prefilter the roughness map based on the bump values.
  53473. */
  53474. protected _enableSpecularAntiAliasing: boolean;
  53475. /**
  53476. * Default configuration related to image processing available in the PBR Material.
  53477. */
  53478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53479. /**
  53480. * Keep track of the image processing observer to allow dispose and replace.
  53481. */
  53482. private _imageProcessingObserver;
  53483. /**
  53484. * Attaches a new image processing configuration to the PBR Material.
  53485. * @param configuration
  53486. */
  53487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53488. /**
  53489. * Stores the available render targets.
  53490. */
  53491. private _renderTargets;
  53492. /**
  53493. * Sets the global ambient color for the material used in lighting calculations.
  53494. */
  53495. private _globalAmbientColor;
  53496. /**
  53497. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53498. */
  53499. private _useLogarithmicDepth;
  53500. /**
  53501. * If set to true, no lighting calculations will be applied.
  53502. */
  53503. private _unlit;
  53504. private _debugMode;
  53505. /**
  53506. * @hidden
  53507. * This is reserved for the inspector.
  53508. * Defines the material debug mode.
  53509. * It helps seeing only some components of the material while troubleshooting.
  53510. */
  53511. debugMode: number;
  53512. /**
  53513. * @hidden
  53514. * This is reserved for the inspector.
  53515. * Specify from where on screen the debug mode should start.
  53516. * The value goes from -1 (full screen) to 1 (not visible)
  53517. * It helps with side by side comparison against the final render
  53518. * This defaults to -1
  53519. */
  53520. private debugLimit;
  53521. /**
  53522. * @hidden
  53523. * This is reserved for the inspector.
  53524. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53525. * You can use the factor to better multiply the final value.
  53526. */
  53527. private debugFactor;
  53528. /**
  53529. * Defines the clear coat layer parameters for the material.
  53530. */
  53531. readonly clearCoat: PBRClearCoatConfiguration;
  53532. /**
  53533. * Defines the anisotropic parameters for the material.
  53534. */
  53535. readonly anisotropy: PBRAnisotropicConfiguration;
  53536. /**
  53537. * Defines the BRDF parameters for the material.
  53538. */
  53539. readonly brdf: PBRBRDFConfiguration;
  53540. /**
  53541. * Defines the Sheen parameters for the material.
  53542. */
  53543. readonly sheen: PBRSheenConfiguration;
  53544. /**
  53545. * Defines the SubSurface parameters for the material.
  53546. */
  53547. readonly subSurface: PBRSubSurfaceConfiguration;
  53548. /**
  53549. * Custom callback helping to override the default shader used in the material.
  53550. */
  53551. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53552. protected _rebuildInParallel: boolean;
  53553. /**
  53554. * Instantiates a new PBRMaterial instance.
  53555. *
  53556. * @param name The material name
  53557. * @param scene The scene the material will be use in.
  53558. */
  53559. constructor(name: string, scene: Scene);
  53560. /**
  53561. * Gets a boolean indicating that current material needs to register RTT
  53562. */
  53563. get hasRenderTargetTextures(): boolean;
  53564. /**
  53565. * Gets the name of the material class.
  53566. */
  53567. getClassName(): string;
  53568. /**
  53569. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53570. */
  53571. get useLogarithmicDepth(): boolean;
  53572. /**
  53573. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53574. */
  53575. set useLogarithmicDepth(value: boolean);
  53576. /**
  53577. * Gets the current transparency mode.
  53578. */
  53579. get transparencyMode(): Nullable<number>;
  53580. /**
  53581. * Sets the transparency mode of the material.
  53582. *
  53583. * | Value | Type | Description |
  53584. * | ----- | ----------------------------------- | ----------- |
  53585. * | 0 | OPAQUE | |
  53586. * | 1 | ALPHATEST | |
  53587. * | 2 | ALPHABLEND | |
  53588. * | 3 | ALPHATESTANDBLEND | |
  53589. *
  53590. */
  53591. set transparencyMode(value: Nullable<number>);
  53592. /**
  53593. * Returns true if alpha blending should be disabled.
  53594. */
  53595. private get _disableAlphaBlending();
  53596. /**
  53597. * Specifies whether or not this material should be rendered in alpha blend mode.
  53598. */
  53599. needAlphaBlending(): boolean;
  53600. /**
  53601. * Specifies if the mesh will require alpha blending.
  53602. * @param mesh - BJS mesh.
  53603. */
  53604. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53605. /**
  53606. * Specifies whether or not this material should be rendered in alpha test mode.
  53607. */
  53608. needAlphaTesting(): boolean;
  53609. /**
  53610. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53611. */
  53612. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53613. /**
  53614. * Gets the texture used for the alpha test.
  53615. */
  53616. getAlphaTestTexture(): Nullable<BaseTexture>;
  53617. /**
  53618. * Specifies that the submesh is ready to be used.
  53619. * @param mesh - BJS mesh.
  53620. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53621. * @param useInstances - Specifies that instances should be used.
  53622. * @returns - boolean indicating that the submesh is ready or not.
  53623. */
  53624. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53625. /**
  53626. * Specifies if the material uses metallic roughness workflow.
  53627. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53628. */
  53629. isMetallicWorkflow(): boolean;
  53630. private _prepareEffect;
  53631. private _prepareDefines;
  53632. /**
  53633. * Force shader compilation
  53634. */
  53635. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53636. /**
  53637. * Initializes the uniform buffer layout for the shader.
  53638. */
  53639. buildUniformLayout(): void;
  53640. /**
  53641. * Unbinds the material from the mesh
  53642. */
  53643. unbind(): void;
  53644. /**
  53645. * Binds the submesh data.
  53646. * @param world - The world matrix.
  53647. * @param mesh - The BJS mesh.
  53648. * @param subMesh - A submesh of the BJS mesh.
  53649. */
  53650. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53651. /**
  53652. * Returns the animatable textures.
  53653. * @returns - Array of animatable textures.
  53654. */
  53655. getAnimatables(): IAnimatable[];
  53656. /**
  53657. * Returns the texture used for reflections.
  53658. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53659. */
  53660. private _getReflectionTexture;
  53661. /**
  53662. * Returns an array of the actively used textures.
  53663. * @returns - Array of BaseTextures
  53664. */
  53665. getActiveTextures(): BaseTexture[];
  53666. /**
  53667. * Checks to see if a texture is used in the material.
  53668. * @param texture - Base texture to use.
  53669. * @returns - Boolean specifying if a texture is used in the material.
  53670. */
  53671. hasTexture(texture: BaseTexture): boolean;
  53672. /**
  53673. * Disposes the resources of the material.
  53674. * @param forceDisposeEffect - Forces the disposal of effects.
  53675. * @param forceDisposeTextures - Forces the disposal of all textures.
  53676. */
  53677. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53678. }
  53679. }
  53680. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53681. import { Nullable } from "babylonjs/types";
  53682. import { Scene } from "babylonjs/scene";
  53683. import { Color3 } from "babylonjs/Maths/math.color";
  53684. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53685. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53687. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53688. /**
  53689. * The Physically based material of BJS.
  53690. *
  53691. * This offers the main features of a standard PBR material.
  53692. * For more information, please refer to the documentation :
  53693. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53694. */
  53695. export class PBRMaterial extends PBRBaseMaterial {
  53696. /**
  53697. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53698. */
  53699. static readonly PBRMATERIAL_OPAQUE: number;
  53700. /**
  53701. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53702. */
  53703. static readonly PBRMATERIAL_ALPHATEST: number;
  53704. /**
  53705. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53706. */
  53707. static readonly PBRMATERIAL_ALPHABLEND: number;
  53708. /**
  53709. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53710. * They are also discarded below the alpha cutoff threshold to improve performances.
  53711. */
  53712. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53713. /**
  53714. * Defines the default value of how much AO map is occluding the analytical lights
  53715. * (point spot...).
  53716. */
  53717. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53718. /**
  53719. * Intensity of the direct lights e.g. the four lights available in your scene.
  53720. * This impacts both the direct diffuse and specular highlights.
  53721. */
  53722. directIntensity: number;
  53723. /**
  53724. * Intensity of the emissive part of the material.
  53725. * This helps controlling the emissive effect without modifying the emissive color.
  53726. */
  53727. emissiveIntensity: number;
  53728. /**
  53729. * Intensity of the environment e.g. how much the environment will light the object
  53730. * either through harmonics for rough material or through the refelction for shiny ones.
  53731. */
  53732. environmentIntensity: number;
  53733. /**
  53734. * This is a special control allowing the reduction of the specular highlights coming from the
  53735. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53736. */
  53737. specularIntensity: number;
  53738. /**
  53739. * Debug Control allowing disabling the bump map on this material.
  53740. */
  53741. disableBumpMap: boolean;
  53742. /**
  53743. * AKA Diffuse Texture in standard nomenclature.
  53744. */
  53745. albedoTexture: BaseTexture;
  53746. /**
  53747. * AKA Occlusion Texture in other nomenclature.
  53748. */
  53749. ambientTexture: BaseTexture;
  53750. /**
  53751. * AKA Occlusion Texture Intensity in other nomenclature.
  53752. */
  53753. ambientTextureStrength: number;
  53754. /**
  53755. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53756. * 1 means it completely occludes it
  53757. * 0 mean it has no impact
  53758. */
  53759. ambientTextureImpactOnAnalyticalLights: number;
  53760. /**
  53761. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53762. */
  53763. opacityTexture: BaseTexture;
  53764. /**
  53765. * Stores the reflection values in a texture.
  53766. */
  53767. reflectionTexture: Nullable<BaseTexture>;
  53768. /**
  53769. * Stores the emissive values in a texture.
  53770. */
  53771. emissiveTexture: BaseTexture;
  53772. /**
  53773. * AKA Specular texture in other nomenclature.
  53774. */
  53775. reflectivityTexture: BaseTexture;
  53776. /**
  53777. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53778. */
  53779. metallicTexture: BaseTexture;
  53780. /**
  53781. * Specifies the metallic scalar of the metallic/roughness workflow.
  53782. * Can also be used to scale the metalness values of the metallic texture.
  53783. */
  53784. metallic: Nullable<number>;
  53785. /**
  53786. * Specifies the roughness scalar of the metallic/roughness workflow.
  53787. * Can also be used to scale the roughness values of the metallic texture.
  53788. */
  53789. roughness: Nullable<number>;
  53790. /**
  53791. * Specifies the an F0 factor to help configuring the material F0.
  53792. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53793. * to 0.5 the previously hard coded value stays the same.
  53794. * Can also be used to scale the F0 values of the metallic texture.
  53795. */
  53796. metallicF0Factor: number;
  53797. /**
  53798. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53799. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53800. * your expectation as it multiplies with the texture data.
  53801. */
  53802. useMetallicF0FactorFromMetallicTexture: boolean;
  53803. /**
  53804. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53805. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53806. */
  53807. microSurfaceTexture: BaseTexture;
  53808. /**
  53809. * Stores surface normal data used to displace a mesh in a texture.
  53810. */
  53811. bumpTexture: BaseTexture;
  53812. /**
  53813. * Stores the pre-calculated light information of a mesh in a texture.
  53814. */
  53815. lightmapTexture: BaseTexture;
  53816. /**
  53817. * Stores the refracted light information in a texture.
  53818. */
  53819. get refractionTexture(): Nullable<BaseTexture>;
  53820. set refractionTexture(value: Nullable<BaseTexture>);
  53821. /**
  53822. * The color of a material in ambient lighting.
  53823. */
  53824. ambientColor: Color3;
  53825. /**
  53826. * AKA Diffuse Color in other nomenclature.
  53827. */
  53828. albedoColor: Color3;
  53829. /**
  53830. * AKA Specular Color in other nomenclature.
  53831. */
  53832. reflectivityColor: Color3;
  53833. /**
  53834. * The color reflected from the material.
  53835. */
  53836. reflectionColor: Color3;
  53837. /**
  53838. * The color emitted from the material.
  53839. */
  53840. emissiveColor: Color3;
  53841. /**
  53842. * AKA Glossiness in other nomenclature.
  53843. */
  53844. microSurface: number;
  53845. /**
  53846. * source material index of refraction (IOR)' / 'destination material IOR.
  53847. */
  53848. get indexOfRefraction(): number;
  53849. set indexOfRefraction(value: number);
  53850. /**
  53851. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53852. */
  53853. get invertRefractionY(): boolean;
  53854. set invertRefractionY(value: boolean);
  53855. /**
  53856. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53857. * Materials half opaque for instance using refraction could benefit from this control.
  53858. */
  53859. get linkRefractionWithTransparency(): boolean;
  53860. set linkRefractionWithTransparency(value: boolean);
  53861. /**
  53862. * If true, the light map contains occlusion information instead of lighting info.
  53863. */
  53864. useLightmapAsShadowmap: boolean;
  53865. /**
  53866. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53867. */
  53868. useAlphaFromAlbedoTexture: boolean;
  53869. /**
  53870. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53871. */
  53872. forceAlphaTest: boolean;
  53873. /**
  53874. * Defines the alpha limits in alpha test mode.
  53875. */
  53876. alphaCutOff: number;
  53877. /**
  53878. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53879. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53880. */
  53881. useSpecularOverAlpha: boolean;
  53882. /**
  53883. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53884. */
  53885. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53886. /**
  53887. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53888. */
  53889. useRoughnessFromMetallicTextureAlpha: boolean;
  53890. /**
  53891. * Specifies if the metallic texture contains the roughness information in its green channel.
  53892. */
  53893. useRoughnessFromMetallicTextureGreen: boolean;
  53894. /**
  53895. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53896. */
  53897. useMetallnessFromMetallicTextureBlue: boolean;
  53898. /**
  53899. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53900. */
  53901. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53902. /**
  53903. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53904. */
  53905. useAmbientInGrayScale: boolean;
  53906. /**
  53907. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53908. * The material will try to infer what glossiness each pixel should be.
  53909. */
  53910. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53911. /**
  53912. * BJS is using an harcoded light falloff based on a manually sets up range.
  53913. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53914. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53915. */
  53916. get usePhysicalLightFalloff(): boolean;
  53917. /**
  53918. * BJS is using an harcoded light falloff based on a manually sets up range.
  53919. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53920. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53921. */
  53922. set usePhysicalLightFalloff(value: boolean);
  53923. /**
  53924. * In order to support the falloff compatibility with gltf, a special mode has been added
  53925. * to reproduce the gltf light falloff.
  53926. */
  53927. get useGLTFLightFalloff(): boolean;
  53928. /**
  53929. * In order to support the falloff compatibility with gltf, a special mode has been added
  53930. * to reproduce the gltf light falloff.
  53931. */
  53932. set useGLTFLightFalloff(value: boolean);
  53933. /**
  53934. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53935. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53936. */
  53937. useRadianceOverAlpha: boolean;
  53938. /**
  53939. * Allows using an object space normal map (instead of tangent space).
  53940. */
  53941. useObjectSpaceNormalMap: boolean;
  53942. /**
  53943. * Allows using the bump map in parallax mode.
  53944. */
  53945. useParallax: boolean;
  53946. /**
  53947. * Allows using the bump map in parallax occlusion mode.
  53948. */
  53949. useParallaxOcclusion: boolean;
  53950. /**
  53951. * Controls the scale bias of the parallax mode.
  53952. */
  53953. parallaxScaleBias: number;
  53954. /**
  53955. * If sets to true, disables all the lights affecting the material.
  53956. */
  53957. disableLighting: boolean;
  53958. /**
  53959. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53960. */
  53961. forceIrradianceInFragment: boolean;
  53962. /**
  53963. * Number of Simultaneous lights allowed on the material.
  53964. */
  53965. maxSimultaneousLights: number;
  53966. /**
  53967. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53968. */
  53969. invertNormalMapX: boolean;
  53970. /**
  53971. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53972. */
  53973. invertNormalMapY: boolean;
  53974. /**
  53975. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53976. */
  53977. twoSidedLighting: boolean;
  53978. /**
  53979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53980. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53981. */
  53982. useAlphaFresnel: boolean;
  53983. /**
  53984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53985. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53986. */
  53987. useLinearAlphaFresnel: boolean;
  53988. /**
  53989. * Let user defines the brdf lookup texture used for IBL.
  53990. * A default 8bit version is embedded but you could point at :
  53991. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53992. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53993. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53994. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53995. */
  53996. environmentBRDFTexture: Nullable<BaseTexture>;
  53997. /**
  53998. * Force normal to face away from face.
  53999. */
  54000. forceNormalForward: boolean;
  54001. /**
  54002. * Enables specular anti aliasing in the PBR shader.
  54003. * It will both interacts on the Geometry for analytical and IBL lighting.
  54004. * It also prefilter the roughness map based on the bump values.
  54005. */
  54006. enableSpecularAntiAliasing: boolean;
  54007. /**
  54008. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54009. * makes the reflect vector face the model (under horizon).
  54010. */
  54011. useHorizonOcclusion: boolean;
  54012. /**
  54013. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54014. * too much the area relying on ambient texture to define their ambient occlusion.
  54015. */
  54016. useRadianceOcclusion: boolean;
  54017. /**
  54018. * If set to true, no lighting calculations will be applied.
  54019. */
  54020. unlit: boolean;
  54021. /**
  54022. * Gets the image processing configuration used either in this material.
  54023. */
  54024. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54025. /**
  54026. * Sets the Default image processing configuration used either in the this material.
  54027. *
  54028. * If sets to null, the scene one is in use.
  54029. */
  54030. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54031. /**
  54032. * Gets wether the color curves effect is enabled.
  54033. */
  54034. get cameraColorCurvesEnabled(): boolean;
  54035. /**
  54036. * Sets wether the color curves effect is enabled.
  54037. */
  54038. set cameraColorCurvesEnabled(value: boolean);
  54039. /**
  54040. * Gets wether the color grading effect is enabled.
  54041. */
  54042. get cameraColorGradingEnabled(): boolean;
  54043. /**
  54044. * Gets wether the color grading effect is enabled.
  54045. */
  54046. set cameraColorGradingEnabled(value: boolean);
  54047. /**
  54048. * Gets wether tonemapping is enabled or not.
  54049. */
  54050. get cameraToneMappingEnabled(): boolean;
  54051. /**
  54052. * Sets wether tonemapping is enabled or not
  54053. */
  54054. set cameraToneMappingEnabled(value: boolean);
  54055. /**
  54056. * The camera exposure used on this material.
  54057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54058. * This corresponds to a photographic exposure.
  54059. */
  54060. get cameraExposure(): number;
  54061. /**
  54062. * The camera exposure used on this material.
  54063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54064. * This corresponds to a photographic exposure.
  54065. */
  54066. set cameraExposure(value: number);
  54067. /**
  54068. * Gets The camera contrast used on this material.
  54069. */
  54070. get cameraContrast(): number;
  54071. /**
  54072. * Sets The camera contrast used on this material.
  54073. */
  54074. set cameraContrast(value: number);
  54075. /**
  54076. * Gets the Color Grading 2D Lookup Texture.
  54077. */
  54078. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54079. /**
  54080. * Sets the Color Grading 2D Lookup Texture.
  54081. */
  54082. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54083. /**
  54084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54086. * 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;
  54087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54088. */
  54089. get cameraColorCurves(): Nullable<ColorCurves>;
  54090. /**
  54091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54093. * 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;
  54094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54095. */
  54096. set cameraColorCurves(value: Nullable<ColorCurves>);
  54097. /**
  54098. * Instantiates a new PBRMaterial instance.
  54099. *
  54100. * @param name The material name
  54101. * @param scene The scene the material will be use in.
  54102. */
  54103. constructor(name: string, scene: Scene);
  54104. /**
  54105. * Returns the name of this material class.
  54106. */
  54107. getClassName(): string;
  54108. /**
  54109. * Makes a duplicate of the current material.
  54110. * @param name - name to use for the new material.
  54111. */
  54112. clone(name: string): PBRMaterial;
  54113. /**
  54114. * Serializes this PBR Material.
  54115. * @returns - An object with the serialized material.
  54116. */
  54117. serialize(): any;
  54118. /**
  54119. * Parses a PBR Material from a serialized object.
  54120. * @param source - Serialized object.
  54121. * @param scene - BJS scene instance.
  54122. * @param rootUrl - url for the scene object
  54123. * @returns - PBRMaterial
  54124. */
  54125. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54126. }
  54127. }
  54128. declare module "babylonjs/Misc/dds" {
  54129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54131. import { Nullable } from "babylonjs/types";
  54132. import { Scene } from "babylonjs/scene";
  54133. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54134. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54135. /**
  54136. * Direct draw surface info
  54137. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54138. */
  54139. export interface DDSInfo {
  54140. /**
  54141. * Width of the texture
  54142. */
  54143. width: number;
  54144. /**
  54145. * Width of the texture
  54146. */
  54147. height: number;
  54148. /**
  54149. * Number of Mipmaps for the texture
  54150. * @see https://en.wikipedia.org/wiki/Mipmap
  54151. */
  54152. mipmapCount: number;
  54153. /**
  54154. * If the textures format is a known fourCC format
  54155. * @see https://www.fourcc.org/
  54156. */
  54157. isFourCC: boolean;
  54158. /**
  54159. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54160. */
  54161. isRGB: boolean;
  54162. /**
  54163. * If the texture is a lumincance format
  54164. */
  54165. isLuminance: boolean;
  54166. /**
  54167. * If this is a cube texture
  54168. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54169. */
  54170. isCube: boolean;
  54171. /**
  54172. * If the texture is a compressed format eg. FOURCC_DXT1
  54173. */
  54174. isCompressed: boolean;
  54175. /**
  54176. * The dxgiFormat of the texture
  54177. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54178. */
  54179. dxgiFormat: number;
  54180. /**
  54181. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54182. */
  54183. textureType: number;
  54184. /**
  54185. * Sphericle polynomial created for the dds texture
  54186. */
  54187. sphericalPolynomial?: SphericalPolynomial;
  54188. }
  54189. /**
  54190. * Class used to provide DDS decompression tools
  54191. */
  54192. export class DDSTools {
  54193. /**
  54194. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54195. */
  54196. static StoreLODInAlphaChannel: boolean;
  54197. /**
  54198. * Gets DDS information from an array buffer
  54199. * @param data defines the array buffer view to read data from
  54200. * @returns the DDS information
  54201. */
  54202. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54203. private static _FloatView;
  54204. private static _Int32View;
  54205. private static _ToHalfFloat;
  54206. private static _FromHalfFloat;
  54207. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54208. private static _GetHalfFloatRGBAArrayBuffer;
  54209. private static _GetFloatRGBAArrayBuffer;
  54210. private static _GetFloatAsUIntRGBAArrayBuffer;
  54211. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54212. private static _GetRGBAArrayBuffer;
  54213. private static _ExtractLongWordOrder;
  54214. private static _GetRGBArrayBuffer;
  54215. private static _GetLuminanceArrayBuffer;
  54216. /**
  54217. * Uploads DDS Levels to a Babylon Texture
  54218. * @hidden
  54219. */
  54220. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54221. }
  54222. module "babylonjs/Engines/thinEngine" {
  54223. interface ThinEngine {
  54224. /**
  54225. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54226. * @param rootUrl defines the url where the file to load is located
  54227. * @param scene defines the current scene
  54228. * @param lodScale defines scale to apply to the mip map selection
  54229. * @param lodOffset defines offset to apply to the mip map selection
  54230. * @param onLoad defines an optional callback raised when the texture is loaded
  54231. * @param onError defines an optional callback raised if there is an issue to load the texture
  54232. * @param format defines the format of the data
  54233. * @param forcedExtension defines the extension to use to pick the right loader
  54234. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54235. * @returns the cube texture as an InternalTexture
  54236. */
  54237. 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;
  54238. }
  54239. }
  54240. }
  54241. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54242. import { Nullable } from "babylonjs/types";
  54243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54244. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54245. /**
  54246. * Implementation of the DDS Texture Loader.
  54247. * @hidden
  54248. */
  54249. export class _DDSTextureLoader implements IInternalTextureLoader {
  54250. /**
  54251. * Defines wether the loader supports cascade loading the different faces.
  54252. */
  54253. readonly supportCascades: boolean;
  54254. /**
  54255. * This returns if the loader support the current file information.
  54256. * @param extension defines the file extension of the file being loaded
  54257. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54258. * @param fallback defines the fallback internal texture if any
  54259. * @param isBase64 defines whether the texture is encoded as a base64
  54260. * @param isBuffer defines whether the texture data are stored as a buffer
  54261. * @returns true if the loader can load the specified file
  54262. */
  54263. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54264. /**
  54265. * Transform the url before loading if required.
  54266. * @param rootUrl the url of the texture
  54267. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54268. * @returns the transformed texture
  54269. */
  54270. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54271. /**
  54272. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54273. * @param rootUrl the url of the texture
  54274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54275. * @returns the fallback texture
  54276. */
  54277. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54278. /**
  54279. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54280. * @param data contains the texture data
  54281. * @param texture defines the BabylonJS internal texture
  54282. * @param createPolynomials will be true if polynomials have been requested
  54283. * @param onLoad defines the callback to trigger once the texture is ready
  54284. * @param onError defines the callback to trigger in case of error
  54285. */
  54286. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54287. /**
  54288. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54289. * @param data contains the texture data
  54290. * @param texture defines the BabylonJS internal texture
  54291. * @param callback defines the method to call once ready to upload
  54292. */
  54293. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54294. }
  54295. }
  54296. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54297. import { Nullable } from "babylonjs/types";
  54298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54299. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54300. /**
  54301. * Implementation of the ENV Texture Loader.
  54302. * @hidden
  54303. */
  54304. export class _ENVTextureLoader implements IInternalTextureLoader {
  54305. /**
  54306. * Defines wether the loader supports cascade loading the different faces.
  54307. */
  54308. readonly supportCascades: boolean;
  54309. /**
  54310. * This returns if the loader support the current file information.
  54311. * @param extension defines the file extension of the file being loaded
  54312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54313. * @param fallback defines the fallback internal texture if any
  54314. * @param isBase64 defines whether the texture is encoded as a base64
  54315. * @param isBuffer defines whether the texture data are stored as a buffer
  54316. * @returns true if the loader can load the specified file
  54317. */
  54318. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54319. /**
  54320. * Transform the url before loading if required.
  54321. * @param rootUrl the url of the texture
  54322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54323. * @returns the transformed texture
  54324. */
  54325. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54326. /**
  54327. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54328. * @param rootUrl the url of the texture
  54329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54330. * @returns the fallback texture
  54331. */
  54332. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54333. /**
  54334. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54335. * @param data contains the texture data
  54336. * @param texture defines the BabylonJS internal texture
  54337. * @param createPolynomials will be true if polynomials have been requested
  54338. * @param onLoad defines the callback to trigger once the texture is ready
  54339. * @param onError defines the callback to trigger in case of error
  54340. */
  54341. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54342. /**
  54343. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54344. * @param data contains the texture data
  54345. * @param texture defines the BabylonJS internal texture
  54346. * @param callback defines the method to call once ready to upload
  54347. */
  54348. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54349. }
  54350. }
  54351. declare module "babylonjs/Misc/khronosTextureContainer" {
  54352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54353. /**
  54354. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54355. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54356. */
  54357. export class KhronosTextureContainer {
  54358. /** contents of the KTX container file */
  54359. data: ArrayBufferView;
  54360. private static HEADER_LEN;
  54361. private static COMPRESSED_2D;
  54362. private static COMPRESSED_3D;
  54363. private static TEX_2D;
  54364. private static TEX_3D;
  54365. /**
  54366. * Gets the openGL type
  54367. */
  54368. glType: number;
  54369. /**
  54370. * Gets the openGL type size
  54371. */
  54372. glTypeSize: number;
  54373. /**
  54374. * Gets the openGL format
  54375. */
  54376. glFormat: number;
  54377. /**
  54378. * Gets the openGL internal format
  54379. */
  54380. glInternalFormat: number;
  54381. /**
  54382. * Gets the base internal format
  54383. */
  54384. glBaseInternalFormat: number;
  54385. /**
  54386. * Gets image width in pixel
  54387. */
  54388. pixelWidth: number;
  54389. /**
  54390. * Gets image height in pixel
  54391. */
  54392. pixelHeight: number;
  54393. /**
  54394. * Gets image depth in pixels
  54395. */
  54396. pixelDepth: number;
  54397. /**
  54398. * Gets the number of array elements
  54399. */
  54400. numberOfArrayElements: number;
  54401. /**
  54402. * Gets the number of faces
  54403. */
  54404. numberOfFaces: number;
  54405. /**
  54406. * Gets the number of mipmap levels
  54407. */
  54408. numberOfMipmapLevels: number;
  54409. /**
  54410. * Gets the bytes of key value data
  54411. */
  54412. bytesOfKeyValueData: number;
  54413. /**
  54414. * Gets the load type
  54415. */
  54416. loadType: number;
  54417. /**
  54418. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54419. */
  54420. isInvalid: boolean;
  54421. /**
  54422. * Creates a new KhronosTextureContainer
  54423. * @param data contents of the KTX container file
  54424. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54425. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54426. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54427. */
  54428. constructor(
  54429. /** contents of the KTX container file */
  54430. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54431. /**
  54432. * Uploads KTX content to a Babylon Texture.
  54433. * It is assumed that the texture has already been created & is currently bound
  54434. * @hidden
  54435. */
  54436. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54437. private _upload2DCompressedLevels;
  54438. }
  54439. }
  54440. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54441. import { Nullable } from "babylonjs/types";
  54442. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54443. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54444. /**
  54445. * Implementation of the KTX Texture Loader.
  54446. * @hidden
  54447. */
  54448. export class _KTXTextureLoader implements IInternalTextureLoader {
  54449. /**
  54450. * Defines wether the loader supports cascade loading the different faces.
  54451. */
  54452. readonly supportCascades: boolean;
  54453. /**
  54454. * This returns if the loader support the current file information.
  54455. * @param extension defines the file extension of the file being loaded
  54456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54457. * @param fallback defines the fallback internal texture if any
  54458. * @param isBase64 defines whether the texture is encoded as a base64
  54459. * @param isBuffer defines whether the texture data are stored as a buffer
  54460. * @returns true if the loader can load the specified file
  54461. */
  54462. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54463. /**
  54464. * Transform the url before loading if required.
  54465. * @param rootUrl the url of the texture
  54466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54467. * @returns the transformed texture
  54468. */
  54469. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54470. /**
  54471. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54472. * @param rootUrl the url of the texture
  54473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54474. * @returns the fallback texture
  54475. */
  54476. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54477. /**
  54478. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54479. * @param data contains the texture data
  54480. * @param texture defines the BabylonJS internal texture
  54481. * @param createPolynomials will be true if polynomials have been requested
  54482. * @param onLoad defines the callback to trigger once the texture is ready
  54483. * @param onError defines the callback to trigger in case of error
  54484. */
  54485. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54486. /**
  54487. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54488. * @param data contains the texture data
  54489. * @param texture defines the BabylonJS internal texture
  54490. * @param callback defines the method to call once ready to upload
  54491. */
  54492. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54493. }
  54494. }
  54495. declare module "babylonjs/Helpers/sceneHelpers" {
  54496. import { Nullable } from "babylonjs/types";
  54497. import { Mesh } from "babylonjs/Meshes/mesh";
  54498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54499. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54500. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54501. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54502. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54503. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54504. import "babylonjs/Meshes/Builders/boxBuilder";
  54505. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54506. /** @hidden */
  54507. export var _forceSceneHelpersToBundle: boolean;
  54508. module "babylonjs/scene" {
  54509. interface Scene {
  54510. /**
  54511. * Creates a default light for the scene.
  54512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54513. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54514. */
  54515. createDefaultLight(replace?: boolean): void;
  54516. /**
  54517. * Creates a default camera for the scene.
  54518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54519. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54520. * @param replace has default false, when true replaces the active camera in the scene
  54521. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54522. */
  54523. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54524. /**
  54525. * Creates a default camera and a default light.
  54526. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54528. * @param replace has the default false, when true replaces the active camera/light in the scene
  54529. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54530. */
  54531. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54532. /**
  54533. * Creates a new sky box
  54534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54535. * @param environmentTexture defines the texture to use as environment texture
  54536. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54537. * @param scale defines the overall scale of the skybox
  54538. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54539. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54540. * @returns a new mesh holding the sky box
  54541. */
  54542. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54543. /**
  54544. * Creates a new environment
  54545. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54546. * @param options defines the options you can use to configure the environment
  54547. * @returns the new EnvironmentHelper
  54548. */
  54549. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54550. /**
  54551. * Creates a new VREXperienceHelper
  54552. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54553. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54554. * @returns a new VREXperienceHelper
  54555. */
  54556. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54557. /**
  54558. * Creates a new WebXRDefaultExperience
  54559. * @see http://doc.babylonjs.com/how_to/webxr
  54560. * @param options experience options
  54561. * @returns a promise for a new WebXRDefaultExperience
  54562. */
  54563. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54564. }
  54565. }
  54566. }
  54567. declare module "babylonjs/Helpers/videoDome" {
  54568. import { Scene } from "babylonjs/scene";
  54569. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54570. import { Mesh } from "babylonjs/Meshes/mesh";
  54571. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54572. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54573. import "babylonjs/Meshes/Builders/sphereBuilder";
  54574. /**
  54575. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54576. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54577. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54578. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54579. */
  54580. export class VideoDome extends TransformNode {
  54581. /**
  54582. * Define the video source as a Monoscopic panoramic 360 video.
  54583. */
  54584. static readonly MODE_MONOSCOPIC: number;
  54585. /**
  54586. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54587. */
  54588. static readonly MODE_TOPBOTTOM: number;
  54589. /**
  54590. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54591. */
  54592. static readonly MODE_SIDEBYSIDE: number;
  54593. private _halfDome;
  54594. private _useDirectMapping;
  54595. /**
  54596. * The video texture being displayed on the sphere
  54597. */
  54598. protected _videoTexture: VideoTexture;
  54599. /**
  54600. * Gets the video texture being displayed on the sphere
  54601. */
  54602. get videoTexture(): VideoTexture;
  54603. /**
  54604. * The skybox material
  54605. */
  54606. protected _material: BackgroundMaterial;
  54607. /**
  54608. * The surface used for the skybox
  54609. */
  54610. protected _mesh: Mesh;
  54611. /**
  54612. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54613. */
  54614. private _halfDomeMask;
  54615. /**
  54616. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54617. * Also see the options.resolution property.
  54618. */
  54619. get fovMultiplier(): number;
  54620. set fovMultiplier(value: number);
  54621. private _videoMode;
  54622. /**
  54623. * Gets or set the current video mode for the video. It can be:
  54624. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54625. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54626. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54627. */
  54628. get videoMode(): number;
  54629. set videoMode(value: number);
  54630. /**
  54631. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54632. *
  54633. */
  54634. get halfDome(): boolean;
  54635. /**
  54636. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54637. */
  54638. set halfDome(enabled: boolean);
  54639. /**
  54640. * Oberserver used in Stereoscopic VR Mode.
  54641. */
  54642. private _onBeforeCameraRenderObserver;
  54643. /**
  54644. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54645. * @param name Element's name, child elements will append suffixes for their own names.
  54646. * @param urlsOrVideo defines the url(s) or the video element to use
  54647. * @param options An object containing optional or exposed sub element properties
  54648. */
  54649. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54650. resolution?: number;
  54651. clickToPlay?: boolean;
  54652. autoPlay?: boolean;
  54653. loop?: boolean;
  54654. size?: number;
  54655. poster?: string;
  54656. faceForward?: boolean;
  54657. useDirectMapping?: boolean;
  54658. halfDomeMode?: boolean;
  54659. }, scene: Scene);
  54660. private _changeVideoMode;
  54661. /**
  54662. * Releases resources associated with this node.
  54663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54665. */
  54666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54667. }
  54668. }
  54669. declare module "babylonjs/Helpers/index" {
  54670. export * from "babylonjs/Helpers/environmentHelper";
  54671. export * from "babylonjs/Helpers/photoDome";
  54672. export * from "babylonjs/Helpers/sceneHelpers";
  54673. export * from "babylonjs/Helpers/videoDome";
  54674. }
  54675. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54676. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54677. import { IDisposable } from "babylonjs/scene";
  54678. import { Engine } from "babylonjs/Engines/engine";
  54679. /**
  54680. * This class can be used to get instrumentation data from a Babylon engine
  54681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54682. */
  54683. export class EngineInstrumentation implements IDisposable {
  54684. /**
  54685. * Define the instrumented engine.
  54686. */
  54687. engine: Engine;
  54688. private _captureGPUFrameTime;
  54689. private _gpuFrameTimeToken;
  54690. private _gpuFrameTime;
  54691. private _captureShaderCompilationTime;
  54692. private _shaderCompilationTime;
  54693. private _onBeginFrameObserver;
  54694. private _onEndFrameObserver;
  54695. private _onBeforeShaderCompilationObserver;
  54696. private _onAfterShaderCompilationObserver;
  54697. /**
  54698. * Gets the perf counter used for GPU frame time
  54699. */
  54700. get gpuFrameTimeCounter(): PerfCounter;
  54701. /**
  54702. * Gets the GPU frame time capture status
  54703. */
  54704. get captureGPUFrameTime(): boolean;
  54705. /**
  54706. * Enable or disable the GPU frame time capture
  54707. */
  54708. set captureGPUFrameTime(value: boolean);
  54709. /**
  54710. * Gets the perf counter used for shader compilation time
  54711. */
  54712. get shaderCompilationTimeCounter(): PerfCounter;
  54713. /**
  54714. * Gets the shader compilation time capture status
  54715. */
  54716. get captureShaderCompilationTime(): boolean;
  54717. /**
  54718. * Enable or disable the shader compilation time capture
  54719. */
  54720. set captureShaderCompilationTime(value: boolean);
  54721. /**
  54722. * Instantiates a new engine instrumentation.
  54723. * This class can be used to get instrumentation data from a Babylon engine
  54724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54725. * @param engine Defines the engine to instrument
  54726. */
  54727. constructor(
  54728. /**
  54729. * Define the instrumented engine.
  54730. */
  54731. engine: Engine);
  54732. /**
  54733. * Dispose and release associated resources.
  54734. */
  54735. dispose(): void;
  54736. }
  54737. }
  54738. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54739. import { Scene, IDisposable } from "babylonjs/scene";
  54740. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54741. /**
  54742. * This class can be used to get instrumentation data from a Babylon engine
  54743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54744. */
  54745. export class SceneInstrumentation implements IDisposable {
  54746. /**
  54747. * Defines the scene to instrument
  54748. */
  54749. scene: Scene;
  54750. private _captureActiveMeshesEvaluationTime;
  54751. private _activeMeshesEvaluationTime;
  54752. private _captureRenderTargetsRenderTime;
  54753. private _renderTargetsRenderTime;
  54754. private _captureFrameTime;
  54755. private _frameTime;
  54756. private _captureRenderTime;
  54757. private _renderTime;
  54758. private _captureInterFrameTime;
  54759. private _interFrameTime;
  54760. private _captureParticlesRenderTime;
  54761. private _particlesRenderTime;
  54762. private _captureSpritesRenderTime;
  54763. private _spritesRenderTime;
  54764. private _capturePhysicsTime;
  54765. private _physicsTime;
  54766. private _captureAnimationsTime;
  54767. private _animationsTime;
  54768. private _captureCameraRenderTime;
  54769. private _cameraRenderTime;
  54770. private _onBeforeActiveMeshesEvaluationObserver;
  54771. private _onAfterActiveMeshesEvaluationObserver;
  54772. private _onBeforeRenderTargetsRenderObserver;
  54773. private _onAfterRenderTargetsRenderObserver;
  54774. private _onAfterRenderObserver;
  54775. private _onBeforeDrawPhaseObserver;
  54776. private _onAfterDrawPhaseObserver;
  54777. private _onBeforeAnimationsObserver;
  54778. private _onBeforeParticlesRenderingObserver;
  54779. private _onAfterParticlesRenderingObserver;
  54780. private _onBeforeSpritesRenderingObserver;
  54781. private _onAfterSpritesRenderingObserver;
  54782. private _onBeforePhysicsObserver;
  54783. private _onAfterPhysicsObserver;
  54784. private _onAfterAnimationsObserver;
  54785. private _onBeforeCameraRenderObserver;
  54786. private _onAfterCameraRenderObserver;
  54787. /**
  54788. * Gets the perf counter used for active meshes evaluation time
  54789. */
  54790. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54791. /**
  54792. * Gets the active meshes evaluation time capture status
  54793. */
  54794. get captureActiveMeshesEvaluationTime(): boolean;
  54795. /**
  54796. * Enable or disable the active meshes evaluation time capture
  54797. */
  54798. set captureActiveMeshesEvaluationTime(value: boolean);
  54799. /**
  54800. * Gets the perf counter used for render targets render time
  54801. */
  54802. get renderTargetsRenderTimeCounter(): PerfCounter;
  54803. /**
  54804. * Gets the render targets render time capture status
  54805. */
  54806. get captureRenderTargetsRenderTime(): boolean;
  54807. /**
  54808. * Enable or disable the render targets render time capture
  54809. */
  54810. set captureRenderTargetsRenderTime(value: boolean);
  54811. /**
  54812. * Gets the perf counter used for particles render time
  54813. */
  54814. get particlesRenderTimeCounter(): PerfCounter;
  54815. /**
  54816. * Gets the particles render time capture status
  54817. */
  54818. get captureParticlesRenderTime(): boolean;
  54819. /**
  54820. * Enable or disable the particles render time capture
  54821. */
  54822. set captureParticlesRenderTime(value: boolean);
  54823. /**
  54824. * Gets the perf counter used for sprites render time
  54825. */
  54826. get spritesRenderTimeCounter(): PerfCounter;
  54827. /**
  54828. * Gets the sprites render time capture status
  54829. */
  54830. get captureSpritesRenderTime(): boolean;
  54831. /**
  54832. * Enable or disable the sprites render time capture
  54833. */
  54834. set captureSpritesRenderTime(value: boolean);
  54835. /**
  54836. * Gets the perf counter used for physics time
  54837. */
  54838. get physicsTimeCounter(): PerfCounter;
  54839. /**
  54840. * Gets the physics time capture status
  54841. */
  54842. get capturePhysicsTime(): boolean;
  54843. /**
  54844. * Enable or disable the physics time capture
  54845. */
  54846. set capturePhysicsTime(value: boolean);
  54847. /**
  54848. * Gets the perf counter used for animations time
  54849. */
  54850. get animationsTimeCounter(): PerfCounter;
  54851. /**
  54852. * Gets the animations time capture status
  54853. */
  54854. get captureAnimationsTime(): boolean;
  54855. /**
  54856. * Enable or disable the animations time capture
  54857. */
  54858. set captureAnimationsTime(value: boolean);
  54859. /**
  54860. * Gets the perf counter used for frame time capture
  54861. */
  54862. get frameTimeCounter(): PerfCounter;
  54863. /**
  54864. * Gets the frame time capture status
  54865. */
  54866. get captureFrameTime(): boolean;
  54867. /**
  54868. * Enable or disable the frame time capture
  54869. */
  54870. set captureFrameTime(value: boolean);
  54871. /**
  54872. * Gets the perf counter used for inter-frames time capture
  54873. */
  54874. get interFrameTimeCounter(): PerfCounter;
  54875. /**
  54876. * Gets the inter-frames time capture status
  54877. */
  54878. get captureInterFrameTime(): boolean;
  54879. /**
  54880. * Enable or disable the inter-frames time capture
  54881. */
  54882. set captureInterFrameTime(value: boolean);
  54883. /**
  54884. * Gets the perf counter used for render time capture
  54885. */
  54886. get renderTimeCounter(): PerfCounter;
  54887. /**
  54888. * Gets the render time capture status
  54889. */
  54890. get captureRenderTime(): boolean;
  54891. /**
  54892. * Enable or disable the render time capture
  54893. */
  54894. set captureRenderTime(value: boolean);
  54895. /**
  54896. * Gets the perf counter used for camera render time capture
  54897. */
  54898. get cameraRenderTimeCounter(): PerfCounter;
  54899. /**
  54900. * Gets the camera render time capture status
  54901. */
  54902. get captureCameraRenderTime(): boolean;
  54903. /**
  54904. * Enable or disable the camera render time capture
  54905. */
  54906. set captureCameraRenderTime(value: boolean);
  54907. /**
  54908. * Gets the perf counter used for draw calls
  54909. */
  54910. get drawCallsCounter(): PerfCounter;
  54911. /**
  54912. * Instantiates a new scene instrumentation.
  54913. * This class can be used to get instrumentation data from a Babylon engine
  54914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54915. * @param scene Defines the scene to instrument
  54916. */
  54917. constructor(
  54918. /**
  54919. * Defines the scene to instrument
  54920. */
  54921. scene: Scene);
  54922. /**
  54923. * Dispose and release associated resources.
  54924. */
  54925. dispose(): void;
  54926. }
  54927. }
  54928. declare module "babylonjs/Instrumentation/index" {
  54929. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54930. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54931. export * from "babylonjs/Instrumentation/timeToken";
  54932. }
  54933. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54934. /** @hidden */
  54935. export var glowMapGenerationPixelShader: {
  54936. name: string;
  54937. shader: string;
  54938. };
  54939. }
  54940. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54946. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54947. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54948. /** @hidden */
  54949. export var glowMapGenerationVertexShader: {
  54950. name: string;
  54951. shader: string;
  54952. };
  54953. }
  54954. declare module "babylonjs/Layers/effectLayer" {
  54955. import { Observable } from "babylonjs/Misc/observable";
  54956. import { Nullable } from "babylonjs/types";
  54957. import { Camera } from "babylonjs/Cameras/camera";
  54958. import { Scene } from "babylonjs/scene";
  54959. import { ISize } from "babylonjs/Maths/math.size";
  54960. import { Color4 } from "babylonjs/Maths/math.color";
  54961. import { Engine } from "babylonjs/Engines/engine";
  54962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54964. import { Mesh } from "babylonjs/Meshes/mesh";
  54965. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54968. import { Effect } from "babylonjs/Materials/effect";
  54969. import { Material } from "babylonjs/Materials/material";
  54970. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54971. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54972. /**
  54973. * Effect layer options. This helps customizing the behaviour
  54974. * of the effect layer.
  54975. */
  54976. export interface IEffectLayerOptions {
  54977. /**
  54978. * Multiplication factor apply to the canvas size to compute the render target size
  54979. * used to generated the objects (the smaller the faster).
  54980. */
  54981. mainTextureRatio: number;
  54982. /**
  54983. * Enforces a fixed size texture to ensure effect stability across devices.
  54984. */
  54985. mainTextureFixedSize?: number;
  54986. /**
  54987. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54988. */
  54989. alphaBlendingMode: number;
  54990. /**
  54991. * The camera attached to the layer.
  54992. */
  54993. camera: Nullable<Camera>;
  54994. /**
  54995. * The rendering group to draw the layer in.
  54996. */
  54997. renderingGroupId: number;
  54998. }
  54999. /**
  55000. * The effect layer Helps adding post process effect blended with the main pass.
  55001. *
  55002. * This can be for instance use to generate glow or higlight effects on the scene.
  55003. *
  55004. * The effect layer class can not be used directly and is intented to inherited from to be
  55005. * customized per effects.
  55006. */
  55007. export abstract class EffectLayer {
  55008. private _vertexBuffers;
  55009. private _indexBuffer;
  55010. private _cachedDefines;
  55011. private _effectLayerMapGenerationEffect;
  55012. private _effectLayerOptions;
  55013. private _mergeEffect;
  55014. protected _scene: Scene;
  55015. protected _engine: Engine;
  55016. protected _maxSize: number;
  55017. protected _mainTextureDesiredSize: ISize;
  55018. protected _mainTexture: RenderTargetTexture;
  55019. protected _shouldRender: boolean;
  55020. protected _postProcesses: PostProcess[];
  55021. protected _textures: BaseTexture[];
  55022. protected _emissiveTextureAndColor: {
  55023. texture: Nullable<BaseTexture>;
  55024. color: Color4;
  55025. };
  55026. /**
  55027. * The name of the layer
  55028. */
  55029. name: string;
  55030. /**
  55031. * The clear color of the texture used to generate the glow map.
  55032. */
  55033. neutralColor: Color4;
  55034. /**
  55035. * Specifies whether the highlight layer is enabled or not.
  55036. */
  55037. isEnabled: boolean;
  55038. /**
  55039. * Gets the camera attached to the layer.
  55040. */
  55041. get camera(): Nullable<Camera>;
  55042. /**
  55043. * Gets the rendering group id the layer should render in.
  55044. */
  55045. get renderingGroupId(): number;
  55046. set renderingGroupId(renderingGroupId: number);
  55047. /**
  55048. * An event triggered when the effect layer has been disposed.
  55049. */
  55050. onDisposeObservable: Observable<EffectLayer>;
  55051. /**
  55052. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55053. */
  55054. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55055. /**
  55056. * An event triggered when the generated texture is being merged in the scene.
  55057. */
  55058. onBeforeComposeObservable: Observable<EffectLayer>;
  55059. /**
  55060. * An event triggered when the mesh is rendered into the effect render target.
  55061. */
  55062. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55063. /**
  55064. * An event triggered after the mesh has been rendered into the effect render target.
  55065. */
  55066. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55067. /**
  55068. * An event triggered when the generated texture has been merged in the scene.
  55069. */
  55070. onAfterComposeObservable: Observable<EffectLayer>;
  55071. /**
  55072. * An event triggered when the efffect layer changes its size.
  55073. */
  55074. onSizeChangedObservable: Observable<EffectLayer>;
  55075. /** @hidden */
  55076. static _SceneComponentInitialization: (scene: Scene) => void;
  55077. /**
  55078. * Instantiates a new effect Layer and references it in the scene.
  55079. * @param name The name of the layer
  55080. * @param scene The scene to use the layer in
  55081. */
  55082. constructor(
  55083. /** The Friendly of the effect in the scene */
  55084. name: string, scene: Scene);
  55085. /**
  55086. * Get the effect name of the layer.
  55087. * @return The effect name
  55088. */
  55089. abstract getEffectName(): string;
  55090. /**
  55091. * Checks for the readiness of the element composing the layer.
  55092. * @param subMesh the mesh to check for
  55093. * @param useInstances specify whether or not to use instances to render the mesh
  55094. * @return true if ready otherwise, false
  55095. */
  55096. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55097. /**
  55098. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55099. * @returns true if the effect requires stencil during the main canvas render pass.
  55100. */
  55101. abstract needStencil(): boolean;
  55102. /**
  55103. * Create the merge effect. This is the shader use to blit the information back
  55104. * to the main canvas at the end of the scene rendering.
  55105. * @returns The effect containing the shader used to merge the effect on the main canvas
  55106. */
  55107. protected abstract _createMergeEffect(): Effect;
  55108. /**
  55109. * Creates the render target textures and post processes used in the effect layer.
  55110. */
  55111. protected abstract _createTextureAndPostProcesses(): void;
  55112. /**
  55113. * Implementation specific of rendering the generating effect on the main canvas.
  55114. * @param effect The effect used to render through
  55115. */
  55116. protected abstract _internalRender(effect: Effect): void;
  55117. /**
  55118. * Sets the required values for both the emissive texture and and the main color.
  55119. */
  55120. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55121. /**
  55122. * Free any resources and references associated to a mesh.
  55123. * Internal use
  55124. * @param mesh The mesh to free.
  55125. */
  55126. abstract _disposeMesh(mesh: Mesh): void;
  55127. /**
  55128. * Serializes this layer (Glow or Highlight for example)
  55129. * @returns a serialized layer object
  55130. */
  55131. abstract serialize?(): any;
  55132. /**
  55133. * Initializes the effect layer with the required options.
  55134. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55135. */
  55136. protected _init(options: Partial<IEffectLayerOptions>): void;
  55137. /**
  55138. * Generates the index buffer of the full screen quad blending to the main canvas.
  55139. */
  55140. private _generateIndexBuffer;
  55141. /**
  55142. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55143. */
  55144. private _generateVertexBuffer;
  55145. /**
  55146. * Sets the main texture desired size which is the closest power of two
  55147. * of the engine canvas size.
  55148. */
  55149. private _setMainTextureSize;
  55150. /**
  55151. * Creates the main texture for the effect layer.
  55152. */
  55153. protected _createMainTexture(): void;
  55154. /**
  55155. * Adds specific effects defines.
  55156. * @param defines The defines to add specifics to.
  55157. */
  55158. protected _addCustomEffectDefines(defines: string[]): void;
  55159. /**
  55160. * Checks for the readiness of the element composing the layer.
  55161. * @param subMesh the mesh to check for
  55162. * @param useInstances specify whether or not to use instances to render the mesh
  55163. * @param emissiveTexture the associated emissive texture used to generate the glow
  55164. * @return true if ready otherwise, false
  55165. */
  55166. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55167. /**
  55168. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55169. */
  55170. render(): void;
  55171. /**
  55172. * Determine if a given mesh will be used in the current effect.
  55173. * @param mesh mesh to test
  55174. * @returns true if the mesh will be used
  55175. */
  55176. hasMesh(mesh: AbstractMesh): boolean;
  55177. /**
  55178. * Returns true if the layer contains information to display, otherwise false.
  55179. * @returns true if the glow layer should be rendered
  55180. */
  55181. shouldRender(): boolean;
  55182. /**
  55183. * Returns true if the mesh should render, otherwise false.
  55184. * @param mesh The mesh to render
  55185. * @returns true if it should render otherwise false
  55186. */
  55187. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55188. /**
  55189. * Returns true if the mesh can be rendered, otherwise false.
  55190. * @param mesh The mesh to render
  55191. * @param material The material used on the mesh
  55192. * @returns true if it can be rendered otherwise false
  55193. */
  55194. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55195. /**
  55196. * Returns true if the mesh should render, otherwise false.
  55197. * @param mesh The mesh to render
  55198. * @returns true if it should render otherwise false
  55199. */
  55200. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55201. /**
  55202. * Renders the submesh passed in parameter to the generation map.
  55203. */
  55204. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55205. /**
  55206. * Defines whether the current material of the mesh should be use to render the effect.
  55207. * @param mesh defines the current mesh to render
  55208. */
  55209. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55210. /**
  55211. * Rebuild the required buffers.
  55212. * @hidden Internal use only.
  55213. */
  55214. _rebuild(): void;
  55215. /**
  55216. * Dispose only the render target textures and post process.
  55217. */
  55218. private _disposeTextureAndPostProcesses;
  55219. /**
  55220. * Dispose the highlight layer and free resources.
  55221. */
  55222. dispose(): void;
  55223. /**
  55224. * Gets the class name of the effect layer
  55225. * @returns the string with the class name of the effect layer
  55226. */
  55227. getClassName(): string;
  55228. /**
  55229. * Creates an effect layer from parsed effect layer data
  55230. * @param parsedEffectLayer defines effect layer data
  55231. * @param scene defines the current scene
  55232. * @param rootUrl defines the root URL containing the effect layer information
  55233. * @returns a parsed effect Layer
  55234. */
  55235. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55236. }
  55237. }
  55238. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55239. import { Scene } from "babylonjs/scene";
  55240. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55241. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55242. import { AbstractScene } from "babylonjs/abstractScene";
  55243. module "babylonjs/abstractScene" {
  55244. interface AbstractScene {
  55245. /**
  55246. * The list of effect layers (highlights/glow) added to the scene
  55247. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55248. * @see http://doc.babylonjs.com/how_to/glow_layer
  55249. */
  55250. effectLayers: Array<EffectLayer>;
  55251. /**
  55252. * Removes the given effect layer from this scene.
  55253. * @param toRemove defines the effect layer to remove
  55254. * @returns the index of the removed effect layer
  55255. */
  55256. removeEffectLayer(toRemove: EffectLayer): number;
  55257. /**
  55258. * Adds the given effect layer to this scene
  55259. * @param newEffectLayer defines the effect layer to add
  55260. */
  55261. addEffectLayer(newEffectLayer: EffectLayer): void;
  55262. }
  55263. }
  55264. /**
  55265. * Defines the layer scene component responsible to manage any effect layers
  55266. * in a given scene.
  55267. */
  55268. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55269. /**
  55270. * The component name helpfull to identify the component in the list of scene components.
  55271. */
  55272. readonly name: string;
  55273. /**
  55274. * The scene the component belongs to.
  55275. */
  55276. scene: Scene;
  55277. private _engine;
  55278. private _renderEffects;
  55279. private _needStencil;
  55280. private _previousStencilState;
  55281. /**
  55282. * Creates a new instance of the component for the given scene
  55283. * @param scene Defines the scene to register the component in
  55284. */
  55285. constructor(scene: Scene);
  55286. /**
  55287. * Registers the component in a given scene
  55288. */
  55289. register(): void;
  55290. /**
  55291. * Rebuilds the elements related to this component in case of
  55292. * context lost for instance.
  55293. */
  55294. rebuild(): void;
  55295. /**
  55296. * Serializes the component data to the specified json object
  55297. * @param serializationObject The object to serialize to
  55298. */
  55299. serialize(serializationObject: any): void;
  55300. /**
  55301. * Adds all the elements from the container to the scene
  55302. * @param container the container holding the elements
  55303. */
  55304. addFromContainer(container: AbstractScene): void;
  55305. /**
  55306. * Removes all the elements in the container from the scene
  55307. * @param container contains the elements to remove
  55308. * @param dispose if the removed element should be disposed (default: false)
  55309. */
  55310. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55311. /**
  55312. * Disposes the component and the associated ressources.
  55313. */
  55314. dispose(): void;
  55315. private _isReadyForMesh;
  55316. private _renderMainTexture;
  55317. private _setStencil;
  55318. private _setStencilBack;
  55319. private _draw;
  55320. private _drawCamera;
  55321. private _drawRenderingGroup;
  55322. }
  55323. }
  55324. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55325. /** @hidden */
  55326. export var glowMapMergePixelShader: {
  55327. name: string;
  55328. shader: string;
  55329. };
  55330. }
  55331. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55332. /** @hidden */
  55333. export var glowMapMergeVertexShader: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module "babylonjs/Layers/glowLayer" {
  55339. import { Nullable } from "babylonjs/types";
  55340. import { Camera } from "babylonjs/Cameras/camera";
  55341. import { Scene } from "babylonjs/scene";
  55342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55344. import { Mesh } from "babylonjs/Meshes/mesh";
  55345. import { Texture } from "babylonjs/Materials/Textures/texture";
  55346. import { Effect } from "babylonjs/Materials/effect";
  55347. import { Material } from "babylonjs/Materials/material";
  55348. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55349. import { Color4 } from "babylonjs/Maths/math.color";
  55350. import "babylonjs/Shaders/glowMapMerge.fragment";
  55351. import "babylonjs/Shaders/glowMapMerge.vertex";
  55352. import "babylonjs/Layers/effectLayerSceneComponent";
  55353. module "babylonjs/abstractScene" {
  55354. interface AbstractScene {
  55355. /**
  55356. * Return a the first highlight layer of the scene with a given name.
  55357. * @param name The name of the highlight layer to look for.
  55358. * @return The highlight layer if found otherwise null.
  55359. */
  55360. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55361. }
  55362. }
  55363. /**
  55364. * Glow layer options. This helps customizing the behaviour
  55365. * of the glow layer.
  55366. */
  55367. export interface IGlowLayerOptions {
  55368. /**
  55369. * Multiplication factor apply to the canvas size to compute the render target size
  55370. * used to generated the glowing objects (the smaller the faster).
  55371. */
  55372. mainTextureRatio: number;
  55373. /**
  55374. * Enforces a fixed size texture to ensure resize independant blur.
  55375. */
  55376. mainTextureFixedSize?: number;
  55377. /**
  55378. * How big is the kernel of the blur texture.
  55379. */
  55380. blurKernelSize: number;
  55381. /**
  55382. * The camera attached to the layer.
  55383. */
  55384. camera: Nullable<Camera>;
  55385. /**
  55386. * Enable MSAA by chosing the number of samples.
  55387. */
  55388. mainTextureSamples?: number;
  55389. /**
  55390. * The rendering group to draw the layer in.
  55391. */
  55392. renderingGroupId: number;
  55393. }
  55394. /**
  55395. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55396. *
  55397. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55398. *
  55399. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55400. */
  55401. export class GlowLayer extends EffectLayer {
  55402. /**
  55403. * Effect Name of the layer.
  55404. */
  55405. static readonly EffectName: string;
  55406. /**
  55407. * The default blur kernel size used for the glow.
  55408. */
  55409. static DefaultBlurKernelSize: number;
  55410. /**
  55411. * The default texture size ratio used for the glow.
  55412. */
  55413. static DefaultTextureRatio: number;
  55414. /**
  55415. * Sets the kernel size of the blur.
  55416. */
  55417. set blurKernelSize(value: number);
  55418. /**
  55419. * Gets the kernel size of the blur.
  55420. */
  55421. get blurKernelSize(): number;
  55422. /**
  55423. * Sets the glow intensity.
  55424. */
  55425. set intensity(value: number);
  55426. /**
  55427. * Gets the glow intensity.
  55428. */
  55429. get intensity(): number;
  55430. private _options;
  55431. private _intensity;
  55432. private _horizontalBlurPostprocess1;
  55433. private _verticalBlurPostprocess1;
  55434. private _horizontalBlurPostprocess2;
  55435. private _verticalBlurPostprocess2;
  55436. private _blurTexture1;
  55437. private _blurTexture2;
  55438. private _postProcesses1;
  55439. private _postProcesses2;
  55440. private _includedOnlyMeshes;
  55441. private _excludedMeshes;
  55442. private _meshesUsingTheirOwnMaterials;
  55443. /**
  55444. * Callback used to let the user override the color selection on a per mesh basis
  55445. */
  55446. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55447. /**
  55448. * Callback used to let the user override the texture selection on a per mesh basis
  55449. */
  55450. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55451. /**
  55452. * Instantiates a new glow Layer and references it to the scene.
  55453. * @param name The name of the layer
  55454. * @param scene The scene to use the layer in
  55455. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55456. */
  55457. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55458. /**
  55459. * Get the effect name of the layer.
  55460. * @return The effect name
  55461. */
  55462. getEffectName(): string;
  55463. /**
  55464. * Create the merge effect. This is the shader use to blit the information back
  55465. * to the main canvas at the end of the scene rendering.
  55466. */
  55467. protected _createMergeEffect(): Effect;
  55468. /**
  55469. * Creates the render target textures and post processes used in the glow layer.
  55470. */
  55471. protected _createTextureAndPostProcesses(): void;
  55472. /**
  55473. * Checks for the readiness of the element composing the layer.
  55474. * @param subMesh the mesh to check for
  55475. * @param useInstances specify wether or not to use instances to render the mesh
  55476. * @param emissiveTexture the associated emissive texture used to generate the glow
  55477. * @return true if ready otherwise, false
  55478. */
  55479. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55480. /**
  55481. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55482. */
  55483. needStencil(): boolean;
  55484. /**
  55485. * Returns true if the mesh can be rendered, otherwise false.
  55486. * @param mesh The mesh to render
  55487. * @param material The material used on the mesh
  55488. * @returns true if it can be rendered otherwise false
  55489. */
  55490. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55491. /**
  55492. * Implementation specific of rendering the generating effect on the main canvas.
  55493. * @param effect The effect used to render through
  55494. */
  55495. protected _internalRender(effect: Effect): void;
  55496. /**
  55497. * Sets the required values for both the emissive texture and and the main color.
  55498. */
  55499. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55500. /**
  55501. * Returns true if the mesh should render, otherwise false.
  55502. * @param mesh The mesh to render
  55503. * @returns true if it should render otherwise false
  55504. */
  55505. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55506. /**
  55507. * Adds specific effects defines.
  55508. * @param defines The defines to add specifics to.
  55509. */
  55510. protected _addCustomEffectDefines(defines: string[]): void;
  55511. /**
  55512. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55513. * @param mesh The mesh to exclude from the glow layer
  55514. */
  55515. addExcludedMesh(mesh: Mesh): void;
  55516. /**
  55517. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55518. * @param mesh The mesh to remove
  55519. */
  55520. removeExcludedMesh(mesh: Mesh): void;
  55521. /**
  55522. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55523. * @param mesh The mesh to include in the glow layer
  55524. */
  55525. addIncludedOnlyMesh(mesh: Mesh): void;
  55526. /**
  55527. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55528. * @param mesh The mesh to remove
  55529. */
  55530. removeIncludedOnlyMesh(mesh: Mesh): void;
  55531. /**
  55532. * Determine if a given mesh will be used in the glow layer
  55533. * @param mesh The mesh to test
  55534. * @returns true if the mesh will be highlighted by the current glow layer
  55535. */
  55536. hasMesh(mesh: AbstractMesh): boolean;
  55537. /**
  55538. * Defines whether the current material of the mesh should be use to render the effect.
  55539. * @param mesh defines the current mesh to render
  55540. */
  55541. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55542. /**
  55543. * Add a mesh to be rendered through its own material and not with emissive only.
  55544. * @param mesh The mesh for which we need to use its material
  55545. */
  55546. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55547. /**
  55548. * Remove a mesh from being rendered through its own material and not with emissive only.
  55549. * @param mesh The mesh for which we need to not use its material
  55550. */
  55551. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55552. /**
  55553. * Free any resources and references associated to a mesh.
  55554. * Internal use
  55555. * @param mesh The mesh to free.
  55556. * @hidden
  55557. */
  55558. _disposeMesh(mesh: Mesh): void;
  55559. /**
  55560. * Gets the class name of the effect layer
  55561. * @returns the string with the class name of the effect layer
  55562. */
  55563. getClassName(): string;
  55564. /**
  55565. * Serializes this glow layer
  55566. * @returns a serialized glow layer object
  55567. */
  55568. serialize(): any;
  55569. /**
  55570. * Creates a Glow Layer from parsed glow layer data
  55571. * @param parsedGlowLayer defines glow layer data
  55572. * @param scene defines the current scene
  55573. * @param rootUrl defines the root URL containing the glow layer information
  55574. * @returns a parsed Glow Layer
  55575. */
  55576. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55577. }
  55578. }
  55579. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55580. /** @hidden */
  55581. export var glowBlurPostProcessPixelShader: {
  55582. name: string;
  55583. shader: string;
  55584. };
  55585. }
  55586. declare module "babylonjs/Layers/highlightLayer" {
  55587. import { Observable } from "babylonjs/Misc/observable";
  55588. import { Nullable } from "babylonjs/types";
  55589. import { Camera } from "babylonjs/Cameras/camera";
  55590. import { Scene } from "babylonjs/scene";
  55591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55593. import { Mesh } from "babylonjs/Meshes/mesh";
  55594. import { Effect } from "babylonjs/Materials/effect";
  55595. import { Material } from "babylonjs/Materials/material";
  55596. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55597. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55598. import "babylonjs/Shaders/glowMapMerge.fragment";
  55599. import "babylonjs/Shaders/glowMapMerge.vertex";
  55600. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55601. module "babylonjs/abstractScene" {
  55602. interface AbstractScene {
  55603. /**
  55604. * Return a the first highlight layer of the scene with a given name.
  55605. * @param name The name of the highlight layer to look for.
  55606. * @return The highlight layer if found otherwise null.
  55607. */
  55608. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55609. }
  55610. }
  55611. /**
  55612. * Highlight layer options. This helps customizing the behaviour
  55613. * of the highlight layer.
  55614. */
  55615. export interface IHighlightLayerOptions {
  55616. /**
  55617. * Multiplication factor apply to the canvas size to compute the render target size
  55618. * used to generated the glowing objects (the smaller the faster).
  55619. */
  55620. mainTextureRatio: number;
  55621. /**
  55622. * Enforces a fixed size texture to ensure resize independant blur.
  55623. */
  55624. mainTextureFixedSize?: number;
  55625. /**
  55626. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55627. * of the picture to blur (the smaller the faster).
  55628. */
  55629. blurTextureSizeRatio: number;
  55630. /**
  55631. * How big in texel of the blur texture is the vertical blur.
  55632. */
  55633. blurVerticalSize: number;
  55634. /**
  55635. * How big in texel of the blur texture is the horizontal blur.
  55636. */
  55637. blurHorizontalSize: number;
  55638. /**
  55639. * Alpha blending mode used to apply the blur. Default is combine.
  55640. */
  55641. alphaBlendingMode: number;
  55642. /**
  55643. * The camera attached to the layer.
  55644. */
  55645. camera: Nullable<Camera>;
  55646. /**
  55647. * Should we display highlight as a solid stroke?
  55648. */
  55649. isStroke?: boolean;
  55650. /**
  55651. * The rendering group to draw the layer in.
  55652. */
  55653. renderingGroupId: number;
  55654. }
  55655. /**
  55656. * The highlight layer Helps adding a glow effect around a mesh.
  55657. *
  55658. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55659. * glowy meshes to your scene.
  55660. *
  55661. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55662. */
  55663. export class HighlightLayer extends EffectLayer {
  55664. name: string;
  55665. /**
  55666. * Effect Name of the highlight layer.
  55667. */
  55668. static readonly EffectName: string;
  55669. /**
  55670. * The neutral color used during the preparation of the glow effect.
  55671. * This is black by default as the blend operation is a blend operation.
  55672. */
  55673. static NeutralColor: Color4;
  55674. /**
  55675. * Stencil value used for glowing meshes.
  55676. */
  55677. static GlowingMeshStencilReference: number;
  55678. /**
  55679. * Stencil value used for the other meshes in the scene.
  55680. */
  55681. static NormalMeshStencilReference: number;
  55682. /**
  55683. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55684. */
  55685. innerGlow: boolean;
  55686. /**
  55687. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55688. */
  55689. outerGlow: boolean;
  55690. /**
  55691. * Specifies the horizontal size of the blur.
  55692. */
  55693. set blurHorizontalSize(value: number);
  55694. /**
  55695. * Specifies the vertical size of the blur.
  55696. */
  55697. set blurVerticalSize(value: number);
  55698. /**
  55699. * Gets the horizontal size of the blur.
  55700. */
  55701. get blurHorizontalSize(): number;
  55702. /**
  55703. * Gets the vertical size of the blur.
  55704. */
  55705. get blurVerticalSize(): number;
  55706. /**
  55707. * An event triggered when the highlight layer is being blurred.
  55708. */
  55709. onBeforeBlurObservable: Observable<HighlightLayer>;
  55710. /**
  55711. * An event triggered when the highlight layer has been blurred.
  55712. */
  55713. onAfterBlurObservable: Observable<HighlightLayer>;
  55714. private _instanceGlowingMeshStencilReference;
  55715. private _options;
  55716. private _downSamplePostprocess;
  55717. private _horizontalBlurPostprocess;
  55718. private _verticalBlurPostprocess;
  55719. private _blurTexture;
  55720. private _meshes;
  55721. private _excludedMeshes;
  55722. /**
  55723. * Instantiates a new highlight Layer and references it to the scene..
  55724. * @param name The name of the layer
  55725. * @param scene The scene to use the layer in
  55726. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55727. */
  55728. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55729. /**
  55730. * Get the effect name of the layer.
  55731. * @return The effect name
  55732. */
  55733. getEffectName(): string;
  55734. /**
  55735. * Create the merge effect. This is the shader use to blit the information back
  55736. * to the main canvas at the end of the scene rendering.
  55737. */
  55738. protected _createMergeEffect(): Effect;
  55739. /**
  55740. * Creates the render target textures and post processes used in the highlight layer.
  55741. */
  55742. protected _createTextureAndPostProcesses(): void;
  55743. /**
  55744. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55745. */
  55746. needStencil(): boolean;
  55747. /**
  55748. * Checks for the readiness of the element composing the layer.
  55749. * @param subMesh the mesh to check for
  55750. * @param useInstances specify wether or not to use instances to render the mesh
  55751. * @param emissiveTexture the associated emissive texture used to generate the glow
  55752. * @return true if ready otherwise, false
  55753. */
  55754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55755. /**
  55756. * Implementation specific of rendering the generating effect on the main canvas.
  55757. * @param effect The effect used to render through
  55758. */
  55759. protected _internalRender(effect: Effect): void;
  55760. /**
  55761. * Returns true if the layer contains information to display, otherwise false.
  55762. */
  55763. shouldRender(): boolean;
  55764. /**
  55765. * Returns true if the mesh should render, otherwise false.
  55766. * @param mesh The mesh to render
  55767. * @returns true if it should render otherwise false
  55768. */
  55769. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55770. /**
  55771. * Sets the required values for both the emissive texture and and the main color.
  55772. */
  55773. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55774. /**
  55775. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55776. * @param mesh The mesh to exclude from the highlight layer
  55777. */
  55778. addExcludedMesh(mesh: Mesh): void;
  55779. /**
  55780. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55781. * @param mesh The mesh to highlight
  55782. */
  55783. removeExcludedMesh(mesh: Mesh): void;
  55784. /**
  55785. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55786. * @param mesh mesh to test
  55787. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55788. */
  55789. hasMesh(mesh: AbstractMesh): boolean;
  55790. /**
  55791. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55792. * @param mesh The mesh to highlight
  55793. * @param color The color of the highlight
  55794. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55795. */
  55796. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55797. /**
  55798. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55799. * @param mesh The mesh to highlight
  55800. */
  55801. removeMesh(mesh: Mesh): void;
  55802. /**
  55803. * Force the stencil to the normal expected value for none glowing parts
  55804. */
  55805. private _defaultStencilReference;
  55806. /**
  55807. * Free any resources and references associated to a mesh.
  55808. * Internal use
  55809. * @param mesh The mesh to free.
  55810. * @hidden
  55811. */
  55812. _disposeMesh(mesh: Mesh): void;
  55813. /**
  55814. * Dispose the highlight layer and free resources.
  55815. */
  55816. dispose(): void;
  55817. /**
  55818. * Gets the class name of the effect layer
  55819. * @returns the string with the class name of the effect layer
  55820. */
  55821. getClassName(): string;
  55822. /**
  55823. * Serializes this Highlight layer
  55824. * @returns a serialized Highlight layer object
  55825. */
  55826. serialize(): any;
  55827. /**
  55828. * Creates a Highlight layer from parsed Highlight layer data
  55829. * @param parsedHightlightLayer defines the Highlight layer data
  55830. * @param scene defines the current scene
  55831. * @param rootUrl defines the root URL containing the Highlight layer information
  55832. * @returns a parsed Highlight layer
  55833. */
  55834. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55835. }
  55836. }
  55837. declare module "babylonjs/Layers/layerSceneComponent" {
  55838. import { Scene } from "babylonjs/scene";
  55839. import { ISceneComponent } from "babylonjs/sceneComponent";
  55840. import { Layer } from "babylonjs/Layers/layer";
  55841. import { AbstractScene } from "babylonjs/abstractScene";
  55842. module "babylonjs/abstractScene" {
  55843. interface AbstractScene {
  55844. /**
  55845. * The list of layers (background and foreground) of the scene
  55846. */
  55847. layers: Array<Layer>;
  55848. }
  55849. }
  55850. /**
  55851. * Defines the layer scene component responsible to manage any layers
  55852. * in a given scene.
  55853. */
  55854. export class LayerSceneComponent implements ISceneComponent {
  55855. /**
  55856. * The component name helpfull to identify the component in the list of scene components.
  55857. */
  55858. readonly name: string;
  55859. /**
  55860. * The scene the component belongs to.
  55861. */
  55862. scene: Scene;
  55863. private _engine;
  55864. /**
  55865. * Creates a new instance of the component for the given scene
  55866. * @param scene Defines the scene to register the component in
  55867. */
  55868. constructor(scene: Scene);
  55869. /**
  55870. * Registers the component in a given scene
  55871. */
  55872. register(): void;
  55873. /**
  55874. * Rebuilds the elements related to this component in case of
  55875. * context lost for instance.
  55876. */
  55877. rebuild(): void;
  55878. /**
  55879. * Disposes the component and the associated ressources.
  55880. */
  55881. dispose(): void;
  55882. private _draw;
  55883. private _drawCameraPredicate;
  55884. private _drawCameraBackground;
  55885. private _drawCameraForeground;
  55886. private _drawRenderTargetPredicate;
  55887. private _drawRenderTargetBackground;
  55888. private _drawRenderTargetForeground;
  55889. /**
  55890. * Adds all the elements from the container to the scene
  55891. * @param container the container holding the elements
  55892. */
  55893. addFromContainer(container: AbstractScene): void;
  55894. /**
  55895. * Removes all the elements in the container from the scene
  55896. * @param container contains the elements to remove
  55897. * @param dispose if the removed element should be disposed (default: false)
  55898. */
  55899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55900. }
  55901. }
  55902. declare module "babylonjs/Shaders/layer.fragment" {
  55903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55904. /** @hidden */
  55905. export var layerPixelShader: {
  55906. name: string;
  55907. shader: string;
  55908. };
  55909. }
  55910. declare module "babylonjs/Shaders/layer.vertex" {
  55911. /** @hidden */
  55912. export var layerVertexShader: {
  55913. name: string;
  55914. shader: string;
  55915. };
  55916. }
  55917. declare module "babylonjs/Layers/layer" {
  55918. import { Observable } from "babylonjs/Misc/observable";
  55919. import { Nullable } from "babylonjs/types";
  55920. import { Scene } from "babylonjs/scene";
  55921. import { Vector2 } from "babylonjs/Maths/math.vector";
  55922. import { Color4 } from "babylonjs/Maths/math.color";
  55923. import { Texture } from "babylonjs/Materials/Textures/texture";
  55924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55925. import "babylonjs/Shaders/layer.fragment";
  55926. import "babylonjs/Shaders/layer.vertex";
  55927. /**
  55928. * This represents a full screen 2d layer.
  55929. * This can be useful to display a picture in the background of your scene for instance.
  55930. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55931. */
  55932. export class Layer {
  55933. /**
  55934. * Define the name of the layer.
  55935. */
  55936. name: string;
  55937. /**
  55938. * Define the texture the layer should display.
  55939. */
  55940. texture: Nullable<Texture>;
  55941. /**
  55942. * Is the layer in background or foreground.
  55943. */
  55944. isBackground: boolean;
  55945. /**
  55946. * Define the color of the layer (instead of texture).
  55947. */
  55948. color: Color4;
  55949. /**
  55950. * Define the scale of the layer in order to zoom in out of the texture.
  55951. */
  55952. scale: Vector2;
  55953. /**
  55954. * Define an offset for the layer in order to shift the texture.
  55955. */
  55956. offset: Vector2;
  55957. /**
  55958. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55959. */
  55960. alphaBlendingMode: number;
  55961. /**
  55962. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55963. * Alpha test will not mix with the background color in case of transparency.
  55964. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55965. */
  55966. alphaTest: boolean;
  55967. /**
  55968. * Define a mask to restrict the layer to only some of the scene cameras.
  55969. */
  55970. layerMask: number;
  55971. /**
  55972. * Define the list of render target the layer is visible into.
  55973. */
  55974. renderTargetTextures: RenderTargetTexture[];
  55975. /**
  55976. * Define if the layer is only used in renderTarget or if it also
  55977. * renders in the main frame buffer of the canvas.
  55978. */
  55979. renderOnlyInRenderTargetTextures: boolean;
  55980. private _scene;
  55981. private _vertexBuffers;
  55982. private _indexBuffer;
  55983. private _effect;
  55984. private _previousDefines;
  55985. /**
  55986. * An event triggered when the layer is disposed.
  55987. */
  55988. onDisposeObservable: Observable<Layer>;
  55989. private _onDisposeObserver;
  55990. /**
  55991. * Back compatibility with callback before the onDisposeObservable existed.
  55992. * The set callback will be triggered when the layer has been disposed.
  55993. */
  55994. set onDispose(callback: () => void);
  55995. /**
  55996. * An event triggered before rendering the scene
  55997. */
  55998. onBeforeRenderObservable: Observable<Layer>;
  55999. private _onBeforeRenderObserver;
  56000. /**
  56001. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56002. * The set callback will be triggered just before rendering the layer.
  56003. */
  56004. set onBeforeRender(callback: () => void);
  56005. /**
  56006. * An event triggered after rendering the scene
  56007. */
  56008. onAfterRenderObservable: Observable<Layer>;
  56009. private _onAfterRenderObserver;
  56010. /**
  56011. * Back compatibility with callback before the onAfterRenderObservable existed.
  56012. * The set callback will be triggered just after rendering the layer.
  56013. */
  56014. set onAfterRender(callback: () => void);
  56015. /**
  56016. * Instantiates a new layer.
  56017. * This represents a full screen 2d layer.
  56018. * This can be useful to display a picture in the background of your scene for instance.
  56019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56020. * @param name Define the name of the layer in the scene
  56021. * @param imgUrl Define the url of the texture to display in the layer
  56022. * @param scene Define the scene the layer belongs to
  56023. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56024. * @param color Defines a color for the layer
  56025. */
  56026. constructor(
  56027. /**
  56028. * Define the name of the layer.
  56029. */
  56030. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56031. private _createIndexBuffer;
  56032. /** @hidden */
  56033. _rebuild(): void;
  56034. /**
  56035. * Renders the layer in the scene.
  56036. */
  56037. render(): void;
  56038. /**
  56039. * Disposes and releases the associated ressources.
  56040. */
  56041. dispose(): void;
  56042. }
  56043. }
  56044. declare module "babylonjs/Layers/index" {
  56045. export * from "babylonjs/Layers/effectLayer";
  56046. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56047. export * from "babylonjs/Layers/glowLayer";
  56048. export * from "babylonjs/Layers/highlightLayer";
  56049. export * from "babylonjs/Layers/layer";
  56050. export * from "babylonjs/Layers/layerSceneComponent";
  56051. }
  56052. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56053. /** @hidden */
  56054. export var lensFlarePixelShader: {
  56055. name: string;
  56056. shader: string;
  56057. };
  56058. }
  56059. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56060. /** @hidden */
  56061. export var lensFlareVertexShader: {
  56062. name: string;
  56063. shader: string;
  56064. };
  56065. }
  56066. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56067. import { Scene } from "babylonjs/scene";
  56068. import { Vector3 } from "babylonjs/Maths/math.vector";
  56069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56070. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56071. import "babylonjs/Shaders/lensFlare.fragment";
  56072. import "babylonjs/Shaders/lensFlare.vertex";
  56073. import { Viewport } from "babylonjs/Maths/math.viewport";
  56074. /**
  56075. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56076. * It is usually composed of several `lensFlare`.
  56077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56078. */
  56079. export class LensFlareSystem {
  56080. /**
  56081. * Define the name of the lens flare system
  56082. */
  56083. name: string;
  56084. /**
  56085. * List of lens flares used in this system.
  56086. */
  56087. lensFlares: LensFlare[];
  56088. /**
  56089. * Define a limit from the border the lens flare can be visible.
  56090. */
  56091. borderLimit: number;
  56092. /**
  56093. * Define a viewport border we do not want to see the lens flare in.
  56094. */
  56095. viewportBorder: number;
  56096. /**
  56097. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56098. */
  56099. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56100. /**
  56101. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56102. */
  56103. layerMask: number;
  56104. /**
  56105. * Define the id of the lens flare system in the scene.
  56106. * (equal to name by default)
  56107. */
  56108. id: string;
  56109. private _scene;
  56110. private _emitter;
  56111. private _vertexBuffers;
  56112. private _indexBuffer;
  56113. private _effect;
  56114. private _positionX;
  56115. private _positionY;
  56116. private _isEnabled;
  56117. /** @hidden */
  56118. static _SceneComponentInitialization: (scene: Scene) => void;
  56119. /**
  56120. * Instantiates a lens flare system.
  56121. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56122. * It is usually composed of several `lensFlare`.
  56123. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56124. * @param name Define the name of the lens flare system in the scene
  56125. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56126. * @param scene Define the scene the lens flare system belongs to
  56127. */
  56128. constructor(
  56129. /**
  56130. * Define the name of the lens flare system
  56131. */
  56132. name: string, emitter: any, scene: Scene);
  56133. /**
  56134. * Define if the lens flare system is enabled.
  56135. */
  56136. get isEnabled(): boolean;
  56137. set isEnabled(value: boolean);
  56138. /**
  56139. * Get the scene the effects belongs to.
  56140. * @returns the scene holding the lens flare system
  56141. */
  56142. getScene(): Scene;
  56143. /**
  56144. * Get the emitter of the lens flare system.
  56145. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56146. * @returns the emitter of the lens flare system
  56147. */
  56148. getEmitter(): any;
  56149. /**
  56150. * Set the emitter of the lens flare system.
  56151. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56152. * @param newEmitter Define the new emitter of the system
  56153. */
  56154. setEmitter(newEmitter: any): void;
  56155. /**
  56156. * Get the lens flare system emitter position.
  56157. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56158. * @returns the position
  56159. */
  56160. getEmitterPosition(): Vector3;
  56161. /**
  56162. * @hidden
  56163. */
  56164. computeEffectivePosition(globalViewport: Viewport): boolean;
  56165. /** @hidden */
  56166. _isVisible(): boolean;
  56167. /**
  56168. * @hidden
  56169. */
  56170. render(): boolean;
  56171. /**
  56172. * Dispose and release the lens flare with its associated resources.
  56173. */
  56174. dispose(): void;
  56175. /**
  56176. * Parse a lens flare system from a JSON repressentation
  56177. * @param parsedLensFlareSystem Define the JSON to parse
  56178. * @param scene Define the scene the parsed system should be instantiated in
  56179. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56180. * @returns the parsed system
  56181. */
  56182. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56183. /**
  56184. * Serialize the current Lens Flare System into a JSON representation.
  56185. * @returns the serialized JSON
  56186. */
  56187. serialize(): any;
  56188. }
  56189. }
  56190. declare module "babylonjs/LensFlares/lensFlare" {
  56191. import { Nullable } from "babylonjs/types";
  56192. import { Color3 } from "babylonjs/Maths/math.color";
  56193. import { Texture } from "babylonjs/Materials/Textures/texture";
  56194. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56195. /**
  56196. * This represents one of the lens effect in a `lensFlareSystem`.
  56197. * It controls one of the indiviual texture used in the effect.
  56198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56199. */
  56200. export class LensFlare {
  56201. /**
  56202. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56203. */
  56204. size: number;
  56205. /**
  56206. * 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.
  56207. */
  56208. position: number;
  56209. /**
  56210. * Define the lens color.
  56211. */
  56212. color: Color3;
  56213. /**
  56214. * Define the lens texture.
  56215. */
  56216. texture: Nullable<Texture>;
  56217. /**
  56218. * Define the alpha mode to render this particular lens.
  56219. */
  56220. alphaMode: number;
  56221. private _system;
  56222. /**
  56223. * Creates a new Lens Flare.
  56224. * This represents one of the lens effect in a `lensFlareSystem`.
  56225. * It controls one of the indiviual texture used in the effect.
  56226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56227. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56228. * @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.
  56229. * @param color Define the lens color
  56230. * @param imgUrl Define the lens texture url
  56231. * @param system Define the `lensFlareSystem` this flare is part of
  56232. * @returns The newly created Lens Flare
  56233. */
  56234. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56235. /**
  56236. * Instantiates a new Lens Flare.
  56237. * This represents one of the lens effect in a `lensFlareSystem`.
  56238. * It controls one of the indiviual texture used in the effect.
  56239. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56240. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56241. * @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.
  56242. * @param color Define the lens color
  56243. * @param imgUrl Define the lens texture url
  56244. * @param system Define the `lensFlareSystem` this flare is part of
  56245. */
  56246. constructor(
  56247. /**
  56248. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56249. */
  56250. size: number,
  56251. /**
  56252. * 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.
  56253. */
  56254. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56255. /**
  56256. * Dispose and release the lens flare with its associated resources.
  56257. */
  56258. dispose(): void;
  56259. }
  56260. }
  56261. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56262. import { Nullable } from "babylonjs/types";
  56263. import { Scene } from "babylonjs/scene";
  56264. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56265. import { AbstractScene } from "babylonjs/abstractScene";
  56266. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56267. module "babylonjs/abstractScene" {
  56268. interface AbstractScene {
  56269. /**
  56270. * The list of lens flare system added to the scene
  56271. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56272. */
  56273. lensFlareSystems: Array<LensFlareSystem>;
  56274. /**
  56275. * Removes the given lens flare system from this scene.
  56276. * @param toRemove The lens flare system to remove
  56277. * @returns The index of the removed lens flare system
  56278. */
  56279. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56280. /**
  56281. * Adds the given lens flare system to this scene
  56282. * @param newLensFlareSystem The lens flare system to add
  56283. */
  56284. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56285. /**
  56286. * Gets a lens flare system using its name
  56287. * @param name defines the name to look for
  56288. * @returns the lens flare system or null if not found
  56289. */
  56290. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56291. /**
  56292. * Gets a lens flare system using its id
  56293. * @param id defines the id to look for
  56294. * @returns the lens flare system or null if not found
  56295. */
  56296. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56297. }
  56298. }
  56299. /**
  56300. * Defines the lens flare scene component responsible to manage any lens flares
  56301. * in a given scene.
  56302. */
  56303. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56304. /**
  56305. * The component name helpfull to identify the component in the list of scene components.
  56306. */
  56307. readonly name: string;
  56308. /**
  56309. * The scene the component belongs to.
  56310. */
  56311. scene: Scene;
  56312. /**
  56313. * Creates a new instance of the component for the given scene
  56314. * @param scene Defines the scene to register the component in
  56315. */
  56316. constructor(scene: Scene);
  56317. /**
  56318. * Registers the component in a given scene
  56319. */
  56320. register(): void;
  56321. /**
  56322. * Rebuilds the elements related to this component in case of
  56323. * context lost for instance.
  56324. */
  56325. rebuild(): void;
  56326. /**
  56327. * Adds all the elements from the container to the scene
  56328. * @param container the container holding the elements
  56329. */
  56330. addFromContainer(container: AbstractScene): void;
  56331. /**
  56332. * Removes all the elements in the container from the scene
  56333. * @param container contains the elements to remove
  56334. * @param dispose if the removed element should be disposed (default: false)
  56335. */
  56336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56337. /**
  56338. * Serializes the component data to the specified json object
  56339. * @param serializationObject The object to serialize to
  56340. */
  56341. serialize(serializationObject: any): void;
  56342. /**
  56343. * Disposes the component and the associated ressources.
  56344. */
  56345. dispose(): void;
  56346. private _draw;
  56347. }
  56348. }
  56349. declare module "babylonjs/LensFlares/index" {
  56350. export * from "babylonjs/LensFlares/lensFlare";
  56351. export * from "babylonjs/LensFlares/lensFlareSystem";
  56352. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56353. }
  56354. declare module "babylonjs/Shaders/depth.fragment" {
  56355. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56356. /** @hidden */
  56357. export var depthPixelShader: {
  56358. name: string;
  56359. shader: string;
  56360. };
  56361. }
  56362. declare module "babylonjs/Shaders/depth.vertex" {
  56363. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56364. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56365. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56366. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56368. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56369. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56370. /** @hidden */
  56371. export var depthVertexShader: {
  56372. name: string;
  56373. shader: string;
  56374. };
  56375. }
  56376. declare module "babylonjs/Rendering/depthRenderer" {
  56377. import { Nullable } from "babylonjs/types";
  56378. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56379. import { Scene } from "babylonjs/scene";
  56380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56381. import { Camera } from "babylonjs/Cameras/camera";
  56382. import "babylonjs/Shaders/depth.fragment";
  56383. import "babylonjs/Shaders/depth.vertex";
  56384. /**
  56385. * This represents a depth renderer in Babylon.
  56386. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56387. */
  56388. export class DepthRenderer {
  56389. private _scene;
  56390. private _depthMap;
  56391. private _effect;
  56392. private readonly _storeNonLinearDepth;
  56393. private readonly _clearColor;
  56394. /** Get if the depth renderer is using packed depth or not */
  56395. readonly isPacked: boolean;
  56396. private _cachedDefines;
  56397. private _camera;
  56398. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56399. enabled: boolean;
  56400. /**
  56401. * Specifiess that the depth renderer will only be used within
  56402. * the camera it is created for.
  56403. * This can help forcing its rendering during the camera processing.
  56404. */
  56405. useOnlyInActiveCamera: boolean;
  56406. /** @hidden */
  56407. static _SceneComponentInitialization: (scene: Scene) => void;
  56408. /**
  56409. * Instantiates a depth renderer
  56410. * @param scene The scene the renderer belongs to
  56411. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56412. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56413. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56414. */
  56415. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56416. /**
  56417. * Creates the depth rendering effect and checks if the effect is ready.
  56418. * @param subMesh The submesh to be used to render the depth map of
  56419. * @param useInstances If multiple world instances should be used
  56420. * @returns if the depth renderer is ready to render the depth map
  56421. */
  56422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56423. /**
  56424. * Gets the texture which the depth map will be written to.
  56425. * @returns The depth map texture
  56426. */
  56427. getDepthMap(): RenderTargetTexture;
  56428. /**
  56429. * Disposes of the depth renderer.
  56430. */
  56431. dispose(): void;
  56432. }
  56433. }
  56434. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56435. /** @hidden */
  56436. export var minmaxReduxPixelShader: {
  56437. name: string;
  56438. shader: string;
  56439. };
  56440. }
  56441. declare module "babylonjs/Misc/minMaxReducer" {
  56442. import { Nullable } from "babylonjs/types";
  56443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56444. import { Camera } from "babylonjs/Cameras/camera";
  56445. import { Observer } from "babylonjs/Misc/observable";
  56446. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56447. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56448. import { Observable } from "babylonjs/Misc/observable";
  56449. import "babylonjs/Shaders/minmaxRedux.fragment";
  56450. /**
  56451. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56452. * and maximum values from all values of the texture.
  56453. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56454. * The source values are read from the red channel of the texture.
  56455. */
  56456. export class MinMaxReducer {
  56457. /**
  56458. * Observable triggered when the computation has been performed
  56459. */
  56460. onAfterReductionPerformed: Observable<{
  56461. min: number;
  56462. max: number;
  56463. }>;
  56464. protected _camera: Camera;
  56465. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56466. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56467. protected _postProcessManager: PostProcessManager;
  56468. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56469. protected _forceFullscreenViewport: boolean;
  56470. /**
  56471. * Creates a min/max reducer
  56472. * @param camera The camera to use for the post processes
  56473. */
  56474. constructor(camera: Camera);
  56475. /**
  56476. * Gets the texture used to read the values from.
  56477. */
  56478. get sourceTexture(): Nullable<RenderTargetTexture>;
  56479. /**
  56480. * Sets the source texture to read the values from.
  56481. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56482. * because in such textures '1' value must not be taken into account to compute the maximum
  56483. * as this value is used to clear the texture.
  56484. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56485. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56486. * @param depthRedux Indicates if the texture is a depth texture or not
  56487. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56488. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56489. */
  56490. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56491. /**
  56492. * Defines the refresh rate of the computation.
  56493. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56494. */
  56495. get refreshRate(): number;
  56496. set refreshRate(value: number);
  56497. protected _activated: boolean;
  56498. /**
  56499. * Gets the activation status of the reducer
  56500. */
  56501. get activated(): boolean;
  56502. /**
  56503. * Activates the reduction computation.
  56504. * When activated, the observers registered in onAfterReductionPerformed are
  56505. * called after the compuation is performed
  56506. */
  56507. activate(): void;
  56508. /**
  56509. * Deactivates the reduction computation.
  56510. */
  56511. deactivate(): void;
  56512. /**
  56513. * Disposes the min/max reducer
  56514. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56515. */
  56516. dispose(disposeAll?: boolean): void;
  56517. }
  56518. }
  56519. declare module "babylonjs/Misc/depthReducer" {
  56520. import { Nullable } from "babylonjs/types";
  56521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56522. import { Camera } from "babylonjs/Cameras/camera";
  56523. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56524. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56525. /**
  56526. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56527. */
  56528. export class DepthReducer extends MinMaxReducer {
  56529. private _depthRenderer;
  56530. private _depthRendererId;
  56531. /**
  56532. * Gets the depth renderer used for the computation.
  56533. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56534. */
  56535. get depthRenderer(): Nullable<DepthRenderer>;
  56536. /**
  56537. * Creates a depth reducer
  56538. * @param camera The camera used to render the depth texture
  56539. */
  56540. constructor(camera: Camera);
  56541. /**
  56542. * Sets the depth renderer to use to generate the depth map
  56543. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56544. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56545. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56546. */
  56547. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56548. /** @hidden */
  56549. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56550. /**
  56551. * Activates the reduction computation.
  56552. * When activated, the observers registered in onAfterReductionPerformed are
  56553. * called after the compuation is performed
  56554. */
  56555. activate(): void;
  56556. /**
  56557. * Deactivates the reduction computation.
  56558. */
  56559. deactivate(): void;
  56560. /**
  56561. * Disposes the depth reducer
  56562. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56563. */
  56564. dispose(disposeAll?: boolean): void;
  56565. }
  56566. }
  56567. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56568. import { Nullable } from "babylonjs/types";
  56569. import { Scene } from "babylonjs/scene";
  56570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56572. import { Effect } from "babylonjs/Materials/effect";
  56573. import "babylonjs/Shaders/shadowMap.fragment";
  56574. import "babylonjs/Shaders/shadowMap.vertex";
  56575. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56576. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56577. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56578. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56579. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56580. /**
  56581. * A CSM implementation allowing casting shadows on large scenes.
  56582. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56583. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56584. */
  56585. export class CascadedShadowGenerator extends ShadowGenerator {
  56586. private static readonly frustumCornersNDCSpace;
  56587. /**
  56588. * Name of the CSM class
  56589. */
  56590. static CLASSNAME: string;
  56591. /**
  56592. * Defines the default number of cascades used by the CSM.
  56593. */
  56594. static readonly DEFAULT_CASCADES_COUNT: number;
  56595. /**
  56596. * Defines the minimum number of cascades used by the CSM.
  56597. */
  56598. static readonly MIN_CASCADES_COUNT: number;
  56599. /**
  56600. * Defines the maximum number of cascades used by the CSM.
  56601. */
  56602. static readonly MAX_CASCADES_COUNT: number;
  56603. protected _validateFilter(filter: number): number;
  56604. /**
  56605. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56606. */
  56607. penumbraDarkness: number;
  56608. private _numCascades;
  56609. /**
  56610. * Gets or set the number of cascades used by the CSM.
  56611. */
  56612. get numCascades(): number;
  56613. set numCascades(value: number);
  56614. /**
  56615. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56616. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56617. */
  56618. stabilizeCascades: boolean;
  56619. private _freezeShadowCastersBoundingInfo;
  56620. private _freezeShadowCastersBoundingInfoObservable;
  56621. /**
  56622. * Enables or disables the shadow casters bounding info computation.
  56623. * If your shadow casters don't move, you can disable this feature.
  56624. * If it is enabled, the bounding box computation is done every frame.
  56625. */
  56626. get freezeShadowCastersBoundingInfo(): boolean;
  56627. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56628. private _scbiMin;
  56629. private _scbiMax;
  56630. protected _computeShadowCastersBoundingInfo(): void;
  56631. protected _shadowCastersBoundingInfo: BoundingInfo;
  56632. /**
  56633. * Gets or sets the shadow casters bounding info.
  56634. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56635. * so that the system won't overwrite the bounds you provide
  56636. */
  56637. get shadowCastersBoundingInfo(): BoundingInfo;
  56638. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56639. protected _breaksAreDirty: boolean;
  56640. protected _minDistance: number;
  56641. protected _maxDistance: number;
  56642. /**
  56643. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56644. *
  56645. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56646. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56647. * @param min minimal distance for the breaks (default to 0.)
  56648. * @param max maximal distance for the breaks (default to 1.)
  56649. */
  56650. setMinMaxDistance(min: number, max: number): void;
  56651. /** Gets the minimal distance used in the cascade break computation */
  56652. get minDistance(): number;
  56653. /** Gets the maximal distance used in the cascade break computation */
  56654. get maxDistance(): number;
  56655. /**
  56656. * Gets the class name of that object
  56657. * @returns "CascadedShadowGenerator"
  56658. */
  56659. getClassName(): string;
  56660. private _cascadeMinExtents;
  56661. private _cascadeMaxExtents;
  56662. /**
  56663. * Gets a cascade minimum extents
  56664. * @param cascadeIndex index of the cascade
  56665. * @returns the minimum cascade extents
  56666. */
  56667. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56668. /**
  56669. * Gets a cascade maximum extents
  56670. * @param cascadeIndex index of the cascade
  56671. * @returns the maximum cascade extents
  56672. */
  56673. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56674. private _cascades;
  56675. private _currentLayer;
  56676. private _viewSpaceFrustumsZ;
  56677. private _viewMatrices;
  56678. private _projectionMatrices;
  56679. private _transformMatrices;
  56680. private _transformMatricesAsArray;
  56681. private _frustumLengths;
  56682. private _lightSizeUVCorrection;
  56683. private _depthCorrection;
  56684. private _frustumCornersWorldSpace;
  56685. private _frustumCenter;
  56686. private _shadowCameraPos;
  56687. private _shadowMaxZ;
  56688. /**
  56689. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56690. * It defaults to camera.maxZ
  56691. */
  56692. get shadowMaxZ(): number;
  56693. /**
  56694. * Sets the shadow max z distance.
  56695. */
  56696. set shadowMaxZ(value: number);
  56697. protected _debug: boolean;
  56698. /**
  56699. * Gets or sets the debug flag.
  56700. * When enabled, the cascades are materialized by different colors on the screen.
  56701. */
  56702. get debug(): boolean;
  56703. set debug(dbg: boolean);
  56704. private _depthClamp;
  56705. /**
  56706. * Gets or sets the depth clamping value.
  56707. *
  56708. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56709. * to account for the shadow casters far away.
  56710. *
  56711. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56712. */
  56713. get depthClamp(): boolean;
  56714. set depthClamp(value: boolean);
  56715. private _cascadeBlendPercentage;
  56716. /**
  56717. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56718. * It defaults to 0.1 (10% blending).
  56719. */
  56720. get cascadeBlendPercentage(): number;
  56721. set cascadeBlendPercentage(value: number);
  56722. private _lambda;
  56723. /**
  56724. * Gets or set the lambda parameter.
  56725. * This parameter is used to split the camera frustum and create the cascades.
  56726. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  56727. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56728. */
  56729. get lambda(): number;
  56730. set lambda(value: number);
  56731. /**
  56732. * Gets the view matrix corresponding to a given cascade
  56733. * @param cascadeNum cascade to retrieve the view matrix from
  56734. * @returns the cascade view matrix
  56735. */
  56736. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56737. /**
  56738. * Gets the projection matrix corresponding to a given cascade
  56739. * @param cascadeNum cascade to retrieve the projection matrix from
  56740. * @returns the cascade projection matrix
  56741. */
  56742. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56743. /**
  56744. * Gets the transformation matrix corresponding to a given cascade
  56745. * @param cascadeNum cascade to retrieve the transformation matrix from
  56746. * @returns the cascade transformation matrix
  56747. */
  56748. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56749. private _depthRenderer;
  56750. /**
  56751. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56752. *
  56753. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56754. *
  56755. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56756. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56757. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  56758. */
  56759. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56760. private _depthReducer;
  56761. private _autoCalcDepthBounds;
  56762. /**
  56763. * Gets or sets the autoCalcDepthBounds property.
  56764. *
  56765. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56766. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56767. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56768. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56769. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56770. */
  56771. get autoCalcDepthBounds(): boolean;
  56772. set autoCalcDepthBounds(value: boolean);
  56773. /**
  56774. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56775. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56776. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56777. * for setting the refresh rate on the renderer yourself!
  56778. */
  56779. get autoCalcDepthBoundsRefreshRate(): number;
  56780. set autoCalcDepthBoundsRefreshRate(value: number);
  56781. /**
  56782. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56783. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56784. * you change the camera near/far planes!
  56785. */
  56786. splitFrustum(): void;
  56787. private _splitFrustum;
  56788. private _computeMatrices;
  56789. private _computeFrustumInWorldSpace;
  56790. private _computeCascadeFrustum;
  56791. /** @hidden */
  56792. static _SceneComponentInitialization: (scene: Scene) => void;
  56793. /**
  56794. * Creates a Cascaded Shadow Generator object.
  56795. * A ShadowGenerator is the required tool to use the shadows.
  56796. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56797. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56798. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56799. * @param light The directional light object generating the shadows.
  56800. * @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.
  56801. */
  56802. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56803. protected _initializeGenerator(): void;
  56804. protected _createTargetRenderTexture(): void;
  56805. protected _initializeShadowMap(): void;
  56806. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56807. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56808. /**
  56809. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56810. * @param defines Defines of the material we want to update
  56811. * @param lightIndex Index of the light in the enabled light list of the material
  56812. */
  56813. prepareDefines(defines: any, lightIndex: number): void;
  56814. /**
  56815. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56816. * defined in the generator but impacting the effect).
  56817. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56818. * @param effect The effect we are binfing the information for
  56819. */
  56820. bindShadowLight(lightIndex: string, effect: Effect): void;
  56821. /**
  56822. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56823. * (eq to view projection * shadow projection matrices)
  56824. * @returns The transform matrix used to create the shadow map
  56825. */
  56826. getTransformMatrix(): Matrix;
  56827. /**
  56828. * Disposes the ShadowGenerator.
  56829. * Returns nothing.
  56830. */
  56831. dispose(): void;
  56832. /**
  56833. * Serializes the shadow generator setup to a json object.
  56834. * @returns The serialized JSON object
  56835. */
  56836. serialize(): any;
  56837. /**
  56838. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56839. * @param parsedShadowGenerator The JSON object to parse
  56840. * @param scene The scene to create the shadow map for
  56841. * @returns The parsed shadow generator
  56842. */
  56843. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56844. }
  56845. }
  56846. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56847. import { Scene } from "babylonjs/scene";
  56848. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56849. import { AbstractScene } from "babylonjs/abstractScene";
  56850. /**
  56851. * Defines the shadow generator component responsible to manage any shadow generators
  56852. * in a given scene.
  56853. */
  56854. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56855. /**
  56856. * The component name helpfull to identify the component in the list of scene components.
  56857. */
  56858. readonly name: string;
  56859. /**
  56860. * The scene the component belongs to.
  56861. */
  56862. scene: Scene;
  56863. /**
  56864. * Creates a new instance of the component for the given scene
  56865. * @param scene Defines the scene to register the component in
  56866. */
  56867. constructor(scene: Scene);
  56868. /**
  56869. * Registers the component in a given scene
  56870. */
  56871. register(): void;
  56872. /**
  56873. * Rebuilds the elements related to this component in case of
  56874. * context lost for instance.
  56875. */
  56876. rebuild(): void;
  56877. /**
  56878. * Serializes the component data to the specified json object
  56879. * @param serializationObject The object to serialize to
  56880. */
  56881. serialize(serializationObject: any): void;
  56882. /**
  56883. * Adds all the elements from the container to the scene
  56884. * @param container the container holding the elements
  56885. */
  56886. addFromContainer(container: AbstractScene): void;
  56887. /**
  56888. * Removes all the elements in the container from the scene
  56889. * @param container contains the elements to remove
  56890. * @param dispose if the removed element should be disposed (default: false)
  56891. */
  56892. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56893. /**
  56894. * Rebuilds the elements related to this component in case of
  56895. * context lost for instance.
  56896. */
  56897. dispose(): void;
  56898. private _gatherRenderTargets;
  56899. }
  56900. }
  56901. declare module "babylonjs/Lights/Shadows/index" {
  56902. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56903. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56904. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56905. }
  56906. declare module "babylonjs/Lights/pointLight" {
  56907. import { Scene } from "babylonjs/scene";
  56908. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56910. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56911. import { Effect } from "babylonjs/Materials/effect";
  56912. /**
  56913. * A point light is a light defined by an unique point in world space.
  56914. * The light is emitted in every direction from this point.
  56915. * A good example of a point light is a standard light bulb.
  56916. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56917. */
  56918. export class PointLight extends ShadowLight {
  56919. private _shadowAngle;
  56920. /**
  56921. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56922. * This specifies what angle the shadow will use to be created.
  56923. *
  56924. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56925. */
  56926. get shadowAngle(): number;
  56927. /**
  56928. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56929. * This specifies what angle the shadow will use to be created.
  56930. *
  56931. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56932. */
  56933. set shadowAngle(value: number);
  56934. /**
  56935. * Gets the direction if it has been set.
  56936. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56937. */
  56938. get direction(): Vector3;
  56939. /**
  56940. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56941. */
  56942. set direction(value: Vector3);
  56943. /**
  56944. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56945. * A PointLight emits the light in every direction.
  56946. * It can cast shadows.
  56947. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56948. * ```javascript
  56949. * var pointLight = new PointLight("pl", camera.position, scene);
  56950. * ```
  56951. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56952. * @param name The light friendly name
  56953. * @param position The position of the point light in the scene
  56954. * @param scene The scene the lights belongs to
  56955. */
  56956. constructor(name: string, position: Vector3, scene: Scene);
  56957. /**
  56958. * Returns the string "PointLight"
  56959. * @returns the class name
  56960. */
  56961. getClassName(): string;
  56962. /**
  56963. * Returns the integer 0.
  56964. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56965. */
  56966. getTypeID(): number;
  56967. /**
  56968. * Specifies wether or not the shadowmap should be a cube texture.
  56969. * @returns true if the shadowmap needs to be a cube texture.
  56970. */
  56971. needCube(): boolean;
  56972. /**
  56973. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56976. */
  56977. getShadowDirection(faceIndex?: number): Vector3;
  56978. /**
  56979. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56980. * - fov = PI / 2
  56981. * - aspect ratio : 1.0
  56982. * - z-near and far equal to the active camera minZ and maxZ.
  56983. * Returns the PointLight.
  56984. */
  56985. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56986. protected _buildUniformLayout(): void;
  56987. /**
  56988. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56989. * @param effect The effect to update
  56990. * @param lightIndex The index of the light in the effect to update
  56991. * @returns The point light
  56992. */
  56993. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56994. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56995. /**
  56996. * Prepares the list of defines specific to the light type.
  56997. * @param defines the list of defines
  56998. * @param lightIndex defines the index of the light for the effect
  56999. */
  57000. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57001. }
  57002. }
  57003. declare module "babylonjs/Lights/index" {
  57004. export * from "babylonjs/Lights/light";
  57005. export * from "babylonjs/Lights/shadowLight";
  57006. export * from "babylonjs/Lights/Shadows/index";
  57007. export * from "babylonjs/Lights/directionalLight";
  57008. export * from "babylonjs/Lights/hemisphericLight";
  57009. export * from "babylonjs/Lights/pointLight";
  57010. export * from "babylonjs/Lights/spotLight";
  57011. }
  57012. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57013. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57014. /**
  57015. * Header information of HDR texture files.
  57016. */
  57017. export interface HDRInfo {
  57018. /**
  57019. * The height of the texture in pixels.
  57020. */
  57021. height: number;
  57022. /**
  57023. * The width of the texture in pixels.
  57024. */
  57025. width: number;
  57026. /**
  57027. * The index of the beginning of the data in the binary file.
  57028. */
  57029. dataPosition: number;
  57030. }
  57031. /**
  57032. * This groups tools to convert HDR texture to native colors array.
  57033. */
  57034. export class HDRTools {
  57035. private static Ldexp;
  57036. private static Rgbe2float;
  57037. private static readStringLine;
  57038. /**
  57039. * Reads header information from an RGBE texture stored in a native array.
  57040. * More information on this format are available here:
  57041. * https://en.wikipedia.org/wiki/RGBE_image_format
  57042. *
  57043. * @param uint8array The binary file stored in native array.
  57044. * @return The header information.
  57045. */
  57046. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57047. /**
  57048. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57049. * This RGBE texture needs to store the information as a panorama.
  57050. *
  57051. * More information on this format are available here:
  57052. * https://en.wikipedia.org/wiki/RGBE_image_format
  57053. *
  57054. * @param buffer The binary file stored in an array buffer.
  57055. * @param size The expected size of the extracted cubemap.
  57056. * @return The Cube Map information.
  57057. */
  57058. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57059. /**
  57060. * Returns the pixels data extracted from an RGBE texture.
  57061. * This pixels will be stored left to right up to down in the R G B order in one array.
  57062. *
  57063. * More information on this format are available here:
  57064. * https://en.wikipedia.org/wiki/RGBE_image_format
  57065. *
  57066. * @param uint8array The binary file stored in an array buffer.
  57067. * @param hdrInfo The header information of the file.
  57068. * @return The pixels data in RGB right to left up to down order.
  57069. */
  57070. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57071. private static RGBE_ReadPixels_RLE;
  57072. }
  57073. }
  57074. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57075. import { Nullable } from "babylonjs/types";
  57076. import { Scene } from "babylonjs/scene";
  57077. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57079. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57080. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57081. /**
  57082. * This represents a texture coming from an HDR input.
  57083. *
  57084. * The only supported format is currently panorama picture stored in RGBE format.
  57085. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57086. */
  57087. export class HDRCubeTexture extends BaseTexture {
  57088. private static _facesMapping;
  57089. private _generateHarmonics;
  57090. private _noMipmap;
  57091. private _textureMatrix;
  57092. private _size;
  57093. private _onLoad;
  57094. private _onError;
  57095. /**
  57096. * The texture URL.
  57097. */
  57098. url: string;
  57099. /**
  57100. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57101. */
  57102. coordinatesMode: number;
  57103. protected _isBlocking: boolean;
  57104. /**
  57105. * Sets wether or not the texture is blocking during loading.
  57106. */
  57107. set isBlocking(value: boolean);
  57108. /**
  57109. * Gets wether or not the texture is blocking during loading.
  57110. */
  57111. get isBlocking(): boolean;
  57112. protected _rotationY: number;
  57113. /**
  57114. * Sets texture matrix rotation angle around Y axis in radians.
  57115. */
  57116. set rotationY(value: number);
  57117. /**
  57118. * Gets texture matrix rotation angle around Y axis radians.
  57119. */
  57120. get rotationY(): number;
  57121. /**
  57122. * Gets or sets the center of the bounding box associated with the cube texture
  57123. * It must define where the camera used to render the texture was set
  57124. */
  57125. boundingBoxPosition: Vector3;
  57126. private _boundingBoxSize;
  57127. /**
  57128. * Gets or sets the size of the bounding box associated with the cube texture
  57129. * When defined, the cubemap will switch to local mode
  57130. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57131. * @example https://www.babylonjs-playground.com/#RNASML
  57132. */
  57133. set boundingBoxSize(value: Vector3);
  57134. get boundingBoxSize(): Vector3;
  57135. /**
  57136. * Instantiates an HDRTexture from the following parameters.
  57137. *
  57138. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57139. * @param scene The scene the texture will be used in
  57140. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57141. * @param noMipmap Forces to not generate the mipmap if true
  57142. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57143. * @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)
  57144. * @param reserved Reserved flag for internal use.
  57145. */
  57146. 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>);
  57147. /**
  57148. * Get the current class name of the texture useful for serialization or dynamic coding.
  57149. * @returns "HDRCubeTexture"
  57150. */
  57151. getClassName(): string;
  57152. /**
  57153. * Occurs when the file is raw .hdr file.
  57154. */
  57155. private loadTexture;
  57156. clone(): HDRCubeTexture;
  57157. delayLoad(): void;
  57158. /**
  57159. * Get the texture reflection matrix used to rotate/transform the reflection.
  57160. * @returns the reflection matrix
  57161. */
  57162. getReflectionTextureMatrix(): Matrix;
  57163. /**
  57164. * Set the texture reflection matrix used to rotate/transform the reflection.
  57165. * @param value Define the reflection matrix to set
  57166. */
  57167. setReflectionTextureMatrix(value: Matrix): void;
  57168. /**
  57169. * Parses a JSON representation of an HDR Texture in order to create the texture
  57170. * @param parsedTexture Define the JSON representation
  57171. * @param scene Define the scene the texture should be created in
  57172. * @param rootUrl Define the root url in case we need to load relative dependencies
  57173. * @returns the newly created texture after parsing
  57174. */
  57175. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57176. serialize(): any;
  57177. }
  57178. }
  57179. declare module "babylonjs/Physics/physicsEngine" {
  57180. import { Nullable } from "babylonjs/types";
  57181. import { Vector3 } from "babylonjs/Maths/math.vector";
  57182. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57183. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57184. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57185. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57186. /**
  57187. * Class used to control physics engine
  57188. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57189. */
  57190. export class PhysicsEngine implements IPhysicsEngine {
  57191. private _physicsPlugin;
  57192. /**
  57193. * Global value used to control the smallest number supported by the simulation
  57194. */
  57195. static Epsilon: number;
  57196. private _impostors;
  57197. private _joints;
  57198. private _subTimeStep;
  57199. /**
  57200. * Gets the gravity vector used by the simulation
  57201. */
  57202. gravity: Vector3;
  57203. /**
  57204. * Factory used to create the default physics plugin.
  57205. * @returns The default physics plugin
  57206. */
  57207. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57208. /**
  57209. * Creates a new Physics Engine
  57210. * @param gravity defines the gravity vector used by the simulation
  57211. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57212. */
  57213. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57214. /**
  57215. * Sets the gravity vector used by the simulation
  57216. * @param gravity defines the gravity vector to use
  57217. */
  57218. setGravity(gravity: Vector3): void;
  57219. /**
  57220. * Set the time step of the physics engine.
  57221. * Default is 1/60.
  57222. * To slow it down, enter 1/600 for example.
  57223. * To speed it up, 1/30
  57224. * @param newTimeStep defines the new timestep to apply to this world.
  57225. */
  57226. setTimeStep(newTimeStep?: number): void;
  57227. /**
  57228. * Get the time step of the physics engine.
  57229. * @returns the current time step
  57230. */
  57231. getTimeStep(): number;
  57232. /**
  57233. * Set the sub time step of the physics engine.
  57234. * Default is 0 meaning there is no sub steps
  57235. * To increase physics resolution precision, set a small value (like 1 ms)
  57236. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57237. */
  57238. setSubTimeStep(subTimeStep?: number): void;
  57239. /**
  57240. * Get the sub time step of the physics engine.
  57241. * @returns the current sub time step
  57242. */
  57243. getSubTimeStep(): number;
  57244. /**
  57245. * Release all resources
  57246. */
  57247. dispose(): void;
  57248. /**
  57249. * Gets the name of the current physics plugin
  57250. * @returns the name of the plugin
  57251. */
  57252. getPhysicsPluginName(): string;
  57253. /**
  57254. * Adding a new impostor for the impostor tracking.
  57255. * This will be done by the impostor itself.
  57256. * @param impostor the impostor to add
  57257. */
  57258. addImpostor(impostor: PhysicsImpostor): void;
  57259. /**
  57260. * Remove an impostor from the engine.
  57261. * This impostor and its mesh will not longer be updated by the physics engine.
  57262. * @param impostor the impostor to remove
  57263. */
  57264. removeImpostor(impostor: PhysicsImpostor): void;
  57265. /**
  57266. * Add a joint to the physics engine
  57267. * @param mainImpostor defines the main impostor to which the joint is added.
  57268. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57269. * @param joint defines the joint that will connect both impostors.
  57270. */
  57271. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57272. /**
  57273. * Removes a joint from the simulation
  57274. * @param mainImpostor defines the impostor used with the joint
  57275. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57276. * @param joint defines the joint to remove
  57277. */
  57278. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57279. /**
  57280. * Called by the scene. No need to call it.
  57281. * @param delta defines the timespam between frames
  57282. */
  57283. _step(delta: number): void;
  57284. /**
  57285. * Gets the current plugin used to run the simulation
  57286. * @returns current plugin
  57287. */
  57288. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57289. /**
  57290. * Gets the list of physic impostors
  57291. * @returns an array of PhysicsImpostor
  57292. */
  57293. getImpostors(): Array<PhysicsImpostor>;
  57294. /**
  57295. * Gets the impostor for a physics enabled object
  57296. * @param object defines the object impersonated by the impostor
  57297. * @returns the PhysicsImpostor or null if not found
  57298. */
  57299. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57300. /**
  57301. * Gets the impostor for a physics body object
  57302. * @param body defines physics body used by the impostor
  57303. * @returns the PhysicsImpostor or null if not found
  57304. */
  57305. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57306. /**
  57307. * Does a raycast in the physics world
  57308. * @param from when should the ray start?
  57309. * @param to when should the ray end?
  57310. * @returns PhysicsRaycastResult
  57311. */
  57312. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57313. }
  57314. }
  57315. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57316. import { Nullable } from "babylonjs/types";
  57317. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57319. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57320. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57321. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57322. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57323. /** @hidden */
  57324. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57325. private _useDeltaForWorldStep;
  57326. world: any;
  57327. name: string;
  57328. private _physicsMaterials;
  57329. private _fixedTimeStep;
  57330. private _cannonRaycastResult;
  57331. private _raycastResult;
  57332. private _physicsBodysToRemoveAfterStep;
  57333. BJSCANNON: any;
  57334. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57335. setGravity(gravity: Vector3): void;
  57336. setTimeStep(timeStep: number): void;
  57337. getTimeStep(): number;
  57338. executeStep(delta: number): void;
  57339. private _removeMarkedPhysicsBodiesFromWorld;
  57340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57343. private _processChildMeshes;
  57344. removePhysicsBody(impostor: PhysicsImpostor): void;
  57345. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57347. private _addMaterial;
  57348. private _checkWithEpsilon;
  57349. private _createShape;
  57350. private _createHeightmap;
  57351. private _minus90X;
  57352. private _plus90X;
  57353. private _tmpPosition;
  57354. private _tmpDeltaPosition;
  57355. private _tmpUnityRotation;
  57356. private _updatePhysicsBodyTransformation;
  57357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57358. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57359. isSupported(): boolean;
  57360. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57361. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57362. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57363. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57364. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57365. getBodyMass(impostor: PhysicsImpostor): number;
  57366. getBodyFriction(impostor: PhysicsImpostor): number;
  57367. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57368. getBodyRestitution(impostor: PhysicsImpostor): number;
  57369. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57370. sleepBody(impostor: PhysicsImpostor): void;
  57371. wakeUpBody(impostor: PhysicsImpostor): void;
  57372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57373. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57376. getRadius(impostor: PhysicsImpostor): number;
  57377. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57378. dispose(): void;
  57379. private _extendNamespace;
  57380. /**
  57381. * Does a raycast in the physics world
  57382. * @param from when should the ray start?
  57383. * @param to when should the ray end?
  57384. * @returns PhysicsRaycastResult
  57385. */
  57386. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57387. }
  57388. }
  57389. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57390. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57391. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57392. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57394. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57395. import { Nullable } from "babylonjs/types";
  57396. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57397. /** @hidden */
  57398. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57399. world: any;
  57400. name: string;
  57401. BJSOIMO: any;
  57402. private _raycastResult;
  57403. constructor(iterations?: number, oimoInjection?: any);
  57404. setGravity(gravity: Vector3): void;
  57405. setTimeStep(timeStep: number): void;
  57406. getTimeStep(): number;
  57407. private _tmpImpostorsArray;
  57408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57412. private _tmpPositionVector;
  57413. removePhysicsBody(impostor: PhysicsImpostor): void;
  57414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57415. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57416. isSupported(): boolean;
  57417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57424. getBodyMass(impostor: PhysicsImpostor): number;
  57425. getBodyFriction(impostor: PhysicsImpostor): number;
  57426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57427. getBodyRestitution(impostor: PhysicsImpostor): number;
  57428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57429. sleepBody(impostor: PhysicsImpostor): void;
  57430. wakeUpBody(impostor: PhysicsImpostor): void;
  57431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57432. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57435. getRadius(impostor: PhysicsImpostor): number;
  57436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57437. dispose(): void;
  57438. /**
  57439. * Does a raycast in the physics world
  57440. * @param from when should the ray start?
  57441. * @param to when should the ray end?
  57442. * @returns PhysicsRaycastResult
  57443. */
  57444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57445. }
  57446. }
  57447. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57448. import { Nullable } from "babylonjs/types";
  57449. import { Scene } from "babylonjs/scene";
  57450. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57451. import { Color4 } from "babylonjs/Maths/math.color";
  57452. import { Mesh } from "babylonjs/Meshes/mesh";
  57453. /**
  57454. * Class containing static functions to help procedurally build meshes
  57455. */
  57456. export class RibbonBuilder {
  57457. /**
  57458. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57459. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57460. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57461. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57462. * * 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
  57463. * * 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
  57464. * * 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
  57465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57468. * * 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
  57469. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57470. * * 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
  57471. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57473. * @param name defines the name of the mesh
  57474. * @param options defines the options used to create the mesh
  57475. * @param scene defines the hosting scene
  57476. * @returns the ribbon mesh
  57477. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57479. */
  57480. static CreateRibbon(name: string, options: {
  57481. pathArray: Vector3[][];
  57482. closeArray?: boolean;
  57483. closePath?: boolean;
  57484. offset?: number;
  57485. updatable?: boolean;
  57486. sideOrientation?: number;
  57487. frontUVs?: Vector4;
  57488. backUVs?: Vector4;
  57489. instance?: Mesh;
  57490. invertUV?: boolean;
  57491. uvs?: Vector2[];
  57492. colors?: Color4[];
  57493. }, scene?: Nullable<Scene>): Mesh;
  57494. }
  57495. }
  57496. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57497. import { Nullable } from "babylonjs/types";
  57498. import { Scene } from "babylonjs/scene";
  57499. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57500. import { Mesh } from "babylonjs/Meshes/mesh";
  57501. /**
  57502. * Class containing static functions to help procedurally build meshes
  57503. */
  57504. export class ShapeBuilder {
  57505. /**
  57506. * 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.
  57507. * * 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.
  57508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57509. * * 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.
  57510. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57511. * * 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
  57512. * * 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
  57513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57518. * @param name defines the name of the mesh
  57519. * @param options defines the options used to create the mesh
  57520. * @param scene defines the hosting scene
  57521. * @returns the extruded shape mesh
  57522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57524. */
  57525. static ExtrudeShape(name: string, options: {
  57526. shape: Vector3[];
  57527. path: Vector3[];
  57528. scale?: number;
  57529. rotation?: number;
  57530. cap?: number;
  57531. updatable?: boolean;
  57532. sideOrientation?: number;
  57533. frontUVs?: Vector4;
  57534. backUVs?: Vector4;
  57535. instance?: Mesh;
  57536. invertUV?: boolean;
  57537. }, scene?: Nullable<Scene>): Mesh;
  57538. /**
  57539. * Creates an custom extruded shape mesh.
  57540. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57541. * * 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.
  57542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57543. * * 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
  57544. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57545. * * 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
  57546. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57547. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57548. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57549. * * 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
  57550. * * 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
  57551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57556. * @param name defines the name of the mesh
  57557. * @param options defines the options used to create the mesh
  57558. * @param scene defines the hosting scene
  57559. * @returns the custom extruded shape mesh
  57560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57563. */
  57564. static ExtrudeShapeCustom(name: string, options: {
  57565. shape: Vector3[];
  57566. path: Vector3[];
  57567. scaleFunction?: any;
  57568. rotationFunction?: any;
  57569. ribbonCloseArray?: boolean;
  57570. ribbonClosePath?: boolean;
  57571. cap?: number;
  57572. updatable?: boolean;
  57573. sideOrientation?: number;
  57574. frontUVs?: Vector4;
  57575. backUVs?: Vector4;
  57576. instance?: Mesh;
  57577. invertUV?: boolean;
  57578. }, scene?: Nullable<Scene>): Mesh;
  57579. private static _ExtrudeShapeGeneric;
  57580. }
  57581. }
  57582. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57583. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57584. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57585. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57586. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57587. import { Nullable } from "babylonjs/types";
  57588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57589. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57590. /**
  57591. * AmmoJS Physics plugin
  57592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57593. * @see https://github.com/kripken/ammo.js/
  57594. */
  57595. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57596. private _useDeltaForWorldStep;
  57597. /**
  57598. * Reference to the Ammo library
  57599. */
  57600. bjsAMMO: any;
  57601. /**
  57602. * Created ammoJS world which physics bodies are added to
  57603. */
  57604. world: any;
  57605. /**
  57606. * Name of the plugin
  57607. */
  57608. name: string;
  57609. private _timeStep;
  57610. private _fixedTimeStep;
  57611. private _maxSteps;
  57612. private _tmpQuaternion;
  57613. private _tmpAmmoTransform;
  57614. private _tmpAmmoQuaternion;
  57615. private _tmpAmmoConcreteContactResultCallback;
  57616. private _collisionConfiguration;
  57617. private _dispatcher;
  57618. private _overlappingPairCache;
  57619. private _solver;
  57620. private _softBodySolver;
  57621. private _tmpAmmoVectorA;
  57622. private _tmpAmmoVectorB;
  57623. private _tmpAmmoVectorC;
  57624. private _tmpAmmoVectorD;
  57625. private _tmpContactCallbackResult;
  57626. private _tmpAmmoVectorRCA;
  57627. private _tmpAmmoVectorRCB;
  57628. private _raycastResult;
  57629. private static readonly DISABLE_COLLISION_FLAG;
  57630. private static readonly KINEMATIC_FLAG;
  57631. private static readonly DISABLE_DEACTIVATION_FLAG;
  57632. /**
  57633. * Initializes the ammoJS plugin
  57634. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57635. * @param ammoInjection can be used to inject your own ammo reference
  57636. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57637. */
  57638. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57639. /**
  57640. * Sets the gravity of the physics world (m/(s^2))
  57641. * @param gravity Gravity to set
  57642. */
  57643. setGravity(gravity: Vector3): void;
  57644. /**
  57645. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57646. * @param timeStep timestep to use in seconds
  57647. */
  57648. setTimeStep(timeStep: number): void;
  57649. /**
  57650. * 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)
  57651. * @param fixedTimeStep fixedTimeStep to use in seconds
  57652. */
  57653. setFixedTimeStep(fixedTimeStep: number): void;
  57654. /**
  57655. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57656. * @param maxSteps the maximum number of steps by the physics engine per frame
  57657. */
  57658. setMaxSteps(maxSteps: number): void;
  57659. /**
  57660. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57661. * @returns the current timestep in seconds
  57662. */
  57663. getTimeStep(): number;
  57664. /**
  57665. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57666. */
  57667. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57668. private _isImpostorInContact;
  57669. private _isImpostorPairInContact;
  57670. private _stepSimulation;
  57671. /**
  57672. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57673. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57674. * After the step the babylon meshes are set to the position of the physics imposters
  57675. * @param delta amount of time to step forward
  57676. * @param impostors array of imposters to update before/after the step
  57677. */
  57678. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57679. /**
  57680. * Update babylon mesh to match physics world object
  57681. * @param impostor imposter to match
  57682. */
  57683. private _afterSoftStep;
  57684. /**
  57685. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57686. * @param impostor imposter to match
  57687. */
  57688. private _ropeStep;
  57689. /**
  57690. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57691. * @param impostor imposter to match
  57692. */
  57693. private _softbodyOrClothStep;
  57694. private _tmpVector;
  57695. private _tmpMatrix;
  57696. /**
  57697. * Applies an impulse on the imposter
  57698. * @param impostor imposter to apply impulse to
  57699. * @param force amount of force to be applied to the imposter
  57700. * @param contactPoint the location to apply the impulse on the imposter
  57701. */
  57702. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57703. /**
  57704. * Applies a force on the imposter
  57705. * @param impostor imposter to apply force
  57706. * @param force amount of force to be applied to the imposter
  57707. * @param contactPoint the location to apply the force on the imposter
  57708. */
  57709. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57710. /**
  57711. * Creates a physics body using the plugin
  57712. * @param impostor the imposter to create the physics body on
  57713. */
  57714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57715. /**
  57716. * Removes the physics body from the imposter and disposes of the body's memory
  57717. * @param impostor imposter to remove the physics body from
  57718. */
  57719. removePhysicsBody(impostor: PhysicsImpostor): void;
  57720. /**
  57721. * Generates a joint
  57722. * @param impostorJoint the imposter joint to create the joint with
  57723. */
  57724. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57725. /**
  57726. * Removes a joint
  57727. * @param impostorJoint the imposter joint to remove the joint from
  57728. */
  57729. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57730. private _addMeshVerts;
  57731. /**
  57732. * Initialise the soft body vertices to match its object's (mesh) vertices
  57733. * Softbody vertices (nodes) are in world space and to match this
  57734. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57735. * @param impostor to create the softbody for
  57736. */
  57737. private _softVertexData;
  57738. /**
  57739. * Create an impostor's soft body
  57740. * @param impostor to create the softbody for
  57741. */
  57742. private _createSoftbody;
  57743. /**
  57744. * Create cloth for an impostor
  57745. * @param impostor to create the softbody for
  57746. */
  57747. private _createCloth;
  57748. /**
  57749. * Create rope for an impostor
  57750. * @param impostor to create the softbody for
  57751. */
  57752. private _createRope;
  57753. /**
  57754. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57755. * @param impostor to create the custom physics shape for
  57756. */
  57757. private _createCustom;
  57758. private _addHullVerts;
  57759. private _createShape;
  57760. /**
  57761. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57762. * @param impostor imposter containing the physics body and babylon object
  57763. */
  57764. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57765. /**
  57766. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57767. * @param impostor imposter containing the physics body and babylon object
  57768. * @param newPosition new position
  57769. * @param newRotation new rotation
  57770. */
  57771. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57772. /**
  57773. * If this plugin is supported
  57774. * @returns true if its supported
  57775. */
  57776. isSupported(): boolean;
  57777. /**
  57778. * Sets the linear velocity of the physics body
  57779. * @param impostor imposter to set the velocity on
  57780. * @param velocity velocity to set
  57781. */
  57782. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57783. /**
  57784. * Sets the angular velocity of the physics body
  57785. * @param impostor imposter to set the velocity on
  57786. * @param velocity velocity to set
  57787. */
  57788. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57789. /**
  57790. * gets the linear velocity
  57791. * @param impostor imposter to get linear velocity from
  57792. * @returns linear velocity
  57793. */
  57794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57795. /**
  57796. * gets the angular velocity
  57797. * @param impostor imposter to get angular velocity from
  57798. * @returns angular velocity
  57799. */
  57800. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57801. /**
  57802. * Sets the mass of physics body
  57803. * @param impostor imposter to set the mass on
  57804. * @param mass mass to set
  57805. */
  57806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57807. /**
  57808. * Gets the mass of the physics body
  57809. * @param impostor imposter to get the mass from
  57810. * @returns mass
  57811. */
  57812. getBodyMass(impostor: PhysicsImpostor): number;
  57813. /**
  57814. * Gets friction of the impostor
  57815. * @param impostor impostor to get friction from
  57816. * @returns friction value
  57817. */
  57818. getBodyFriction(impostor: PhysicsImpostor): number;
  57819. /**
  57820. * Sets friction of the impostor
  57821. * @param impostor impostor to set friction on
  57822. * @param friction friction value
  57823. */
  57824. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57825. /**
  57826. * Gets restitution of the impostor
  57827. * @param impostor impostor to get restitution from
  57828. * @returns restitution value
  57829. */
  57830. getBodyRestitution(impostor: PhysicsImpostor): number;
  57831. /**
  57832. * Sets resitution of the impostor
  57833. * @param impostor impostor to set resitution on
  57834. * @param restitution resitution value
  57835. */
  57836. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57837. /**
  57838. * Gets pressure inside the impostor
  57839. * @param impostor impostor to get pressure from
  57840. * @returns pressure value
  57841. */
  57842. getBodyPressure(impostor: PhysicsImpostor): number;
  57843. /**
  57844. * Sets pressure inside a soft body impostor
  57845. * Cloth and rope must remain 0 pressure
  57846. * @param impostor impostor to set pressure on
  57847. * @param pressure pressure value
  57848. */
  57849. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57850. /**
  57851. * Gets stiffness of the impostor
  57852. * @param impostor impostor to get stiffness from
  57853. * @returns pressure value
  57854. */
  57855. getBodyStiffness(impostor: PhysicsImpostor): number;
  57856. /**
  57857. * Sets stiffness of the impostor
  57858. * @param impostor impostor to set stiffness on
  57859. * @param stiffness stiffness value from 0 to 1
  57860. */
  57861. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57862. /**
  57863. * Gets velocityIterations of the impostor
  57864. * @param impostor impostor to get velocity iterations from
  57865. * @returns velocityIterations value
  57866. */
  57867. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57868. /**
  57869. * Sets velocityIterations of the impostor
  57870. * @param impostor impostor to set velocity iterations on
  57871. * @param velocityIterations velocityIterations value
  57872. */
  57873. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57874. /**
  57875. * Gets positionIterations of the impostor
  57876. * @param impostor impostor to get position iterations from
  57877. * @returns positionIterations value
  57878. */
  57879. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57880. /**
  57881. * Sets positionIterations of the impostor
  57882. * @param impostor impostor to set position on
  57883. * @param positionIterations positionIterations value
  57884. */
  57885. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57886. /**
  57887. * Append an anchor to a cloth object
  57888. * @param impostor is the cloth impostor to add anchor to
  57889. * @param otherImpostor is the rigid impostor to anchor to
  57890. * @param width ratio across width from 0 to 1
  57891. * @param height ratio up height from 0 to 1
  57892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57893. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57894. */
  57895. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57896. /**
  57897. * Append an hook to a rope object
  57898. * @param impostor is the rope impostor to add hook to
  57899. * @param otherImpostor is the rigid impostor to hook to
  57900. * @param length ratio along the rope from 0 to 1
  57901. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57903. */
  57904. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57905. /**
  57906. * Sleeps the physics body and stops it from being active
  57907. * @param impostor impostor to sleep
  57908. */
  57909. sleepBody(impostor: PhysicsImpostor): void;
  57910. /**
  57911. * Activates the physics body
  57912. * @param impostor impostor to activate
  57913. */
  57914. wakeUpBody(impostor: PhysicsImpostor): void;
  57915. /**
  57916. * Updates the distance parameters of the joint
  57917. * @param joint joint to update
  57918. * @param maxDistance maximum distance of the joint
  57919. * @param minDistance minimum distance of the joint
  57920. */
  57921. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57922. /**
  57923. * Sets a motor on the joint
  57924. * @param joint joint to set motor on
  57925. * @param speed speed of the motor
  57926. * @param maxForce maximum force of the motor
  57927. * @param motorIndex index of the motor
  57928. */
  57929. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57930. /**
  57931. * Sets the motors limit
  57932. * @param joint joint to set limit on
  57933. * @param upperLimit upper limit
  57934. * @param lowerLimit lower limit
  57935. */
  57936. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57937. /**
  57938. * Syncs the position and rotation of a mesh with the impostor
  57939. * @param mesh mesh to sync
  57940. * @param impostor impostor to update the mesh with
  57941. */
  57942. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57943. /**
  57944. * Gets the radius of the impostor
  57945. * @param impostor impostor to get radius from
  57946. * @returns the radius
  57947. */
  57948. getRadius(impostor: PhysicsImpostor): number;
  57949. /**
  57950. * Gets the box size of the impostor
  57951. * @param impostor impostor to get box size from
  57952. * @param result the resulting box size
  57953. */
  57954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57955. /**
  57956. * Disposes of the impostor
  57957. */
  57958. dispose(): void;
  57959. /**
  57960. * Does a raycast in the physics world
  57961. * @param from when should the ray start?
  57962. * @param to when should the ray end?
  57963. * @returns PhysicsRaycastResult
  57964. */
  57965. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57966. }
  57967. }
  57968. declare module "babylonjs/Probes/reflectionProbe" {
  57969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57970. import { Vector3 } from "babylonjs/Maths/math.vector";
  57971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57972. import { Nullable } from "babylonjs/types";
  57973. import { Scene } from "babylonjs/scene";
  57974. module "babylonjs/abstractScene" {
  57975. interface AbstractScene {
  57976. /**
  57977. * The list of reflection probes added to the scene
  57978. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57979. */
  57980. reflectionProbes: Array<ReflectionProbe>;
  57981. /**
  57982. * Removes the given reflection probe from this scene.
  57983. * @param toRemove The reflection probe to remove
  57984. * @returns The index of the removed reflection probe
  57985. */
  57986. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57987. /**
  57988. * Adds the given reflection probe to this scene.
  57989. * @param newReflectionProbe The reflection probe to add
  57990. */
  57991. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57992. }
  57993. }
  57994. /**
  57995. * Class used to generate realtime reflection / refraction cube textures
  57996. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57997. */
  57998. export class ReflectionProbe {
  57999. /** defines the name of the probe */
  58000. name: string;
  58001. private _scene;
  58002. private _renderTargetTexture;
  58003. private _projectionMatrix;
  58004. private _viewMatrix;
  58005. private _target;
  58006. private _add;
  58007. private _attachedMesh;
  58008. private _invertYAxis;
  58009. /** Gets or sets probe position (center of the cube map) */
  58010. position: Vector3;
  58011. /**
  58012. * Creates a new reflection probe
  58013. * @param name defines the name of the probe
  58014. * @param size defines the texture resolution (for each face)
  58015. * @param scene defines the hosting scene
  58016. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58017. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58018. */
  58019. constructor(
  58020. /** defines the name of the probe */
  58021. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58022. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58023. get samples(): number;
  58024. set samples(value: number);
  58025. /** Gets or sets the refresh rate to use (on every frame by default) */
  58026. get refreshRate(): number;
  58027. set refreshRate(value: number);
  58028. /**
  58029. * Gets the hosting scene
  58030. * @returns a Scene
  58031. */
  58032. getScene(): Scene;
  58033. /** Gets the internal CubeTexture used to render to */
  58034. get cubeTexture(): RenderTargetTexture;
  58035. /** Gets the list of meshes to render */
  58036. get renderList(): Nullable<AbstractMesh[]>;
  58037. /**
  58038. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58039. * @param mesh defines the mesh to attach to
  58040. */
  58041. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58042. /**
  58043. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58044. * @param renderingGroupId The rendering group id corresponding to its index
  58045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58046. */
  58047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58048. /**
  58049. * Clean all associated resources
  58050. */
  58051. dispose(): void;
  58052. /**
  58053. * Converts the reflection probe information to a readable string for debug purpose.
  58054. * @param fullDetails Supports for multiple levels of logging within scene loading
  58055. * @returns the human readable reflection probe info
  58056. */
  58057. toString(fullDetails?: boolean): string;
  58058. /**
  58059. * Get the class name of the relfection probe.
  58060. * @returns "ReflectionProbe"
  58061. */
  58062. getClassName(): string;
  58063. /**
  58064. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58065. * @returns The JSON representation of the texture
  58066. */
  58067. serialize(): any;
  58068. /**
  58069. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58070. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58071. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58072. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58073. * @returns The parsed reflection probe if successful
  58074. */
  58075. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58076. }
  58077. }
  58078. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58079. /** @hidden */
  58080. export var _BabylonLoaderRegistered: boolean;
  58081. /**
  58082. * Helps setting up some configuration for the babylon file loader.
  58083. */
  58084. export class BabylonFileLoaderConfiguration {
  58085. /**
  58086. * The loader does not allow injecting custom physix engine into the plugins.
  58087. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58088. * So you could set this variable to your engine import to make it work.
  58089. */
  58090. static LoaderInjectedPhysicsEngine: any;
  58091. }
  58092. }
  58093. declare module "babylonjs/Loading/Plugins/index" {
  58094. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58095. }
  58096. declare module "babylonjs/Loading/index" {
  58097. export * from "babylonjs/Loading/loadingScreen";
  58098. export * from "babylonjs/Loading/Plugins/index";
  58099. export * from "babylonjs/Loading/sceneLoader";
  58100. export * from "babylonjs/Loading/sceneLoaderFlags";
  58101. }
  58102. declare module "babylonjs/Materials/Background/index" {
  58103. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58104. }
  58105. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58106. import { Scene } from "babylonjs/scene";
  58107. import { Color3 } from "babylonjs/Maths/math.color";
  58108. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58110. /**
  58111. * The Physically based simple base material of BJS.
  58112. *
  58113. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58114. * It is used as the base class for both the specGloss and metalRough conventions.
  58115. */
  58116. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58117. /**
  58118. * Number of Simultaneous lights allowed on the material.
  58119. */
  58120. maxSimultaneousLights: number;
  58121. /**
  58122. * If sets to true, disables all the lights affecting the material.
  58123. */
  58124. disableLighting: boolean;
  58125. /**
  58126. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58127. */
  58128. environmentTexture: BaseTexture;
  58129. /**
  58130. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58131. */
  58132. invertNormalMapX: boolean;
  58133. /**
  58134. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58135. */
  58136. invertNormalMapY: boolean;
  58137. /**
  58138. * Normal map used in the model.
  58139. */
  58140. normalTexture: BaseTexture;
  58141. /**
  58142. * Emissivie color used to self-illuminate the model.
  58143. */
  58144. emissiveColor: Color3;
  58145. /**
  58146. * Emissivie texture used to self-illuminate the model.
  58147. */
  58148. emissiveTexture: BaseTexture;
  58149. /**
  58150. * Occlusion Channel Strenght.
  58151. */
  58152. occlusionStrength: number;
  58153. /**
  58154. * Occlusion Texture of the material (adding extra occlusion effects).
  58155. */
  58156. occlusionTexture: BaseTexture;
  58157. /**
  58158. * Defines the alpha limits in alpha test mode.
  58159. */
  58160. alphaCutOff: number;
  58161. /**
  58162. * Gets the current double sided mode.
  58163. */
  58164. get doubleSided(): boolean;
  58165. /**
  58166. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58167. */
  58168. set doubleSided(value: boolean);
  58169. /**
  58170. * Stores the pre-calculated light information of a mesh in a texture.
  58171. */
  58172. lightmapTexture: BaseTexture;
  58173. /**
  58174. * If true, the light map contains occlusion information instead of lighting info.
  58175. */
  58176. useLightmapAsShadowmap: boolean;
  58177. /**
  58178. * Instantiates a new PBRMaterial instance.
  58179. *
  58180. * @param name The material name
  58181. * @param scene The scene the material will be use in.
  58182. */
  58183. constructor(name: string, scene: Scene);
  58184. getClassName(): string;
  58185. }
  58186. }
  58187. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58188. import { Scene } from "babylonjs/scene";
  58189. import { Color3 } from "babylonjs/Maths/math.color";
  58190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58191. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58192. /**
  58193. * The PBR material of BJS following the metal roughness convention.
  58194. *
  58195. * This fits to the PBR convention in the GLTF definition:
  58196. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58197. */
  58198. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58199. /**
  58200. * The base color has two different interpretations depending on the value of metalness.
  58201. * When the material is a metal, the base color is the specific measured reflectance value
  58202. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58203. * of the material.
  58204. */
  58205. baseColor: Color3;
  58206. /**
  58207. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58208. * well as opacity information in the alpha channel.
  58209. */
  58210. baseTexture: BaseTexture;
  58211. /**
  58212. * Specifies the metallic scalar value of the material.
  58213. * Can also be used to scale the metalness values of the metallic texture.
  58214. */
  58215. metallic: number;
  58216. /**
  58217. * Specifies the roughness scalar value of the material.
  58218. * Can also be used to scale the roughness values of the metallic texture.
  58219. */
  58220. roughness: number;
  58221. /**
  58222. * Texture containing both the metallic value in the B channel and the
  58223. * roughness value in the G channel to keep better precision.
  58224. */
  58225. metallicRoughnessTexture: BaseTexture;
  58226. /**
  58227. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58228. *
  58229. * @param name The material name
  58230. * @param scene The scene the material will be use in.
  58231. */
  58232. constructor(name: string, scene: Scene);
  58233. /**
  58234. * Return the currrent class name of the material.
  58235. */
  58236. getClassName(): string;
  58237. /**
  58238. * Makes a duplicate of the current material.
  58239. * @param name - name to use for the new material.
  58240. */
  58241. clone(name: string): PBRMetallicRoughnessMaterial;
  58242. /**
  58243. * Serialize the material to a parsable JSON object.
  58244. */
  58245. serialize(): any;
  58246. /**
  58247. * Parses a JSON object correponding to the serialize function.
  58248. */
  58249. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58250. }
  58251. }
  58252. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58253. import { Scene } from "babylonjs/scene";
  58254. import { Color3 } from "babylonjs/Maths/math.color";
  58255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58256. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58257. /**
  58258. * The PBR material of BJS following the specular glossiness convention.
  58259. *
  58260. * This fits to the PBR convention in the GLTF definition:
  58261. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58262. */
  58263. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58264. /**
  58265. * Specifies the diffuse color of the material.
  58266. */
  58267. diffuseColor: Color3;
  58268. /**
  58269. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58270. * channel.
  58271. */
  58272. diffuseTexture: BaseTexture;
  58273. /**
  58274. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58275. */
  58276. specularColor: Color3;
  58277. /**
  58278. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58279. */
  58280. glossiness: number;
  58281. /**
  58282. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58283. */
  58284. specularGlossinessTexture: BaseTexture;
  58285. /**
  58286. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58287. *
  58288. * @param name The material name
  58289. * @param scene The scene the material will be use in.
  58290. */
  58291. constructor(name: string, scene: Scene);
  58292. /**
  58293. * Return the currrent class name of the material.
  58294. */
  58295. getClassName(): string;
  58296. /**
  58297. * Makes a duplicate of the current material.
  58298. * @param name - name to use for the new material.
  58299. */
  58300. clone(name: string): PBRSpecularGlossinessMaterial;
  58301. /**
  58302. * Serialize the material to a parsable JSON object.
  58303. */
  58304. serialize(): any;
  58305. /**
  58306. * Parses a JSON object correponding to the serialize function.
  58307. */
  58308. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58309. }
  58310. }
  58311. declare module "babylonjs/Materials/PBR/index" {
  58312. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58313. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58314. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58315. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58316. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58317. }
  58318. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58319. import { Nullable } from "babylonjs/types";
  58320. import { Scene } from "babylonjs/scene";
  58321. import { Matrix } from "babylonjs/Maths/math.vector";
  58322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58323. /**
  58324. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58325. * It can help converting any input color in a desired output one. This can then be used to create effects
  58326. * from sepia, black and white to sixties or futuristic rendering...
  58327. *
  58328. * The only supported format is currently 3dl.
  58329. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58330. */
  58331. export class ColorGradingTexture extends BaseTexture {
  58332. /**
  58333. * The current texture matrix. (will always be identity in color grading texture)
  58334. */
  58335. private _textureMatrix;
  58336. /**
  58337. * The texture URL.
  58338. */
  58339. url: string;
  58340. /**
  58341. * Empty line regex stored for GC.
  58342. */
  58343. private static _noneEmptyLineRegex;
  58344. private _engine;
  58345. /**
  58346. * Instantiates a ColorGradingTexture from the following parameters.
  58347. *
  58348. * @param url The location of the color gradind data (currently only supporting 3dl)
  58349. * @param scene The scene the texture will be used in
  58350. */
  58351. constructor(url: string, scene: Scene);
  58352. /**
  58353. * Returns the texture matrix used in most of the material.
  58354. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58355. */
  58356. getTextureMatrix(): Matrix;
  58357. /**
  58358. * Occurs when the file being loaded is a .3dl LUT file.
  58359. */
  58360. private load3dlTexture;
  58361. /**
  58362. * Starts the loading process of the texture.
  58363. */
  58364. private loadTexture;
  58365. /**
  58366. * Clones the color gradind texture.
  58367. */
  58368. clone(): ColorGradingTexture;
  58369. /**
  58370. * Called during delayed load for textures.
  58371. */
  58372. delayLoad(): void;
  58373. /**
  58374. * Parses a color grading texture serialized by Babylon.
  58375. * @param parsedTexture The texture information being parsedTexture
  58376. * @param scene The scene to load the texture in
  58377. * @param rootUrl The root url of the data assets to load
  58378. * @return A color gradind texture
  58379. */
  58380. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58381. /**
  58382. * Serializes the LUT texture to json format.
  58383. */
  58384. serialize(): any;
  58385. }
  58386. }
  58387. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58389. import { Scene } from "babylonjs/scene";
  58390. import { Nullable } from "babylonjs/types";
  58391. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58392. /**
  58393. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58394. */
  58395. export class EquiRectangularCubeTexture extends BaseTexture {
  58396. /** The six faces of the cube. */
  58397. private static _FacesMapping;
  58398. private _noMipmap;
  58399. private _onLoad;
  58400. private _onError;
  58401. /** The size of the cubemap. */
  58402. private _size;
  58403. /** The buffer of the image. */
  58404. private _buffer;
  58405. /** The width of the input image. */
  58406. private _width;
  58407. /** The height of the input image. */
  58408. private _height;
  58409. /** The URL to the image. */
  58410. url: string;
  58411. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58412. coordinatesMode: number;
  58413. /**
  58414. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58415. * @param url The location of the image
  58416. * @param scene The scene the texture will be used in
  58417. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58418. * @param noMipmap Forces to not generate the mipmap if true
  58419. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58420. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58421. * @param onLoad — defines a callback called when texture is loaded
  58422. * @param onError — defines a callback called if there is an error
  58423. */
  58424. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58425. /**
  58426. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58427. */
  58428. private loadImage;
  58429. /**
  58430. * Convert the image buffer into a cubemap and create a CubeTexture.
  58431. */
  58432. private loadTexture;
  58433. /**
  58434. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58435. * @param buffer The ArrayBuffer that should be converted.
  58436. * @returns The buffer as Float32Array.
  58437. */
  58438. private getFloat32ArrayFromArrayBuffer;
  58439. /**
  58440. * Get the current class name of the texture useful for serialization or dynamic coding.
  58441. * @returns "EquiRectangularCubeTexture"
  58442. */
  58443. getClassName(): string;
  58444. /**
  58445. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58446. * @returns A clone of the current EquiRectangularCubeTexture.
  58447. */
  58448. clone(): EquiRectangularCubeTexture;
  58449. }
  58450. }
  58451. declare module "babylonjs/Misc/tga" {
  58452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58453. /**
  58454. * Based on jsTGALoader - Javascript loader for TGA file
  58455. * By Vincent Thibault
  58456. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58457. */
  58458. export class TGATools {
  58459. private static _TYPE_INDEXED;
  58460. private static _TYPE_RGB;
  58461. private static _TYPE_GREY;
  58462. private static _TYPE_RLE_INDEXED;
  58463. private static _TYPE_RLE_RGB;
  58464. private static _TYPE_RLE_GREY;
  58465. private static _ORIGIN_MASK;
  58466. private static _ORIGIN_SHIFT;
  58467. private static _ORIGIN_BL;
  58468. private static _ORIGIN_BR;
  58469. private static _ORIGIN_UL;
  58470. private static _ORIGIN_UR;
  58471. /**
  58472. * Gets the header of a TGA file
  58473. * @param data defines the TGA data
  58474. * @returns the header
  58475. */
  58476. static GetTGAHeader(data: Uint8Array): any;
  58477. /**
  58478. * Uploads TGA content to a Babylon Texture
  58479. * @hidden
  58480. */
  58481. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58482. /** @hidden */
  58483. 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;
  58484. /** @hidden */
  58485. 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;
  58486. /** @hidden */
  58487. 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;
  58488. /** @hidden */
  58489. 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;
  58490. /** @hidden */
  58491. 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;
  58492. /** @hidden */
  58493. 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;
  58494. }
  58495. }
  58496. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58497. import { Nullable } from "babylonjs/types";
  58498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58499. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58500. /**
  58501. * Implementation of the TGA Texture Loader.
  58502. * @hidden
  58503. */
  58504. export class _TGATextureLoader implements IInternalTextureLoader {
  58505. /**
  58506. * Defines wether the loader supports cascade loading the different faces.
  58507. */
  58508. readonly supportCascades: boolean;
  58509. /**
  58510. * This returns if the loader support the current file information.
  58511. * @param extension defines the file extension of the file being loaded
  58512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58513. * @param fallback defines the fallback internal texture if any
  58514. * @param isBase64 defines whether the texture is encoded as a base64
  58515. * @param isBuffer defines whether the texture data are stored as a buffer
  58516. * @returns true if the loader can load the specified file
  58517. */
  58518. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58519. /**
  58520. * Transform the url before loading if required.
  58521. * @param rootUrl the url of the texture
  58522. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58523. * @returns the transformed texture
  58524. */
  58525. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58526. /**
  58527. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58528. * @param rootUrl the url of the texture
  58529. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58530. * @returns the fallback texture
  58531. */
  58532. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58533. /**
  58534. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58535. * @param data contains the texture data
  58536. * @param texture defines the BabylonJS internal texture
  58537. * @param createPolynomials will be true if polynomials have been requested
  58538. * @param onLoad defines the callback to trigger once the texture is ready
  58539. * @param onError defines the callback to trigger in case of error
  58540. */
  58541. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58542. /**
  58543. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58544. * @param data contains the texture data
  58545. * @param texture defines the BabylonJS internal texture
  58546. * @param callback defines the method to call once ready to upload
  58547. */
  58548. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58549. }
  58550. }
  58551. declare module "babylonjs/Misc/basis" {
  58552. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58553. /**
  58554. * Info about the .basis files
  58555. */
  58556. class BasisFileInfo {
  58557. /**
  58558. * If the file has alpha
  58559. */
  58560. hasAlpha: boolean;
  58561. /**
  58562. * Info about each image of the basis file
  58563. */
  58564. images: Array<{
  58565. levels: Array<{
  58566. width: number;
  58567. height: number;
  58568. transcodedPixels: ArrayBufferView;
  58569. }>;
  58570. }>;
  58571. }
  58572. /**
  58573. * Result of transcoding a basis file
  58574. */
  58575. class TranscodeResult {
  58576. /**
  58577. * Info about the .basis file
  58578. */
  58579. fileInfo: BasisFileInfo;
  58580. /**
  58581. * Format to use when loading the file
  58582. */
  58583. format: number;
  58584. }
  58585. /**
  58586. * Configuration options for the Basis transcoder
  58587. */
  58588. export class BasisTranscodeConfiguration {
  58589. /**
  58590. * Supported compression formats used to determine the supported output format of the transcoder
  58591. */
  58592. supportedCompressionFormats?: {
  58593. /**
  58594. * etc1 compression format
  58595. */
  58596. etc1?: boolean;
  58597. /**
  58598. * s3tc compression format
  58599. */
  58600. s3tc?: boolean;
  58601. /**
  58602. * pvrtc compression format
  58603. */
  58604. pvrtc?: boolean;
  58605. /**
  58606. * etc2 compression format
  58607. */
  58608. etc2?: boolean;
  58609. };
  58610. /**
  58611. * If mipmap levels should be loaded for transcoded images (Default: true)
  58612. */
  58613. loadMipmapLevels?: boolean;
  58614. /**
  58615. * Index of a single image to load (Default: all images)
  58616. */
  58617. loadSingleImage?: number;
  58618. }
  58619. /**
  58620. * Used to load .Basis files
  58621. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58622. */
  58623. export class BasisTools {
  58624. private static _IgnoreSupportedFormats;
  58625. /**
  58626. * URL to use when loading the basis transcoder
  58627. */
  58628. static JSModuleURL: string;
  58629. /**
  58630. * URL to use when loading the wasm module for the transcoder
  58631. */
  58632. static WasmModuleURL: string;
  58633. /**
  58634. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58635. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58636. * @returns internal format corresponding to the Basis format
  58637. */
  58638. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58639. private static _WorkerPromise;
  58640. private static _Worker;
  58641. private static _actionId;
  58642. private static _CreateWorkerAsync;
  58643. /**
  58644. * Transcodes a loaded image file to compressed pixel data
  58645. * @param data image data to transcode
  58646. * @param config configuration options for the transcoding
  58647. * @returns a promise resulting in the transcoded image
  58648. */
  58649. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58650. /**
  58651. * Loads a texture from the transcode result
  58652. * @param texture texture load to
  58653. * @param transcodeResult the result of transcoding the basis file to load from
  58654. */
  58655. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58656. }
  58657. }
  58658. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58659. import { Nullable } from "babylonjs/types";
  58660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58661. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58662. /**
  58663. * Loader for .basis file format
  58664. */
  58665. export class _BasisTextureLoader implements IInternalTextureLoader {
  58666. /**
  58667. * Defines whether the loader supports cascade loading the different faces.
  58668. */
  58669. readonly supportCascades: boolean;
  58670. /**
  58671. * This returns if the loader support the current file information.
  58672. * @param extension defines the file extension of the file being loaded
  58673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58674. * @param fallback defines the fallback internal texture if any
  58675. * @param isBase64 defines whether the texture is encoded as a base64
  58676. * @param isBuffer defines whether the texture data are stored as a buffer
  58677. * @returns true if the loader can load the specified file
  58678. */
  58679. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58680. /**
  58681. * Transform the url before loading if required.
  58682. * @param rootUrl the url of the texture
  58683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58684. * @returns the transformed texture
  58685. */
  58686. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58687. /**
  58688. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58689. * @param rootUrl the url of the texture
  58690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58691. * @returns the fallback texture
  58692. */
  58693. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58694. /**
  58695. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58696. * @param data contains the texture data
  58697. * @param texture defines the BabylonJS internal texture
  58698. * @param createPolynomials will be true if polynomials have been requested
  58699. * @param onLoad defines the callback to trigger once the texture is ready
  58700. * @param onError defines the callback to trigger in case of error
  58701. */
  58702. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58703. /**
  58704. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58705. * @param data contains the texture data
  58706. * @param texture defines the BabylonJS internal texture
  58707. * @param callback defines the method to call once ready to upload
  58708. */
  58709. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58710. }
  58711. }
  58712. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58713. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58714. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58715. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58716. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58717. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58718. }
  58719. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58720. import { Scene } from "babylonjs/scene";
  58721. import { Texture } from "babylonjs/Materials/Textures/texture";
  58722. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58723. /**
  58724. * 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.
  58725. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58726. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58727. */
  58728. export class CustomProceduralTexture extends ProceduralTexture {
  58729. private _animate;
  58730. private _time;
  58731. private _config;
  58732. private _texturePath;
  58733. /**
  58734. * Instantiates a new Custom Procedural Texture.
  58735. * 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.
  58736. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58737. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58738. * @param name Define the name of the texture
  58739. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58740. * @param size Define the size of the texture to create
  58741. * @param scene Define the scene the texture belongs to
  58742. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58743. * @param generateMipMaps Define if the texture should creates mip maps or not
  58744. */
  58745. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58746. private _loadJson;
  58747. /**
  58748. * Is the texture ready to be used ? (rendered at least once)
  58749. * @returns true if ready, otherwise, false.
  58750. */
  58751. isReady(): boolean;
  58752. /**
  58753. * Render the texture to its associated render target.
  58754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58755. */
  58756. render(useCameraPostProcess?: boolean): void;
  58757. /**
  58758. * Update the list of dependant textures samplers in the shader.
  58759. */
  58760. updateTextures(): void;
  58761. /**
  58762. * Update the uniform values of the procedural texture in the shader.
  58763. */
  58764. updateShaderUniforms(): void;
  58765. /**
  58766. * Define if the texture animates or not.
  58767. */
  58768. get animate(): boolean;
  58769. set animate(value: boolean);
  58770. }
  58771. }
  58772. declare module "babylonjs/Shaders/noise.fragment" {
  58773. /** @hidden */
  58774. export var noisePixelShader: {
  58775. name: string;
  58776. shader: string;
  58777. };
  58778. }
  58779. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58780. import { Nullable } from "babylonjs/types";
  58781. import { Scene } from "babylonjs/scene";
  58782. import { Texture } from "babylonjs/Materials/Textures/texture";
  58783. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58784. import "babylonjs/Shaders/noise.fragment";
  58785. /**
  58786. * Class used to generate noise procedural textures
  58787. */
  58788. export class NoiseProceduralTexture extends ProceduralTexture {
  58789. private _time;
  58790. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58791. brightness: number;
  58792. /** Defines the number of octaves to process */
  58793. octaves: number;
  58794. /** Defines the level of persistence (0.8 by default) */
  58795. persistence: number;
  58796. /** Gets or sets animation speed factor (default is 1) */
  58797. animationSpeedFactor: number;
  58798. /**
  58799. * Creates a new NoiseProceduralTexture
  58800. * @param name defines the name fo the texture
  58801. * @param size defines the size of the texture (default is 256)
  58802. * @param scene defines the hosting scene
  58803. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58804. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58805. */
  58806. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58807. private _updateShaderUniforms;
  58808. protected _getDefines(): string;
  58809. /** Generate the current state of the procedural texture */
  58810. render(useCameraPostProcess?: boolean): void;
  58811. /**
  58812. * Serializes this noise procedural texture
  58813. * @returns a serialized noise procedural texture object
  58814. */
  58815. serialize(): any;
  58816. /**
  58817. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58818. * @param parsedTexture defines parsed texture data
  58819. * @param scene defines the current scene
  58820. * @param rootUrl defines the root URL containing noise procedural texture information
  58821. * @returns a parsed NoiseProceduralTexture
  58822. */
  58823. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58824. }
  58825. }
  58826. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58827. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58828. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58829. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58830. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58831. }
  58832. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58833. import { Nullable } from "babylonjs/types";
  58834. import { Scene } from "babylonjs/scene";
  58835. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58836. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58837. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58838. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58839. /**
  58840. * Raw cube texture where the raw buffers are passed in
  58841. */
  58842. export class RawCubeTexture extends CubeTexture {
  58843. /**
  58844. * Creates a cube texture where the raw buffers are passed in.
  58845. * @param scene defines the scene the texture is attached to
  58846. * @param data defines the array of data to use to create each face
  58847. * @param size defines the size of the textures
  58848. * @param format defines the format of the data
  58849. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58850. * @param generateMipMaps defines if the engine should generate the mip levels
  58851. * @param invertY defines if data must be stored with Y axis inverted
  58852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58853. * @param compression defines the compression used (null by default)
  58854. */
  58855. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58856. /**
  58857. * Updates the raw cube texture.
  58858. * @param data defines the data to store
  58859. * @param format defines the data format
  58860. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58861. * @param invertY defines if data must be stored with Y axis inverted
  58862. * @param compression defines the compression used (null by default)
  58863. * @param level defines which level of the texture to update
  58864. */
  58865. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58866. /**
  58867. * Updates a raw cube texture with RGBD encoded data.
  58868. * @param data defines the array of data [mipmap][face] to use to create each face
  58869. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58870. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58871. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58872. * @returns a promsie that resolves when the operation is complete
  58873. */
  58874. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58875. /**
  58876. * Clones the raw cube texture.
  58877. * @return a new cube texture
  58878. */
  58879. clone(): CubeTexture;
  58880. /** @hidden */
  58881. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58882. }
  58883. }
  58884. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58885. import { Scene } from "babylonjs/scene";
  58886. import { Texture } from "babylonjs/Materials/Textures/texture";
  58887. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58888. /**
  58889. * Class used to store 3D textures containing user data
  58890. */
  58891. export class RawTexture3D extends Texture {
  58892. /** Gets or sets the texture format to use */
  58893. format: number;
  58894. private _engine;
  58895. /**
  58896. * Create a new RawTexture3D
  58897. * @param data defines the data of the texture
  58898. * @param width defines the width of the texture
  58899. * @param height defines the height of the texture
  58900. * @param depth defines the depth of the texture
  58901. * @param format defines the texture format to use
  58902. * @param scene defines the hosting scene
  58903. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58904. * @param invertY defines if texture must be stored with Y axis inverted
  58905. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58907. */
  58908. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58909. /** Gets or sets the texture format to use */
  58910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58911. /**
  58912. * Update the texture with new data
  58913. * @param data defines the data to store in the texture
  58914. */
  58915. update(data: ArrayBufferView): void;
  58916. }
  58917. }
  58918. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58919. import { Scene } from "babylonjs/scene";
  58920. import { Texture } from "babylonjs/Materials/Textures/texture";
  58921. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58922. /**
  58923. * Class used to store 2D array textures containing user data
  58924. */
  58925. export class RawTexture2DArray extends Texture {
  58926. /** Gets or sets the texture format to use */
  58927. format: number;
  58928. private _engine;
  58929. /**
  58930. * Create a new RawTexture2DArray
  58931. * @param data defines the data of the texture
  58932. * @param width defines the width of the texture
  58933. * @param height defines the height of the texture
  58934. * @param depth defines the number of layers of the texture
  58935. * @param format defines the texture format to use
  58936. * @param scene defines the hosting scene
  58937. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58938. * @param invertY defines if texture must be stored with Y axis inverted
  58939. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58940. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58941. */
  58942. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58943. /** Gets or sets the texture format to use */
  58944. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58945. /**
  58946. * Update the texture with new data
  58947. * @param data defines the data to store in the texture
  58948. */
  58949. update(data: ArrayBufferView): void;
  58950. }
  58951. }
  58952. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58953. import { Scene } from "babylonjs/scene";
  58954. import { Plane } from "babylonjs/Maths/math.plane";
  58955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58956. /**
  58957. * Creates a refraction texture used by refraction channel of the standard material.
  58958. * It is like a mirror but to see through a material.
  58959. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58960. */
  58961. export class RefractionTexture extends RenderTargetTexture {
  58962. /**
  58963. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58964. * 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.
  58965. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58966. */
  58967. refractionPlane: Plane;
  58968. /**
  58969. * Define how deep under the surface we should see.
  58970. */
  58971. depth: number;
  58972. /**
  58973. * Creates a refraction texture used by refraction channel of the standard material.
  58974. * It is like a mirror but to see through a material.
  58975. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58976. * @param name Define the texture name
  58977. * @param size Define the size of the underlying texture
  58978. * @param scene Define the scene the refraction belongs to
  58979. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58980. */
  58981. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58982. /**
  58983. * Clone the refraction texture.
  58984. * @returns the cloned texture
  58985. */
  58986. clone(): RefractionTexture;
  58987. /**
  58988. * Serialize the texture to a JSON representation you could use in Parse later on
  58989. * @returns the serialized JSON representation
  58990. */
  58991. serialize(): any;
  58992. }
  58993. }
  58994. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58995. import { Nullable } from "babylonjs/types";
  58996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58997. import { Matrix } from "babylonjs/Maths/math.vector";
  58998. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58999. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59000. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59001. import { Scene } from "babylonjs/scene";
  59002. /**
  59003. * Defines the options related to the creation of an HtmlElementTexture
  59004. */
  59005. export interface IHtmlElementTextureOptions {
  59006. /**
  59007. * Defines wether mip maps should be created or not.
  59008. */
  59009. generateMipMaps?: boolean;
  59010. /**
  59011. * Defines the sampling mode of the texture.
  59012. */
  59013. samplingMode?: number;
  59014. /**
  59015. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59016. */
  59017. engine: Nullable<ThinEngine>;
  59018. /**
  59019. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59020. */
  59021. scene: Nullable<Scene>;
  59022. }
  59023. /**
  59024. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59025. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59026. * is automatically managed.
  59027. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59028. * in your application.
  59029. *
  59030. * As the update is not automatic, you need to call them manually.
  59031. */
  59032. export class HtmlElementTexture extends BaseTexture {
  59033. /**
  59034. * The texture URL.
  59035. */
  59036. element: HTMLVideoElement | HTMLCanvasElement;
  59037. private static readonly DefaultOptions;
  59038. private _textureMatrix;
  59039. private _engine;
  59040. private _isVideo;
  59041. private _generateMipMaps;
  59042. private _samplingMode;
  59043. /**
  59044. * Instantiates a HtmlElementTexture from the following parameters.
  59045. *
  59046. * @param name Defines the name of the texture
  59047. * @param element Defines the video or canvas the texture is filled with
  59048. * @param options Defines the other none mandatory texture creation options
  59049. */
  59050. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59051. private _createInternalTexture;
  59052. /**
  59053. * Returns the texture matrix used in most of the material.
  59054. */
  59055. getTextureMatrix(): Matrix;
  59056. /**
  59057. * Updates the content of the texture.
  59058. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59059. */
  59060. update(invertY?: Nullable<boolean>): void;
  59061. }
  59062. }
  59063. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59064. import { Vector2 } from "babylonjs/Maths/math.vector";
  59065. /**
  59066. * Defines the basic options interface of a TexturePacker Frame
  59067. */
  59068. export interface ITexturePackerFrame {
  59069. /**
  59070. * The frame ID
  59071. */
  59072. id: number;
  59073. /**
  59074. * The frames Scale
  59075. */
  59076. scale: Vector2;
  59077. /**
  59078. * The Frames offset
  59079. */
  59080. offset: Vector2;
  59081. }
  59082. /**
  59083. * This is a support class for frame Data on texture packer sets.
  59084. */
  59085. export class TexturePackerFrame implements ITexturePackerFrame {
  59086. /**
  59087. * The frame ID
  59088. */
  59089. id: number;
  59090. /**
  59091. * The frames Scale
  59092. */
  59093. scale: Vector2;
  59094. /**
  59095. * The Frames offset
  59096. */
  59097. offset: Vector2;
  59098. /**
  59099. * Initializes a texture package frame.
  59100. * @param id The numerical frame identifier
  59101. * @param scale Scalar Vector2 for UV frame
  59102. * @param offset Vector2 for the frame position in UV units.
  59103. * @returns TexturePackerFrame
  59104. */
  59105. constructor(id: number, scale: Vector2, offset: Vector2);
  59106. }
  59107. }
  59108. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59110. import { Scene } from "babylonjs/scene";
  59111. import { Nullable } from "babylonjs/types";
  59112. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59113. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59114. /**
  59115. * Defines the basic options interface of a TexturePacker
  59116. */
  59117. export interface ITexturePackerOptions {
  59118. /**
  59119. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59120. */
  59121. map?: string[];
  59122. /**
  59123. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59124. */
  59125. uvsIn?: string;
  59126. /**
  59127. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59128. */
  59129. uvsOut?: string;
  59130. /**
  59131. * number representing the layout style. Defaults to LAYOUT_STRIP
  59132. */
  59133. layout?: number;
  59134. /**
  59135. * number of columns if using custom column count layout(2). This defaults to 4.
  59136. */
  59137. colnum?: number;
  59138. /**
  59139. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59140. */
  59141. updateInputMeshes?: boolean;
  59142. /**
  59143. * boolean flag to dispose all the source textures. Defaults to true.
  59144. */
  59145. disposeSources?: boolean;
  59146. /**
  59147. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59148. */
  59149. fillBlanks?: boolean;
  59150. /**
  59151. * string value representing the context fill style color. Defaults to 'black'.
  59152. */
  59153. customFillColor?: string;
  59154. /**
  59155. * Width and Height Value of each Frame in the TexturePacker Sets
  59156. */
  59157. frameSize?: number;
  59158. /**
  59159. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59160. */
  59161. paddingRatio?: number;
  59162. /**
  59163. * Number that declares the fill method for the padding gutter.
  59164. */
  59165. paddingMode?: number;
  59166. /**
  59167. * If in SUBUV_COLOR padding mode what color to use.
  59168. */
  59169. paddingColor?: Color3 | Color4;
  59170. }
  59171. /**
  59172. * Defines the basic interface of a TexturePacker JSON File
  59173. */
  59174. export interface ITexturePackerJSON {
  59175. /**
  59176. * The frame ID
  59177. */
  59178. name: string;
  59179. /**
  59180. * The base64 channel data
  59181. */
  59182. sets: any;
  59183. /**
  59184. * The options of the Packer
  59185. */
  59186. options: ITexturePackerOptions;
  59187. /**
  59188. * The frame data of the Packer
  59189. */
  59190. frames: Array<number>;
  59191. }
  59192. /**
  59193. * This is a support class that generates a series of packed texture sets.
  59194. * @see https://doc.babylonjs.com/babylon101/materials
  59195. */
  59196. export class TexturePacker {
  59197. /** Packer Layout Constant 0 */
  59198. static readonly LAYOUT_STRIP: number;
  59199. /** Packer Layout Constant 1 */
  59200. static readonly LAYOUT_POWER2: number;
  59201. /** Packer Layout Constant 2 */
  59202. static readonly LAYOUT_COLNUM: number;
  59203. /** Packer Layout Constant 0 */
  59204. static readonly SUBUV_WRAP: number;
  59205. /** Packer Layout Constant 1 */
  59206. static readonly SUBUV_EXTEND: number;
  59207. /** Packer Layout Constant 2 */
  59208. static readonly SUBUV_COLOR: number;
  59209. /** The Name of the Texture Package */
  59210. name: string;
  59211. /** The scene scope of the TexturePacker */
  59212. scene: Scene;
  59213. /** The Meshes to target */
  59214. meshes: AbstractMesh[];
  59215. /** Arguments passed with the Constructor */
  59216. options: ITexturePackerOptions;
  59217. /** The promise that is started upon initialization */
  59218. promise: Nullable<Promise<TexturePacker | string>>;
  59219. /** The Container object for the channel sets that are generated */
  59220. sets: object;
  59221. /** The Container array for the frames that are generated */
  59222. frames: TexturePackerFrame[];
  59223. /** The expected number of textures the system is parsing. */
  59224. private _expecting;
  59225. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59226. private _paddingValue;
  59227. /**
  59228. * Initializes a texture package series from an array of meshes or a single mesh.
  59229. * @param name The name of the package
  59230. * @param meshes The target meshes to compose the package from
  59231. * @param options The arguments that texture packer should follow while building.
  59232. * @param scene The scene which the textures are scoped to.
  59233. * @returns TexturePacker
  59234. */
  59235. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59236. /**
  59237. * Starts the package process
  59238. * @param resolve The promises resolution function
  59239. * @returns TexturePacker
  59240. */
  59241. private _createFrames;
  59242. /**
  59243. * Calculates the Size of the Channel Sets
  59244. * @returns Vector2
  59245. */
  59246. private _calculateSize;
  59247. /**
  59248. * Calculates the UV data for the frames.
  59249. * @param baseSize the base frameSize
  59250. * @param padding the base frame padding
  59251. * @param dtSize size of the Dynamic Texture for that channel
  59252. * @param dtUnits is 1/dtSize
  59253. * @param update flag to update the input meshes
  59254. */
  59255. private _calculateMeshUVFrames;
  59256. /**
  59257. * Calculates the frames Offset.
  59258. * @param index of the frame
  59259. * @returns Vector2
  59260. */
  59261. private _getFrameOffset;
  59262. /**
  59263. * Updates a Mesh to the frame data
  59264. * @param mesh that is the target
  59265. * @param frameID or the frame index
  59266. */
  59267. private _updateMeshUV;
  59268. /**
  59269. * Updates a Meshes materials to use the texture packer channels
  59270. * @param m is the mesh to target
  59271. * @param force all channels on the packer to be set.
  59272. */
  59273. private _updateTextureReferences;
  59274. /**
  59275. * Public method to set a Mesh to a frame
  59276. * @param m that is the target
  59277. * @param frameID or the frame index
  59278. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59279. */
  59280. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59281. /**
  59282. * Starts the async promise to compile the texture packer.
  59283. * @returns Promise<void>
  59284. */
  59285. processAsync(): Promise<void>;
  59286. /**
  59287. * Disposes all textures associated with this packer
  59288. */
  59289. dispose(): void;
  59290. /**
  59291. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59292. * @param imageType is the image type to use.
  59293. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59294. */
  59295. download(imageType?: string, quality?: number): void;
  59296. /**
  59297. * Public method to load a texturePacker JSON file.
  59298. * @param data of the JSON file in string format.
  59299. */
  59300. updateFromJSON(data: string): void;
  59301. }
  59302. }
  59303. declare module "babylonjs/Materials/Textures/Packer/index" {
  59304. export * from "babylonjs/Materials/Textures/Packer/packer";
  59305. export * from "babylonjs/Materials/Textures/Packer/frame";
  59306. }
  59307. declare module "babylonjs/Materials/Textures/index" {
  59308. export * from "babylonjs/Materials/Textures/baseTexture";
  59309. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59310. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59311. export * from "babylonjs/Materials/Textures/cubeTexture";
  59312. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59313. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59314. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59315. export * from "babylonjs/Materials/Textures/internalTexture";
  59316. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59317. export * from "babylonjs/Materials/Textures/Loaders/index";
  59318. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59319. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59320. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59321. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59322. export * from "babylonjs/Materials/Textures/rawTexture";
  59323. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59324. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59325. export * from "babylonjs/Materials/Textures/refractionTexture";
  59326. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59327. export * from "babylonjs/Materials/Textures/texture";
  59328. export * from "babylonjs/Materials/Textures/videoTexture";
  59329. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59330. export * from "babylonjs/Materials/Textures/Packer/index";
  59331. }
  59332. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59333. /**
  59334. * Enum used to define the target of a block
  59335. */
  59336. export enum NodeMaterialBlockTargets {
  59337. /** Vertex shader */
  59338. Vertex = 1,
  59339. /** Fragment shader */
  59340. Fragment = 2,
  59341. /** Neutral */
  59342. Neutral = 4,
  59343. /** Vertex and Fragment */
  59344. VertexAndFragment = 3
  59345. }
  59346. }
  59347. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59348. /**
  59349. * Defines the kind of connection point for node based material
  59350. */
  59351. export enum NodeMaterialBlockConnectionPointTypes {
  59352. /** Float */
  59353. Float = 1,
  59354. /** Int */
  59355. Int = 2,
  59356. /** Vector2 */
  59357. Vector2 = 4,
  59358. /** Vector3 */
  59359. Vector3 = 8,
  59360. /** Vector4 */
  59361. Vector4 = 16,
  59362. /** Color3 */
  59363. Color3 = 32,
  59364. /** Color4 */
  59365. Color4 = 64,
  59366. /** Matrix */
  59367. Matrix = 128,
  59368. /** Detect type based on connection */
  59369. AutoDetect = 1024,
  59370. /** Output type that will be defined by input type */
  59371. BasedOnInput = 2048
  59372. }
  59373. }
  59374. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59375. /**
  59376. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59377. */
  59378. export enum NodeMaterialBlockConnectionPointMode {
  59379. /** Value is an uniform */
  59380. Uniform = 0,
  59381. /** Value is a mesh attribute */
  59382. Attribute = 1,
  59383. /** Value is a varying between vertex and fragment shaders */
  59384. Varying = 2,
  59385. /** Mode is undefined */
  59386. Undefined = 3
  59387. }
  59388. }
  59389. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59390. /**
  59391. * Enum used to define system values e.g. values automatically provided by the system
  59392. */
  59393. export enum NodeMaterialSystemValues {
  59394. /** World */
  59395. World = 1,
  59396. /** View */
  59397. View = 2,
  59398. /** Projection */
  59399. Projection = 3,
  59400. /** ViewProjection */
  59401. ViewProjection = 4,
  59402. /** WorldView */
  59403. WorldView = 5,
  59404. /** WorldViewProjection */
  59405. WorldViewProjection = 6,
  59406. /** CameraPosition */
  59407. CameraPosition = 7,
  59408. /** Fog Color */
  59409. FogColor = 8,
  59410. /** Delta time */
  59411. DeltaTime = 9
  59412. }
  59413. }
  59414. declare module "babylonjs/Materials/Node/Enums/index" {
  59415. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59416. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59417. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59418. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59419. }
  59420. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59422. /**
  59423. * Root class for all node material optimizers
  59424. */
  59425. export class NodeMaterialOptimizer {
  59426. /**
  59427. * Function used to optimize a NodeMaterial graph
  59428. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59429. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59430. */
  59431. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59432. }
  59433. }
  59434. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59438. import { Scene } from "babylonjs/scene";
  59439. /**
  59440. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59441. */
  59442. export class TransformBlock extends NodeMaterialBlock {
  59443. /**
  59444. * Defines the value to use to complement W value to transform it to a Vector4
  59445. */
  59446. complementW: number;
  59447. /**
  59448. * Defines the value to use to complement z value to transform it to a Vector4
  59449. */
  59450. complementZ: number;
  59451. /**
  59452. * Creates a new TransformBlock
  59453. * @param name defines the block name
  59454. */
  59455. constructor(name: string);
  59456. /**
  59457. * Gets the current class name
  59458. * @returns the class name
  59459. */
  59460. getClassName(): string;
  59461. /**
  59462. * Gets the vector input
  59463. */
  59464. get vector(): NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the output component
  59467. */
  59468. get output(): NodeMaterialConnectionPoint;
  59469. /**
  59470. * Gets the matrix transform input
  59471. */
  59472. get transform(): NodeMaterialConnectionPoint;
  59473. protected _buildBlock(state: NodeMaterialBuildState): this;
  59474. serialize(): any;
  59475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59476. protected _dumpPropertiesCode(): string;
  59477. }
  59478. }
  59479. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59483. /**
  59484. * Block used to output the vertex position
  59485. */
  59486. export class VertexOutputBlock extends NodeMaterialBlock {
  59487. /**
  59488. * Creates a new VertexOutputBlock
  59489. * @param name defines the block name
  59490. */
  59491. constructor(name: string);
  59492. /**
  59493. * Gets the current class name
  59494. * @returns the class name
  59495. */
  59496. getClassName(): string;
  59497. /**
  59498. * Gets the vector input component
  59499. */
  59500. get vector(): NodeMaterialConnectionPoint;
  59501. protected _buildBlock(state: NodeMaterialBuildState): this;
  59502. }
  59503. }
  59504. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59508. /**
  59509. * Block used to output the final color
  59510. */
  59511. export class FragmentOutputBlock extends NodeMaterialBlock {
  59512. /**
  59513. * Create a new FragmentOutputBlock
  59514. * @param name defines the block name
  59515. */
  59516. constructor(name: string);
  59517. /**
  59518. * Gets the current class name
  59519. * @returns the class name
  59520. */
  59521. getClassName(): string;
  59522. /**
  59523. * Gets the rgba input component
  59524. */
  59525. get rgba(): NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the rgb input component
  59528. */
  59529. get rgb(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the a input component
  59532. */
  59533. get a(): NodeMaterialConnectionPoint;
  59534. protected _buildBlock(state: NodeMaterialBuildState): this;
  59535. }
  59536. }
  59537. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59543. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59544. import { Effect } from "babylonjs/Materials/effect";
  59545. import { Mesh } from "babylonjs/Meshes/mesh";
  59546. import { Nullable } from "babylonjs/types";
  59547. import { Scene } from "babylonjs/scene";
  59548. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59549. /**
  59550. * Block used to read a reflection texture from a sampler
  59551. */
  59552. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59553. private _define3DName;
  59554. private _defineCubicName;
  59555. private _defineExplicitName;
  59556. private _defineProjectionName;
  59557. private _defineLocalCubicName;
  59558. private _defineSphericalName;
  59559. private _definePlanarName;
  59560. private _defineEquirectangularName;
  59561. private _defineMirroredEquirectangularFixedName;
  59562. private _defineEquirectangularFixedName;
  59563. private _defineSkyboxName;
  59564. private _cubeSamplerName;
  59565. private _2DSamplerName;
  59566. private _positionUVWName;
  59567. private _directionWName;
  59568. private _reflectionCoordsName;
  59569. private _reflection2DCoordsName;
  59570. private _reflectionColorName;
  59571. private _reflectionMatrixName;
  59572. /**
  59573. * Gets or sets the texture associated with the node
  59574. */
  59575. texture: Nullable<BaseTexture>;
  59576. /**
  59577. * Create a new TextureBlock
  59578. * @param name defines the block name
  59579. */
  59580. constructor(name: string);
  59581. /**
  59582. * Gets the current class name
  59583. * @returns the class name
  59584. */
  59585. getClassName(): string;
  59586. /**
  59587. * Gets the world position input component
  59588. */
  59589. get position(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the world position input component
  59592. */
  59593. get worldPosition(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the world normal input component
  59596. */
  59597. get worldNormal(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the world input component
  59600. */
  59601. get world(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the camera (or eye) position component
  59604. */
  59605. get cameraPosition(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the view input component
  59608. */
  59609. get view(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the rgb output component
  59612. */
  59613. get rgb(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the r output component
  59616. */
  59617. get r(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the g output component
  59620. */
  59621. get g(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the b output component
  59624. */
  59625. get b(): NodeMaterialConnectionPoint;
  59626. autoConfigure(material: NodeMaterial): void;
  59627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59628. isReady(): boolean;
  59629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59630. private _injectVertexCode;
  59631. private _writeOutput;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59633. protected _dumpPropertiesCode(): string;
  59634. serialize(): any;
  59635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59636. }
  59637. }
  59638. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59640. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59641. import { Scene } from "babylonjs/scene";
  59642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59643. import { Matrix } from "babylonjs/Maths/math.vector";
  59644. import { Mesh } from "babylonjs/Meshes/mesh";
  59645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59646. import { Observable } from "babylonjs/Misc/observable";
  59647. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59648. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59649. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59650. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59651. import { Nullable } from "babylonjs/types";
  59652. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59653. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59654. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59655. /**
  59656. * Interface used to configure the node material editor
  59657. */
  59658. export interface INodeMaterialEditorOptions {
  59659. /** Define the URl to load node editor script */
  59660. editorURL?: string;
  59661. }
  59662. /** @hidden */
  59663. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59664. NORMAL: boolean;
  59665. TANGENT: boolean;
  59666. UV1: boolean;
  59667. /** BONES */
  59668. NUM_BONE_INFLUENCERS: number;
  59669. BonesPerMesh: number;
  59670. BONETEXTURE: boolean;
  59671. /** MORPH TARGETS */
  59672. MORPHTARGETS: boolean;
  59673. MORPHTARGETS_NORMAL: boolean;
  59674. MORPHTARGETS_TANGENT: boolean;
  59675. MORPHTARGETS_UV: boolean;
  59676. NUM_MORPH_INFLUENCERS: number;
  59677. /** IMAGE PROCESSING */
  59678. IMAGEPROCESSING: boolean;
  59679. VIGNETTE: boolean;
  59680. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59681. VIGNETTEBLENDMODEOPAQUE: boolean;
  59682. TONEMAPPING: boolean;
  59683. TONEMAPPING_ACES: boolean;
  59684. CONTRAST: boolean;
  59685. EXPOSURE: boolean;
  59686. COLORCURVES: boolean;
  59687. COLORGRADING: boolean;
  59688. COLORGRADING3D: boolean;
  59689. SAMPLER3DGREENDEPTH: boolean;
  59690. SAMPLER3DBGRMAP: boolean;
  59691. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59692. /** MISC. */
  59693. BUMPDIRECTUV: number;
  59694. constructor();
  59695. setValue(name: string, value: boolean): void;
  59696. }
  59697. /**
  59698. * Class used to configure NodeMaterial
  59699. */
  59700. export interface INodeMaterialOptions {
  59701. /**
  59702. * Defines if blocks should emit comments
  59703. */
  59704. emitComments: boolean;
  59705. }
  59706. /**
  59707. * Class used to create a node based material built by assembling shader blocks
  59708. */
  59709. export class NodeMaterial extends PushMaterial {
  59710. private static _BuildIdGenerator;
  59711. private _options;
  59712. private _vertexCompilationState;
  59713. private _fragmentCompilationState;
  59714. private _sharedData;
  59715. private _buildId;
  59716. private _buildWasSuccessful;
  59717. private _cachedWorldViewMatrix;
  59718. private _cachedWorldViewProjectionMatrix;
  59719. private _optimizers;
  59720. private _animationFrame;
  59721. /** Define the Url to load node editor script */
  59722. static EditorURL: string;
  59723. /** Define the Url to load snippets */
  59724. static SnippetUrl: string;
  59725. private BJSNODEMATERIALEDITOR;
  59726. /** Get the inspector from bundle or global */
  59727. private _getGlobalNodeMaterialEditor;
  59728. /**
  59729. * Gets or sets data used by visual editor
  59730. * @see https://nme.babylonjs.com
  59731. */
  59732. editorData: any;
  59733. /**
  59734. * 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)
  59735. */
  59736. ignoreAlpha: boolean;
  59737. /**
  59738. * Defines the maximum number of lights that can be used in the material
  59739. */
  59740. maxSimultaneousLights: number;
  59741. /**
  59742. * Observable raised when the material is built
  59743. */
  59744. onBuildObservable: Observable<NodeMaterial>;
  59745. /**
  59746. * Gets or sets the root nodes of the material vertex shader
  59747. */
  59748. _vertexOutputNodes: NodeMaterialBlock[];
  59749. /**
  59750. * Gets or sets the root nodes of the material fragment (pixel) shader
  59751. */
  59752. _fragmentOutputNodes: NodeMaterialBlock[];
  59753. /** Gets or sets options to control the node material overall behavior */
  59754. get options(): INodeMaterialOptions;
  59755. set options(options: INodeMaterialOptions);
  59756. /**
  59757. * Default configuration related to image processing available in the standard Material.
  59758. */
  59759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59760. /**
  59761. * Gets the image processing configuration used either in this material.
  59762. */
  59763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59764. /**
  59765. * Sets the Default image processing configuration used either in the this material.
  59766. *
  59767. * If sets to null, the scene one is in use.
  59768. */
  59769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59770. /**
  59771. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59772. */
  59773. attachedBlocks: NodeMaterialBlock[];
  59774. /**
  59775. * Create a new node based material
  59776. * @param name defines the material name
  59777. * @param scene defines the hosting scene
  59778. * @param options defines creation option
  59779. */
  59780. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59781. /**
  59782. * Gets the current class name of the material e.g. "NodeMaterial"
  59783. * @returns the class name
  59784. */
  59785. getClassName(): string;
  59786. /**
  59787. * Keep track of the image processing observer to allow dispose and replace.
  59788. */
  59789. private _imageProcessingObserver;
  59790. /**
  59791. * Attaches a new image processing configuration to the Standard Material.
  59792. * @param configuration
  59793. */
  59794. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59795. /**
  59796. * Get a block by its name
  59797. * @param name defines the name of the block to retrieve
  59798. * @returns the required block or null if not found
  59799. */
  59800. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59801. /**
  59802. * Get a block by its name
  59803. * @param predicate defines the predicate used to find the good candidate
  59804. * @returns the required block or null if not found
  59805. */
  59806. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59807. /**
  59808. * Get an input block by its name
  59809. * @param predicate defines the predicate used to find the good candidate
  59810. * @returns the required input block or null if not found
  59811. */
  59812. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59813. /**
  59814. * Gets the list of input blocks attached to this material
  59815. * @returns an array of InputBlocks
  59816. */
  59817. getInputBlocks(): InputBlock[];
  59818. /**
  59819. * Adds a new optimizer to the list of optimizers
  59820. * @param optimizer defines the optimizers to add
  59821. * @returns the current material
  59822. */
  59823. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59824. /**
  59825. * Remove an optimizer from the list of optimizers
  59826. * @param optimizer defines the optimizers to remove
  59827. * @returns the current material
  59828. */
  59829. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59830. /**
  59831. * Add a new block to the list of output nodes
  59832. * @param node defines the node to add
  59833. * @returns the current material
  59834. */
  59835. addOutputNode(node: NodeMaterialBlock): this;
  59836. /**
  59837. * Remove a block from the list of root nodes
  59838. * @param node defines the node to remove
  59839. * @returns the current material
  59840. */
  59841. removeOutputNode(node: NodeMaterialBlock): this;
  59842. private _addVertexOutputNode;
  59843. private _removeVertexOutputNode;
  59844. private _addFragmentOutputNode;
  59845. private _removeFragmentOutputNode;
  59846. /**
  59847. * Specifies if the material will require alpha blending
  59848. * @returns a boolean specifying if alpha blending is needed
  59849. */
  59850. needAlphaBlending(): boolean;
  59851. /**
  59852. * Specifies if this material should be rendered in alpha test mode
  59853. * @returns a boolean specifying if an alpha test is needed.
  59854. */
  59855. needAlphaTesting(): boolean;
  59856. private _initializeBlock;
  59857. private _resetDualBlocks;
  59858. /**
  59859. * Remove a block from the current node material
  59860. * @param block defines the block to remove
  59861. */
  59862. removeBlock(block: NodeMaterialBlock): void;
  59863. /**
  59864. * Build the material and generates the inner effect
  59865. * @param verbose defines if the build should log activity
  59866. */
  59867. build(verbose?: boolean): void;
  59868. /**
  59869. * Runs an otpimization phase to try to improve the shader code
  59870. */
  59871. optimize(): void;
  59872. private _prepareDefinesForAttributes;
  59873. /**
  59874. * Get if the submesh is ready to be used and all its information available.
  59875. * Child classes can use it to update shaders
  59876. * @param mesh defines the mesh to check
  59877. * @param subMesh defines which submesh to check
  59878. * @param useInstances specifies that instances should be used
  59879. * @returns a boolean indicating that the submesh is ready or not
  59880. */
  59881. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59882. /**
  59883. * Get a string representing the shaders built by the current node graph
  59884. */
  59885. get compiledShaders(): string;
  59886. /**
  59887. * Binds the world matrix to the material
  59888. * @param world defines the world transformation matrix
  59889. */
  59890. bindOnlyWorldMatrix(world: Matrix): void;
  59891. /**
  59892. * Binds the submesh to this material by preparing the effect and shader to draw
  59893. * @param world defines the world transformation matrix
  59894. * @param mesh defines the mesh containing the submesh
  59895. * @param subMesh defines the submesh to bind the material to
  59896. */
  59897. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59898. /**
  59899. * Gets the active textures from the material
  59900. * @returns an array of textures
  59901. */
  59902. getActiveTextures(): BaseTexture[];
  59903. /**
  59904. * Gets the list of texture blocks
  59905. * @returns an array of texture blocks
  59906. */
  59907. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59908. /**
  59909. * Specifies if the material uses a texture
  59910. * @param texture defines the texture to check against the material
  59911. * @returns a boolean specifying if the material uses the texture
  59912. */
  59913. hasTexture(texture: BaseTexture): boolean;
  59914. /**
  59915. * Disposes the material
  59916. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59917. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59918. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59919. */
  59920. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59921. /** Creates the node editor window. */
  59922. private _createNodeEditor;
  59923. /**
  59924. * Launch the node material editor
  59925. * @param config Define the configuration of the editor
  59926. * @return a promise fulfilled when the node editor is visible
  59927. */
  59928. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59929. /**
  59930. * Clear the current material
  59931. */
  59932. clear(): void;
  59933. /**
  59934. * Clear the current material and set it to a default state
  59935. */
  59936. setToDefault(): void;
  59937. /**
  59938. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59939. * @param url defines the url to load from
  59940. * @returns a promise that will fullfil when the material is fully loaded
  59941. */
  59942. loadAsync(url: string): Promise<void>;
  59943. private _gatherBlocks;
  59944. /**
  59945. * Generate a string containing the code declaration required to create an equivalent of this material
  59946. * @returns a string
  59947. */
  59948. generateCode(): string;
  59949. /**
  59950. * Serializes this material in a JSON representation
  59951. * @returns the serialized material object
  59952. */
  59953. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59954. private _restoreConnections;
  59955. /**
  59956. * Clear the current graph and load a new one from a serialization object
  59957. * @param source defines the JSON representation of the material
  59958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59959. */
  59960. loadFromSerialization(source: any, rootUrl?: string): void;
  59961. /**
  59962. * Creates a node material from parsed material data
  59963. * @param source defines the JSON representation of the material
  59964. * @param scene defines the hosting scene
  59965. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59966. * @returns a new node material
  59967. */
  59968. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59969. /**
  59970. * Creates a node material from a snippet saved in a remote file
  59971. * @param name defines the name of the material to create
  59972. * @param url defines the url to load from
  59973. * @param scene defines the hosting scene
  59974. * @returns a promise that will resolve to the new node material
  59975. */
  59976. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59977. /**
  59978. * Creates a node material from a snippet saved by the node material editor
  59979. * @param snippetId defines the snippet to load
  59980. * @param scene defines the hosting scene
  59981. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59982. * @returns a promise that will resolve to the new node material
  59983. */
  59984. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59985. /**
  59986. * Creates a new node material set to default basic configuration
  59987. * @param name defines the name of the material
  59988. * @param scene defines the hosting scene
  59989. * @returns a new NodeMaterial
  59990. */
  59991. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59992. }
  59993. }
  59994. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59997. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60000. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60001. import { Effect } from "babylonjs/Materials/effect";
  60002. import { Mesh } from "babylonjs/Meshes/mesh";
  60003. import { Nullable } from "babylonjs/types";
  60004. import { Texture } from "babylonjs/Materials/Textures/texture";
  60005. import { Scene } from "babylonjs/scene";
  60006. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60007. /**
  60008. * Block used to read a texture from a sampler
  60009. */
  60010. export class TextureBlock extends NodeMaterialBlock {
  60011. private _defineName;
  60012. private _linearDefineName;
  60013. private _tempTextureRead;
  60014. private _samplerName;
  60015. private _transformedUVName;
  60016. private _textureTransformName;
  60017. private _textureInfoName;
  60018. private _mainUVName;
  60019. private _mainUVDefineName;
  60020. /**
  60021. * Gets or sets the texture associated with the node
  60022. */
  60023. texture: Nullable<Texture>;
  60024. /**
  60025. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60026. */
  60027. convertToGammaSpace: boolean;
  60028. /**
  60029. * Create a new TextureBlock
  60030. * @param name defines the block name
  60031. */
  60032. constructor(name: string);
  60033. /**
  60034. * Gets the current class name
  60035. * @returns the class name
  60036. */
  60037. getClassName(): string;
  60038. /**
  60039. * Gets the uv input component
  60040. */
  60041. get uv(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the rgba output component
  60044. */
  60045. get rgba(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the rgb output component
  60048. */
  60049. get rgb(): NodeMaterialConnectionPoint;
  60050. /**
  60051. * Gets the r output component
  60052. */
  60053. get r(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the g output component
  60056. */
  60057. get g(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the b output component
  60060. */
  60061. get b(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the a output component
  60064. */
  60065. get a(): NodeMaterialConnectionPoint;
  60066. get target(): NodeMaterialBlockTargets;
  60067. autoConfigure(material: NodeMaterial): void;
  60068. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60070. isReady(): boolean;
  60071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60072. private get _isMixed();
  60073. private _injectVertexCode;
  60074. private _writeTextureRead;
  60075. private _writeOutput;
  60076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60077. protected _dumpPropertiesCode(): string;
  60078. serialize(): any;
  60079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60080. }
  60081. }
  60082. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60085. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60086. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60087. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60088. import { Scene } from "babylonjs/scene";
  60089. /**
  60090. * Class used to store shared data between 2 NodeMaterialBuildState
  60091. */
  60092. export class NodeMaterialBuildStateSharedData {
  60093. /**
  60094. * Gets the list of emitted varyings
  60095. */
  60096. temps: string[];
  60097. /**
  60098. * Gets the list of emitted varyings
  60099. */
  60100. varyings: string[];
  60101. /**
  60102. * Gets the varying declaration string
  60103. */
  60104. varyingDeclaration: string;
  60105. /**
  60106. * Input blocks
  60107. */
  60108. inputBlocks: InputBlock[];
  60109. /**
  60110. * Input blocks
  60111. */
  60112. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60113. /**
  60114. * Bindable blocks (Blocks that need to set data to the effect)
  60115. */
  60116. bindableBlocks: NodeMaterialBlock[];
  60117. /**
  60118. * List of blocks that can provide a compilation fallback
  60119. */
  60120. blocksWithFallbacks: NodeMaterialBlock[];
  60121. /**
  60122. * List of blocks that can provide a define update
  60123. */
  60124. blocksWithDefines: NodeMaterialBlock[];
  60125. /**
  60126. * List of blocks that can provide a repeatable content
  60127. */
  60128. repeatableContentBlocks: NodeMaterialBlock[];
  60129. /**
  60130. * List of blocks that can provide a dynamic list of uniforms
  60131. */
  60132. dynamicUniformBlocks: NodeMaterialBlock[];
  60133. /**
  60134. * List of blocks that can block the isReady function for the material
  60135. */
  60136. blockingBlocks: NodeMaterialBlock[];
  60137. /**
  60138. * Gets the list of animated inputs
  60139. */
  60140. animatedInputs: InputBlock[];
  60141. /**
  60142. * Build Id used to avoid multiple recompilations
  60143. */
  60144. buildId: number;
  60145. /** List of emitted variables */
  60146. variableNames: {
  60147. [key: string]: number;
  60148. };
  60149. /** List of emitted defines */
  60150. defineNames: {
  60151. [key: string]: number;
  60152. };
  60153. /** Should emit comments? */
  60154. emitComments: boolean;
  60155. /** Emit build activity */
  60156. verbose: boolean;
  60157. /** Gets or sets the hosting scene */
  60158. scene: Scene;
  60159. /**
  60160. * Gets the compilation hints emitted at compilation time
  60161. */
  60162. hints: {
  60163. needWorldViewMatrix: boolean;
  60164. needWorldViewProjectionMatrix: boolean;
  60165. needAlphaBlending: boolean;
  60166. needAlphaTesting: boolean;
  60167. };
  60168. /**
  60169. * List of compilation checks
  60170. */
  60171. checks: {
  60172. emitVertex: boolean;
  60173. emitFragment: boolean;
  60174. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60175. };
  60176. /** Creates a new shared data */
  60177. constructor();
  60178. /**
  60179. * Emits console errors and exceptions if there is a failing check
  60180. */
  60181. emitErrors(): void;
  60182. }
  60183. }
  60184. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60185. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60187. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60188. /**
  60189. * Class used to store node based material build state
  60190. */
  60191. export class NodeMaterialBuildState {
  60192. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60193. supportUniformBuffers: boolean;
  60194. /**
  60195. * Gets the list of emitted attributes
  60196. */
  60197. attributes: string[];
  60198. /**
  60199. * Gets the list of emitted uniforms
  60200. */
  60201. uniforms: string[];
  60202. /**
  60203. * Gets the list of emitted constants
  60204. */
  60205. constants: string[];
  60206. /**
  60207. * Gets the list of emitted samplers
  60208. */
  60209. samplers: string[];
  60210. /**
  60211. * Gets the list of emitted functions
  60212. */
  60213. functions: {
  60214. [key: string]: string;
  60215. };
  60216. /**
  60217. * Gets the list of emitted extensions
  60218. */
  60219. extensions: {
  60220. [key: string]: string;
  60221. };
  60222. /**
  60223. * Gets the target of the compilation state
  60224. */
  60225. target: NodeMaterialBlockTargets;
  60226. /**
  60227. * Gets the list of emitted counters
  60228. */
  60229. counters: {
  60230. [key: string]: number;
  60231. };
  60232. /**
  60233. * Shared data between multiple NodeMaterialBuildState instances
  60234. */
  60235. sharedData: NodeMaterialBuildStateSharedData;
  60236. /** @hidden */
  60237. _vertexState: NodeMaterialBuildState;
  60238. /** @hidden */
  60239. _attributeDeclaration: string;
  60240. /** @hidden */
  60241. _uniformDeclaration: string;
  60242. /** @hidden */
  60243. _constantDeclaration: string;
  60244. /** @hidden */
  60245. _samplerDeclaration: string;
  60246. /** @hidden */
  60247. _varyingTransfer: string;
  60248. private _repeatableContentAnchorIndex;
  60249. /** @hidden */
  60250. _builtCompilationString: string;
  60251. /**
  60252. * Gets the emitted compilation strings
  60253. */
  60254. compilationString: string;
  60255. /**
  60256. * Finalize the compilation strings
  60257. * @param state defines the current compilation state
  60258. */
  60259. finalize(state: NodeMaterialBuildState): void;
  60260. /** @hidden */
  60261. get _repeatableContentAnchor(): string;
  60262. /** @hidden */
  60263. _getFreeVariableName(prefix: string): string;
  60264. /** @hidden */
  60265. _getFreeDefineName(prefix: string): string;
  60266. /** @hidden */
  60267. _excludeVariableName(name: string): void;
  60268. /** @hidden */
  60269. _emit2DSampler(name: string): void;
  60270. /** @hidden */
  60271. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60272. /** @hidden */
  60273. _emitExtension(name: string, extension: string): void;
  60274. /** @hidden */
  60275. _emitFunction(name: string, code: string, comments: string): void;
  60276. /** @hidden */
  60277. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60278. replaceStrings?: {
  60279. search: RegExp;
  60280. replace: string;
  60281. }[];
  60282. repeatKey?: string;
  60283. }): string;
  60284. /** @hidden */
  60285. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60286. repeatKey?: string;
  60287. removeAttributes?: boolean;
  60288. removeUniforms?: boolean;
  60289. removeVaryings?: boolean;
  60290. removeIfDef?: boolean;
  60291. replaceStrings?: {
  60292. search: RegExp;
  60293. replace: string;
  60294. }[];
  60295. }, storeKey?: string): void;
  60296. /** @hidden */
  60297. _registerTempVariable(name: string): boolean;
  60298. /** @hidden */
  60299. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60300. /** @hidden */
  60301. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60302. /** @hidden */
  60303. _emitFloat(value: number): string;
  60304. }
  60305. }
  60306. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60307. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60309. import { Nullable } from "babylonjs/types";
  60310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60311. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60312. import { Effect } from "babylonjs/Materials/effect";
  60313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60314. import { Mesh } from "babylonjs/Meshes/mesh";
  60315. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60316. import { Scene } from "babylonjs/scene";
  60317. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60318. /**
  60319. * Defines a block that can be used inside a node based material
  60320. */
  60321. export class NodeMaterialBlock {
  60322. private _buildId;
  60323. private _buildTarget;
  60324. private _target;
  60325. private _isFinalMerger;
  60326. private _isInput;
  60327. protected _isUnique: boolean;
  60328. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60329. inputsAreExclusive: boolean;
  60330. /** @hidden */
  60331. _codeVariableName: string;
  60332. /** @hidden */
  60333. _inputs: NodeMaterialConnectionPoint[];
  60334. /** @hidden */
  60335. _outputs: NodeMaterialConnectionPoint[];
  60336. /** @hidden */
  60337. _preparationId: number;
  60338. /**
  60339. * Gets or sets the name of the block
  60340. */
  60341. name: string;
  60342. /**
  60343. * Gets or sets the unique id of the node
  60344. */
  60345. uniqueId: number;
  60346. /**
  60347. * Gets or sets the comments associated with this block
  60348. */
  60349. comments: string;
  60350. /**
  60351. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60352. */
  60353. get isUnique(): boolean;
  60354. /**
  60355. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60356. */
  60357. get isFinalMerger(): boolean;
  60358. /**
  60359. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60360. */
  60361. get isInput(): boolean;
  60362. /**
  60363. * Gets or sets the build Id
  60364. */
  60365. get buildId(): number;
  60366. set buildId(value: number);
  60367. /**
  60368. * Gets or sets the target of the block
  60369. */
  60370. get target(): NodeMaterialBlockTargets;
  60371. set target(value: NodeMaterialBlockTargets);
  60372. /**
  60373. * Gets the list of input points
  60374. */
  60375. get inputs(): NodeMaterialConnectionPoint[];
  60376. /** Gets the list of output points */
  60377. get outputs(): NodeMaterialConnectionPoint[];
  60378. /**
  60379. * Find an input by its name
  60380. * @param name defines the name of the input to look for
  60381. * @returns the input or null if not found
  60382. */
  60383. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60384. /**
  60385. * Find an output by its name
  60386. * @param name defines the name of the outputto look for
  60387. * @returns the output or null if not found
  60388. */
  60389. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60390. /**
  60391. * Creates a new NodeMaterialBlock
  60392. * @param name defines the block name
  60393. * @param target defines the target of that block (Vertex by default)
  60394. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60395. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60396. */
  60397. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60398. /**
  60399. * Initialize the block and prepare the context for build
  60400. * @param state defines the state that will be used for the build
  60401. */
  60402. initialize(state: NodeMaterialBuildState): void;
  60403. /**
  60404. * Bind data to effect. Will only be called for blocks with isBindable === true
  60405. * @param effect defines the effect to bind data to
  60406. * @param nodeMaterial defines the hosting NodeMaterial
  60407. * @param mesh defines the mesh that will be rendered
  60408. */
  60409. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60410. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60411. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60412. protected _writeFloat(value: number): string;
  60413. /**
  60414. * Gets the current class name e.g. "NodeMaterialBlock"
  60415. * @returns the class name
  60416. */
  60417. getClassName(): string;
  60418. /**
  60419. * Register a new input. Must be called inside a block constructor
  60420. * @param name defines the connection point name
  60421. * @param type defines the connection point type
  60422. * @param isOptional defines a boolean indicating that this input can be omitted
  60423. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60424. * @returns the current block
  60425. */
  60426. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60427. /**
  60428. * Register a new output. Must be called inside a block constructor
  60429. * @param name defines the connection point name
  60430. * @param type defines the connection point type
  60431. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60432. * @returns the current block
  60433. */
  60434. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60435. /**
  60436. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60437. * @param forOutput defines an optional connection point to check compatibility with
  60438. * @returns the first available input or null
  60439. */
  60440. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60441. /**
  60442. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60443. * @param forBlock defines an optional block to check compatibility with
  60444. * @returns the first available input or null
  60445. */
  60446. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60447. /**
  60448. * Gets the sibling of the given output
  60449. * @param current defines the current output
  60450. * @returns the next output in the list or null
  60451. */
  60452. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60453. /**
  60454. * Connect current block with another block
  60455. * @param other defines the block to connect with
  60456. * @param options define the various options to help pick the right connections
  60457. * @returns the current block
  60458. */
  60459. connectTo(other: NodeMaterialBlock, options?: {
  60460. input?: string;
  60461. output?: string;
  60462. outputSwizzle?: string;
  60463. }): this | undefined;
  60464. protected _buildBlock(state: NodeMaterialBuildState): void;
  60465. /**
  60466. * Add uniforms, samplers and uniform buffers at compilation time
  60467. * @param state defines the state to update
  60468. * @param nodeMaterial defines the node material requesting the update
  60469. * @param defines defines the material defines to update
  60470. * @param uniformBuffers defines the list of uniform buffer names
  60471. */
  60472. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60473. /**
  60474. * Add potential fallbacks if shader compilation fails
  60475. * @param mesh defines the mesh to be rendered
  60476. * @param fallbacks defines the current prioritized list of fallbacks
  60477. */
  60478. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60479. /**
  60480. * Initialize defines for shader compilation
  60481. * @param mesh defines the mesh to be rendered
  60482. * @param nodeMaterial defines the node material requesting the update
  60483. * @param defines defines the material defines to update
  60484. * @param useInstances specifies that instances should be used
  60485. */
  60486. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60487. /**
  60488. * Update defines for shader compilation
  60489. * @param mesh defines the mesh to be rendered
  60490. * @param nodeMaterial defines the node material requesting the update
  60491. * @param defines defines the material defines to update
  60492. * @param useInstances specifies that instances should be used
  60493. */
  60494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60495. /**
  60496. * Lets the block try to connect some inputs automatically
  60497. * @param material defines the hosting NodeMaterial
  60498. */
  60499. autoConfigure(material: NodeMaterial): void;
  60500. /**
  60501. * Function called when a block is declared as repeatable content generator
  60502. * @param vertexShaderState defines the current compilation state for the vertex shader
  60503. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60504. * @param mesh defines the mesh to be rendered
  60505. * @param defines defines the material defines to update
  60506. */
  60507. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60508. /**
  60509. * Checks if the block is ready
  60510. * @param mesh defines the mesh to be rendered
  60511. * @param nodeMaterial defines the node material requesting the update
  60512. * @param defines defines the material defines to update
  60513. * @param useInstances specifies that instances should be used
  60514. * @returns true if the block is ready
  60515. */
  60516. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60517. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60518. private _processBuild;
  60519. /**
  60520. * Compile the current node and generate the shader code
  60521. * @param state defines the current compilation state (uniforms, samplers, current string)
  60522. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60523. * @returns true if already built
  60524. */
  60525. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60526. protected _inputRename(name: string): string;
  60527. protected _outputRename(name: string): string;
  60528. protected _dumpPropertiesCode(): string;
  60529. /** @hidden */
  60530. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60531. /** @hidden */
  60532. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60533. /**
  60534. * Clone the current block to a new identical block
  60535. * @param scene defines the hosting scene
  60536. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60537. * @returns a copy of the current block
  60538. */
  60539. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60540. /**
  60541. * Serializes this block in a JSON representation
  60542. * @returns the serialized block object
  60543. */
  60544. serialize(): any;
  60545. /** @hidden */
  60546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60547. /**
  60548. * Release resources
  60549. */
  60550. dispose(): void;
  60551. }
  60552. }
  60553. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60554. /**
  60555. * Enum defining the type of animations supported by InputBlock
  60556. */
  60557. export enum AnimatedInputBlockTypes {
  60558. /** No animation */
  60559. None = 0,
  60560. /** Time based animation. Will only work for floats */
  60561. Time = 1
  60562. }
  60563. }
  60564. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60566. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60567. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60568. import { Nullable } from "babylonjs/types";
  60569. import { Effect } from "babylonjs/Materials/effect";
  60570. import { Matrix } from "babylonjs/Maths/math.vector";
  60571. import { Scene } from "babylonjs/scene";
  60572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60574. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60575. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60576. /**
  60577. * Block used to expose an input value
  60578. */
  60579. export class InputBlock extends NodeMaterialBlock {
  60580. private _mode;
  60581. private _associatedVariableName;
  60582. private _storedValue;
  60583. private _valueCallback;
  60584. private _type;
  60585. private _animationType;
  60586. /** Gets or set a value used to limit the range of float values */
  60587. min: number;
  60588. /** Gets or set a value used to limit the range of float values */
  60589. max: number;
  60590. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60591. isBoolean: boolean;
  60592. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60593. matrixMode: number;
  60594. /** @hidden */
  60595. _systemValue: Nullable<NodeMaterialSystemValues>;
  60596. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60597. visibleInInspector: boolean;
  60598. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60599. isConstant: boolean;
  60600. /** Gets or sets the group to use to display this block in the Inspector */
  60601. groupInInspector: string;
  60602. /**
  60603. * Gets or sets the connection point type (default is float)
  60604. */
  60605. get type(): NodeMaterialBlockConnectionPointTypes;
  60606. /**
  60607. * Creates a new InputBlock
  60608. * @param name defines the block name
  60609. * @param target defines the target of that block (Vertex by default)
  60610. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60611. */
  60612. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60613. /**
  60614. * Gets the output component
  60615. */
  60616. get output(): NodeMaterialConnectionPoint;
  60617. /**
  60618. * Set the source of this connection point to a vertex attribute
  60619. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60620. * @returns the current connection point
  60621. */
  60622. setAsAttribute(attributeName?: string): InputBlock;
  60623. /**
  60624. * Set the source of this connection point to a system value
  60625. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60626. * @returns the current connection point
  60627. */
  60628. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60629. /**
  60630. * Gets or sets the value of that point.
  60631. * Please note that this value will be ignored if valueCallback is defined
  60632. */
  60633. get value(): any;
  60634. set value(value: any);
  60635. /**
  60636. * Gets or sets a callback used to get the value of that point.
  60637. * Please note that setting this value will force the connection point to ignore the value property
  60638. */
  60639. get valueCallback(): () => any;
  60640. set valueCallback(value: () => any);
  60641. /**
  60642. * Gets or sets the associated variable name in the shader
  60643. */
  60644. get associatedVariableName(): string;
  60645. set associatedVariableName(value: string);
  60646. /** Gets or sets the type of animation applied to the input */
  60647. get animationType(): AnimatedInputBlockTypes;
  60648. set animationType(value: AnimatedInputBlockTypes);
  60649. /**
  60650. * Gets a boolean indicating that this connection point not defined yet
  60651. */
  60652. get isUndefined(): boolean;
  60653. /**
  60654. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60655. * In this case the connection point name must be the name of the uniform to use.
  60656. * Can only be set on inputs
  60657. */
  60658. get isUniform(): boolean;
  60659. set isUniform(value: boolean);
  60660. /**
  60661. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60662. * In this case the connection point name must be the name of the attribute to use
  60663. * Can only be set on inputs
  60664. */
  60665. get isAttribute(): boolean;
  60666. set isAttribute(value: boolean);
  60667. /**
  60668. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60669. * Can only be set on exit points
  60670. */
  60671. get isVarying(): boolean;
  60672. set isVarying(value: boolean);
  60673. /**
  60674. * Gets a boolean indicating that the current connection point is a system value
  60675. */
  60676. get isSystemValue(): boolean;
  60677. /**
  60678. * Gets or sets the current well known value or null if not defined as a system value
  60679. */
  60680. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60681. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60682. /**
  60683. * Gets the current class name
  60684. * @returns the class name
  60685. */
  60686. getClassName(): string;
  60687. /**
  60688. * Animate the input if animationType !== None
  60689. * @param scene defines the rendering scene
  60690. */
  60691. animate(scene: Scene): void;
  60692. private _emitDefine;
  60693. initialize(state: NodeMaterialBuildState): void;
  60694. /**
  60695. * Set the input block to its default value (based on its type)
  60696. */
  60697. setDefaultValue(): void;
  60698. private _emitConstant;
  60699. private _emit;
  60700. /** @hidden */
  60701. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60702. /** @hidden */
  60703. _transmit(effect: Effect, scene: Scene): void;
  60704. protected _buildBlock(state: NodeMaterialBuildState): void;
  60705. protected _dumpPropertiesCode(): string;
  60706. serialize(): any;
  60707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60708. }
  60709. }
  60710. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60711. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60712. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60713. import { Nullable } from "babylonjs/types";
  60714. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60715. import { Observable } from "babylonjs/Misc/observable";
  60716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60717. /**
  60718. * Enum used to define the compatibility state between two connection points
  60719. */
  60720. export enum NodeMaterialConnectionPointCompatibilityStates {
  60721. /** Points are compatibles */
  60722. Compatible = 0,
  60723. /** Points are incompatible because of their types */
  60724. TypeIncompatible = 1,
  60725. /** Points are incompatible because of their targets (vertex vs fragment) */
  60726. TargetIncompatible = 2
  60727. }
  60728. /**
  60729. * Defines the direction of a connection point
  60730. */
  60731. export enum NodeMaterialConnectionPointDirection {
  60732. /** Input */
  60733. Input = 0,
  60734. /** Output */
  60735. Output = 1
  60736. }
  60737. /**
  60738. * Defines a connection point for a block
  60739. */
  60740. export class NodeMaterialConnectionPoint {
  60741. /** @hidden */
  60742. _ownerBlock: NodeMaterialBlock;
  60743. /** @hidden */
  60744. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60745. private _endpoints;
  60746. private _associatedVariableName;
  60747. private _direction;
  60748. /** @hidden */
  60749. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60750. /** @hidden */
  60751. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60752. private _type;
  60753. /** @hidden */
  60754. _enforceAssociatedVariableName: boolean;
  60755. /** Gets the direction of the point */
  60756. get direction(): NodeMaterialConnectionPointDirection;
  60757. /**
  60758. * Gets or sets the additional types supported by this connection point
  60759. */
  60760. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60761. /**
  60762. * Gets or sets the additional types excluded by this connection point
  60763. */
  60764. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60765. /**
  60766. * Observable triggered when this point is connected
  60767. */
  60768. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60769. /**
  60770. * Gets or sets the associated variable name in the shader
  60771. */
  60772. get associatedVariableName(): string;
  60773. set associatedVariableName(value: string);
  60774. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60775. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60776. /**
  60777. * Gets or sets the connection point type (default is float)
  60778. */
  60779. get type(): NodeMaterialBlockConnectionPointTypes;
  60780. set type(value: NodeMaterialBlockConnectionPointTypes);
  60781. /**
  60782. * Gets or sets the connection point name
  60783. */
  60784. name: string;
  60785. /**
  60786. * Gets or sets a boolean indicating that this connection point can be omitted
  60787. */
  60788. isOptional: boolean;
  60789. /**
  60790. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60791. */
  60792. define: string;
  60793. /** @hidden */
  60794. _prioritizeVertex: boolean;
  60795. private _target;
  60796. /** Gets or sets the target of that connection point */
  60797. get target(): NodeMaterialBlockTargets;
  60798. set target(value: NodeMaterialBlockTargets);
  60799. /**
  60800. * Gets a boolean indicating that the current point is connected
  60801. */
  60802. get isConnected(): boolean;
  60803. /**
  60804. * Gets a boolean indicating that the current point is connected to an input block
  60805. */
  60806. get isConnectedToInputBlock(): boolean;
  60807. /**
  60808. * Gets a the connected input block (if any)
  60809. */
  60810. get connectInputBlock(): Nullable<InputBlock>;
  60811. /** Get the other side of the connection (if any) */
  60812. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60813. /** Get the block that owns this connection point */
  60814. get ownerBlock(): NodeMaterialBlock;
  60815. /** Get the block connected on the other side of this connection (if any) */
  60816. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60817. /** Get the block connected on the endpoints of this connection (if any) */
  60818. get connectedBlocks(): Array<NodeMaterialBlock>;
  60819. /** Gets the list of connected endpoints */
  60820. get endpoints(): NodeMaterialConnectionPoint[];
  60821. /** Gets a boolean indicating if that output point is connected to at least one input */
  60822. get hasEndpoints(): boolean;
  60823. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60824. get isConnectedInVertexShader(): boolean;
  60825. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60826. get isConnectedInFragmentShader(): boolean;
  60827. /**
  60828. * Creates a new connection point
  60829. * @param name defines the connection point name
  60830. * @param ownerBlock defines the block hosting this connection point
  60831. * @param direction defines the direction of the connection point
  60832. */
  60833. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60834. /**
  60835. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60836. * @returns the class name
  60837. */
  60838. getClassName(): string;
  60839. /**
  60840. * Gets a boolean indicating if the current point can be connected to another point
  60841. * @param connectionPoint defines the other connection point
  60842. * @returns a boolean
  60843. */
  60844. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60845. /**
  60846. * Gets a number indicating if the current point can be connected to another point
  60847. * @param connectionPoint defines the other connection point
  60848. * @returns a number defining the compatibility state
  60849. */
  60850. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60851. /**
  60852. * Connect this point to another connection point
  60853. * @param connectionPoint defines the other connection point
  60854. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60855. * @returns the current connection point
  60856. */
  60857. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Disconnect this point from one of his endpoint
  60860. * @param endpoint defines the other connection point
  60861. * @returns the current connection point
  60862. */
  60863. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Serializes this point in a JSON representation
  60866. * @returns the serialized point object
  60867. */
  60868. serialize(): any;
  60869. /**
  60870. * Release resources
  60871. */
  60872. dispose(): void;
  60873. }
  60874. }
  60875. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60879. import { Mesh } from "babylonjs/Meshes/mesh";
  60880. import { Effect } from "babylonjs/Materials/effect";
  60881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60882. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60883. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60884. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60885. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60886. /**
  60887. * Block used to add support for vertex skinning (bones)
  60888. */
  60889. export class BonesBlock extends NodeMaterialBlock {
  60890. /**
  60891. * Creates a new BonesBlock
  60892. * @param name defines the block name
  60893. */
  60894. constructor(name: string);
  60895. /**
  60896. * Initialize the block and prepare the context for build
  60897. * @param state defines the state that will be used for the build
  60898. */
  60899. initialize(state: NodeMaterialBuildState): void;
  60900. /**
  60901. * Gets the current class name
  60902. * @returns the class name
  60903. */
  60904. getClassName(): string;
  60905. /**
  60906. * Gets the matrix indices input component
  60907. */
  60908. get matricesIndices(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the matrix weights input component
  60911. */
  60912. get matricesWeights(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the extra matrix indices input component
  60915. */
  60916. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the extra matrix weights input component
  60919. */
  60920. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the world input component
  60923. */
  60924. get world(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the output component
  60927. */
  60928. get output(): NodeMaterialConnectionPoint;
  60929. autoConfigure(material: NodeMaterial): void;
  60930. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60933. protected _buildBlock(state: NodeMaterialBuildState): this;
  60934. }
  60935. }
  60936. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60941. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60942. /**
  60943. * Block used to add support for instances
  60944. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60945. */
  60946. export class InstancesBlock extends NodeMaterialBlock {
  60947. /**
  60948. * Creates a new InstancesBlock
  60949. * @param name defines the block name
  60950. */
  60951. constructor(name: string);
  60952. /**
  60953. * Gets the current class name
  60954. * @returns the class name
  60955. */
  60956. getClassName(): string;
  60957. /**
  60958. * Gets the first world row input component
  60959. */
  60960. get world0(): NodeMaterialConnectionPoint;
  60961. /**
  60962. * Gets the second world row input component
  60963. */
  60964. get world1(): NodeMaterialConnectionPoint;
  60965. /**
  60966. * Gets the third world row input component
  60967. */
  60968. get world2(): NodeMaterialConnectionPoint;
  60969. /**
  60970. * Gets the forth world row input component
  60971. */
  60972. get world3(): NodeMaterialConnectionPoint;
  60973. /**
  60974. * Gets the world input component
  60975. */
  60976. get world(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the output component
  60979. */
  60980. get output(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the isntanceID component
  60983. */
  60984. get instanceID(): NodeMaterialConnectionPoint;
  60985. autoConfigure(material: NodeMaterial): void;
  60986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60987. protected _buildBlock(state: NodeMaterialBuildState): this;
  60988. }
  60989. }
  60990. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60995. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60996. import { Effect } from "babylonjs/Materials/effect";
  60997. import { Mesh } from "babylonjs/Meshes/mesh";
  60998. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60999. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61000. /**
  61001. * Block used to add morph targets support to vertex shader
  61002. */
  61003. export class MorphTargetsBlock extends NodeMaterialBlock {
  61004. private _repeatableContentAnchor;
  61005. /**
  61006. * Create a new MorphTargetsBlock
  61007. * @param name defines the block name
  61008. */
  61009. constructor(name: string);
  61010. /**
  61011. * Gets the current class name
  61012. * @returns the class name
  61013. */
  61014. getClassName(): string;
  61015. /**
  61016. * Gets the position input component
  61017. */
  61018. get position(): NodeMaterialConnectionPoint;
  61019. /**
  61020. * Gets the normal input component
  61021. */
  61022. get normal(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the tangent input component
  61025. */
  61026. get tangent(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the tangent input component
  61029. */
  61030. get uv(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the position output component
  61033. */
  61034. get positionOutput(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the normal output component
  61037. */
  61038. get normalOutput(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the tangent output component
  61041. */
  61042. get tangentOutput(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the tangent output component
  61045. */
  61046. get uvOutput(): NodeMaterialConnectionPoint;
  61047. initialize(state: NodeMaterialBuildState): void;
  61048. autoConfigure(material: NodeMaterial): void;
  61049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61050. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61051. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61052. protected _buildBlock(state: NodeMaterialBuildState): this;
  61053. }
  61054. }
  61055. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61059. import { Nullable } from "babylonjs/types";
  61060. import { Scene } from "babylonjs/scene";
  61061. import { Effect } from "babylonjs/Materials/effect";
  61062. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61063. import { Mesh } from "babylonjs/Meshes/mesh";
  61064. import { Light } from "babylonjs/Lights/light";
  61065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61066. /**
  61067. * Block used to get data information from a light
  61068. */
  61069. export class LightInformationBlock extends NodeMaterialBlock {
  61070. private _lightDataUniformName;
  61071. private _lightColorUniformName;
  61072. private _lightTypeDefineName;
  61073. /**
  61074. * Gets or sets the light associated with this block
  61075. */
  61076. light: Nullable<Light>;
  61077. /**
  61078. * Creates a new LightInformationBlock
  61079. * @param name defines the block name
  61080. */
  61081. constructor(name: string);
  61082. /**
  61083. * Gets the current class name
  61084. * @returns the class name
  61085. */
  61086. getClassName(): string;
  61087. /**
  61088. * Gets the world position input component
  61089. */
  61090. get worldPosition(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the direction output component
  61093. */
  61094. get direction(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the direction output component
  61097. */
  61098. get color(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the direction output component
  61101. */
  61102. get intensity(): NodeMaterialConnectionPoint;
  61103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61105. protected _buildBlock(state: NodeMaterialBuildState): this;
  61106. serialize(): any;
  61107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61108. }
  61109. }
  61110. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61111. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61112. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61113. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61114. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61115. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61116. }
  61117. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61122. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61123. import { Effect } from "babylonjs/Materials/effect";
  61124. import { Mesh } from "babylonjs/Meshes/mesh";
  61125. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61126. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61127. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61128. /**
  61129. * Block used to add image processing support to fragment shader
  61130. */
  61131. export class ImageProcessingBlock extends NodeMaterialBlock {
  61132. /**
  61133. * Create a new ImageProcessingBlock
  61134. * @param name defines the block name
  61135. */
  61136. constructor(name: string);
  61137. /**
  61138. * Gets the current class name
  61139. * @returns the class name
  61140. */
  61141. getClassName(): string;
  61142. /**
  61143. * Gets the color input component
  61144. */
  61145. get color(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the output component
  61148. */
  61149. get output(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Initialize the block and prepare the context for build
  61152. * @param state defines the state that will be used for the build
  61153. */
  61154. initialize(state: NodeMaterialBuildState): void;
  61155. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61158. protected _buildBlock(state: NodeMaterialBuildState): this;
  61159. }
  61160. }
  61161. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61167. import { Effect } from "babylonjs/Materials/effect";
  61168. import { Mesh } from "babylonjs/Meshes/mesh";
  61169. import { Scene } from "babylonjs/scene";
  61170. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61171. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61172. /**
  61173. * Block used to pertub normals based on a normal map
  61174. */
  61175. export class PerturbNormalBlock extends NodeMaterialBlock {
  61176. private _tangentSpaceParameterName;
  61177. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61178. invertX: boolean;
  61179. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61180. invertY: boolean;
  61181. /**
  61182. * Create a new PerturbNormalBlock
  61183. * @param name defines the block name
  61184. */
  61185. constructor(name: string);
  61186. /**
  61187. * Gets the current class name
  61188. * @returns the class name
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Gets the world position input component
  61193. */
  61194. get worldPosition(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the world normal input component
  61197. */
  61198. get worldNormal(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the world tangent input component
  61201. */
  61202. get worldTangent(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the uv input component
  61205. */
  61206. get uv(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the normal map color input component
  61209. */
  61210. get normalMapColor(): NodeMaterialConnectionPoint;
  61211. /**
  61212. * Gets the strength input component
  61213. */
  61214. get strength(): NodeMaterialConnectionPoint;
  61215. /**
  61216. * Gets the output component
  61217. */
  61218. get output(): NodeMaterialConnectionPoint;
  61219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61221. autoConfigure(material: NodeMaterial): void;
  61222. protected _buildBlock(state: NodeMaterialBuildState): this;
  61223. protected _dumpPropertiesCode(): string;
  61224. serialize(): any;
  61225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61226. }
  61227. }
  61228. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61232. /**
  61233. * Block used to discard a pixel if a value is smaller than a cutoff
  61234. */
  61235. export class DiscardBlock extends NodeMaterialBlock {
  61236. /**
  61237. * Create a new DiscardBlock
  61238. * @param name defines the block name
  61239. */
  61240. constructor(name: string);
  61241. /**
  61242. * Gets the current class name
  61243. * @returns the class name
  61244. */
  61245. getClassName(): string;
  61246. /**
  61247. * Gets the color input component
  61248. */
  61249. get value(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the cutoff input component
  61252. */
  61253. get cutoff(): NodeMaterialConnectionPoint;
  61254. protected _buildBlock(state: NodeMaterialBuildState): this;
  61255. }
  61256. }
  61257. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61261. /**
  61262. * Block used to test if the fragment shader is front facing
  61263. */
  61264. export class FrontFacingBlock extends NodeMaterialBlock {
  61265. /**
  61266. * Creates a new FrontFacingBlock
  61267. * @param name defines the block name
  61268. */
  61269. constructor(name: string);
  61270. /**
  61271. * Gets the current class name
  61272. * @returns the class name
  61273. */
  61274. getClassName(): string;
  61275. /**
  61276. * Gets the output component
  61277. */
  61278. get output(): NodeMaterialConnectionPoint;
  61279. protected _buildBlock(state: NodeMaterialBuildState): this;
  61280. }
  61281. }
  61282. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61286. /**
  61287. * Block used to get the derivative value on x and y of a given input
  61288. */
  61289. export class DerivativeBlock extends NodeMaterialBlock {
  61290. /**
  61291. * Create a new DerivativeBlock
  61292. * @param name defines the block name
  61293. */
  61294. constructor(name: string);
  61295. /**
  61296. * Gets the current class name
  61297. * @returns the class name
  61298. */
  61299. getClassName(): string;
  61300. /**
  61301. * Gets the input component
  61302. */
  61303. get input(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the derivative output on x
  61306. */
  61307. get dx(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the derivative output on y
  61310. */
  61311. get dy(): NodeMaterialConnectionPoint;
  61312. protected _buildBlock(state: NodeMaterialBuildState): this;
  61313. }
  61314. }
  61315. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61316. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61317. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61318. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61319. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61320. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61321. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61322. }
  61323. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61326. import { Mesh } from "babylonjs/Meshes/mesh";
  61327. import { Effect } from "babylonjs/Materials/effect";
  61328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61330. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61331. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61332. /**
  61333. * Block used to add support for scene fog
  61334. */
  61335. export class FogBlock extends NodeMaterialBlock {
  61336. private _fogDistanceName;
  61337. private _fogParameters;
  61338. /**
  61339. * Create a new FogBlock
  61340. * @param name defines the block name
  61341. */
  61342. constructor(name: string);
  61343. /**
  61344. * Gets the current class name
  61345. * @returns the class name
  61346. */
  61347. getClassName(): string;
  61348. /**
  61349. * Gets the world position input component
  61350. */
  61351. get worldPosition(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the view input component
  61354. */
  61355. get view(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the color input component
  61358. */
  61359. get input(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the fog color input component
  61362. */
  61363. get fogColor(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the output component
  61366. */
  61367. get output(): NodeMaterialConnectionPoint;
  61368. autoConfigure(material: NodeMaterial): void;
  61369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61370. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61371. protected _buildBlock(state: NodeMaterialBuildState): this;
  61372. }
  61373. }
  61374. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61379. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61380. import { Effect } from "babylonjs/Materials/effect";
  61381. import { Mesh } from "babylonjs/Meshes/mesh";
  61382. import { Light } from "babylonjs/Lights/light";
  61383. import { Nullable } from "babylonjs/types";
  61384. import { Scene } from "babylonjs/scene";
  61385. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61386. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61387. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61388. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61389. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61390. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61391. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61392. /**
  61393. * Block used to add light in the fragment shader
  61394. */
  61395. export class LightBlock extends NodeMaterialBlock {
  61396. private _lightId;
  61397. /**
  61398. * Gets or sets the light associated with this block
  61399. */
  61400. light: Nullable<Light>;
  61401. /**
  61402. * Create a new LightBlock
  61403. * @param name defines the block name
  61404. */
  61405. constructor(name: string);
  61406. /**
  61407. * Gets the current class name
  61408. * @returns the class name
  61409. */
  61410. getClassName(): string;
  61411. /**
  61412. * Gets the world position input component
  61413. */
  61414. get worldPosition(): NodeMaterialConnectionPoint;
  61415. /**
  61416. * Gets the world normal input component
  61417. */
  61418. get worldNormal(): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Gets the camera (or eye) position component
  61421. */
  61422. get cameraPosition(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the glossiness component
  61425. */
  61426. get glossiness(): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Gets the glossinness power component
  61429. */
  61430. get glossPower(): NodeMaterialConnectionPoint;
  61431. /**
  61432. * Gets the diffuse color component
  61433. */
  61434. get diffuseColor(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the specular color component
  61437. */
  61438. get specularColor(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the diffuse output component
  61441. */
  61442. get diffuseOutput(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the specular output component
  61445. */
  61446. get specularOutput(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the shadow output component
  61449. */
  61450. get shadow(): NodeMaterialConnectionPoint;
  61451. autoConfigure(material: NodeMaterial): void;
  61452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61453. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61455. private _injectVertexCode;
  61456. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61457. serialize(): any;
  61458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61459. }
  61460. }
  61461. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61462. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61463. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61464. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61465. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61466. }
  61467. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61468. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61469. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61470. }
  61471. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61475. /**
  61476. * Block used to multiply 2 values
  61477. */
  61478. export class MultiplyBlock extends NodeMaterialBlock {
  61479. /**
  61480. * Creates a new MultiplyBlock
  61481. * @param name defines the block name
  61482. */
  61483. constructor(name: string);
  61484. /**
  61485. * Gets the current class name
  61486. * @returns the class name
  61487. */
  61488. getClassName(): string;
  61489. /**
  61490. * Gets the left operand input component
  61491. */
  61492. get left(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the right operand input component
  61495. */
  61496. get right(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the output component
  61499. */
  61500. get output(): NodeMaterialConnectionPoint;
  61501. protected _buildBlock(state: NodeMaterialBuildState): this;
  61502. }
  61503. }
  61504. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61508. /**
  61509. * Block used to add 2 vectors
  61510. */
  61511. export class AddBlock extends NodeMaterialBlock {
  61512. /**
  61513. * Creates a new AddBlock
  61514. * @param name defines the block name
  61515. */
  61516. constructor(name: string);
  61517. /**
  61518. * Gets the current class name
  61519. * @returns the class name
  61520. */
  61521. getClassName(): string;
  61522. /**
  61523. * Gets the left operand input component
  61524. */
  61525. get left(): NodeMaterialConnectionPoint;
  61526. /**
  61527. * Gets the right operand input component
  61528. */
  61529. get right(): NodeMaterialConnectionPoint;
  61530. /**
  61531. * Gets the output component
  61532. */
  61533. get output(): NodeMaterialConnectionPoint;
  61534. protected _buildBlock(state: NodeMaterialBuildState): this;
  61535. }
  61536. }
  61537. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61541. /**
  61542. * Block used to scale a vector by a float
  61543. */
  61544. export class ScaleBlock extends NodeMaterialBlock {
  61545. /**
  61546. * Creates a new ScaleBlock
  61547. * @param name defines the block name
  61548. */
  61549. constructor(name: string);
  61550. /**
  61551. * Gets the current class name
  61552. * @returns the class name
  61553. */
  61554. getClassName(): string;
  61555. /**
  61556. * Gets the input component
  61557. */
  61558. get input(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the factor input component
  61561. */
  61562. get factor(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the output component
  61565. */
  61566. get output(): NodeMaterialConnectionPoint;
  61567. protected _buildBlock(state: NodeMaterialBuildState): this;
  61568. }
  61569. }
  61570. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61574. import { Scene } from "babylonjs/scene";
  61575. /**
  61576. * Block used to clamp a float
  61577. */
  61578. export class ClampBlock extends NodeMaterialBlock {
  61579. /** Gets or sets the minimum range */
  61580. minimum: number;
  61581. /** Gets or sets the maximum range */
  61582. maximum: number;
  61583. /**
  61584. * Creates a new ClampBlock
  61585. * @param name defines the block name
  61586. */
  61587. constructor(name: string);
  61588. /**
  61589. * Gets the current class name
  61590. * @returns the class name
  61591. */
  61592. getClassName(): string;
  61593. /**
  61594. * Gets the value input component
  61595. */
  61596. get value(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the output component
  61599. */
  61600. get output(): NodeMaterialConnectionPoint;
  61601. protected _buildBlock(state: NodeMaterialBuildState): this;
  61602. protected _dumpPropertiesCode(): string;
  61603. serialize(): any;
  61604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61605. }
  61606. }
  61607. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61611. /**
  61612. * Block used to apply a cross product between 2 vectors
  61613. */
  61614. export class CrossBlock extends NodeMaterialBlock {
  61615. /**
  61616. * Creates a new CrossBlock
  61617. * @param name defines the block name
  61618. */
  61619. constructor(name: string);
  61620. /**
  61621. * Gets the current class name
  61622. * @returns the class name
  61623. */
  61624. getClassName(): string;
  61625. /**
  61626. * Gets the left operand input component
  61627. */
  61628. get left(): NodeMaterialConnectionPoint;
  61629. /**
  61630. * Gets the right operand input component
  61631. */
  61632. get right(): NodeMaterialConnectionPoint;
  61633. /**
  61634. * Gets the output component
  61635. */
  61636. get output(): NodeMaterialConnectionPoint;
  61637. protected _buildBlock(state: NodeMaterialBuildState): this;
  61638. }
  61639. }
  61640. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61644. /**
  61645. * Block used to apply a dot product between 2 vectors
  61646. */
  61647. export class DotBlock extends NodeMaterialBlock {
  61648. /**
  61649. * Creates a new DotBlock
  61650. * @param name defines the block name
  61651. */
  61652. constructor(name: string);
  61653. /**
  61654. * Gets the current class name
  61655. * @returns the class name
  61656. */
  61657. getClassName(): string;
  61658. /**
  61659. * Gets the left operand input component
  61660. */
  61661. get left(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the right operand input component
  61664. */
  61665. get right(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the output component
  61668. */
  61669. get output(): NodeMaterialConnectionPoint;
  61670. protected _buildBlock(state: NodeMaterialBuildState): this;
  61671. }
  61672. }
  61673. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61677. import { Vector2 } from "babylonjs/Maths/math.vector";
  61678. import { Scene } from "babylonjs/scene";
  61679. /**
  61680. * Block used to remap a float from a range to a new one
  61681. */
  61682. export class RemapBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Gets or sets the source range
  61685. */
  61686. sourceRange: Vector2;
  61687. /**
  61688. * Gets or sets the target range
  61689. */
  61690. targetRange: Vector2;
  61691. /**
  61692. * Creates a new RemapBlock
  61693. * @param name defines the block name
  61694. */
  61695. constructor(name: string);
  61696. /**
  61697. * Gets the current class name
  61698. * @returns the class name
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * Gets the input component
  61703. */
  61704. get input(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the source min input component
  61707. */
  61708. get sourceMin(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the source max input component
  61711. */
  61712. get sourceMax(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the target min input component
  61715. */
  61716. get targetMin(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the target max input component
  61719. */
  61720. get targetMax(): NodeMaterialConnectionPoint;
  61721. /**
  61722. * Gets the output component
  61723. */
  61724. get output(): NodeMaterialConnectionPoint;
  61725. protected _buildBlock(state: NodeMaterialBuildState): this;
  61726. protected _dumpPropertiesCode(): string;
  61727. serialize(): any;
  61728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61729. }
  61730. }
  61731. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61735. /**
  61736. * Block used to normalize a vector
  61737. */
  61738. export class NormalizeBlock extends NodeMaterialBlock {
  61739. /**
  61740. * Creates a new NormalizeBlock
  61741. * @param name defines the block name
  61742. */
  61743. constructor(name: string);
  61744. /**
  61745. * Gets the current class name
  61746. * @returns the class name
  61747. */
  61748. getClassName(): string;
  61749. /**
  61750. * Gets the input component
  61751. */
  61752. get input(): NodeMaterialConnectionPoint;
  61753. /**
  61754. * Gets the output component
  61755. */
  61756. get output(): NodeMaterialConnectionPoint;
  61757. protected _buildBlock(state: NodeMaterialBuildState): this;
  61758. }
  61759. }
  61760. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61764. import { Scene } from "babylonjs/scene";
  61765. /**
  61766. * Operations supported by the Trigonometry block
  61767. */
  61768. export enum TrigonometryBlockOperations {
  61769. /** Cos */
  61770. Cos = 0,
  61771. /** Sin */
  61772. Sin = 1,
  61773. /** Abs */
  61774. Abs = 2,
  61775. /** Exp */
  61776. Exp = 3,
  61777. /** Exp2 */
  61778. Exp2 = 4,
  61779. /** Round */
  61780. Round = 5,
  61781. /** Floor */
  61782. Floor = 6,
  61783. /** Ceiling */
  61784. Ceiling = 7,
  61785. /** Square root */
  61786. Sqrt = 8,
  61787. /** Log */
  61788. Log = 9,
  61789. /** Tangent */
  61790. Tan = 10,
  61791. /** Arc tangent */
  61792. ArcTan = 11,
  61793. /** Arc cosinus */
  61794. ArcCos = 12,
  61795. /** Arc sinus */
  61796. ArcSin = 13,
  61797. /** Fraction */
  61798. Fract = 14,
  61799. /** Sign */
  61800. Sign = 15,
  61801. /** To radians (from degrees) */
  61802. Radians = 16,
  61803. /** To degrees (from radians) */
  61804. Degrees = 17
  61805. }
  61806. /**
  61807. * Block used to apply trigonometry operation to floats
  61808. */
  61809. export class TrigonometryBlock extends NodeMaterialBlock {
  61810. /**
  61811. * Gets or sets the operation applied by the block
  61812. */
  61813. operation: TrigonometryBlockOperations;
  61814. /**
  61815. * Creates a new TrigonometryBlock
  61816. * @param name defines the block name
  61817. */
  61818. constructor(name: string);
  61819. /**
  61820. * Gets the current class name
  61821. * @returns the class name
  61822. */
  61823. getClassName(): string;
  61824. /**
  61825. * Gets the input component
  61826. */
  61827. get input(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the output component
  61830. */
  61831. get output(): NodeMaterialConnectionPoint;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. serialize(): any;
  61834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61835. protected _dumpPropertiesCode(): string;
  61836. }
  61837. }
  61838. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61842. /**
  61843. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61844. */
  61845. export class ColorMergerBlock extends NodeMaterialBlock {
  61846. /**
  61847. * Create a new ColorMergerBlock
  61848. * @param name defines the block name
  61849. */
  61850. constructor(name: string);
  61851. /**
  61852. * Gets the current class name
  61853. * @returns the class name
  61854. */
  61855. getClassName(): string;
  61856. /**
  61857. * Gets the rgb component (input)
  61858. */
  61859. get rgbIn(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the r component (input)
  61862. */
  61863. get r(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the g component (input)
  61866. */
  61867. get g(): NodeMaterialConnectionPoint;
  61868. /**
  61869. * Gets the b component (input)
  61870. */
  61871. get b(): NodeMaterialConnectionPoint;
  61872. /**
  61873. * Gets the a component (input)
  61874. */
  61875. get a(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the rgba component (output)
  61878. */
  61879. get rgba(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the rgb component (output)
  61882. */
  61883. get rgbOut(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the rgb component (output)
  61886. * @deprecated Please use rgbOut instead.
  61887. */
  61888. get rgb(): NodeMaterialConnectionPoint;
  61889. protected _buildBlock(state: NodeMaterialBuildState): this;
  61890. }
  61891. }
  61892. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61896. /**
  61897. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61898. */
  61899. export class VectorMergerBlock extends NodeMaterialBlock {
  61900. /**
  61901. * Create a new VectorMergerBlock
  61902. * @param name defines the block name
  61903. */
  61904. constructor(name: string);
  61905. /**
  61906. * Gets the current class name
  61907. * @returns the class name
  61908. */
  61909. getClassName(): string;
  61910. /**
  61911. * Gets the xyz component (input)
  61912. */
  61913. get xyzIn(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the xy component (input)
  61916. */
  61917. get xyIn(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the x component (input)
  61920. */
  61921. get x(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the y component (input)
  61924. */
  61925. get y(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the z component (input)
  61928. */
  61929. get z(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the w component (input)
  61932. */
  61933. get w(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the xyzw component (output)
  61936. */
  61937. get xyzw(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the xyz component (output)
  61940. */
  61941. get xyzOut(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the xy component (output)
  61944. */
  61945. get xyOut(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the xy component (output)
  61948. * @deprecated Please use xyOut instead.
  61949. */
  61950. get xy(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the xyz component (output)
  61953. * @deprecated Please use xyzOut instead.
  61954. */
  61955. get xyz(): NodeMaterialConnectionPoint;
  61956. protected _buildBlock(state: NodeMaterialBuildState): this;
  61957. }
  61958. }
  61959. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61963. /**
  61964. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61965. */
  61966. export class ColorSplitterBlock extends NodeMaterialBlock {
  61967. /**
  61968. * Create a new ColorSplitterBlock
  61969. * @param name defines the block name
  61970. */
  61971. constructor(name: string);
  61972. /**
  61973. * Gets the current class name
  61974. * @returns the class name
  61975. */
  61976. getClassName(): string;
  61977. /**
  61978. * Gets the rgba component (input)
  61979. */
  61980. get rgba(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the rgb component (input)
  61983. */
  61984. get rgbIn(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the rgb component (output)
  61987. */
  61988. get rgbOut(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the r component (output)
  61991. */
  61992. get r(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the g component (output)
  61995. */
  61996. get g(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the b component (output)
  61999. */
  62000. get b(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the a component (output)
  62003. */
  62004. get a(): NodeMaterialConnectionPoint;
  62005. protected _inputRename(name: string): string;
  62006. protected _outputRename(name: string): string;
  62007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62008. }
  62009. }
  62010. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62014. /**
  62015. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62016. */
  62017. export class VectorSplitterBlock extends NodeMaterialBlock {
  62018. /**
  62019. * Create a new VectorSplitterBlock
  62020. * @param name defines the block name
  62021. */
  62022. constructor(name: string);
  62023. /**
  62024. * Gets the current class name
  62025. * @returns the class name
  62026. */
  62027. getClassName(): string;
  62028. /**
  62029. * Gets the xyzw component (input)
  62030. */
  62031. get xyzw(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the xyz component (input)
  62034. */
  62035. get xyzIn(): NodeMaterialConnectionPoint;
  62036. /**
  62037. * Gets the xy component (input)
  62038. */
  62039. get xyIn(): NodeMaterialConnectionPoint;
  62040. /**
  62041. * Gets the xyz component (output)
  62042. */
  62043. get xyzOut(): NodeMaterialConnectionPoint;
  62044. /**
  62045. * Gets the xy component (output)
  62046. */
  62047. get xyOut(): NodeMaterialConnectionPoint;
  62048. /**
  62049. * Gets the x component (output)
  62050. */
  62051. get x(): NodeMaterialConnectionPoint;
  62052. /**
  62053. * Gets the y component (output)
  62054. */
  62055. get y(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the z component (output)
  62058. */
  62059. get z(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the w component (output)
  62062. */
  62063. get w(): NodeMaterialConnectionPoint;
  62064. protected _inputRename(name: string): string;
  62065. protected _outputRename(name: string): string;
  62066. protected _buildBlock(state: NodeMaterialBuildState): this;
  62067. }
  62068. }
  62069. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62073. /**
  62074. * Block used to lerp between 2 values
  62075. */
  62076. export class LerpBlock extends NodeMaterialBlock {
  62077. /**
  62078. * Creates a new LerpBlock
  62079. * @param name defines the block name
  62080. */
  62081. constructor(name: string);
  62082. /**
  62083. * Gets the current class name
  62084. * @returns the class name
  62085. */
  62086. getClassName(): string;
  62087. /**
  62088. * Gets the left operand input component
  62089. */
  62090. get left(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the right operand input component
  62093. */
  62094. get right(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the gradient operand input component
  62097. */
  62098. get gradient(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the output component
  62101. */
  62102. get output(): NodeMaterialConnectionPoint;
  62103. protected _buildBlock(state: NodeMaterialBuildState): this;
  62104. }
  62105. }
  62106. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62108. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62110. /**
  62111. * Block used to divide 2 vectors
  62112. */
  62113. export class DivideBlock extends NodeMaterialBlock {
  62114. /**
  62115. * Creates a new DivideBlock
  62116. * @param name defines the block name
  62117. */
  62118. constructor(name: string);
  62119. /**
  62120. * Gets the current class name
  62121. * @returns the class name
  62122. */
  62123. getClassName(): string;
  62124. /**
  62125. * Gets the left operand input component
  62126. */
  62127. get left(): NodeMaterialConnectionPoint;
  62128. /**
  62129. * Gets the right operand input component
  62130. */
  62131. get right(): NodeMaterialConnectionPoint;
  62132. /**
  62133. * Gets the output component
  62134. */
  62135. get output(): NodeMaterialConnectionPoint;
  62136. protected _buildBlock(state: NodeMaterialBuildState): this;
  62137. }
  62138. }
  62139. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62140. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62143. /**
  62144. * Block used to subtract 2 vectors
  62145. */
  62146. export class SubtractBlock extends NodeMaterialBlock {
  62147. /**
  62148. * Creates a new SubtractBlock
  62149. * @param name defines the block name
  62150. */
  62151. constructor(name: string);
  62152. /**
  62153. * Gets the current class name
  62154. * @returns the class name
  62155. */
  62156. getClassName(): string;
  62157. /**
  62158. * Gets the left operand input component
  62159. */
  62160. get left(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the right operand input component
  62163. */
  62164. get right(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the output component
  62167. */
  62168. get output(): NodeMaterialConnectionPoint;
  62169. protected _buildBlock(state: NodeMaterialBuildState): this;
  62170. }
  62171. }
  62172. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62176. /**
  62177. * Block used to step a value
  62178. */
  62179. export class StepBlock extends NodeMaterialBlock {
  62180. /**
  62181. * Creates a new StepBlock
  62182. * @param name defines the block name
  62183. */
  62184. constructor(name: string);
  62185. /**
  62186. * Gets the current class name
  62187. * @returns the class name
  62188. */
  62189. getClassName(): string;
  62190. /**
  62191. * Gets the value operand input component
  62192. */
  62193. get value(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the edge operand input component
  62196. */
  62197. get edge(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the output component
  62200. */
  62201. get output(): NodeMaterialConnectionPoint;
  62202. protected _buildBlock(state: NodeMaterialBuildState): this;
  62203. }
  62204. }
  62205. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62209. /**
  62210. * Block used to get the opposite (1 - x) of a value
  62211. */
  62212. export class OneMinusBlock extends NodeMaterialBlock {
  62213. /**
  62214. * Creates a new OneMinusBlock
  62215. * @param name defines the block name
  62216. */
  62217. constructor(name: string);
  62218. /**
  62219. * Gets the current class name
  62220. * @returns the class name
  62221. */
  62222. getClassName(): string;
  62223. /**
  62224. * Gets the input component
  62225. */
  62226. get input(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the output component
  62229. */
  62230. get output(): NodeMaterialConnectionPoint;
  62231. protected _buildBlock(state: NodeMaterialBuildState): this;
  62232. }
  62233. }
  62234. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62238. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62239. /**
  62240. * Block used to get the view direction
  62241. */
  62242. export class ViewDirectionBlock extends NodeMaterialBlock {
  62243. /**
  62244. * Creates a new ViewDirectionBlock
  62245. * @param name defines the block name
  62246. */
  62247. constructor(name: string);
  62248. /**
  62249. * Gets the current class name
  62250. * @returns the class name
  62251. */
  62252. getClassName(): string;
  62253. /**
  62254. * Gets the world position component
  62255. */
  62256. get worldPosition(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the camera position component
  62259. */
  62260. get cameraPosition(): NodeMaterialConnectionPoint;
  62261. /**
  62262. * Gets the output component
  62263. */
  62264. get output(): NodeMaterialConnectionPoint;
  62265. autoConfigure(material: NodeMaterial): void;
  62266. protected _buildBlock(state: NodeMaterialBuildState): this;
  62267. }
  62268. }
  62269. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62273. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62274. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62275. /**
  62276. * Block used to compute fresnel value
  62277. */
  62278. export class FresnelBlock extends NodeMaterialBlock {
  62279. /**
  62280. * Create a new FresnelBlock
  62281. * @param name defines the block name
  62282. */
  62283. constructor(name: string);
  62284. /**
  62285. * Gets the current class name
  62286. * @returns the class name
  62287. */
  62288. getClassName(): string;
  62289. /**
  62290. * Gets the world normal input component
  62291. */
  62292. get worldNormal(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the view direction input component
  62295. */
  62296. get viewDirection(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the bias input component
  62299. */
  62300. get bias(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the camera (or eye) position component
  62303. */
  62304. get power(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the fresnel output component
  62307. */
  62308. get fresnel(): NodeMaterialConnectionPoint;
  62309. autoConfigure(material: NodeMaterial): void;
  62310. protected _buildBlock(state: NodeMaterialBuildState): this;
  62311. }
  62312. }
  62313. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62317. /**
  62318. * Block used to get the max of 2 values
  62319. */
  62320. export class MaxBlock extends NodeMaterialBlock {
  62321. /**
  62322. * Creates a new MaxBlock
  62323. * @param name defines the block name
  62324. */
  62325. constructor(name: string);
  62326. /**
  62327. * Gets the current class name
  62328. * @returns the class name
  62329. */
  62330. getClassName(): string;
  62331. /**
  62332. * Gets the left operand input component
  62333. */
  62334. get left(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the right operand input component
  62337. */
  62338. get right(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the output component
  62341. */
  62342. get output(): NodeMaterialConnectionPoint;
  62343. protected _buildBlock(state: NodeMaterialBuildState): this;
  62344. }
  62345. }
  62346. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62350. /**
  62351. * Block used to get the min of 2 values
  62352. */
  62353. export class MinBlock extends NodeMaterialBlock {
  62354. /**
  62355. * Creates a new MinBlock
  62356. * @param name defines the block name
  62357. */
  62358. constructor(name: string);
  62359. /**
  62360. * Gets the current class name
  62361. * @returns the class name
  62362. */
  62363. getClassName(): string;
  62364. /**
  62365. * Gets the left operand input component
  62366. */
  62367. get left(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the right operand input component
  62370. */
  62371. get right(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the output component
  62374. */
  62375. get output(): NodeMaterialConnectionPoint;
  62376. protected _buildBlock(state: NodeMaterialBuildState): this;
  62377. }
  62378. }
  62379. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62383. /**
  62384. * Block used to get the distance between 2 values
  62385. */
  62386. export class DistanceBlock extends NodeMaterialBlock {
  62387. /**
  62388. * Creates a new DistanceBlock
  62389. * @param name defines the block name
  62390. */
  62391. constructor(name: string);
  62392. /**
  62393. * Gets the current class name
  62394. * @returns the class name
  62395. */
  62396. getClassName(): string;
  62397. /**
  62398. * Gets the left operand input component
  62399. */
  62400. get left(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the right operand input component
  62403. */
  62404. get right(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the output component
  62407. */
  62408. get output(): NodeMaterialConnectionPoint;
  62409. protected _buildBlock(state: NodeMaterialBuildState): this;
  62410. }
  62411. }
  62412. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62416. /**
  62417. * Block used to get the length of a vector
  62418. */
  62419. export class LengthBlock extends NodeMaterialBlock {
  62420. /**
  62421. * Creates a new LengthBlock
  62422. * @param name defines the block name
  62423. */
  62424. constructor(name: string);
  62425. /**
  62426. * Gets the current class name
  62427. * @returns the class name
  62428. */
  62429. getClassName(): string;
  62430. /**
  62431. * Gets the value input component
  62432. */
  62433. get value(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the output component
  62436. */
  62437. get output(): NodeMaterialConnectionPoint;
  62438. protected _buildBlock(state: NodeMaterialBuildState): this;
  62439. }
  62440. }
  62441. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62445. /**
  62446. * Block used to get negative version of a value (i.e. x * -1)
  62447. */
  62448. export class NegateBlock extends NodeMaterialBlock {
  62449. /**
  62450. * Creates a new NegateBlock
  62451. * @param name defines the block name
  62452. */
  62453. constructor(name: string);
  62454. /**
  62455. * Gets the current class name
  62456. * @returns the class name
  62457. */
  62458. getClassName(): string;
  62459. /**
  62460. * Gets the value input component
  62461. */
  62462. get value(): NodeMaterialConnectionPoint;
  62463. /**
  62464. * Gets the output component
  62465. */
  62466. get output(): NodeMaterialConnectionPoint;
  62467. protected _buildBlock(state: NodeMaterialBuildState): this;
  62468. }
  62469. }
  62470. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62474. /**
  62475. * Block used to get the value of the first parameter raised to the power of the second
  62476. */
  62477. export class PowBlock extends NodeMaterialBlock {
  62478. /**
  62479. * Creates a new PowBlock
  62480. * @param name defines the block name
  62481. */
  62482. constructor(name: string);
  62483. /**
  62484. * Gets the current class name
  62485. * @returns the class name
  62486. */
  62487. getClassName(): string;
  62488. /**
  62489. * Gets the value operand input component
  62490. */
  62491. get value(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the power operand input component
  62494. */
  62495. get power(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the output component
  62498. */
  62499. get output(): NodeMaterialConnectionPoint;
  62500. protected _buildBlock(state: NodeMaterialBuildState): this;
  62501. }
  62502. }
  62503. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62507. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62508. /**
  62509. * Block used to get a random number
  62510. */
  62511. export class RandomNumberBlock extends NodeMaterialBlock {
  62512. /**
  62513. * Creates a new RandomNumberBlock
  62514. * @param name defines the block name
  62515. */
  62516. constructor(name: string);
  62517. /**
  62518. * Gets the current class name
  62519. * @returns the class name
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Gets the seed input component
  62524. */
  62525. get seed(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the output component
  62528. */
  62529. get output(): NodeMaterialConnectionPoint;
  62530. protected _buildBlock(state: NodeMaterialBuildState): this;
  62531. }
  62532. }
  62533. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62537. /**
  62538. * Block used to compute arc tangent of 2 values
  62539. */
  62540. export class ArcTan2Block extends NodeMaterialBlock {
  62541. /**
  62542. * Creates a new ArcTan2Block
  62543. * @param name defines the block name
  62544. */
  62545. constructor(name: string);
  62546. /**
  62547. * Gets the current class name
  62548. * @returns the class name
  62549. */
  62550. getClassName(): string;
  62551. /**
  62552. * Gets the x operand input component
  62553. */
  62554. get x(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the y operand input component
  62557. */
  62558. get y(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the output component
  62561. */
  62562. get output(): NodeMaterialConnectionPoint;
  62563. protected _buildBlock(state: NodeMaterialBuildState): this;
  62564. }
  62565. }
  62566. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62570. /**
  62571. * Block used to smooth step a value
  62572. */
  62573. export class SmoothStepBlock extends NodeMaterialBlock {
  62574. /**
  62575. * Creates a new SmoothStepBlock
  62576. * @param name defines the block name
  62577. */
  62578. constructor(name: string);
  62579. /**
  62580. * Gets the current class name
  62581. * @returns the class name
  62582. */
  62583. getClassName(): string;
  62584. /**
  62585. * Gets the value operand input component
  62586. */
  62587. get value(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the first edge operand input component
  62590. */
  62591. get edge0(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the second edge operand input component
  62594. */
  62595. get edge1(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the output component
  62598. */
  62599. get output(): NodeMaterialConnectionPoint;
  62600. protected _buildBlock(state: NodeMaterialBuildState): this;
  62601. }
  62602. }
  62603. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62607. /**
  62608. * Block used to get the reciprocal (1 / x) of a value
  62609. */
  62610. export class ReciprocalBlock extends NodeMaterialBlock {
  62611. /**
  62612. * Creates a new ReciprocalBlock
  62613. * @param name defines the block name
  62614. */
  62615. constructor(name: string);
  62616. /**
  62617. * Gets the current class name
  62618. * @returns the class name
  62619. */
  62620. getClassName(): string;
  62621. /**
  62622. * Gets the input component
  62623. */
  62624. get input(): NodeMaterialConnectionPoint;
  62625. /**
  62626. * Gets the output component
  62627. */
  62628. get output(): NodeMaterialConnectionPoint;
  62629. protected _buildBlock(state: NodeMaterialBuildState): this;
  62630. }
  62631. }
  62632. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62636. /**
  62637. * Block used to replace a color by another one
  62638. */
  62639. export class ReplaceColorBlock extends NodeMaterialBlock {
  62640. /**
  62641. * Creates a new ReplaceColorBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the value input component
  62652. */
  62653. get value(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the reference input component
  62656. */
  62657. get reference(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the distance input component
  62660. */
  62661. get distance(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the replacement input component
  62664. */
  62665. get replacement(): NodeMaterialConnectionPoint;
  62666. /**
  62667. * Gets the output component
  62668. */
  62669. get output(): NodeMaterialConnectionPoint;
  62670. protected _buildBlock(state: NodeMaterialBuildState): this;
  62671. }
  62672. }
  62673. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62677. /**
  62678. * Block used to posterize a value
  62679. * @see https://en.wikipedia.org/wiki/Posterization
  62680. */
  62681. export class PosterizeBlock extends NodeMaterialBlock {
  62682. /**
  62683. * Creates a new PosterizeBlock
  62684. * @param name defines the block name
  62685. */
  62686. constructor(name: string);
  62687. /**
  62688. * Gets the current class name
  62689. * @returns the class name
  62690. */
  62691. getClassName(): string;
  62692. /**
  62693. * Gets the value input component
  62694. */
  62695. get value(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the steps input component
  62698. */
  62699. get steps(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the output component
  62702. */
  62703. get output(): NodeMaterialConnectionPoint;
  62704. protected _buildBlock(state: NodeMaterialBuildState): this;
  62705. }
  62706. }
  62707. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62711. import { Scene } from "babylonjs/scene";
  62712. /**
  62713. * Operations supported by the Wave block
  62714. */
  62715. export enum WaveBlockKind {
  62716. /** SawTooth */
  62717. SawTooth = 0,
  62718. /** Square */
  62719. Square = 1,
  62720. /** Triangle */
  62721. Triangle = 2
  62722. }
  62723. /**
  62724. * Block used to apply wave operation to floats
  62725. */
  62726. export class WaveBlock extends NodeMaterialBlock {
  62727. /**
  62728. * Gets or sets the kibnd of wave to be applied by the block
  62729. */
  62730. kind: WaveBlockKind;
  62731. /**
  62732. * Creates a new WaveBlock
  62733. * @param name defines the block name
  62734. */
  62735. constructor(name: string);
  62736. /**
  62737. * Gets the current class name
  62738. * @returns the class name
  62739. */
  62740. getClassName(): string;
  62741. /**
  62742. * Gets the input component
  62743. */
  62744. get input(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the output component
  62747. */
  62748. get output(): NodeMaterialConnectionPoint;
  62749. protected _buildBlock(state: NodeMaterialBuildState): this;
  62750. serialize(): any;
  62751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62752. }
  62753. }
  62754. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62758. import { Color3 } from "babylonjs/Maths/math.color";
  62759. import { Scene } from "babylonjs/scene";
  62760. /**
  62761. * Class used to store a color step for the GradientBlock
  62762. */
  62763. export class GradientBlockColorStep {
  62764. /**
  62765. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62766. */
  62767. step: number;
  62768. /**
  62769. * Gets or sets the color associated with this step
  62770. */
  62771. color: Color3;
  62772. /**
  62773. * Creates a new GradientBlockColorStep
  62774. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62775. * @param color defines the color associated with this step
  62776. */
  62777. constructor(
  62778. /**
  62779. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62780. */
  62781. step: number,
  62782. /**
  62783. * Gets or sets the color associated with this step
  62784. */
  62785. color: Color3);
  62786. }
  62787. /**
  62788. * Block used to return a color from a gradient based on an input value between 0 and 1
  62789. */
  62790. export class GradientBlock extends NodeMaterialBlock {
  62791. /**
  62792. * Gets or sets the list of color steps
  62793. */
  62794. colorSteps: GradientBlockColorStep[];
  62795. /**
  62796. * Creates a new GradientBlock
  62797. * @param name defines the block name
  62798. */
  62799. constructor(name: string);
  62800. /**
  62801. * Gets the current class name
  62802. * @returns the class name
  62803. */
  62804. getClassName(): string;
  62805. /**
  62806. * Gets the gradient input component
  62807. */
  62808. get gradient(): NodeMaterialConnectionPoint;
  62809. /**
  62810. * Gets the output component
  62811. */
  62812. get output(): NodeMaterialConnectionPoint;
  62813. private _writeColorConstant;
  62814. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62815. serialize(): any;
  62816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62817. protected _dumpPropertiesCode(): string;
  62818. }
  62819. }
  62820. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62824. /**
  62825. * Block used to normalize lerp between 2 values
  62826. */
  62827. export class NLerpBlock extends NodeMaterialBlock {
  62828. /**
  62829. * Creates a new NLerpBlock
  62830. * @param name defines the block name
  62831. */
  62832. constructor(name: string);
  62833. /**
  62834. * Gets the current class name
  62835. * @returns the class name
  62836. */
  62837. getClassName(): string;
  62838. /**
  62839. * Gets the left operand input component
  62840. */
  62841. get left(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the right operand input component
  62844. */
  62845. get right(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the gradient operand input component
  62848. */
  62849. get gradient(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the output component
  62852. */
  62853. get output(): NodeMaterialConnectionPoint;
  62854. protected _buildBlock(state: NodeMaterialBuildState): this;
  62855. }
  62856. }
  62857. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62861. import { Scene } from "babylonjs/scene";
  62862. /**
  62863. * block used to Generate a Worley Noise 3D Noise Pattern
  62864. */
  62865. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62866. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62867. manhattanDistance: boolean;
  62868. /**
  62869. * Creates a new WorleyNoise3DBlock
  62870. * @param name defines the block name
  62871. */
  62872. constructor(name: string);
  62873. /**
  62874. * Gets the current class name
  62875. * @returns the class name
  62876. */
  62877. getClassName(): string;
  62878. /**
  62879. * Gets the seed input component
  62880. */
  62881. get seed(): NodeMaterialConnectionPoint;
  62882. /**
  62883. * Gets the jitter input component
  62884. */
  62885. get jitter(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the output component
  62888. */
  62889. get output(): NodeMaterialConnectionPoint;
  62890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62891. /**
  62892. * Exposes the properties to the UI?
  62893. */
  62894. protected _dumpPropertiesCode(): string;
  62895. /**
  62896. * Exposes the properties to the Seralize?
  62897. */
  62898. serialize(): any;
  62899. /**
  62900. * Exposes the properties to the deseralize?
  62901. */
  62902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62903. }
  62904. }
  62905. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62909. /**
  62910. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62911. */
  62912. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62913. /**
  62914. * Creates a new SimplexPerlin3DBlock
  62915. * @param name defines the block name
  62916. */
  62917. constructor(name: string);
  62918. /**
  62919. * Gets the current class name
  62920. * @returns the class name
  62921. */
  62922. getClassName(): string;
  62923. /**
  62924. * Gets the seed operand input component
  62925. */
  62926. get seed(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the output component
  62929. */
  62930. get output(): NodeMaterialConnectionPoint;
  62931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62932. }
  62933. }
  62934. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62938. /**
  62939. * Block used to blend normals
  62940. */
  62941. export class NormalBlendBlock extends NodeMaterialBlock {
  62942. /**
  62943. * Creates a new NormalBlendBlock
  62944. * @param name defines the block name
  62945. */
  62946. constructor(name: string);
  62947. /**
  62948. * Gets the current class name
  62949. * @returns the class name
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Gets the first input component
  62954. */
  62955. get normalMap0(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the second input component
  62958. */
  62959. get normalMap1(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the output component
  62962. */
  62963. get output(): NodeMaterialConnectionPoint;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. }
  62966. }
  62967. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62971. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62972. /**
  62973. * Block used to rotate a 2d vector by a given angle
  62974. */
  62975. export class Rotate2dBlock extends NodeMaterialBlock {
  62976. /**
  62977. * Creates a new Rotate2dBlock
  62978. * @param name defines the block name
  62979. */
  62980. constructor(name: string);
  62981. /**
  62982. * Gets the current class name
  62983. * @returns the class name
  62984. */
  62985. getClassName(): string;
  62986. /**
  62987. * Gets the input vector
  62988. */
  62989. get input(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the input angle
  62992. */
  62993. get angle(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the output component
  62996. */
  62997. get output(): NodeMaterialConnectionPoint;
  62998. autoConfigure(material: NodeMaterial): void;
  62999. protected _buildBlock(state: NodeMaterialBuildState): this;
  63000. }
  63001. }
  63002. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63006. /**
  63007. * Block used to get the reflected vector from a direction and a normal
  63008. */
  63009. export class ReflectBlock extends NodeMaterialBlock {
  63010. /**
  63011. * Creates a new ReflectBlock
  63012. * @param name defines the block name
  63013. */
  63014. constructor(name: string);
  63015. /**
  63016. * Gets the current class name
  63017. * @returns the class name
  63018. */
  63019. getClassName(): string;
  63020. /**
  63021. * Gets the incident component
  63022. */
  63023. get incident(): NodeMaterialConnectionPoint;
  63024. /**
  63025. * Gets the normal component
  63026. */
  63027. get normal(): NodeMaterialConnectionPoint;
  63028. /**
  63029. * Gets the output component
  63030. */
  63031. get output(): NodeMaterialConnectionPoint;
  63032. protected _buildBlock(state: NodeMaterialBuildState): this;
  63033. }
  63034. }
  63035. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63039. /**
  63040. * Block used to get the refracted vector from a direction and a normal
  63041. */
  63042. export class RefractBlock extends NodeMaterialBlock {
  63043. /**
  63044. * Creates a new RefractBlock
  63045. * @param name defines the block name
  63046. */
  63047. constructor(name: string);
  63048. /**
  63049. * Gets the current class name
  63050. * @returns the class name
  63051. */
  63052. getClassName(): string;
  63053. /**
  63054. * Gets the incident component
  63055. */
  63056. get incident(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the normal component
  63059. */
  63060. get normal(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the index of refraction component
  63063. */
  63064. get ior(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the output component
  63067. */
  63068. get output(): NodeMaterialConnectionPoint;
  63069. protected _buildBlock(state: NodeMaterialBuildState): this;
  63070. }
  63071. }
  63072. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63076. /**
  63077. * Block used to desaturate a color
  63078. */
  63079. export class DesaturateBlock extends NodeMaterialBlock {
  63080. /**
  63081. * Creates a new DesaturateBlock
  63082. * @param name defines the block name
  63083. */
  63084. constructor(name: string);
  63085. /**
  63086. * Gets the current class name
  63087. * @returns the class name
  63088. */
  63089. getClassName(): string;
  63090. /**
  63091. * Gets the color operand input component
  63092. */
  63093. get color(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the level operand input component
  63096. */
  63097. get level(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the output component
  63100. */
  63101. get output(): NodeMaterialConnectionPoint;
  63102. protected _buildBlock(state: NodeMaterialBuildState): this;
  63103. }
  63104. }
  63105. declare module "babylonjs/Materials/Node/Blocks/index" {
  63106. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63107. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63108. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63109. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63110. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63111. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63112. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63113. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63114. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63115. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63116. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63117. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63118. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63119. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63120. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63121. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63122. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63123. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63124. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63125. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63126. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63127. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63128. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63129. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63130. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63131. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63132. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63133. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63134. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63135. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63136. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63137. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63138. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63139. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63140. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63141. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63142. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63143. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63144. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63145. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63147. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63148. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63149. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63150. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63151. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63152. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63153. }
  63154. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63155. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63156. }
  63157. declare module "babylonjs/Materials/Node/index" {
  63158. export * from "babylonjs/Materials/Node/Enums/index";
  63159. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63160. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63161. export * from "babylonjs/Materials/Node/nodeMaterial";
  63162. export * from "babylonjs/Materials/Node/Blocks/index";
  63163. export * from "babylonjs/Materials/Node/Optimizers/index";
  63164. }
  63165. declare module "babylonjs/Materials/effectRenderer" {
  63166. import { Nullable } from "babylonjs/types";
  63167. import { Texture } from "babylonjs/Materials/Textures/texture";
  63168. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63169. import { Viewport } from "babylonjs/Maths/math.viewport";
  63170. import { Observable } from "babylonjs/Misc/observable";
  63171. import { Effect } from "babylonjs/Materials/effect";
  63172. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63173. import "babylonjs/Shaders/postprocess.vertex";
  63174. /**
  63175. * Effect Render Options
  63176. */
  63177. export interface IEffectRendererOptions {
  63178. /**
  63179. * Defines the vertices positions.
  63180. */
  63181. positions?: number[];
  63182. /**
  63183. * Defines the indices.
  63184. */
  63185. indices?: number[];
  63186. }
  63187. /**
  63188. * Helper class to render one or more effects
  63189. */
  63190. export class EffectRenderer {
  63191. private engine;
  63192. private static _DefaultOptions;
  63193. private _vertexBuffers;
  63194. private _indexBuffer;
  63195. private _ringBufferIndex;
  63196. private _ringScreenBuffer;
  63197. private _fullscreenViewport;
  63198. private _getNextFrameBuffer;
  63199. /**
  63200. * Creates an effect renderer
  63201. * @param engine the engine to use for rendering
  63202. * @param options defines the options of the effect renderer
  63203. */
  63204. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63205. /**
  63206. * Sets the current viewport in normalized coordinates 0-1
  63207. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63208. */
  63209. setViewport(viewport?: Viewport): void;
  63210. /**
  63211. * Binds the embedded attributes buffer to the effect.
  63212. * @param effect Defines the effect to bind the attributes for
  63213. */
  63214. bindBuffers(effect: Effect): void;
  63215. /**
  63216. * Sets the current effect wrapper to use during draw.
  63217. * The effect needs to be ready before calling this api.
  63218. * This also sets the default full screen position attribute.
  63219. * @param effectWrapper Defines the effect to draw with
  63220. */
  63221. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63222. /**
  63223. * Draws a full screen quad.
  63224. */
  63225. draw(): void;
  63226. /**
  63227. * renders one or more effects to a specified texture
  63228. * @param effectWrappers list of effects to renderer
  63229. * @param outputTexture texture to draw to, if null it will render to the screen
  63230. */
  63231. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63232. /**
  63233. * Disposes of the effect renderer
  63234. */
  63235. dispose(): void;
  63236. }
  63237. /**
  63238. * Options to create an EffectWrapper
  63239. */
  63240. interface EffectWrapperCreationOptions {
  63241. /**
  63242. * Engine to use to create the effect
  63243. */
  63244. engine: ThinEngine;
  63245. /**
  63246. * Fragment shader for the effect
  63247. */
  63248. fragmentShader: string;
  63249. /**
  63250. * Vertex shader for the effect
  63251. */
  63252. vertexShader?: string;
  63253. /**
  63254. * Attributes to use in the shader
  63255. */
  63256. attributeNames?: Array<string>;
  63257. /**
  63258. * Uniforms to use in the shader
  63259. */
  63260. uniformNames?: Array<string>;
  63261. /**
  63262. * Texture sampler names to use in the shader
  63263. */
  63264. samplerNames?: Array<string>;
  63265. /**
  63266. * The friendly name of the effect displayed in Spector.
  63267. */
  63268. name?: string;
  63269. }
  63270. /**
  63271. * Wraps an effect to be used for rendering
  63272. */
  63273. export class EffectWrapper {
  63274. /**
  63275. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63276. */
  63277. onApplyObservable: Observable<{}>;
  63278. /**
  63279. * The underlying effect
  63280. */
  63281. effect: Effect;
  63282. /**
  63283. * Creates an effect to be renderer
  63284. * @param creationOptions options to create the effect
  63285. */
  63286. constructor(creationOptions: EffectWrapperCreationOptions);
  63287. /**
  63288. * Disposes of the effect wrapper
  63289. */
  63290. dispose(): void;
  63291. }
  63292. }
  63293. declare module "babylonjs/Materials/index" {
  63294. export * from "babylonjs/Materials/Background/index";
  63295. export * from "babylonjs/Materials/colorCurves";
  63296. export * from "babylonjs/Materials/iEffectFallbacks";
  63297. export * from "babylonjs/Materials/effectFallbacks";
  63298. export * from "babylonjs/Materials/effect";
  63299. export * from "babylonjs/Materials/fresnelParameters";
  63300. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63301. export * from "babylonjs/Materials/material";
  63302. export * from "babylonjs/Materials/materialDefines";
  63303. export * from "babylonjs/Materials/materialHelper";
  63304. export * from "babylonjs/Materials/multiMaterial";
  63305. export * from "babylonjs/Materials/PBR/index";
  63306. export * from "babylonjs/Materials/pushMaterial";
  63307. export * from "babylonjs/Materials/shaderMaterial";
  63308. export * from "babylonjs/Materials/standardMaterial";
  63309. export * from "babylonjs/Materials/Textures/index";
  63310. export * from "babylonjs/Materials/uniformBuffer";
  63311. export * from "babylonjs/Materials/materialFlags";
  63312. export * from "babylonjs/Materials/Node/index";
  63313. export * from "babylonjs/Materials/effectRenderer";
  63314. }
  63315. declare module "babylonjs/Maths/index" {
  63316. export * from "babylonjs/Maths/math.scalar";
  63317. export * from "babylonjs/Maths/math";
  63318. export * from "babylonjs/Maths/sphericalPolynomial";
  63319. }
  63320. declare module "babylonjs/Misc/workerPool" {
  63321. import { IDisposable } from "babylonjs/scene";
  63322. /**
  63323. * Helper class to push actions to a pool of workers.
  63324. */
  63325. export class WorkerPool implements IDisposable {
  63326. private _workerInfos;
  63327. private _pendingActions;
  63328. /**
  63329. * Constructor
  63330. * @param workers Array of workers to use for actions
  63331. */
  63332. constructor(workers: Array<Worker>);
  63333. /**
  63334. * Terminates all workers and clears any pending actions.
  63335. */
  63336. dispose(): void;
  63337. /**
  63338. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63339. * pended until a worker has completed its action.
  63340. * @param action The action to perform. Call onComplete when the action is complete.
  63341. */
  63342. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63343. private _execute;
  63344. }
  63345. }
  63346. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63347. import { IDisposable } from "babylonjs/scene";
  63348. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63349. /**
  63350. * Configuration for Draco compression
  63351. */
  63352. export interface IDracoCompressionConfiguration {
  63353. /**
  63354. * Configuration for the decoder.
  63355. */
  63356. decoder: {
  63357. /**
  63358. * The url to the WebAssembly module.
  63359. */
  63360. wasmUrl?: string;
  63361. /**
  63362. * The url to the WebAssembly binary.
  63363. */
  63364. wasmBinaryUrl?: string;
  63365. /**
  63366. * The url to the fallback JavaScript module.
  63367. */
  63368. fallbackUrl?: string;
  63369. };
  63370. }
  63371. /**
  63372. * Draco compression (https://google.github.io/draco/)
  63373. *
  63374. * This class wraps the Draco module.
  63375. *
  63376. * **Encoder**
  63377. *
  63378. * The encoder is not currently implemented.
  63379. *
  63380. * **Decoder**
  63381. *
  63382. * 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.
  63383. *
  63384. * To update the configuration, use the following code:
  63385. * ```javascript
  63386. * DracoCompression.Configuration = {
  63387. * decoder: {
  63388. * wasmUrl: "<url to the WebAssembly library>",
  63389. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63390. * fallbackUrl: "<url to the fallback JavaScript library>",
  63391. * }
  63392. * };
  63393. * ```
  63394. *
  63395. * 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.
  63396. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63397. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63398. *
  63399. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63400. * ```javascript
  63401. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63402. * ```
  63403. *
  63404. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63405. */
  63406. export class DracoCompression implements IDisposable {
  63407. private _workerPoolPromise?;
  63408. private _decoderModulePromise?;
  63409. /**
  63410. * The configuration. Defaults to the following urls:
  63411. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63412. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63413. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63414. */
  63415. static Configuration: IDracoCompressionConfiguration;
  63416. /**
  63417. * Returns true if the decoder configuration is available.
  63418. */
  63419. static get DecoderAvailable(): boolean;
  63420. /**
  63421. * Default number of workers to create when creating the draco compression object.
  63422. */
  63423. static DefaultNumWorkers: number;
  63424. private static GetDefaultNumWorkers;
  63425. private static _Default;
  63426. /**
  63427. * Default instance for the draco compression object.
  63428. */
  63429. static get Default(): DracoCompression;
  63430. /**
  63431. * Constructor
  63432. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63433. */
  63434. constructor(numWorkers?: number);
  63435. /**
  63436. * Stop all async operations and release resources.
  63437. */
  63438. dispose(): void;
  63439. /**
  63440. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63441. * @returns a promise that resolves when ready
  63442. */
  63443. whenReadyAsync(): Promise<void>;
  63444. /**
  63445. * Decode Draco compressed mesh data to vertex data.
  63446. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63447. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63448. * @returns A promise that resolves with the decoded vertex data
  63449. */
  63450. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63451. [kind: string]: number;
  63452. }): Promise<VertexData>;
  63453. }
  63454. }
  63455. declare module "babylonjs/Meshes/Compression/index" {
  63456. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63457. }
  63458. declare module "babylonjs/Meshes/csg" {
  63459. import { Nullable } from "babylonjs/types";
  63460. import { Scene } from "babylonjs/scene";
  63461. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63462. import { Mesh } from "babylonjs/Meshes/mesh";
  63463. import { Material } from "babylonjs/Materials/material";
  63464. /**
  63465. * Class for building Constructive Solid Geometry
  63466. */
  63467. export class CSG {
  63468. private polygons;
  63469. /**
  63470. * The world matrix
  63471. */
  63472. matrix: Matrix;
  63473. /**
  63474. * Stores the position
  63475. */
  63476. position: Vector3;
  63477. /**
  63478. * Stores the rotation
  63479. */
  63480. rotation: Vector3;
  63481. /**
  63482. * Stores the rotation quaternion
  63483. */
  63484. rotationQuaternion: Nullable<Quaternion>;
  63485. /**
  63486. * Stores the scaling vector
  63487. */
  63488. scaling: Vector3;
  63489. /**
  63490. * Convert the Mesh to CSG
  63491. * @param mesh The Mesh to convert to CSG
  63492. * @returns A new CSG from the Mesh
  63493. */
  63494. static FromMesh(mesh: Mesh): CSG;
  63495. /**
  63496. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63497. * @param polygons Polygons used to construct a CSG solid
  63498. */
  63499. private static FromPolygons;
  63500. /**
  63501. * Clones, or makes a deep copy, of the CSG
  63502. * @returns A new CSG
  63503. */
  63504. clone(): CSG;
  63505. /**
  63506. * Unions this CSG with another CSG
  63507. * @param csg The CSG to union against this CSG
  63508. * @returns The unioned CSG
  63509. */
  63510. union(csg: CSG): CSG;
  63511. /**
  63512. * Unions this CSG with another CSG in place
  63513. * @param csg The CSG to union against this CSG
  63514. */
  63515. unionInPlace(csg: CSG): void;
  63516. /**
  63517. * Subtracts this CSG with another CSG
  63518. * @param csg The CSG to subtract against this CSG
  63519. * @returns A new CSG
  63520. */
  63521. subtract(csg: CSG): CSG;
  63522. /**
  63523. * Subtracts this CSG with another CSG in place
  63524. * @param csg The CSG to subtact against this CSG
  63525. */
  63526. subtractInPlace(csg: CSG): void;
  63527. /**
  63528. * Intersect this CSG with another CSG
  63529. * @param csg The CSG to intersect against this CSG
  63530. * @returns A new CSG
  63531. */
  63532. intersect(csg: CSG): CSG;
  63533. /**
  63534. * Intersects this CSG with another CSG in place
  63535. * @param csg The CSG to intersect against this CSG
  63536. */
  63537. intersectInPlace(csg: CSG): void;
  63538. /**
  63539. * Return a new CSG solid with solid and empty space switched. This solid is
  63540. * not modified.
  63541. * @returns A new CSG solid with solid and empty space switched
  63542. */
  63543. inverse(): CSG;
  63544. /**
  63545. * Inverses the CSG in place
  63546. */
  63547. inverseInPlace(): void;
  63548. /**
  63549. * This is used to keep meshes transformations so they can be restored
  63550. * when we build back a Babylon Mesh
  63551. * NB : All CSG operations are performed in world coordinates
  63552. * @param csg The CSG to copy the transform attributes from
  63553. * @returns This CSG
  63554. */
  63555. copyTransformAttributes(csg: CSG): CSG;
  63556. /**
  63557. * Build Raw mesh from CSG
  63558. * Coordinates here are in world space
  63559. * @param name The name of the mesh geometry
  63560. * @param scene The Scene
  63561. * @param keepSubMeshes Specifies if the submeshes should be kept
  63562. * @returns A new Mesh
  63563. */
  63564. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63565. /**
  63566. * Build Mesh from CSG taking material and transforms into account
  63567. * @param name The name of the Mesh
  63568. * @param material The material of the Mesh
  63569. * @param scene The Scene
  63570. * @param keepSubMeshes Specifies if submeshes should be kept
  63571. * @returns The new Mesh
  63572. */
  63573. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63574. }
  63575. }
  63576. declare module "babylonjs/Meshes/trailMesh" {
  63577. import { Mesh } from "babylonjs/Meshes/mesh";
  63578. import { Scene } from "babylonjs/scene";
  63579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63580. /**
  63581. * Class used to create a trail following a mesh
  63582. */
  63583. export class TrailMesh extends Mesh {
  63584. private _generator;
  63585. private _autoStart;
  63586. private _running;
  63587. private _diameter;
  63588. private _length;
  63589. private _sectionPolygonPointsCount;
  63590. private _sectionVectors;
  63591. private _sectionNormalVectors;
  63592. private _beforeRenderObserver;
  63593. /**
  63594. * @constructor
  63595. * @param name The value used by scene.getMeshByName() to do a lookup.
  63596. * @param generator The mesh or transform node to generate a trail.
  63597. * @param scene The scene to add this mesh to.
  63598. * @param diameter Diameter of trailing mesh. Default is 1.
  63599. * @param length Length of trailing mesh. Default is 60.
  63600. * @param autoStart Automatically start trailing mesh. Default true.
  63601. */
  63602. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63603. /**
  63604. * "TrailMesh"
  63605. * @returns "TrailMesh"
  63606. */
  63607. getClassName(): string;
  63608. private _createMesh;
  63609. /**
  63610. * Start trailing mesh.
  63611. */
  63612. start(): void;
  63613. /**
  63614. * Stop trailing mesh.
  63615. */
  63616. stop(): void;
  63617. /**
  63618. * Update trailing mesh geometry.
  63619. */
  63620. update(): void;
  63621. /**
  63622. * Returns a new TrailMesh object.
  63623. * @param name is a string, the name given to the new mesh
  63624. * @param newGenerator use new generator object for cloned trail mesh
  63625. * @returns a new mesh
  63626. */
  63627. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63628. /**
  63629. * Serializes this trail mesh
  63630. * @param serializationObject object to write serialization to
  63631. */
  63632. serialize(serializationObject: any): void;
  63633. /**
  63634. * Parses a serialized trail mesh
  63635. * @param parsedMesh the serialized mesh
  63636. * @param scene the scene to create the trail mesh in
  63637. * @returns the created trail mesh
  63638. */
  63639. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63640. }
  63641. }
  63642. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63643. import { Nullable } from "babylonjs/types";
  63644. import { Scene } from "babylonjs/scene";
  63645. import { Vector4 } from "babylonjs/Maths/math.vector";
  63646. import { Color4 } from "babylonjs/Maths/math.color";
  63647. import { Mesh } from "babylonjs/Meshes/mesh";
  63648. /**
  63649. * Class containing static functions to help procedurally build meshes
  63650. */
  63651. export class TiledBoxBuilder {
  63652. /**
  63653. * Creates a box mesh
  63654. * 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)
  63655. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63659. * @param name defines the name of the mesh
  63660. * @param options defines the options used to create the mesh
  63661. * @param scene defines the hosting scene
  63662. * @returns the box mesh
  63663. */
  63664. static CreateTiledBox(name: string, options: {
  63665. pattern?: number;
  63666. width?: number;
  63667. height?: number;
  63668. depth?: number;
  63669. tileSize?: number;
  63670. tileWidth?: number;
  63671. tileHeight?: number;
  63672. alignHorizontal?: number;
  63673. alignVertical?: number;
  63674. faceUV?: Vector4[];
  63675. faceColors?: Color4[];
  63676. sideOrientation?: number;
  63677. updatable?: boolean;
  63678. }, scene?: Nullable<Scene>): Mesh;
  63679. }
  63680. }
  63681. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63682. import { Vector4 } from "babylonjs/Maths/math.vector";
  63683. import { Mesh } from "babylonjs/Meshes/mesh";
  63684. /**
  63685. * Class containing static functions to help procedurally build meshes
  63686. */
  63687. export class TorusKnotBuilder {
  63688. /**
  63689. * Creates a torus knot mesh
  63690. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63691. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63692. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63693. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63697. * @param name defines the name of the mesh
  63698. * @param options defines the options used to create the mesh
  63699. * @param scene defines the hosting scene
  63700. * @returns the torus knot mesh
  63701. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63702. */
  63703. static CreateTorusKnot(name: string, options: {
  63704. radius?: number;
  63705. tube?: number;
  63706. radialSegments?: number;
  63707. tubularSegments?: number;
  63708. p?: number;
  63709. q?: number;
  63710. updatable?: boolean;
  63711. sideOrientation?: number;
  63712. frontUVs?: Vector4;
  63713. backUVs?: Vector4;
  63714. }, scene: any): Mesh;
  63715. }
  63716. }
  63717. declare module "babylonjs/Meshes/polygonMesh" {
  63718. import { Scene } from "babylonjs/scene";
  63719. import { Vector2 } from "babylonjs/Maths/math.vector";
  63720. import { Mesh } from "babylonjs/Meshes/mesh";
  63721. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63722. import { Path2 } from "babylonjs/Maths/math.path";
  63723. /**
  63724. * Polygon
  63725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63726. */
  63727. export class Polygon {
  63728. /**
  63729. * Creates a rectangle
  63730. * @param xmin bottom X coord
  63731. * @param ymin bottom Y coord
  63732. * @param xmax top X coord
  63733. * @param ymax top Y coord
  63734. * @returns points that make the resulting rectation
  63735. */
  63736. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63737. /**
  63738. * Creates a circle
  63739. * @param radius radius of circle
  63740. * @param cx scale in x
  63741. * @param cy scale in y
  63742. * @param numberOfSides number of sides that make up the circle
  63743. * @returns points that make the resulting circle
  63744. */
  63745. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63746. /**
  63747. * Creates a polygon from input string
  63748. * @param input Input polygon data
  63749. * @returns the parsed points
  63750. */
  63751. static Parse(input: string): Vector2[];
  63752. /**
  63753. * Starts building a polygon from x and y coordinates
  63754. * @param x x coordinate
  63755. * @param y y coordinate
  63756. * @returns the started path2
  63757. */
  63758. static StartingAt(x: number, y: number): Path2;
  63759. }
  63760. /**
  63761. * Builds a polygon
  63762. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63763. */
  63764. export class PolygonMeshBuilder {
  63765. private _points;
  63766. private _outlinepoints;
  63767. private _holes;
  63768. private _name;
  63769. private _scene;
  63770. private _epoints;
  63771. private _eholes;
  63772. private _addToepoint;
  63773. /**
  63774. * Babylon reference to the earcut plugin.
  63775. */
  63776. bjsEarcut: any;
  63777. /**
  63778. * Creates a PolygonMeshBuilder
  63779. * @param name name of the builder
  63780. * @param contours Path of the polygon
  63781. * @param scene scene to add to when creating the mesh
  63782. * @param earcutInjection can be used to inject your own earcut reference
  63783. */
  63784. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63785. /**
  63786. * Adds a whole within the polygon
  63787. * @param hole Array of points defining the hole
  63788. * @returns this
  63789. */
  63790. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63791. /**
  63792. * Creates the polygon
  63793. * @param updatable If the mesh should be updatable
  63794. * @param depth The depth of the mesh created
  63795. * @returns the created mesh
  63796. */
  63797. build(updatable?: boolean, depth?: number): Mesh;
  63798. /**
  63799. * Creates the polygon
  63800. * @param depth The depth of the mesh created
  63801. * @returns the created VertexData
  63802. */
  63803. buildVertexData(depth?: number): VertexData;
  63804. /**
  63805. * Adds a side to the polygon
  63806. * @param positions points that make the polygon
  63807. * @param normals normals of the polygon
  63808. * @param uvs uvs of the polygon
  63809. * @param indices indices of the polygon
  63810. * @param bounds bounds of the polygon
  63811. * @param points points of the polygon
  63812. * @param depth depth of the polygon
  63813. * @param flip flip of the polygon
  63814. */
  63815. private addSide;
  63816. }
  63817. }
  63818. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63819. import { Scene } from "babylonjs/scene";
  63820. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63821. import { Color4 } from "babylonjs/Maths/math.color";
  63822. import { Mesh } from "babylonjs/Meshes/mesh";
  63823. import { Nullable } from "babylonjs/types";
  63824. /**
  63825. * Class containing static functions to help procedurally build meshes
  63826. */
  63827. export class PolygonBuilder {
  63828. /**
  63829. * Creates a polygon mesh
  63830. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63831. * * 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
  63832. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63835. * * Remember you can only change the shape positions, not their number when updating a polygon
  63836. * @param name defines the name of the mesh
  63837. * @param options defines the options used to create the mesh
  63838. * @param scene defines the hosting scene
  63839. * @param earcutInjection can be used to inject your own earcut reference
  63840. * @returns the polygon mesh
  63841. */
  63842. static CreatePolygon(name: string, options: {
  63843. shape: Vector3[];
  63844. holes?: Vector3[][];
  63845. depth?: number;
  63846. faceUV?: Vector4[];
  63847. faceColors?: Color4[];
  63848. updatable?: boolean;
  63849. sideOrientation?: number;
  63850. frontUVs?: Vector4;
  63851. backUVs?: Vector4;
  63852. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63853. /**
  63854. * Creates an extruded polygon mesh, with depth in the Y direction.
  63855. * * 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)
  63856. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63857. * @param name defines the name of the mesh
  63858. * @param options defines the options used to create the mesh
  63859. * @param scene defines the hosting scene
  63860. * @param earcutInjection can be used to inject your own earcut reference
  63861. * @returns the polygon mesh
  63862. */
  63863. static ExtrudePolygon(name: string, options: {
  63864. shape: Vector3[];
  63865. holes?: Vector3[][];
  63866. depth?: number;
  63867. faceUV?: Vector4[];
  63868. faceColors?: Color4[];
  63869. updatable?: boolean;
  63870. sideOrientation?: number;
  63871. frontUVs?: Vector4;
  63872. backUVs?: Vector4;
  63873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63874. }
  63875. }
  63876. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63877. import { Scene } from "babylonjs/scene";
  63878. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63879. import { Mesh } from "babylonjs/Meshes/mesh";
  63880. import { Nullable } from "babylonjs/types";
  63881. /**
  63882. * Class containing static functions to help procedurally build meshes
  63883. */
  63884. export class LatheBuilder {
  63885. /**
  63886. * Creates lathe mesh.
  63887. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63888. * * 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
  63889. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63890. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63891. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63892. * * 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
  63893. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63894. * * 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
  63895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63899. * @param name defines the name of the mesh
  63900. * @param options defines the options used to create the mesh
  63901. * @param scene defines the hosting scene
  63902. * @returns the lathe mesh
  63903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63904. */
  63905. static CreateLathe(name: string, options: {
  63906. shape: Vector3[];
  63907. radius?: number;
  63908. tessellation?: number;
  63909. clip?: number;
  63910. arc?: number;
  63911. closed?: boolean;
  63912. updatable?: boolean;
  63913. sideOrientation?: number;
  63914. frontUVs?: Vector4;
  63915. backUVs?: Vector4;
  63916. cap?: number;
  63917. invertUV?: boolean;
  63918. }, scene?: Nullable<Scene>): Mesh;
  63919. }
  63920. }
  63921. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63922. import { Nullable } from "babylonjs/types";
  63923. import { Scene } from "babylonjs/scene";
  63924. import { Vector4 } from "babylonjs/Maths/math.vector";
  63925. import { Mesh } from "babylonjs/Meshes/mesh";
  63926. /**
  63927. * Class containing static functions to help procedurally build meshes
  63928. */
  63929. export class TiledPlaneBuilder {
  63930. /**
  63931. * Creates a tiled plane mesh
  63932. * * The parameter `pattern` will, depending on value, do nothing or
  63933. * * * flip (reflect about central vertical) alternate tiles across and up
  63934. * * * flip every tile on alternate rows
  63935. * * * rotate (180 degs) alternate tiles across and up
  63936. * * * rotate every tile on alternate rows
  63937. * * * flip and rotate alternate tiles across and up
  63938. * * * flip and rotate every tile on alternate rows
  63939. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63940. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63943. * * 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)
  63944. * * 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)
  63945. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63946. * @param name defines the name of the mesh
  63947. * @param options defines the options used to create the mesh
  63948. * @param scene defines the hosting scene
  63949. * @returns the box mesh
  63950. */
  63951. static CreateTiledPlane(name: string, options: {
  63952. pattern?: number;
  63953. tileSize?: number;
  63954. tileWidth?: number;
  63955. tileHeight?: number;
  63956. size?: number;
  63957. width?: number;
  63958. height?: number;
  63959. alignHorizontal?: number;
  63960. alignVertical?: number;
  63961. sideOrientation?: number;
  63962. frontUVs?: Vector4;
  63963. backUVs?: Vector4;
  63964. updatable?: boolean;
  63965. }, scene?: Nullable<Scene>): Mesh;
  63966. }
  63967. }
  63968. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63969. import { Nullable } from "babylonjs/types";
  63970. import { Scene } from "babylonjs/scene";
  63971. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63972. import { Mesh } from "babylonjs/Meshes/mesh";
  63973. /**
  63974. * Class containing static functions to help procedurally build meshes
  63975. */
  63976. export class TubeBuilder {
  63977. /**
  63978. * Creates a tube mesh.
  63979. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63980. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63981. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63982. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63983. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63984. * * 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)
  63985. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63986. * * 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
  63987. * * 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
  63988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63992. * @param name defines the name of the mesh
  63993. * @param options defines the options used to create the mesh
  63994. * @param scene defines the hosting scene
  63995. * @returns the tube mesh
  63996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63997. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63998. */
  63999. static CreateTube(name: string, options: {
  64000. path: Vector3[];
  64001. radius?: number;
  64002. tessellation?: number;
  64003. radiusFunction?: {
  64004. (i: number, distance: number): number;
  64005. };
  64006. cap?: number;
  64007. arc?: number;
  64008. updatable?: boolean;
  64009. sideOrientation?: number;
  64010. frontUVs?: Vector4;
  64011. backUVs?: Vector4;
  64012. instance?: Mesh;
  64013. invertUV?: boolean;
  64014. }, scene?: Nullable<Scene>): Mesh;
  64015. }
  64016. }
  64017. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64018. import { Scene } from "babylonjs/scene";
  64019. import { Vector4 } from "babylonjs/Maths/math.vector";
  64020. import { Mesh } from "babylonjs/Meshes/mesh";
  64021. import { Nullable } from "babylonjs/types";
  64022. /**
  64023. * Class containing static functions to help procedurally build meshes
  64024. */
  64025. export class IcoSphereBuilder {
  64026. /**
  64027. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64028. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64029. * * 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`)
  64030. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64031. * * 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
  64032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64035. * @param name defines the name of the mesh
  64036. * @param options defines the options used to create the mesh
  64037. * @param scene defines the hosting scene
  64038. * @returns the icosahedron mesh
  64039. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64040. */
  64041. static CreateIcoSphere(name: string, options: {
  64042. radius?: number;
  64043. radiusX?: number;
  64044. radiusY?: number;
  64045. radiusZ?: number;
  64046. flat?: boolean;
  64047. subdivisions?: number;
  64048. sideOrientation?: number;
  64049. frontUVs?: Vector4;
  64050. backUVs?: Vector4;
  64051. updatable?: boolean;
  64052. }, scene?: Nullable<Scene>): Mesh;
  64053. }
  64054. }
  64055. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64056. import { Vector3 } from "babylonjs/Maths/math.vector";
  64057. import { Mesh } from "babylonjs/Meshes/mesh";
  64058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64059. /**
  64060. * Class containing static functions to help procedurally build meshes
  64061. */
  64062. export class DecalBuilder {
  64063. /**
  64064. * Creates a decal mesh.
  64065. * 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
  64066. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64067. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64068. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64069. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64070. * @param name defines the name of the mesh
  64071. * @param sourceMesh defines the mesh where the decal must be applied
  64072. * @param options defines the options used to create the mesh
  64073. * @param scene defines the hosting scene
  64074. * @returns the decal mesh
  64075. * @see https://doc.babylonjs.com/how_to/decals
  64076. */
  64077. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64078. position?: Vector3;
  64079. normal?: Vector3;
  64080. size?: Vector3;
  64081. angle?: number;
  64082. }): Mesh;
  64083. }
  64084. }
  64085. declare module "babylonjs/Meshes/meshBuilder" {
  64086. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64087. import { Nullable } from "babylonjs/types";
  64088. import { Scene } from "babylonjs/scene";
  64089. import { Mesh } from "babylonjs/Meshes/mesh";
  64090. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64091. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64093. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64094. import { Plane } from "babylonjs/Maths/math.plane";
  64095. /**
  64096. * Class containing static functions to help procedurally build meshes
  64097. */
  64098. export class MeshBuilder {
  64099. /**
  64100. * Creates a box mesh
  64101. * * The parameter `size` sets the size (float) of each box side (default 1)
  64102. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64103. * * 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)
  64104. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64109. * @param name defines the name of the mesh
  64110. * @param options defines the options used to create the mesh
  64111. * @param scene defines the hosting scene
  64112. * @returns the box mesh
  64113. */
  64114. static CreateBox(name: string, options: {
  64115. size?: number;
  64116. width?: number;
  64117. height?: number;
  64118. depth?: number;
  64119. faceUV?: Vector4[];
  64120. faceColors?: Color4[];
  64121. sideOrientation?: number;
  64122. frontUVs?: Vector4;
  64123. backUVs?: Vector4;
  64124. updatable?: boolean;
  64125. }, scene?: Nullable<Scene>): Mesh;
  64126. /**
  64127. * Creates a tiled box mesh
  64128. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64130. * @param name defines the name of the mesh
  64131. * @param options defines the options used to create the mesh
  64132. * @param scene defines the hosting scene
  64133. * @returns the tiled box mesh
  64134. */
  64135. static CreateTiledBox(name: string, options: {
  64136. pattern?: number;
  64137. size?: number;
  64138. width?: number;
  64139. height?: number;
  64140. depth: number;
  64141. tileSize?: number;
  64142. tileWidth?: number;
  64143. tileHeight?: number;
  64144. faceUV?: Vector4[];
  64145. faceColors?: Color4[];
  64146. alignHorizontal?: number;
  64147. alignVertical?: number;
  64148. sideOrientation?: number;
  64149. updatable?: boolean;
  64150. }, scene?: Nullable<Scene>): Mesh;
  64151. /**
  64152. * Creates a sphere mesh
  64153. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64154. * * 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`)
  64155. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64156. * * 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
  64157. * * 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)
  64158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64161. * @param name defines the name of the mesh
  64162. * @param options defines the options used to create the mesh
  64163. * @param scene defines the hosting scene
  64164. * @returns the sphere mesh
  64165. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64166. */
  64167. static CreateSphere(name: string, options: {
  64168. segments?: number;
  64169. diameter?: number;
  64170. diameterX?: number;
  64171. diameterY?: number;
  64172. diameterZ?: number;
  64173. arc?: number;
  64174. slice?: number;
  64175. sideOrientation?: number;
  64176. frontUVs?: Vector4;
  64177. backUVs?: Vector4;
  64178. updatable?: boolean;
  64179. }, scene?: Nullable<Scene>): Mesh;
  64180. /**
  64181. * Creates a plane polygonal mesh. By default, this is a disc
  64182. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64183. * * 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
  64184. * * 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
  64185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64188. * @param name defines the name of the mesh
  64189. * @param options defines the options used to create the mesh
  64190. * @param scene defines the hosting scene
  64191. * @returns the plane polygonal mesh
  64192. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64193. */
  64194. static CreateDisc(name: string, options: {
  64195. radius?: number;
  64196. tessellation?: number;
  64197. arc?: number;
  64198. updatable?: boolean;
  64199. sideOrientation?: number;
  64200. frontUVs?: Vector4;
  64201. backUVs?: Vector4;
  64202. }, scene?: Nullable<Scene>): Mesh;
  64203. /**
  64204. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64205. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64206. * * 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`)
  64207. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64208. * * 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
  64209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64212. * @param name defines the name of the mesh
  64213. * @param options defines the options used to create the mesh
  64214. * @param scene defines the hosting scene
  64215. * @returns the icosahedron mesh
  64216. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64217. */
  64218. static CreateIcoSphere(name: string, options: {
  64219. radius?: number;
  64220. radiusX?: number;
  64221. radiusY?: number;
  64222. radiusZ?: number;
  64223. flat?: boolean;
  64224. subdivisions?: number;
  64225. sideOrientation?: number;
  64226. frontUVs?: Vector4;
  64227. backUVs?: Vector4;
  64228. updatable?: boolean;
  64229. }, scene?: Nullable<Scene>): Mesh;
  64230. /**
  64231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64235. * * 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
  64236. * * 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
  64237. * * 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
  64238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64241. * * 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
  64242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64243. * * 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
  64244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64246. * @param name defines the name of the mesh
  64247. * @param options defines the options used to create the mesh
  64248. * @param scene defines the hosting scene
  64249. * @returns the ribbon mesh
  64250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64252. */
  64253. static CreateRibbon(name: string, options: {
  64254. pathArray: Vector3[][];
  64255. closeArray?: boolean;
  64256. closePath?: boolean;
  64257. offset?: number;
  64258. updatable?: boolean;
  64259. sideOrientation?: number;
  64260. frontUVs?: Vector4;
  64261. backUVs?: Vector4;
  64262. instance?: Mesh;
  64263. invertUV?: boolean;
  64264. uvs?: Vector2[];
  64265. colors?: Color4[];
  64266. }, scene?: Nullable<Scene>): Mesh;
  64267. /**
  64268. * Creates a cylinder or a cone mesh
  64269. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64270. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64271. * * 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.
  64272. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64273. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64274. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64275. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64276. * * 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).
  64277. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64278. * * 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).
  64279. * * 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
  64280. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64281. * * 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
  64282. * * 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.
  64283. * * If `enclose` is false, a ring surface is one element.
  64284. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64285. * * 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
  64286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64289. * @param name defines the name of the mesh
  64290. * @param options defines the options used to create the mesh
  64291. * @param scene defines the hosting scene
  64292. * @returns the cylinder mesh
  64293. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64294. */
  64295. static CreateCylinder(name: string, options: {
  64296. height?: number;
  64297. diameterTop?: number;
  64298. diameterBottom?: number;
  64299. diameter?: number;
  64300. tessellation?: number;
  64301. subdivisions?: number;
  64302. arc?: number;
  64303. faceColors?: Color4[];
  64304. faceUV?: Vector4[];
  64305. updatable?: boolean;
  64306. hasRings?: boolean;
  64307. enclose?: boolean;
  64308. cap?: number;
  64309. sideOrientation?: number;
  64310. frontUVs?: Vector4;
  64311. backUVs?: Vector4;
  64312. }, scene?: Nullable<Scene>): Mesh;
  64313. /**
  64314. * Creates a torus mesh
  64315. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64316. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64317. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64321. * @param name defines the name of the mesh
  64322. * @param options defines the options used to create the mesh
  64323. * @param scene defines the hosting scene
  64324. * @returns the torus mesh
  64325. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64326. */
  64327. static CreateTorus(name: string, options: {
  64328. diameter?: number;
  64329. thickness?: number;
  64330. tessellation?: number;
  64331. updatable?: boolean;
  64332. sideOrientation?: number;
  64333. frontUVs?: Vector4;
  64334. backUVs?: Vector4;
  64335. }, scene?: Nullable<Scene>): Mesh;
  64336. /**
  64337. * Creates a torus knot mesh
  64338. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64339. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64340. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64341. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64345. * @param name defines the name of the mesh
  64346. * @param options defines the options used to create the mesh
  64347. * @param scene defines the hosting scene
  64348. * @returns the torus knot mesh
  64349. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64350. */
  64351. static CreateTorusKnot(name: string, options: {
  64352. radius?: number;
  64353. tube?: number;
  64354. radialSegments?: number;
  64355. tubularSegments?: number;
  64356. p?: number;
  64357. q?: number;
  64358. updatable?: boolean;
  64359. sideOrientation?: number;
  64360. frontUVs?: Vector4;
  64361. backUVs?: Vector4;
  64362. }, scene?: Nullable<Scene>): Mesh;
  64363. /**
  64364. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64365. * * 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
  64366. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64367. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64368. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64369. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64370. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64371. * * 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
  64372. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64375. * @param name defines the name of the new line system
  64376. * @param options defines the options used to create the line system
  64377. * @param scene defines the hosting scene
  64378. * @returns a new line system mesh
  64379. */
  64380. static CreateLineSystem(name: string, options: {
  64381. lines: Vector3[][];
  64382. updatable?: boolean;
  64383. instance?: Nullable<LinesMesh>;
  64384. colors?: Nullable<Color4[][]>;
  64385. useVertexAlpha?: boolean;
  64386. }, scene: Nullable<Scene>): LinesMesh;
  64387. /**
  64388. * Creates a line mesh
  64389. * 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
  64390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64391. * * The parameter `points` is an array successive Vector3
  64392. * * 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
  64393. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64394. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64395. * * When updating an instance, remember that only point positions can change, not the number of points
  64396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64398. * @param name defines the name of the new line system
  64399. * @param options defines the options used to create the line system
  64400. * @param scene defines the hosting scene
  64401. * @returns a new line mesh
  64402. */
  64403. static CreateLines(name: string, options: {
  64404. points: Vector3[];
  64405. updatable?: boolean;
  64406. instance?: Nullable<LinesMesh>;
  64407. colors?: Color4[];
  64408. useVertexAlpha?: boolean;
  64409. }, scene?: Nullable<Scene>): LinesMesh;
  64410. /**
  64411. * Creates a dashed line mesh
  64412. * * 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
  64413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64414. * * The parameter `points` is an array successive Vector3
  64415. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64416. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64417. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64418. * * 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
  64419. * * When updating an instance, remember that only point positions can change, not the number of points
  64420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64421. * @param name defines the name of the mesh
  64422. * @param options defines the options used to create the mesh
  64423. * @param scene defines the hosting scene
  64424. * @returns the dashed line mesh
  64425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64426. */
  64427. static CreateDashedLines(name: string, options: {
  64428. points: Vector3[];
  64429. dashSize?: number;
  64430. gapSize?: number;
  64431. dashNb?: number;
  64432. updatable?: boolean;
  64433. instance?: LinesMesh;
  64434. }, scene?: Nullable<Scene>): LinesMesh;
  64435. /**
  64436. * 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.
  64437. * * 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.
  64438. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64439. * * 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.
  64440. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64441. * * 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
  64442. * * 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
  64443. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64448. * @param name defines the name of the mesh
  64449. * @param options defines the options used to create the mesh
  64450. * @param scene defines the hosting scene
  64451. * @returns the extruded shape mesh
  64452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64454. */
  64455. static ExtrudeShape(name: string, options: {
  64456. shape: Vector3[];
  64457. path: Vector3[];
  64458. scale?: number;
  64459. rotation?: number;
  64460. cap?: number;
  64461. updatable?: boolean;
  64462. sideOrientation?: number;
  64463. frontUVs?: Vector4;
  64464. backUVs?: Vector4;
  64465. instance?: Mesh;
  64466. invertUV?: boolean;
  64467. }, scene?: Nullable<Scene>): Mesh;
  64468. /**
  64469. * Creates an custom extruded shape mesh.
  64470. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64471. * * 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.
  64472. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64473. * * 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
  64474. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64475. * * 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
  64476. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64477. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64478. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64479. * * 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
  64480. * * 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
  64481. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64486. * @param name defines the name of the mesh
  64487. * @param options defines the options used to create the mesh
  64488. * @param scene defines the hosting scene
  64489. * @returns the custom extruded shape mesh
  64490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64493. */
  64494. static ExtrudeShapeCustom(name: string, options: {
  64495. shape: Vector3[];
  64496. path: Vector3[];
  64497. scaleFunction?: any;
  64498. rotationFunction?: any;
  64499. ribbonCloseArray?: boolean;
  64500. ribbonClosePath?: boolean;
  64501. cap?: number;
  64502. updatable?: boolean;
  64503. sideOrientation?: number;
  64504. frontUVs?: Vector4;
  64505. backUVs?: Vector4;
  64506. instance?: Mesh;
  64507. invertUV?: boolean;
  64508. }, scene?: Nullable<Scene>): Mesh;
  64509. /**
  64510. * Creates lathe mesh.
  64511. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64512. * * 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
  64513. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64514. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64515. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64516. * * 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
  64517. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64518. * * 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
  64519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64521. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64523. * @param name defines the name of the mesh
  64524. * @param options defines the options used to create the mesh
  64525. * @param scene defines the hosting scene
  64526. * @returns the lathe mesh
  64527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64528. */
  64529. static CreateLathe(name: string, options: {
  64530. shape: Vector3[];
  64531. radius?: number;
  64532. tessellation?: number;
  64533. clip?: number;
  64534. arc?: number;
  64535. closed?: boolean;
  64536. updatable?: boolean;
  64537. sideOrientation?: number;
  64538. frontUVs?: Vector4;
  64539. backUVs?: Vector4;
  64540. cap?: number;
  64541. invertUV?: boolean;
  64542. }, scene?: Nullable<Scene>): Mesh;
  64543. /**
  64544. * Creates a tiled plane mesh
  64545. * * You can set a limited pattern arrangement with the tiles
  64546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64549. * @param name defines the name of the mesh
  64550. * @param options defines the options used to create the mesh
  64551. * @param scene defines the hosting scene
  64552. * @returns the plane mesh
  64553. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64554. */
  64555. static CreateTiledPlane(name: string, options: {
  64556. pattern?: number;
  64557. tileSize?: number;
  64558. tileWidth?: number;
  64559. tileHeight?: number;
  64560. size?: number;
  64561. width?: number;
  64562. height?: number;
  64563. alignHorizontal?: number;
  64564. alignVertical?: number;
  64565. sideOrientation?: number;
  64566. frontUVs?: Vector4;
  64567. backUVs?: Vector4;
  64568. updatable?: boolean;
  64569. }, scene?: Nullable<Scene>): Mesh;
  64570. /**
  64571. * Creates a plane mesh
  64572. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64573. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64574. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64578. * @param name defines the name of the mesh
  64579. * @param options defines the options used to create the mesh
  64580. * @param scene defines the hosting scene
  64581. * @returns the plane mesh
  64582. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64583. */
  64584. static CreatePlane(name: string, options: {
  64585. size?: number;
  64586. width?: number;
  64587. height?: number;
  64588. sideOrientation?: number;
  64589. frontUVs?: Vector4;
  64590. backUVs?: Vector4;
  64591. updatable?: boolean;
  64592. sourcePlane?: Plane;
  64593. }, scene?: Nullable<Scene>): Mesh;
  64594. /**
  64595. * Creates a ground mesh
  64596. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64597. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64599. * @param name defines the name of the mesh
  64600. * @param options defines the options used to create the mesh
  64601. * @param scene defines the hosting scene
  64602. * @returns the ground mesh
  64603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64604. */
  64605. static CreateGround(name: string, options: {
  64606. width?: number;
  64607. height?: number;
  64608. subdivisions?: number;
  64609. subdivisionsX?: number;
  64610. subdivisionsY?: number;
  64611. updatable?: boolean;
  64612. }, scene?: Nullable<Scene>): Mesh;
  64613. /**
  64614. * Creates a tiled ground mesh
  64615. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64616. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64617. * * 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
  64618. * * 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
  64619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64620. * @param name defines the name of the mesh
  64621. * @param options defines the options used to create the mesh
  64622. * @param scene defines the hosting scene
  64623. * @returns the tiled ground mesh
  64624. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64625. */
  64626. static CreateTiledGround(name: string, options: {
  64627. xmin: number;
  64628. zmin: number;
  64629. xmax: number;
  64630. zmax: number;
  64631. subdivisions?: {
  64632. w: number;
  64633. h: number;
  64634. };
  64635. precision?: {
  64636. w: number;
  64637. h: number;
  64638. };
  64639. updatable?: boolean;
  64640. }, scene?: Nullable<Scene>): Mesh;
  64641. /**
  64642. * Creates a ground mesh from a height map
  64643. * * The parameter `url` sets the URL of the height map image resource.
  64644. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64645. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64646. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64647. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64648. * * 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.
  64649. * * 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).
  64650. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64652. * @param name defines the name of the mesh
  64653. * @param url defines the url to the height map
  64654. * @param options defines the options used to create the mesh
  64655. * @param scene defines the hosting scene
  64656. * @returns the ground mesh
  64657. * @see https://doc.babylonjs.com/babylon101/height_map
  64658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64659. */
  64660. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64661. width?: number;
  64662. height?: number;
  64663. subdivisions?: number;
  64664. minHeight?: number;
  64665. maxHeight?: number;
  64666. colorFilter?: Color3;
  64667. alphaFilter?: number;
  64668. updatable?: boolean;
  64669. onReady?: (mesh: GroundMesh) => void;
  64670. }, scene?: Nullable<Scene>): GroundMesh;
  64671. /**
  64672. * Creates a polygon mesh
  64673. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64674. * * 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
  64675. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64678. * * Remember you can only change the shape positions, not their number when updating a polygon
  64679. * @param name defines the name of the mesh
  64680. * @param options defines the options used to create the mesh
  64681. * @param scene defines the hosting scene
  64682. * @param earcutInjection can be used to inject your own earcut reference
  64683. * @returns the polygon mesh
  64684. */
  64685. static CreatePolygon(name: string, options: {
  64686. shape: Vector3[];
  64687. holes?: Vector3[][];
  64688. depth?: number;
  64689. faceUV?: Vector4[];
  64690. faceColors?: Color4[];
  64691. updatable?: boolean;
  64692. sideOrientation?: number;
  64693. frontUVs?: Vector4;
  64694. backUVs?: Vector4;
  64695. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64696. /**
  64697. * Creates an extruded polygon mesh, with depth in the Y direction.
  64698. * * 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)
  64699. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64700. * @param name defines the name of the mesh
  64701. * @param options defines the options used to create the mesh
  64702. * @param scene defines the hosting scene
  64703. * @param earcutInjection can be used to inject your own earcut reference
  64704. * @returns the polygon mesh
  64705. */
  64706. static ExtrudePolygon(name: string, options: {
  64707. shape: Vector3[];
  64708. holes?: Vector3[][];
  64709. depth?: number;
  64710. faceUV?: Vector4[];
  64711. faceColors?: Color4[];
  64712. updatable?: boolean;
  64713. sideOrientation?: number;
  64714. frontUVs?: Vector4;
  64715. backUVs?: Vector4;
  64716. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64717. /**
  64718. * Creates a tube mesh.
  64719. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64720. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64721. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64722. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64723. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64724. * * 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)
  64725. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64726. * * 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
  64727. * * 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
  64728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64732. * @param name defines the name of the mesh
  64733. * @param options defines the options used to create the mesh
  64734. * @param scene defines the hosting scene
  64735. * @returns the tube mesh
  64736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64737. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64738. */
  64739. static CreateTube(name: string, options: {
  64740. path: Vector3[];
  64741. radius?: number;
  64742. tessellation?: number;
  64743. radiusFunction?: {
  64744. (i: number, distance: number): number;
  64745. };
  64746. cap?: number;
  64747. arc?: number;
  64748. updatable?: boolean;
  64749. sideOrientation?: number;
  64750. frontUVs?: Vector4;
  64751. backUVs?: Vector4;
  64752. instance?: Mesh;
  64753. invertUV?: boolean;
  64754. }, scene?: Nullable<Scene>): Mesh;
  64755. /**
  64756. * Creates a polyhedron mesh
  64757. * * 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
  64758. * * The parameter `size` (positive float, default 1) sets the polygon size
  64759. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64760. * * 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`
  64761. * * 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
  64762. * * 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)`)
  64763. * * 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
  64764. * * 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
  64765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64768. * @param name defines the name of the mesh
  64769. * @param options defines the options used to create the mesh
  64770. * @param scene defines the hosting scene
  64771. * @returns the polyhedron mesh
  64772. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64773. */
  64774. static CreatePolyhedron(name: string, options: {
  64775. type?: number;
  64776. size?: number;
  64777. sizeX?: number;
  64778. sizeY?: number;
  64779. sizeZ?: number;
  64780. custom?: any;
  64781. faceUV?: Vector4[];
  64782. faceColors?: Color4[];
  64783. flat?: boolean;
  64784. updatable?: boolean;
  64785. sideOrientation?: number;
  64786. frontUVs?: Vector4;
  64787. backUVs?: Vector4;
  64788. }, scene?: Nullable<Scene>): Mesh;
  64789. /**
  64790. * Creates a decal mesh.
  64791. * 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
  64792. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64793. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64794. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64795. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64796. * @param name defines the name of the mesh
  64797. * @param sourceMesh defines the mesh where the decal must be applied
  64798. * @param options defines the options used to create the mesh
  64799. * @param scene defines the hosting scene
  64800. * @returns the decal mesh
  64801. * @see https://doc.babylonjs.com/how_to/decals
  64802. */
  64803. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64804. position?: Vector3;
  64805. normal?: Vector3;
  64806. size?: Vector3;
  64807. angle?: number;
  64808. }): Mesh;
  64809. }
  64810. }
  64811. declare module "babylonjs/Meshes/meshSimplification" {
  64812. import { Mesh } from "babylonjs/Meshes/mesh";
  64813. /**
  64814. * A simplifier interface for future simplification implementations
  64815. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64816. */
  64817. export interface ISimplifier {
  64818. /**
  64819. * Simplification of a given mesh according to the given settings.
  64820. * Since this requires computation, it is assumed that the function runs async.
  64821. * @param settings The settings of the simplification, including quality and distance
  64822. * @param successCallback A callback that will be called after the mesh was simplified.
  64823. * @param errorCallback in case of an error, this callback will be called. optional.
  64824. */
  64825. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64826. }
  64827. /**
  64828. * Expected simplification settings.
  64829. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64830. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64831. */
  64832. export interface ISimplificationSettings {
  64833. /**
  64834. * Gets or sets the expected quality
  64835. */
  64836. quality: number;
  64837. /**
  64838. * Gets or sets the distance when this optimized version should be used
  64839. */
  64840. distance: number;
  64841. /**
  64842. * Gets an already optimized mesh
  64843. */
  64844. optimizeMesh?: boolean;
  64845. }
  64846. /**
  64847. * Class used to specify simplification options
  64848. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64849. */
  64850. export class SimplificationSettings implements ISimplificationSettings {
  64851. /** expected quality */
  64852. quality: number;
  64853. /** distance when this optimized version should be used */
  64854. distance: number;
  64855. /** already optimized mesh */
  64856. optimizeMesh?: boolean | undefined;
  64857. /**
  64858. * Creates a SimplificationSettings
  64859. * @param quality expected quality
  64860. * @param distance distance when this optimized version should be used
  64861. * @param optimizeMesh already optimized mesh
  64862. */
  64863. constructor(
  64864. /** expected quality */
  64865. quality: number,
  64866. /** distance when this optimized version should be used */
  64867. distance: number,
  64868. /** already optimized mesh */
  64869. optimizeMesh?: boolean | undefined);
  64870. }
  64871. /**
  64872. * Interface used to define a simplification task
  64873. */
  64874. export interface ISimplificationTask {
  64875. /**
  64876. * Array of settings
  64877. */
  64878. settings: Array<ISimplificationSettings>;
  64879. /**
  64880. * Simplification type
  64881. */
  64882. simplificationType: SimplificationType;
  64883. /**
  64884. * Mesh to simplify
  64885. */
  64886. mesh: Mesh;
  64887. /**
  64888. * Callback called on success
  64889. */
  64890. successCallback?: () => void;
  64891. /**
  64892. * Defines if parallel processing can be used
  64893. */
  64894. parallelProcessing: boolean;
  64895. }
  64896. /**
  64897. * Queue used to order the simplification tasks
  64898. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64899. */
  64900. export class SimplificationQueue {
  64901. private _simplificationArray;
  64902. /**
  64903. * Gets a boolean indicating that the process is still running
  64904. */
  64905. running: boolean;
  64906. /**
  64907. * Creates a new queue
  64908. */
  64909. constructor();
  64910. /**
  64911. * Adds a new simplification task
  64912. * @param task defines a task to add
  64913. */
  64914. addTask(task: ISimplificationTask): void;
  64915. /**
  64916. * Execute next task
  64917. */
  64918. executeNext(): void;
  64919. /**
  64920. * Execute a simplification task
  64921. * @param task defines the task to run
  64922. */
  64923. runSimplification(task: ISimplificationTask): void;
  64924. private getSimplifier;
  64925. }
  64926. /**
  64927. * The implemented types of simplification
  64928. * At the moment only Quadratic Error Decimation is implemented
  64929. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64930. */
  64931. export enum SimplificationType {
  64932. /** Quadratic error decimation */
  64933. QUADRATIC = 0
  64934. }
  64935. }
  64936. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64937. import { Scene } from "babylonjs/scene";
  64938. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64939. import { ISceneComponent } from "babylonjs/sceneComponent";
  64940. module "babylonjs/scene" {
  64941. interface Scene {
  64942. /** @hidden (Backing field) */
  64943. _simplificationQueue: SimplificationQueue;
  64944. /**
  64945. * Gets or sets the simplification queue attached to the scene
  64946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64947. */
  64948. simplificationQueue: SimplificationQueue;
  64949. }
  64950. }
  64951. module "babylonjs/Meshes/mesh" {
  64952. interface Mesh {
  64953. /**
  64954. * Simplify the mesh according to the given array of settings.
  64955. * Function will return immediately and will simplify async
  64956. * @param settings a collection of simplification settings
  64957. * @param parallelProcessing should all levels calculate parallel or one after the other
  64958. * @param simplificationType the type of simplification to run
  64959. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64960. * @returns the current mesh
  64961. */
  64962. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64963. }
  64964. }
  64965. /**
  64966. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64967. * created in a scene
  64968. */
  64969. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64970. /**
  64971. * The component name helpfull to identify the component in the list of scene components.
  64972. */
  64973. readonly name: string;
  64974. /**
  64975. * The scene the component belongs to.
  64976. */
  64977. scene: Scene;
  64978. /**
  64979. * Creates a new instance of the component for the given scene
  64980. * @param scene Defines the scene to register the component in
  64981. */
  64982. constructor(scene: Scene);
  64983. /**
  64984. * Registers the component in a given scene
  64985. */
  64986. register(): void;
  64987. /**
  64988. * Rebuilds the elements related to this component in case of
  64989. * context lost for instance.
  64990. */
  64991. rebuild(): void;
  64992. /**
  64993. * Disposes the component and the associated ressources
  64994. */
  64995. dispose(): void;
  64996. private _beforeCameraUpdate;
  64997. }
  64998. }
  64999. declare module "babylonjs/Meshes/Builders/index" {
  65000. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65001. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65002. export * from "babylonjs/Meshes/Builders/discBuilder";
  65003. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65004. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65005. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65006. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65007. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65008. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65009. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65010. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65011. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65012. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65013. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65014. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65015. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65016. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65017. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65018. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65019. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65020. }
  65021. declare module "babylonjs/Meshes/index" {
  65022. export * from "babylonjs/Meshes/abstractMesh";
  65023. export * from "babylonjs/Meshes/buffer";
  65024. export * from "babylonjs/Meshes/Compression/index";
  65025. export * from "babylonjs/Meshes/csg";
  65026. export * from "babylonjs/Meshes/geometry";
  65027. export * from "babylonjs/Meshes/groundMesh";
  65028. export * from "babylonjs/Meshes/trailMesh";
  65029. export * from "babylonjs/Meshes/instancedMesh";
  65030. export * from "babylonjs/Meshes/linesMesh";
  65031. export * from "babylonjs/Meshes/mesh";
  65032. export * from "babylonjs/Meshes/mesh.vertexData";
  65033. export * from "babylonjs/Meshes/meshBuilder";
  65034. export * from "babylonjs/Meshes/meshSimplification";
  65035. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65036. export * from "babylonjs/Meshes/polygonMesh";
  65037. export * from "babylonjs/Meshes/subMesh";
  65038. export * from "babylonjs/Meshes/meshLODLevel";
  65039. export * from "babylonjs/Meshes/transformNode";
  65040. export * from "babylonjs/Meshes/Builders/index";
  65041. export * from "babylonjs/Meshes/dataBuffer";
  65042. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65043. }
  65044. declare module "babylonjs/Morph/index" {
  65045. export * from "babylonjs/Morph/morphTarget";
  65046. export * from "babylonjs/Morph/morphTargetManager";
  65047. }
  65048. declare module "babylonjs/Navigation/INavigationEngine" {
  65049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65050. import { Vector3 } from "babylonjs/Maths/math";
  65051. import { Mesh } from "babylonjs/Meshes/mesh";
  65052. import { Scene } from "babylonjs/scene";
  65053. /**
  65054. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65055. */
  65056. export interface INavigationEnginePlugin {
  65057. /**
  65058. * plugin name
  65059. */
  65060. name: string;
  65061. /**
  65062. * Creates a navigation mesh
  65063. * @param meshes array of all the geometry used to compute the navigatio mesh
  65064. * @param parameters bunch of parameters used to filter geometry
  65065. */
  65066. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65067. /**
  65068. * Create a navigation mesh debug mesh
  65069. * @param scene is where the mesh will be added
  65070. * @returns debug display mesh
  65071. */
  65072. createDebugNavMesh(scene: Scene): Mesh;
  65073. /**
  65074. * Get a navigation mesh constrained position, closest to the parameter position
  65075. * @param position world position
  65076. * @returns the closest point to position constrained by the navigation mesh
  65077. */
  65078. getClosestPoint(position: Vector3): Vector3;
  65079. /**
  65080. * Get a navigation mesh constrained position, within a particular radius
  65081. * @param position world position
  65082. * @param maxRadius the maximum distance to the constrained world position
  65083. * @returns the closest point to position constrained by the navigation mesh
  65084. */
  65085. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65086. /**
  65087. * Compute the final position from a segment made of destination-position
  65088. * @param position world position
  65089. * @param destination world position
  65090. * @returns the resulting point along the navmesh
  65091. */
  65092. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65093. /**
  65094. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65095. * @param start world position
  65096. * @param end world position
  65097. * @returns array containing world position composing the path
  65098. */
  65099. computePath(start: Vector3, end: Vector3): Vector3[];
  65100. /**
  65101. * If this plugin is supported
  65102. * @returns true if plugin is supported
  65103. */
  65104. isSupported(): boolean;
  65105. /**
  65106. * Create a new Crowd so you can add agents
  65107. * @param maxAgents the maximum agent count in the crowd
  65108. * @param maxAgentRadius the maximum radius an agent can have
  65109. * @param scene to attach the crowd to
  65110. * @returns the crowd you can add agents to
  65111. */
  65112. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65113. /**
  65114. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65115. * The queries will try to find a solution within those bounds
  65116. * default is (1,1,1)
  65117. * @param extent x,y,z value that define the extent around the queries point of reference
  65118. */
  65119. setDefaultQueryExtent(extent: Vector3): void;
  65120. /**
  65121. * Get the Bounding box extent specified by setDefaultQueryExtent
  65122. * @returns the box extent values
  65123. */
  65124. getDefaultQueryExtent(): Vector3;
  65125. /**
  65126. * Release all resources
  65127. */
  65128. dispose(): void;
  65129. }
  65130. /**
  65131. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65132. */
  65133. export interface ICrowd {
  65134. /**
  65135. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65136. * You can attach anything to that node. The node position is updated in the scene update tick.
  65137. * @param pos world position that will be constrained by the navigation mesh
  65138. * @param parameters agent parameters
  65139. * @param transform hooked to the agent that will be update by the scene
  65140. * @returns agent index
  65141. */
  65142. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65143. /**
  65144. * Returns the agent position in world space
  65145. * @param index agent index returned by addAgent
  65146. * @returns world space position
  65147. */
  65148. getAgentPosition(index: number): Vector3;
  65149. /**
  65150. * Gets the agent velocity in world space
  65151. * @param index agent index returned by addAgent
  65152. * @returns world space velocity
  65153. */
  65154. getAgentVelocity(index: number): Vector3;
  65155. /**
  65156. * remove a particular agent previously created
  65157. * @param index agent index returned by addAgent
  65158. */
  65159. removeAgent(index: number): void;
  65160. /**
  65161. * get the list of all agents attached to this crowd
  65162. * @returns list of agent indices
  65163. */
  65164. getAgents(): number[];
  65165. /**
  65166. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65167. * @param deltaTime in seconds
  65168. */
  65169. update(deltaTime: number): void;
  65170. /**
  65171. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65172. * @param index agent index returned by addAgent
  65173. * @param destination targeted world position
  65174. */
  65175. agentGoto(index: number, destination: Vector3): void;
  65176. /**
  65177. * Teleport the agent to a new position
  65178. * @param index agent index returned by addAgent
  65179. * @param destination targeted world position
  65180. */
  65181. agentTeleport(index: number, destination: Vector3): void;
  65182. /**
  65183. * Update agent parameters
  65184. * @param index agent index returned by addAgent
  65185. * @param parameters agent parameters
  65186. */
  65187. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65188. /**
  65189. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65190. * The queries will try to find a solution within those bounds
  65191. * default is (1,1,1)
  65192. * @param extent x,y,z value that define the extent around the queries point of reference
  65193. */
  65194. setDefaultQueryExtent(extent: Vector3): void;
  65195. /**
  65196. * Get the Bounding box extent specified by setDefaultQueryExtent
  65197. * @returns the box extent values
  65198. */
  65199. getDefaultQueryExtent(): Vector3;
  65200. /**
  65201. * Release all resources
  65202. */
  65203. dispose(): void;
  65204. }
  65205. /**
  65206. * Configures an agent
  65207. */
  65208. export interface IAgentParameters {
  65209. /**
  65210. * Agent radius. [Limit: >= 0]
  65211. */
  65212. radius: number;
  65213. /**
  65214. * Agent height. [Limit: > 0]
  65215. */
  65216. height: number;
  65217. /**
  65218. * Maximum allowed acceleration. [Limit: >= 0]
  65219. */
  65220. maxAcceleration: number;
  65221. /**
  65222. * Maximum allowed speed. [Limit: >= 0]
  65223. */
  65224. maxSpeed: number;
  65225. /**
  65226. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65227. */
  65228. collisionQueryRange: number;
  65229. /**
  65230. * The path visibility optimization range. [Limit: > 0]
  65231. */
  65232. pathOptimizationRange: number;
  65233. /**
  65234. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65235. */
  65236. separationWeight: number;
  65237. }
  65238. /**
  65239. * Configures the navigation mesh creation
  65240. */
  65241. export interface INavMeshParameters {
  65242. /**
  65243. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65244. */
  65245. cs: number;
  65246. /**
  65247. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65248. */
  65249. ch: number;
  65250. /**
  65251. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65252. */
  65253. walkableSlopeAngle: number;
  65254. /**
  65255. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65256. * be considered walkable. [Limit: >= 3] [Units: vx]
  65257. */
  65258. walkableHeight: number;
  65259. /**
  65260. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65261. */
  65262. walkableClimb: number;
  65263. /**
  65264. * The distance to erode/shrink the walkable area of the heightfield away from
  65265. * obstructions. [Limit: >=0] [Units: vx]
  65266. */
  65267. walkableRadius: number;
  65268. /**
  65269. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65270. */
  65271. maxEdgeLen: number;
  65272. /**
  65273. * The maximum distance a simplfied contour's border edges should deviate
  65274. * the original raw contour. [Limit: >=0] [Units: vx]
  65275. */
  65276. maxSimplificationError: number;
  65277. /**
  65278. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65279. */
  65280. minRegionArea: number;
  65281. /**
  65282. * Any regions with a span count smaller than this value will, if possible,
  65283. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65284. */
  65285. mergeRegionArea: number;
  65286. /**
  65287. * The maximum number of vertices allowed for polygons generated during the
  65288. * contour to polygon conversion process. [Limit: >= 3]
  65289. */
  65290. maxVertsPerPoly: number;
  65291. /**
  65292. * Sets the sampling distance to use when generating the detail mesh.
  65293. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65294. */
  65295. detailSampleDist: number;
  65296. /**
  65297. * The maximum distance the detail mesh surface should deviate from heightfield
  65298. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65299. */
  65300. detailSampleMaxError: number;
  65301. }
  65302. }
  65303. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65304. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65305. import { Mesh } from "babylonjs/Meshes/mesh";
  65306. import { Scene } from "babylonjs/scene";
  65307. import { Vector3 } from "babylonjs/Maths/math";
  65308. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65309. /**
  65310. * RecastJS navigation plugin
  65311. */
  65312. export class RecastJSPlugin implements INavigationEnginePlugin {
  65313. /**
  65314. * Reference to the Recast library
  65315. */
  65316. bjsRECAST: any;
  65317. /**
  65318. * plugin name
  65319. */
  65320. name: string;
  65321. /**
  65322. * the first navmesh created. We might extend this to support multiple navmeshes
  65323. */
  65324. navMesh: any;
  65325. /**
  65326. * Initializes the recastJS plugin
  65327. * @param recastInjection can be used to inject your own recast reference
  65328. */
  65329. constructor(recastInjection?: any);
  65330. /**
  65331. * Creates a navigation mesh
  65332. * @param meshes array of all the geometry used to compute the navigatio mesh
  65333. * @param parameters bunch of parameters used to filter geometry
  65334. */
  65335. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65336. /**
  65337. * Create a navigation mesh debug mesh
  65338. * @param scene is where the mesh will be added
  65339. * @returns debug display mesh
  65340. */
  65341. createDebugNavMesh(scene: Scene): Mesh;
  65342. /**
  65343. * Get a navigation mesh constrained position, closest to the parameter position
  65344. * @param position world position
  65345. * @returns the closest point to position constrained by the navigation mesh
  65346. */
  65347. getClosestPoint(position: Vector3): Vector3;
  65348. /**
  65349. * Get a navigation mesh constrained position, within a particular radius
  65350. * @param position world position
  65351. * @param maxRadius the maximum distance to the constrained world position
  65352. * @returns the closest point to position constrained by the navigation mesh
  65353. */
  65354. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65355. /**
  65356. * Compute the final position from a segment made of destination-position
  65357. * @param position world position
  65358. * @param destination world position
  65359. * @returns the resulting point along the navmesh
  65360. */
  65361. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65362. /**
  65363. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65364. * @param start world position
  65365. * @param end world position
  65366. * @returns array containing world position composing the path
  65367. */
  65368. computePath(start: Vector3, end: Vector3): Vector3[];
  65369. /**
  65370. * Create a new Crowd so you can add agents
  65371. * @param maxAgents the maximum agent count in the crowd
  65372. * @param maxAgentRadius the maximum radius an agent can have
  65373. * @param scene to attach the crowd to
  65374. * @returns the crowd you can add agents to
  65375. */
  65376. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65377. /**
  65378. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65379. * The queries will try to find a solution within those bounds
  65380. * default is (1,1,1)
  65381. * @param extent x,y,z value that define the extent around the queries point of reference
  65382. */
  65383. setDefaultQueryExtent(extent: Vector3): void;
  65384. /**
  65385. * Get the Bounding box extent specified by setDefaultQueryExtent
  65386. * @returns the box extent values
  65387. */
  65388. getDefaultQueryExtent(): Vector3;
  65389. /**
  65390. * Disposes
  65391. */
  65392. dispose(): void;
  65393. /**
  65394. * If this plugin is supported
  65395. * @returns true if plugin is supported
  65396. */
  65397. isSupported(): boolean;
  65398. }
  65399. /**
  65400. * Recast detour crowd implementation
  65401. */
  65402. export class RecastJSCrowd implements ICrowd {
  65403. /**
  65404. * Recast/detour plugin
  65405. */
  65406. bjsRECASTPlugin: RecastJSPlugin;
  65407. /**
  65408. * Link to the detour crowd
  65409. */
  65410. recastCrowd: any;
  65411. /**
  65412. * One transform per agent
  65413. */
  65414. transforms: TransformNode[];
  65415. /**
  65416. * All agents created
  65417. */
  65418. agents: number[];
  65419. /**
  65420. * Link to the scene is kept to unregister the crowd from the scene
  65421. */
  65422. private _scene;
  65423. /**
  65424. * Observer for crowd updates
  65425. */
  65426. private _onBeforeAnimationsObserver;
  65427. /**
  65428. * Constructor
  65429. * @param plugin recastJS plugin
  65430. * @param maxAgents the maximum agent count in the crowd
  65431. * @param maxAgentRadius the maximum radius an agent can have
  65432. * @param scene to attach the crowd to
  65433. * @returns the crowd you can add agents to
  65434. */
  65435. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65436. /**
  65437. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65438. * You can attach anything to that node. The node position is updated in the scene update tick.
  65439. * @param pos world position that will be constrained by the navigation mesh
  65440. * @param parameters agent parameters
  65441. * @param transform hooked to the agent that will be update by the scene
  65442. * @returns agent index
  65443. */
  65444. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65445. /**
  65446. * Returns the agent position in world space
  65447. * @param index agent index returned by addAgent
  65448. * @returns world space position
  65449. */
  65450. getAgentPosition(index: number): Vector3;
  65451. /**
  65452. * Returns the agent velocity in world space
  65453. * @param index agent index returned by addAgent
  65454. * @returns world space velocity
  65455. */
  65456. getAgentVelocity(index: number): Vector3;
  65457. /**
  65458. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65459. * @param index agent index returned by addAgent
  65460. * @param destination targeted world position
  65461. */
  65462. agentGoto(index: number, destination: Vector3): void;
  65463. /**
  65464. * Teleport the agent to a new position
  65465. * @param index agent index returned by addAgent
  65466. * @param destination targeted world position
  65467. */
  65468. agentTeleport(index: number, destination: Vector3): void;
  65469. /**
  65470. * Update agent parameters
  65471. * @param index agent index returned by addAgent
  65472. * @param parameters agent parameters
  65473. */
  65474. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65475. /**
  65476. * remove a particular agent previously created
  65477. * @param index agent index returned by addAgent
  65478. */
  65479. removeAgent(index: number): void;
  65480. /**
  65481. * get the list of all agents attached to this crowd
  65482. * @returns list of agent indices
  65483. */
  65484. getAgents(): number[];
  65485. /**
  65486. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65487. * @param deltaTime in seconds
  65488. */
  65489. update(deltaTime: number): void;
  65490. /**
  65491. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65492. * The queries will try to find a solution within those bounds
  65493. * default is (1,1,1)
  65494. * @param extent x,y,z value that define the extent around the queries point of reference
  65495. */
  65496. setDefaultQueryExtent(extent: Vector3): void;
  65497. /**
  65498. * Get the Bounding box extent specified by setDefaultQueryExtent
  65499. * @returns the box extent values
  65500. */
  65501. getDefaultQueryExtent(): Vector3;
  65502. /**
  65503. * Release all resources
  65504. */
  65505. dispose(): void;
  65506. }
  65507. }
  65508. declare module "babylonjs/Navigation/Plugins/index" {
  65509. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65510. }
  65511. declare module "babylonjs/Navigation/index" {
  65512. export * from "babylonjs/Navigation/INavigationEngine";
  65513. export * from "babylonjs/Navigation/Plugins/index";
  65514. }
  65515. declare module "babylonjs/Offline/database" {
  65516. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65517. /**
  65518. * Class used to enable access to IndexedDB
  65519. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65520. */
  65521. export class Database implements IOfflineProvider {
  65522. private _callbackManifestChecked;
  65523. private _currentSceneUrl;
  65524. private _db;
  65525. private _enableSceneOffline;
  65526. private _enableTexturesOffline;
  65527. private _manifestVersionFound;
  65528. private _mustUpdateRessources;
  65529. private _hasReachedQuota;
  65530. private _isSupported;
  65531. private _idbFactory;
  65532. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65533. private static IsUASupportingBlobStorage;
  65534. /**
  65535. * Gets a boolean indicating if Database storate is enabled (off by default)
  65536. */
  65537. static IDBStorageEnabled: boolean;
  65538. /**
  65539. * Gets a boolean indicating if scene must be saved in the database
  65540. */
  65541. get enableSceneOffline(): boolean;
  65542. /**
  65543. * Gets a boolean indicating if textures must be saved in the database
  65544. */
  65545. get enableTexturesOffline(): boolean;
  65546. /**
  65547. * Creates a new Database
  65548. * @param urlToScene defines the url to load the scene
  65549. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65550. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65551. */
  65552. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65553. private static _ParseURL;
  65554. private static _ReturnFullUrlLocation;
  65555. private _checkManifestFile;
  65556. /**
  65557. * Open the database and make it available
  65558. * @param successCallback defines the callback to call on success
  65559. * @param errorCallback defines the callback to call on error
  65560. */
  65561. open(successCallback: () => void, errorCallback: () => void): void;
  65562. /**
  65563. * Loads an image from the database
  65564. * @param url defines the url to load from
  65565. * @param image defines the target DOM image
  65566. */
  65567. loadImage(url: string, image: HTMLImageElement): void;
  65568. private _loadImageFromDBAsync;
  65569. private _saveImageIntoDBAsync;
  65570. private _checkVersionFromDB;
  65571. private _loadVersionFromDBAsync;
  65572. private _saveVersionIntoDBAsync;
  65573. /**
  65574. * Loads a file from database
  65575. * @param url defines the URL to load from
  65576. * @param sceneLoaded defines a callback to call on success
  65577. * @param progressCallBack defines a callback to call when progress changed
  65578. * @param errorCallback defines a callback to call on error
  65579. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65580. */
  65581. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65582. private _loadFileAsync;
  65583. private _saveFileAsync;
  65584. /**
  65585. * Validates if xhr data is correct
  65586. * @param xhr defines the request to validate
  65587. * @param dataType defines the expected data type
  65588. * @returns true if data is correct
  65589. */
  65590. private static _ValidateXHRData;
  65591. }
  65592. }
  65593. declare module "babylonjs/Offline/index" {
  65594. export * from "babylonjs/Offline/database";
  65595. export * from "babylonjs/Offline/IOfflineProvider";
  65596. }
  65597. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65598. /** @hidden */
  65599. export var gpuUpdateParticlesPixelShader: {
  65600. name: string;
  65601. shader: string;
  65602. };
  65603. }
  65604. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65605. /** @hidden */
  65606. export var gpuUpdateParticlesVertexShader: {
  65607. name: string;
  65608. shader: string;
  65609. };
  65610. }
  65611. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65612. /** @hidden */
  65613. export var clipPlaneFragmentDeclaration2: {
  65614. name: string;
  65615. shader: string;
  65616. };
  65617. }
  65618. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65620. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65622. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65624. /** @hidden */
  65625. export var gpuRenderParticlesPixelShader: {
  65626. name: string;
  65627. shader: string;
  65628. };
  65629. }
  65630. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65631. /** @hidden */
  65632. export var clipPlaneVertexDeclaration2: {
  65633. name: string;
  65634. shader: string;
  65635. };
  65636. }
  65637. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65638. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65639. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65640. /** @hidden */
  65641. export var gpuRenderParticlesVertexShader: {
  65642. name: string;
  65643. shader: string;
  65644. };
  65645. }
  65646. declare module "babylonjs/Particles/gpuParticleSystem" {
  65647. import { Nullable } from "babylonjs/types";
  65648. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65649. import { Observable } from "babylonjs/Misc/observable";
  65650. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65653. import { Scene, IDisposable } from "babylonjs/scene";
  65654. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65656. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65657. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65658. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65659. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65660. /**
  65661. * This represents a GPU particle system in Babylon
  65662. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65663. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65664. */
  65665. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65666. /**
  65667. * The layer mask we are rendering the particles through.
  65668. */
  65669. layerMask: number;
  65670. private _capacity;
  65671. private _activeCount;
  65672. private _currentActiveCount;
  65673. private _accumulatedCount;
  65674. private _renderEffect;
  65675. private _updateEffect;
  65676. private _buffer0;
  65677. private _buffer1;
  65678. private _spriteBuffer;
  65679. private _updateVAO;
  65680. private _renderVAO;
  65681. private _targetIndex;
  65682. private _sourceBuffer;
  65683. private _targetBuffer;
  65684. private _engine;
  65685. private _currentRenderId;
  65686. private _started;
  65687. private _stopped;
  65688. private _timeDelta;
  65689. private _randomTexture;
  65690. private _randomTexture2;
  65691. private _attributesStrideSize;
  65692. private _updateEffectOptions;
  65693. private _randomTextureSize;
  65694. private _actualFrame;
  65695. private readonly _rawTextureWidth;
  65696. /**
  65697. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65698. */
  65699. static get IsSupported(): boolean;
  65700. /**
  65701. * An event triggered when the system is disposed.
  65702. */
  65703. onDisposeObservable: Observable<GPUParticleSystem>;
  65704. /**
  65705. * Gets the maximum number of particles active at the same time.
  65706. * @returns The max number of active particles.
  65707. */
  65708. getCapacity(): number;
  65709. /**
  65710. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65711. * to override the particles.
  65712. */
  65713. forceDepthWrite: boolean;
  65714. /**
  65715. * Gets or set the number of active particles
  65716. */
  65717. get activeParticleCount(): number;
  65718. set activeParticleCount(value: number);
  65719. private _preWarmDone;
  65720. /**
  65721. * Is this system ready to be used/rendered
  65722. * @return true if the system is ready
  65723. */
  65724. isReady(): boolean;
  65725. /**
  65726. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65727. * @returns True if it has been started, otherwise false.
  65728. */
  65729. isStarted(): boolean;
  65730. /**
  65731. * Starts the particle system and begins to emit
  65732. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65733. */
  65734. start(delay?: number): void;
  65735. /**
  65736. * Stops the particle system.
  65737. */
  65738. stop(): void;
  65739. /**
  65740. * Remove all active particles
  65741. */
  65742. reset(): void;
  65743. /**
  65744. * Returns the string "GPUParticleSystem"
  65745. * @returns a string containing the class name
  65746. */
  65747. getClassName(): string;
  65748. private _colorGradientsTexture;
  65749. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65750. /**
  65751. * Adds a new color gradient
  65752. * @param gradient defines the gradient to use (between 0 and 1)
  65753. * @param color1 defines the color to affect to the specified gradient
  65754. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65755. * @returns the current particle system
  65756. */
  65757. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65758. /**
  65759. * Remove a specific color gradient
  65760. * @param gradient defines the gradient to remove
  65761. * @returns the current particle system
  65762. */
  65763. removeColorGradient(gradient: number): GPUParticleSystem;
  65764. private _angularSpeedGradientsTexture;
  65765. private _sizeGradientsTexture;
  65766. private _velocityGradientsTexture;
  65767. private _limitVelocityGradientsTexture;
  65768. private _dragGradientsTexture;
  65769. private _addFactorGradient;
  65770. /**
  65771. * Adds a new size gradient
  65772. * @param gradient defines the gradient to use (between 0 and 1)
  65773. * @param factor defines the size factor to affect to the specified gradient
  65774. * @returns the current particle system
  65775. */
  65776. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65777. /**
  65778. * Remove a specific size gradient
  65779. * @param gradient defines the gradient to remove
  65780. * @returns the current particle system
  65781. */
  65782. removeSizeGradient(gradient: number): GPUParticleSystem;
  65783. /**
  65784. * Adds a new angular speed gradient
  65785. * @param gradient defines the gradient to use (between 0 and 1)
  65786. * @param factor defines the angular speed to affect to the specified gradient
  65787. * @returns the current particle system
  65788. */
  65789. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65790. /**
  65791. * Remove a specific angular speed gradient
  65792. * @param gradient defines the gradient to remove
  65793. * @returns the current particle system
  65794. */
  65795. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65796. /**
  65797. * Adds a new velocity gradient
  65798. * @param gradient defines the gradient to use (between 0 and 1)
  65799. * @param factor defines the velocity to affect to the specified gradient
  65800. * @returns the current particle system
  65801. */
  65802. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65803. /**
  65804. * Remove a specific velocity gradient
  65805. * @param gradient defines the gradient to remove
  65806. * @returns the current particle system
  65807. */
  65808. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65809. /**
  65810. * Adds a new limit velocity gradient
  65811. * @param gradient defines the gradient to use (between 0 and 1)
  65812. * @param factor defines the limit velocity value to affect to the specified gradient
  65813. * @returns the current particle system
  65814. */
  65815. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65816. /**
  65817. * Remove a specific limit velocity gradient
  65818. * @param gradient defines the gradient to remove
  65819. * @returns the current particle system
  65820. */
  65821. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65822. /**
  65823. * Adds a new drag gradient
  65824. * @param gradient defines the gradient to use (between 0 and 1)
  65825. * @param factor defines the drag value to affect to the specified gradient
  65826. * @returns the current particle system
  65827. */
  65828. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65829. /**
  65830. * Remove a specific drag gradient
  65831. * @param gradient defines the gradient to remove
  65832. * @returns the current particle system
  65833. */
  65834. removeDragGradient(gradient: number): GPUParticleSystem;
  65835. /**
  65836. * Not supported by GPUParticleSystem
  65837. * @param gradient defines the gradient to use (between 0 and 1)
  65838. * @param factor defines the emit rate value to affect to the specified gradient
  65839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65840. * @returns the current particle system
  65841. */
  65842. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65843. /**
  65844. * Not supported by GPUParticleSystem
  65845. * @param gradient defines the gradient to remove
  65846. * @returns the current particle system
  65847. */
  65848. removeEmitRateGradient(gradient: number): IParticleSystem;
  65849. /**
  65850. * Not supported by GPUParticleSystem
  65851. * @param gradient defines the gradient to use (between 0 and 1)
  65852. * @param factor defines the start size value to affect to the specified gradient
  65853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65854. * @returns the current particle system
  65855. */
  65856. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65857. /**
  65858. * Not supported by GPUParticleSystem
  65859. * @param gradient defines the gradient to remove
  65860. * @returns the current particle system
  65861. */
  65862. removeStartSizeGradient(gradient: number): IParticleSystem;
  65863. /**
  65864. * Not supported by GPUParticleSystem
  65865. * @param gradient defines the gradient to use (between 0 and 1)
  65866. * @param min defines the color remap minimal range
  65867. * @param max defines the color remap maximal range
  65868. * @returns the current particle system
  65869. */
  65870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65871. /**
  65872. * Not supported by GPUParticleSystem
  65873. * @param gradient defines the gradient to remove
  65874. * @returns the current particle system
  65875. */
  65876. removeColorRemapGradient(): IParticleSystem;
  65877. /**
  65878. * Not supported by GPUParticleSystem
  65879. * @param gradient defines the gradient to use (between 0 and 1)
  65880. * @param min defines the alpha remap minimal range
  65881. * @param max defines the alpha remap maximal range
  65882. * @returns the current particle system
  65883. */
  65884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65885. /**
  65886. * Not supported by GPUParticleSystem
  65887. * @param gradient defines the gradient to remove
  65888. * @returns the current particle system
  65889. */
  65890. removeAlphaRemapGradient(): IParticleSystem;
  65891. /**
  65892. * Not supported by GPUParticleSystem
  65893. * @param gradient defines the gradient to use (between 0 and 1)
  65894. * @param color defines the color to affect to the specified gradient
  65895. * @returns the current particle system
  65896. */
  65897. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65898. /**
  65899. * Not supported by GPUParticleSystem
  65900. * @param gradient defines the gradient to remove
  65901. * @returns the current particle system
  65902. */
  65903. removeRampGradient(): IParticleSystem;
  65904. /**
  65905. * Not supported by GPUParticleSystem
  65906. * @returns the list of ramp gradients
  65907. */
  65908. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65909. /**
  65910. * Not supported by GPUParticleSystem
  65911. * Gets or sets a boolean indicating that ramp gradients must be used
  65912. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65913. */
  65914. get useRampGradients(): boolean;
  65915. set useRampGradients(value: boolean);
  65916. /**
  65917. * Not supported by GPUParticleSystem
  65918. * @param gradient defines the gradient to use (between 0 and 1)
  65919. * @param factor defines the life time factor to affect to the specified gradient
  65920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65921. * @returns the current particle system
  65922. */
  65923. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65924. /**
  65925. * Not supported by GPUParticleSystem
  65926. * @param gradient defines the gradient to remove
  65927. * @returns the current particle system
  65928. */
  65929. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65930. /**
  65931. * Instantiates a GPU particle system.
  65932. * 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.
  65933. * @param name The name of the particle system
  65934. * @param options The options used to create the system
  65935. * @param scene The scene the particle system belongs to
  65936. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65937. */
  65938. constructor(name: string, options: Partial<{
  65939. capacity: number;
  65940. randomTextureSize: number;
  65941. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65942. protected _reset(): void;
  65943. private _createUpdateVAO;
  65944. private _createRenderVAO;
  65945. private _initialize;
  65946. /** @hidden */
  65947. _recreateUpdateEffect(): void;
  65948. /** @hidden */
  65949. _recreateRenderEffect(): void;
  65950. /**
  65951. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65952. * @param preWarm defines if we are in the pre-warmimg phase
  65953. */
  65954. animate(preWarm?: boolean): void;
  65955. private _createFactorGradientTexture;
  65956. private _createSizeGradientTexture;
  65957. private _createAngularSpeedGradientTexture;
  65958. private _createVelocityGradientTexture;
  65959. private _createLimitVelocityGradientTexture;
  65960. private _createDragGradientTexture;
  65961. private _createColorGradientTexture;
  65962. /**
  65963. * Renders the particle system in its current state
  65964. * @param preWarm defines if the system should only update the particles but not render them
  65965. * @returns the current number of particles
  65966. */
  65967. render(preWarm?: boolean): number;
  65968. /**
  65969. * Rebuilds the particle system
  65970. */
  65971. rebuild(): void;
  65972. private _releaseBuffers;
  65973. private _releaseVAOs;
  65974. /**
  65975. * Disposes the particle system and free the associated resources
  65976. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65977. */
  65978. dispose(disposeTexture?: boolean): void;
  65979. /**
  65980. * Clones the particle system.
  65981. * @param name The name of the cloned object
  65982. * @param newEmitter The new emitter to use
  65983. * @returns the cloned particle system
  65984. */
  65985. clone(name: string, newEmitter: any): GPUParticleSystem;
  65986. /**
  65987. * Serializes the particle system to a JSON object.
  65988. * @returns the JSON object
  65989. */
  65990. serialize(): any;
  65991. /**
  65992. * Parses a JSON object to create a GPU particle system.
  65993. * @param parsedParticleSystem The JSON object to parse
  65994. * @param scene The scene to create the particle system in
  65995. * @param rootUrl The root url to use to load external dependencies like texture
  65996. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65997. * @returns the parsed GPU particle system
  65998. */
  65999. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66000. }
  66001. }
  66002. declare module "babylonjs/Particles/particleSystemSet" {
  66003. import { Nullable } from "babylonjs/types";
  66004. import { Color3 } from "babylonjs/Maths/math.color";
  66005. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66007. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66008. import { Scene, IDisposable } from "babylonjs/scene";
  66009. /**
  66010. * Represents a set of particle systems working together to create a specific effect
  66011. */
  66012. export class ParticleSystemSet implements IDisposable {
  66013. /**
  66014. * Gets or sets base Assets URL
  66015. */
  66016. static BaseAssetsUrl: string;
  66017. private _emitterCreationOptions;
  66018. private _emitterNode;
  66019. /**
  66020. * Gets the particle system list
  66021. */
  66022. systems: IParticleSystem[];
  66023. /**
  66024. * Gets the emitter node used with this set
  66025. */
  66026. get emitterNode(): Nullable<TransformNode>;
  66027. /**
  66028. * Creates a new emitter mesh as a sphere
  66029. * @param options defines the options used to create the sphere
  66030. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66031. * @param scene defines the hosting scene
  66032. */
  66033. setEmitterAsSphere(options: {
  66034. diameter: number;
  66035. segments: number;
  66036. color: Color3;
  66037. }, renderingGroupId: number, scene: Scene): void;
  66038. /**
  66039. * Starts all particle systems of the set
  66040. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66041. */
  66042. start(emitter?: AbstractMesh): void;
  66043. /**
  66044. * Release all associated resources
  66045. */
  66046. dispose(): void;
  66047. /**
  66048. * Serialize the set into a JSON compatible object
  66049. * @returns a JSON compatible representation of the set
  66050. */
  66051. serialize(): any;
  66052. /**
  66053. * Parse a new ParticleSystemSet from a serialized source
  66054. * @param data defines a JSON compatible representation of the set
  66055. * @param scene defines the hosting scene
  66056. * @param gpu defines if we want GPU particles or CPU particles
  66057. * @returns a new ParticleSystemSet
  66058. */
  66059. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66060. }
  66061. }
  66062. declare module "babylonjs/Particles/particleHelper" {
  66063. import { Nullable } from "babylonjs/types";
  66064. import { Scene } from "babylonjs/scene";
  66065. import { Vector3 } from "babylonjs/Maths/math.vector";
  66066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66067. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66068. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66069. /**
  66070. * This class is made for on one-liner static method to help creating particle system set.
  66071. */
  66072. export class ParticleHelper {
  66073. /**
  66074. * Gets or sets base Assets URL
  66075. */
  66076. static BaseAssetsUrl: string;
  66077. /**
  66078. * Create a default particle system that you can tweak
  66079. * @param emitter defines the emitter to use
  66080. * @param capacity defines the system capacity (default is 500 particles)
  66081. * @param scene defines the hosting scene
  66082. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66083. * @returns the new Particle system
  66084. */
  66085. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66086. /**
  66087. * This is the main static method (one-liner) of this helper to create different particle systems
  66088. * @param type This string represents the type to the particle system to create
  66089. * @param scene The scene where the particle system should live
  66090. * @param gpu If the system will use gpu
  66091. * @returns the ParticleSystemSet created
  66092. */
  66093. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66094. /**
  66095. * Static function used to export a particle system to a ParticleSystemSet variable.
  66096. * Please note that the emitter shape is not exported
  66097. * @param systems defines the particle systems to export
  66098. * @returns the created particle system set
  66099. */
  66100. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66101. }
  66102. }
  66103. declare module "babylonjs/Particles/particleSystemComponent" {
  66104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66105. import { Effect } from "babylonjs/Materials/effect";
  66106. import "babylonjs/Shaders/particles.vertex";
  66107. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66108. module "babylonjs/Engines/engine" {
  66109. interface Engine {
  66110. /**
  66111. * Create an effect to use with particle systems.
  66112. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66113. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66114. * @param uniformsNames defines a list of attribute names
  66115. * @param samplers defines an array of string used to represent textures
  66116. * @param defines defines the string containing the defines to use to compile the shaders
  66117. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66118. * @param onCompiled defines a function to call when the effect creation is successful
  66119. * @param onError defines a function to call when the effect creation has failed
  66120. * @returns the new Effect
  66121. */
  66122. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66123. }
  66124. }
  66125. module "babylonjs/Meshes/mesh" {
  66126. interface Mesh {
  66127. /**
  66128. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66129. * @returns an array of IParticleSystem
  66130. */
  66131. getEmittedParticleSystems(): IParticleSystem[];
  66132. /**
  66133. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66134. * @returns an array of IParticleSystem
  66135. */
  66136. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66137. }
  66138. }
  66139. /**
  66140. * @hidden
  66141. */
  66142. export var _IDoNeedToBeInTheBuild: number;
  66143. }
  66144. declare module "babylonjs/Particles/pointsCloudSystem" {
  66145. import { Color4 } from "babylonjs/Maths/math";
  66146. import { Mesh } from "babylonjs/Meshes/mesh";
  66147. import { Scene, IDisposable } from "babylonjs/scene";
  66148. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66149. /** Defines the 4 color options */
  66150. export enum PointColor {
  66151. /** color value */
  66152. Color = 2,
  66153. /** uv value */
  66154. UV = 1,
  66155. /** random value */
  66156. Random = 0,
  66157. /** stated value */
  66158. Stated = 3
  66159. }
  66160. /**
  66161. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66162. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  66163. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66164. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66165. *
  66166. * Full documentation here : TO BE ENTERED
  66167. */
  66168. export class PointsCloudSystem implements IDisposable {
  66169. /**
  66170. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66171. * Example : var p = SPS.particles[i];
  66172. */
  66173. particles: CloudPoint[];
  66174. /**
  66175. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66176. */
  66177. nbParticles: number;
  66178. /**
  66179. * This a counter for your own usage. It's not set by any SPS functions.
  66180. */
  66181. counter: number;
  66182. /**
  66183. * The PCS name. This name is also given to the underlying mesh.
  66184. */
  66185. name: string;
  66186. /**
  66187. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66188. */
  66189. mesh: Mesh;
  66190. /**
  66191. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66192. * Please read :
  66193. */
  66194. vars: any;
  66195. /**
  66196. * @hidden
  66197. */
  66198. _size: number;
  66199. private _scene;
  66200. private _promises;
  66201. private _positions;
  66202. private _indices;
  66203. private _normals;
  66204. private _colors;
  66205. private _uvs;
  66206. private _indices32;
  66207. private _positions32;
  66208. private _colors32;
  66209. private _uvs32;
  66210. private _updatable;
  66211. private _isVisibilityBoxLocked;
  66212. private _alwaysVisible;
  66213. private _groups;
  66214. private _groupCounter;
  66215. private _computeParticleColor;
  66216. private _computeParticleTexture;
  66217. private _computeParticleRotation;
  66218. private _computeBoundingBox;
  66219. private _isReady;
  66220. /**
  66221. * Creates a PCS (Points Cloud System) object
  66222. * @param name (String) is the PCS name, this will be the underlying mesh name
  66223. * @param pointSize (number) is the size for each point
  66224. * @param scene (Scene) is the scene in which the PCS is added
  66225. * @param options defines the options of the PCS e.g.
  66226. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66227. */
  66228. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66229. updatable?: boolean;
  66230. });
  66231. /**
  66232. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66233. * If no points were added to the PCS, the returned mesh is just a single point.
  66234. * @returns a promise for the created mesh
  66235. */
  66236. buildMeshAsync(): Promise<Mesh>;
  66237. /**
  66238. * @hidden
  66239. */
  66240. private _buildMesh;
  66241. private _addParticle;
  66242. private _randomUnitVector;
  66243. private _getColorIndicesForCoord;
  66244. private _setPointsColorOrUV;
  66245. private _colorFromTexture;
  66246. private _calculateDensity;
  66247. /**
  66248. * Adds points to the PCS in random positions within a unit sphere
  66249. * @param nb (positive integer) the number of particles to be created from this model
  66250. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66251. * @returns the number of groups in the system
  66252. */
  66253. addPoints(nb: number, pointFunction?: any): number;
  66254. /**
  66255. * Adds points to the PCS from the surface of the model shape
  66256. * @param mesh is any Mesh object that will be used as a surface model for the points
  66257. * @param nb (positive integer) the number of particles to be created from this model
  66258. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66259. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66260. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66261. * @returns the number of groups in the system
  66262. */
  66263. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66264. /**
  66265. * Adds points to the PCS inside the model shape
  66266. * @param mesh is any Mesh object that will be used as a surface model for the points
  66267. * @param nb (positive integer) the number of particles to be created from this model
  66268. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66269. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66270. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66271. * @returns the number of groups in the system
  66272. */
  66273. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66274. /**
  66275. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66276. * This method calls `updateParticle()` for each particle of the SPS.
  66277. * For an animated SPS, it is usually called within the render loop.
  66278. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66279. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66280. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66281. * @returns the PCS.
  66282. */
  66283. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66284. /**
  66285. * Disposes the PCS.
  66286. */
  66287. dispose(): void;
  66288. /**
  66289. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66290. * doc :
  66291. * @returns the PCS.
  66292. */
  66293. refreshVisibleSize(): PointsCloudSystem;
  66294. /**
  66295. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66296. * @param size the size (float) of the visibility box
  66297. * note : this doesn't lock the PCS mesh bounding box.
  66298. * doc :
  66299. */
  66300. setVisibilityBox(size: number): void;
  66301. /**
  66302. * Gets whether the PCS is always visible or not
  66303. * doc :
  66304. */
  66305. get isAlwaysVisible(): boolean;
  66306. /**
  66307. * Sets the PCS as always visible or not
  66308. * doc :
  66309. */
  66310. set isAlwaysVisible(val: boolean);
  66311. /**
  66312. * Tells to `setParticles()` to compute the particle rotations or not
  66313. * Default value : false. The PCS is faster when it's set to false
  66314. * Note : particle rotations are only applied to parent particles
  66315. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66316. */
  66317. set computeParticleRotation(val: boolean);
  66318. /**
  66319. * Tells to `setParticles()` to compute the particle colors or not.
  66320. * Default value : true. The PCS is faster when it's set to false.
  66321. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66322. */
  66323. set computeParticleColor(val: boolean);
  66324. set computeParticleTexture(val: boolean);
  66325. /**
  66326. * Gets if `setParticles()` computes the particle colors or not.
  66327. * Default value : false. The PCS is faster when it's set to false.
  66328. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66329. */
  66330. get computeParticleColor(): boolean;
  66331. /**
  66332. * Gets if `setParticles()` computes the particle textures or not.
  66333. * Default value : false. The PCS is faster when it's set to false.
  66334. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66335. */
  66336. get computeParticleTexture(): boolean;
  66337. /**
  66338. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66339. */
  66340. set computeBoundingBox(val: boolean);
  66341. /**
  66342. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66343. */
  66344. get computeBoundingBox(): boolean;
  66345. /**
  66346. * This function does nothing. It may be overwritten to set all the particle first values.
  66347. * The PCS doesn't call this function, you may have to call it by your own.
  66348. * doc :
  66349. */
  66350. initParticles(): void;
  66351. /**
  66352. * This function does nothing. It may be overwritten to recycle a particle
  66353. * The PCS doesn't call this function, you can to call it
  66354. * doc :
  66355. * @param particle The particle to recycle
  66356. * @returns the recycled particle
  66357. */
  66358. recycleParticle(particle: CloudPoint): CloudPoint;
  66359. /**
  66360. * Updates a particle : this function should be overwritten by the user.
  66361. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66362. * doc :
  66363. * @example : just set a particle position or velocity and recycle conditions
  66364. * @param particle The particle to update
  66365. * @returns the updated particle
  66366. */
  66367. updateParticle(particle: CloudPoint): CloudPoint;
  66368. /**
  66369. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66370. * This does nothing and may be overwritten by the user.
  66371. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66372. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66373. * @param update the boolean update value actually passed to setParticles()
  66374. */
  66375. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66376. /**
  66377. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66378. * This will be passed three parameters.
  66379. * This does nothing and may be overwritten by the user.
  66380. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66381. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66382. * @param update the boolean update value actually passed to setParticles()
  66383. */
  66384. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66385. }
  66386. }
  66387. declare module "babylonjs/Particles/cloudPoint" {
  66388. import { Nullable } from "babylonjs/types";
  66389. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66390. import { Mesh } from "babylonjs/Meshes/mesh";
  66391. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66392. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66393. /**
  66394. * Represents one particle of a points cloud system.
  66395. */
  66396. export class CloudPoint {
  66397. /**
  66398. * particle global index
  66399. */
  66400. idx: number;
  66401. /**
  66402. * The color of the particle
  66403. */
  66404. color: Nullable<Color4>;
  66405. /**
  66406. * The world space position of the particle.
  66407. */
  66408. position: Vector3;
  66409. /**
  66410. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66411. */
  66412. rotation: Vector3;
  66413. /**
  66414. * The world space rotation quaternion of the particle.
  66415. */
  66416. rotationQuaternion: Nullable<Quaternion>;
  66417. /**
  66418. * The uv of the particle.
  66419. */
  66420. uv: Nullable<Vector2>;
  66421. /**
  66422. * The current speed of the particle.
  66423. */
  66424. velocity: Vector3;
  66425. /**
  66426. * The pivot point in the particle local space.
  66427. */
  66428. pivot: Vector3;
  66429. /**
  66430. * Must the particle be translated from its pivot point in its local space ?
  66431. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66432. * Default : false
  66433. */
  66434. translateFromPivot: boolean;
  66435. /**
  66436. * Index of this particle in the global "positions" array (Internal use)
  66437. * @hidden
  66438. */
  66439. _pos: number;
  66440. /**
  66441. * @hidden Index of this particle in the global "indices" array (Internal use)
  66442. */
  66443. _ind: number;
  66444. /**
  66445. * Group this particle belongs to
  66446. */
  66447. _group: PointsGroup;
  66448. /**
  66449. * Group id of this particle
  66450. */
  66451. groupId: number;
  66452. /**
  66453. * Index of the particle in its group id (Internal use)
  66454. */
  66455. idxInGroup: number;
  66456. /**
  66457. * @hidden Particle BoundingInfo object (Internal use)
  66458. */
  66459. _boundingInfo: BoundingInfo;
  66460. /**
  66461. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66462. */
  66463. _pcs: PointsCloudSystem;
  66464. /**
  66465. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66466. */
  66467. _stillInvisible: boolean;
  66468. /**
  66469. * @hidden Last computed particle rotation matrix
  66470. */
  66471. _rotationMatrix: number[];
  66472. /**
  66473. * Parent particle Id, if any.
  66474. * Default null.
  66475. */
  66476. parentId: Nullable<number>;
  66477. /**
  66478. * @hidden Internal global position in the PCS.
  66479. */
  66480. _globalPosition: Vector3;
  66481. /**
  66482. * Creates a Point Cloud object.
  66483. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66484. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66485. * @param group (PointsGroup) is the group the particle belongs to
  66486. * @param groupId (integer) is the group identifier in the PCS.
  66487. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66488. * @param pcs defines the PCS it is associated to
  66489. */
  66490. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66491. /**
  66492. * get point size
  66493. */
  66494. get size(): Vector3;
  66495. /**
  66496. * Set point size
  66497. */
  66498. set size(scale: Vector3);
  66499. /**
  66500. * Legacy support, changed quaternion to rotationQuaternion
  66501. */
  66502. get quaternion(): Nullable<Quaternion>;
  66503. /**
  66504. * Legacy support, changed quaternion to rotationQuaternion
  66505. */
  66506. set quaternion(q: Nullable<Quaternion>);
  66507. /**
  66508. * Returns a boolean. True if the particle intersects a mesh, else false
  66509. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66510. * @param target is the object (point or mesh) what the intersection is computed against
  66511. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66512. * @returns true if it intersects
  66513. */
  66514. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66515. /**
  66516. * get the rotation matrix of the particle
  66517. * @hidden
  66518. */
  66519. getRotationMatrix(m: Matrix): void;
  66520. }
  66521. /**
  66522. * Represents a group of points in a points cloud system
  66523. * * PCS internal tool, don't use it manually.
  66524. */
  66525. export class PointsGroup {
  66526. /**
  66527. * The group id
  66528. * @hidden
  66529. */
  66530. groupID: number;
  66531. /**
  66532. * image data for group (internal use)
  66533. * @hidden
  66534. */
  66535. _groupImageData: Nullable<ArrayBufferView>;
  66536. /**
  66537. * Image Width (internal use)
  66538. * @hidden
  66539. */
  66540. _groupImgWidth: number;
  66541. /**
  66542. * Image Height (internal use)
  66543. * @hidden
  66544. */
  66545. _groupImgHeight: number;
  66546. /**
  66547. * Custom position function (internal use)
  66548. * @hidden
  66549. */
  66550. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66551. /**
  66552. * density per facet for surface points
  66553. * @hidden
  66554. */
  66555. _groupDensity: number[];
  66556. /**
  66557. * Only when points are colored by texture carries pointer to texture list array
  66558. * @hidden
  66559. */
  66560. _textureNb: number;
  66561. /**
  66562. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66563. * PCS internal tool, don't use it manually.
  66564. * @hidden
  66565. */
  66566. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66567. }
  66568. }
  66569. declare module "babylonjs/Particles/index" {
  66570. export * from "babylonjs/Particles/baseParticleSystem";
  66571. export * from "babylonjs/Particles/EmitterTypes/index";
  66572. export * from "babylonjs/Particles/gpuParticleSystem";
  66573. export * from "babylonjs/Particles/IParticleSystem";
  66574. export * from "babylonjs/Particles/particle";
  66575. export * from "babylonjs/Particles/particleHelper";
  66576. export * from "babylonjs/Particles/particleSystem";
  66577. export * from "babylonjs/Particles/particleSystemComponent";
  66578. export * from "babylonjs/Particles/particleSystemSet";
  66579. export * from "babylonjs/Particles/solidParticle";
  66580. export * from "babylonjs/Particles/solidParticleSystem";
  66581. export * from "babylonjs/Particles/cloudPoint";
  66582. export * from "babylonjs/Particles/pointsCloudSystem";
  66583. export * from "babylonjs/Particles/subEmitter";
  66584. }
  66585. declare module "babylonjs/Physics/physicsEngineComponent" {
  66586. import { Nullable } from "babylonjs/types";
  66587. import { Observable, Observer } from "babylonjs/Misc/observable";
  66588. import { Vector3 } from "babylonjs/Maths/math.vector";
  66589. import { Mesh } from "babylonjs/Meshes/mesh";
  66590. import { ISceneComponent } from "babylonjs/sceneComponent";
  66591. import { Scene } from "babylonjs/scene";
  66592. import { Node } from "babylonjs/node";
  66593. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66594. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66595. module "babylonjs/scene" {
  66596. interface Scene {
  66597. /** @hidden (Backing field) */
  66598. _physicsEngine: Nullable<IPhysicsEngine>;
  66599. /** @hidden */
  66600. _physicsTimeAccumulator: number;
  66601. /**
  66602. * Gets the current physics engine
  66603. * @returns a IPhysicsEngine or null if none attached
  66604. */
  66605. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66606. /**
  66607. * Enables physics to the current scene
  66608. * @param gravity defines the scene's gravity for the physics engine
  66609. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66610. * @return a boolean indicating if the physics engine was initialized
  66611. */
  66612. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66613. /**
  66614. * Disables and disposes the physics engine associated with the scene
  66615. */
  66616. disablePhysicsEngine(): void;
  66617. /**
  66618. * Gets a boolean indicating if there is an active physics engine
  66619. * @returns a boolean indicating if there is an active physics engine
  66620. */
  66621. isPhysicsEnabled(): boolean;
  66622. /**
  66623. * Deletes a physics compound impostor
  66624. * @param compound defines the compound to delete
  66625. */
  66626. deleteCompoundImpostor(compound: any): void;
  66627. /**
  66628. * An event triggered when physic simulation is about to be run
  66629. */
  66630. onBeforePhysicsObservable: Observable<Scene>;
  66631. /**
  66632. * An event triggered when physic simulation has been done
  66633. */
  66634. onAfterPhysicsObservable: Observable<Scene>;
  66635. }
  66636. }
  66637. module "babylonjs/Meshes/abstractMesh" {
  66638. interface AbstractMesh {
  66639. /** @hidden */
  66640. _physicsImpostor: Nullable<PhysicsImpostor>;
  66641. /**
  66642. * Gets or sets impostor used for physic simulation
  66643. * @see http://doc.babylonjs.com/features/physics_engine
  66644. */
  66645. physicsImpostor: Nullable<PhysicsImpostor>;
  66646. /**
  66647. * Gets the current physics impostor
  66648. * @see http://doc.babylonjs.com/features/physics_engine
  66649. * @returns a physics impostor or null
  66650. */
  66651. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66652. /** Apply a physic impulse to the mesh
  66653. * @param force defines the force to apply
  66654. * @param contactPoint defines where to apply the force
  66655. * @returns the current mesh
  66656. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66657. */
  66658. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66659. /**
  66660. * Creates a physic joint between two meshes
  66661. * @param otherMesh defines the other mesh to use
  66662. * @param pivot1 defines the pivot to use on this mesh
  66663. * @param pivot2 defines the pivot to use on the other mesh
  66664. * @param options defines additional options (can be plugin dependent)
  66665. * @returns the current mesh
  66666. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66667. */
  66668. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66669. /** @hidden */
  66670. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66671. }
  66672. }
  66673. /**
  66674. * Defines the physics engine scene component responsible to manage a physics engine
  66675. */
  66676. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66677. /**
  66678. * The component name helpful to identify the component in the list of scene components.
  66679. */
  66680. readonly name: string;
  66681. /**
  66682. * The scene the component belongs to.
  66683. */
  66684. scene: Scene;
  66685. /**
  66686. * Creates a new instance of the component for the given scene
  66687. * @param scene Defines the scene to register the component in
  66688. */
  66689. constructor(scene: Scene);
  66690. /**
  66691. * Registers the component in a given scene
  66692. */
  66693. register(): void;
  66694. /**
  66695. * Rebuilds the elements related to this component in case of
  66696. * context lost for instance.
  66697. */
  66698. rebuild(): void;
  66699. /**
  66700. * Disposes the component and the associated ressources
  66701. */
  66702. dispose(): void;
  66703. }
  66704. }
  66705. declare module "babylonjs/Physics/physicsHelper" {
  66706. import { Nullable } from "babylonjs/types";
  66707. import { Vector3 } from "babylonjs/Maths/math.vector";
  66708. import { Mesh } from "babylonjs/Meshes/mesh";
  66709. import { Scene } from "babylonjs/scene";
  66710. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66711. /**
  66712. * A helper for physics simulations
  66713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66714. */
  66715. export class PhysicsHelper {
  66716. private _scene;
  66717. private _physicsEngine;
  66718. /**
  66719. * Initializes the Physics helper
  66720. * @param scene Babylon.js scene
  66721. */
  66722. constructor(scene: Scene);
  66723. /**
  66724. * Applies a radial explosion impulse
  66725. * @param origin the origin of the explosion
  66726. * @param radiusOrEventOptions the radius or the options of radial explosion
  66727. * @param strength the explosion strength
  66728. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66729. * @returns A physics radial explosion event, or null
  66730. */
  66731. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66732. /**
  66733. * Applies a radial explosion force
  66734. * @param origin the origin of the explosion
  66735. * @param radiusOrEventOptions the radius or the options of radial explosion
  66736. * @param strength the explosion strength
  66737. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66738. * @returns A physics radial explosion event, or null
  66739. */
  66740. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66741. /**
  66742. * Creates a gravitational field
  66743. * @param origin the origin of the explosion
  66744. * @param radiusOrEventOptions the radius or the options of radial explosion
  66745. * @param strength the explosion strength
  66746. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66747. * @returns A physics gravitational field event, or null
  66748. */
  66749. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66750. /**
  66751. * Creates a physics updraft event
  66752. * @param origin the origin of the updraft
  66753. * @param radiusOrEventOptions the radius or the options of the updraft
  66754. * @param strength the strength of the updraft
  66755. * @param height the height of the updraft
  66756. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66757. * @returns A physics updraft event, or null
  66758. */
  66759. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66760. /**
  66761. * Creates a physics vortex event
  66762. * @param origin the of the vortex
  66763. * @param radiusOrEventOptions the radius or the options of the vortex
  66764. * @param strength the strength of the vortex
  66765. * @param height the height of the vortex
  66766. * @returns a Physics vortex event, or null
  66767. * A physics vortex event or null
  66768. */
  66769. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66770. }
  66771. /**
  66772. * Represents a physics radial explosion event
  66773. */
  66774. class PhysicsRadialExplosionEvent {
  66775. private _scene;
  66776. private _options;
  66777. private _sphere;
  66778. private _dataFetched;
  66779. /**
  66780. * Initializes a radial explosioin event
  66781. * @param _scene BabylonJS scene
  66782. * @param _options The options for the vortex event
  66783. */
  66784. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66785. /**
  66786. * Returns the data related to the radial explosion event (sphere).
  66787. * @returns The radial explosion event data
  66788. */
  66789. getData(): PhysicsRadialExplosionEventData;
  66790. /**
  66791. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66792. * @param impostor A physics imposter
  66793. * @param origin the origin of the explosion
  66794. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66795. */
  66796. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66797. /**
  66798. * Triggers affecterd impostors callbacks
  66799. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66800. */
  66801. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66802. /**
  66803. * Disposes the sphere.
  66804. * @param force Specifies if the sphere should be disposed by force
  66805. */
  66806. dispose(force?: boolean): void;
  66807. /*** Helpers ***/
  66808. private _prepareSphere;
  66809. private _intersectsWithSphere;
  66810. }
  66811. /**
  66812. * Represents a gravitational field event
  66813. */
  66814. class PhysicsGravitationalFieldEvent {
  66815. private _physicsHelper;
  66816. private _scene;
  66817. private _origin;
  66818. private _options;
  66819. private _tickCallback;
  66820. private _sphere;
  66821. private _dataFetched;
  66822. /**
  66823. * Initializes the physics gravitational field event
  66824. * @param _physicsHelper A physics helper
  66825. * @param _scene BabylonJS scene
  66826. * @param _origin The origin position of the gravitational field event
  66827. * @param _options The options for the vortex event
  66828. */
  66829. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66830. /**
  66831. * Returns the data related to the gravitational field event (sphere).
  66832. * @returns A gravitational field event
  66833. */
  66834. getData(): PhysicsGravitationalFieldEventData;
  66835. /**
  66836. * Enables the gravitational field.
  66837. */
  66838. enable(): void;
  66839. /**
  66840. * Disables the gravitational field.
  66841. */
  66842. disable(): void;
  66843. /**
  66844. * Disposes the sphere.
  66845. * @param force The force to dispose from the gravitational field event
  66846. */
  66847. dispose(force?: boolean): void;
  66848. private _tick;
  66849. }
  66850. /**
  66851. * Represents a physics updraft event
  66852. */
  66853. class PhysicsUpdraftEvent {
  66854. private _scene;
  66855. private _origin;
  66856. private _options;
  66857. private _physicsEngine;
  66858. private _originTop;
  66859. private _originDirection;
  66860. private _tickCallback;
  66861. private _cylinder;
  66862. private _cylinderPosition;
  66863. private _dataFetched;
  66864. /**
  66865. * Initializes the physics updraft event
  66866. * @param _scene BabylonJS scene
  66867. * @param _origin The origin position of the updraft
  66868. * @param _options The options for the updraft event
  66869. */
  66870. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66871. /**
  66872. * Returns the data related to the updraft event (cylinder).
  66873. * @returns A physics updraft event
  66874. */
  66875. getData(): PhysicsUpdraftEventData;
  66876. /**
  66877. * Enables the updraft.
  66878. */
  66879. enable(): void;
  66880. /**
  66881. * Disables the updraft.
  66882. */
  66883. disable(): void;
  66884. /**
  66885. * Disposes the cylinder.
  66886. * @param force Specifies if the updraft should be disposed by force
  66887. */
  66888. dispose(force?: boolean): void;
  66889. private getImpostorHitData;
  66890. private _tick;
  66891. /*** Helpers ***/
  66892. private _prepareCylinder;
  66893. private _intersectsWithCylinder;
  66894. }
  66895. /**
  66896. * Represents a physics vortex event
  66897. */
  66898. class PhysicsVortexEvent {
  66899. private _scene;
  66900. private _origin;
  66901. private _options;
  66902. private _physicsEngine;
  66903. private _originTop;
  66904. private _tickCallback;
  66905. private _cylinder;
  66906. private _cylinderPosition;
  66907. private _dataFetched;
  66908. /**
  66909. * Initializes the physics vortex event
  66910. * @param _scene The BabylonJS scene
  66911. * @param _origin The origin position of the vortex
  66912. * @param _options The options for the vortex event
  66913. */
  66914. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66915. /**
  66916. * Returns the data related to the vortex event (cylinder).
  66917. * @returns The physics vortex event data
  66918. */
  66919. getData(): PhysicsVortexEventData;
  66920. /**
  66921. * Enables the vortex.
  66922. */
  66923. enable(): void;
  66924. /**
  66925. * Disables the cortex.
  66926. */
  66927. disable(): void;
  66928. /**
  66929. * Disposes the sphere.
  66930. * @param force
  66931. */
  66932. dispose(force?: boolean): void;
  66933. private getImpostorHitData;
  66934. private _tick;
  66935. /*** Helpers ***/
  66936. private _prepareCylinder;
  66937. private _intersectsWithCylinder;
  66938. }
  66939. /**
  66940. * Options fot the radial explosion event
  66941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66942. */
  66943. export class PhysicsRadialExplosionEventOptions {
  66944. /**
  66945. * The radius of the sphere for the radial explosion.
  66946. */
  66947. radius: number;
  66948. /**
  66949. * The strenth of the explosion.
  66950. */
  66951. strength: number;
  66952. /**
  66953. * The strenght of the force in correspondence to the distance of the affected object
  66954. */
  66955. falloff: PhysicsRadialImpulseFalloff;
  66956. /**
  66957. * Sphere options for the radial explosion.
  66958. */
  66959. sphere: {
  66960. segments: number;
  66961. diameter: number;
  66962. };
  66963. /**
  66964. * Sphere options for the radial explosion.
  66965. */
  66966. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66967. }
  66968. /**
  66969. * Options fot the updraft event
  66970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66971. */
  66972. export class PhysicsUpdraftEventOptions {
  66973. /**
  66974. * The radius of the cylinder for the vortex
  66975. */
  66976. radius: number;
  66977. /**
  66978. * The strenth of the updraft.
  66979. */
  66980. strength: number;
  66981. /**
  66982. * The height of the cylinder for the updraft.
  66983. */
  66984. height: number;
  66985. /**
  66986. * The mode for the the updraft.
  66987. */
  66988. updraftMode: PhysicsUpdraftMode;
  66989. }
  66990. /**
  66991. * Options fot the vortex event
  66992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66993. */
  66994. export class PhysicsVortexEventOptions {
  66995. /**
  66996. * The radius of the cylinder for the vortex
  66997. */
  66998. radius: number;
  66999. /**
  67000. * The strenth of the vortex.
  67001. */
  67002. strength: number;
  67003. /**
  67004. * The height of the cylinder for the vortex.
  67005. */
  67006. height: number;
  67007. /**
  67008. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67009. */
  67010. centripetalForceThreshold: number;
  67011. /**
  67012. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67013. */
  67014. centripetalForceMultiplier: number;
  67015. /**
  67016. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67017. */
  67018. centrifugalForceMultiplier: number;
  67019. /**
  67020. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67021. */
  67022. updraftForceMultiplier: number;
  67023. }
  67024. /**
  67025. * The strenght of the force in correspondence to the distance of the affected object
  67026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67027. */
  67028. export enum PhysicsRadialImpulseFalloff {
  67029. /** Defines that impulse is constant in strength across it's whole radius */
  67030. Constant = 0,
  67031. /** Defines that impulse gets weaker if it's further from the origin */
  67032. Linear = 1
  67033. }
  67034. /**
  67035. * The strength of the force in correspondence to the distance of the affected object
  67036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67037. */
  67038. export enum PhysicsUpdraftMode {
  67039. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67040. Center = 0,
  67041. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67042. Perpendicular = 1
  67043. }
  67044. /**
  67045. * Interface for a physics hit data
  67046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67047. */
  67048. export interface PhysicsHitData {
  67049. /**
  67050. * The force applied at the contact point
  67051. */
  67052. force: Vector3;
  67053. /**
  67054. * The contact point
  67055. */
  67056. contactPoint: Vector3;
  67057. /**
  67058. * The distance from the origin to the contact point
  67059. */
  67060. distanceFromOrigin: number;
  67061. }
  67062. /**
  67063. * Interface for radial explosion event data
  67064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67065. */
  67066. export interface PhysicsRadialExplosionEventData {
  67067. /**
  67068. * A sphere used for the radial explosion event
  67069. */
  67070. sphere: Mesh;
  67071. }
  67072. /**
  67073. * Interface for gravitational field event data
  67074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67075. */
  67076. export interface PhysicsGravitationalFieldEventData {
  67077. /**
  67078. * A sphere mesh used for the gravitational field event
  67079. */
  67080. sphere: Mesh;
  67081. }
  67082. /**
  67083. * Interface for updraft event data
  67084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67085. */
  67086. export interface PhysicsUpdraftEventData {
  67087. /**
  67088. * A cylinder used for the updraft event
  67089. */
  67090. cylinder: Mesh;
  67091. }
  67092. /**
  67093. * Interface for vortex event data
  67094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67095. */
  67096. export interface PhysicsVortexEventData {
  67097. /**
  67098. * A cylinder used for the vortex event
  67099. */
  67100. cylinder: Mesh;
  67101. }
  67102. /**
  67103. * Interface for an affected physics impostor
  67104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67105. */
  67106. export interface PhysicsAffectedImpostorWithData {
  67107. /**
  67108. * The impostor affected by the effect
  67109. */
  67110. impostor: PhysicsImpostor;
  67111. /**
  67112. * The data about the hit/horce from the explosion
  67113. */
  67114. hitData: PhysicsHitData;
  67115. }
  67116. }
  67117. declare module "babylonjs/Physics/Plugins/index" {
  67118. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67119. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67120. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67121. }
  67122. declare module "babylonjs/Physics/index" {
  67123. export * from "babylonjs/Physics/IPhysicsEngine";
  67124. export * from "babylonjs/Physics/physicsEngine";
  67125. export * from "babylonjs/Physics/physicsEngineComponent";
  67126. export * from "babylonjs/Physics/physicsHelper";
  67127. export * from "babylonjs/Physics/physicsImpostor";
  67128. export * from "babylonjs/Physics/physicsJoint";
  67129. export * from "babylonjs/Physics/Plugins/index";
  67130. }
  67131. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67132. /** @hidden */
  67133. export var blackAndWhitePixelShader: {
  67134. name: string;
  67135. shader: string;
  67136. };
  67137. }
  67138. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67139. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67140. import { Camera } from "babylonjs/Cameras/camera";
  67141. import { Engine } from "babylonjs/Engines/engine";
  67142. import "babylonjs/Shaders/blackAndWhite.fragment";
  67143. /**
  67144. * Post process used to render in black and white
  67145. */
  67146. export class BlackAndWhitePostProcess extends PostProcess {
  67147. /**
  67148. * Linear about to convert he result to black and white (default: 1)
  67149. */
  67150. degree: number;
  67151. /**
  67152. * Creates a black and white post process
  67153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67154. * @param name The name of the effect.
  67155. * @param options The required width/height ratio to downsize to before computing the render pass.
  67156. * @param camera The camera to apply the render pass to.
  67157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67158. * @param engine The engine which the post process will be applied. (default: current engine)
  67159. * @param reusable If the post process can be reused on the same frame. (default: false)
  67160. */
  67161. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67162. }
  67163. }
  67164. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67165. import { Nullable } from "babylonjs/types";
  67166. import { Camera } from "babylonjs/Cameras/camera";
  67167. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67168. import { Engine } from "babylonjs/Engines/engine";
  67169. /**
  67170. * This represents a set of one or more post processes in Babylon.
  67171. * A post process can be used to apply a shader to a texture after it is rendered.
  67172. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67173. */
  67174. export class PostProcessRenderEffect {
  67175. private _postProcesses;
  67176. private _getPostProcesses;
  67177. private _singleInstance;
  67178. private _cameras;
  67179. private _indicesForCamera;
  67180. /**
  67181. * Name of the effect
  67182. * @hidden
  67183. */
  67184. _name: string;
  67185. /**
  67186. * Instantiates a post process render effect.
  67187. * A post process can be used to apply a shader to a texture after it is rendered.
  67188. * @param engine The engine the effect is tied to
  67189. * @param name The name of the effect
  67190. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67191. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67192. */
  67193. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67194. /**
  67195. * Checks if all the post processes in the effect are supported.
  67196. */
  67197. get isSupported(): boolean;
  67198. /**
  67199. * Updates the current state of the effect
  67200. * @hidden
  67201. */
  67202. _update(): void;
  67203. /**
  67204. * Attaches the effect on cameras
  67205. * @param cameras The camera to attach to.
  67206. * @hidden
  67207. */
  67208. _attachCameras(cameras: Camera): void;
  67209. /**
  67210. * Attaches the effect on cameras
  67211. * @param cameras The camera to attach to.
  67212. * @hidden
  67213. */
  67214. _attachCameras(cameras: Camera[]): void;
  67215. /**
  67216. * Detaches the effect on cameras
  67217. * @param cameras The camera to detatch from.
  67218. * @hidden
  67219. */
  67220. _detachCameras(cameras: Camera): void;
  67221. /**
  67222. * Detatches the effect on cameras
  67223. * @param cameras The camera to detatch from.
  67224. * @hidden
  67225. */
  67226. _detachCameras(cameras: Camera[]): void;
  67227. /**
  67228. * Enables the effect on given cameras
  67229. * @param cameras The camera to enable.
  67230. * @hidden
  67231. */
  67232. _enable(cameras: Camera): void;
  67233. /**
  67234. * Enables the effect on given cameras
  67235. * @param cameras The camera to enable.
  67236. * @hidden
  67237. */
  67238. _enable(cameras: Nullable<Camera[]>): void;
  67239. /**
  67240. * Disables the effect on the given cameras
  67241. * @param cameras The camera to disable.
  67242. * @hidden
  67243. */
  67244. _disable(cameras: Camera): void;
  67245. /**
  67246. * Disables the effect on the given cameras
  67247. * @param cameras The camera to disable.
  67248. * @hidden
  67249. */
  67250. _disable(cameras: Nullable<Camera[]>): void;
  67251. /**
  67252. * Gets a list of the post processes contained in the effect.
  67253. * @param camera The camera to get the post processes on.
  67254. * @returns The list of the post processes in the effect.
  67255. */
  67256. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67257. }
  67258. }
  67259. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67260. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67261. /** @hidden */
  67262. export var extractHighlightsPixelShader: {
  67263. name: string;
  67264. shader: string;
  67265. };
  67266. }
  67267. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67268. import { Nullable } from "babylonjs/types";
  67269. import { Camera } from "babylonjs/Cameras/camera";
  67270. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67271. import { Engine } from "babylonjs/Engines/engine";
  67272. import "babylonjs/Shaders/extractHighlights.fragment";
  67273. /**
  67274. * 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.
  67275. */
  67276. export class ExtractHighlightsPostProcess extends PostProcess {
  67277. /**
  67278. * The luminance threshold, pixels below this value will be set to black.
  67279. */
  67280. threshold: number;
  67281. /** @hidden */
  67282. _exposure: number;
  67283. /**
  67284. * Post process which has the input texture to be used when performing highlight extraction
  67285. * @hidden
  67286. */
  67287. _inputPostProcess: Nullable<PostProcess>;
  67288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67289. }
  67290. }
  67291. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67292. /** @hidden */
  67293. export var bloomMergePixelShader: {
  67294. name: string;
  67295. shader: string;
  67296. };
  67297. }
  67298. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67300. import { Nullable } from "babylonjs/types";
  67301. import { Engine } from "babylonjs/Engines/engine";
  67302. import { Camera } from "babylonjs/Cameras/camera";
  67303. import "babylonjs/Shaders/bloomMerge.fragment";
  67304. /**
  67305. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67306. */
  67307. export class BloomMergePostProcess extends PostProcess {
  67308. /** Weight of the bloom to be added to the original input. */
  67309. weight: number;
  67310. /**
  67311. * Creates a new instance of @see BloomMergePostProcess
  67312. * @param name The name of the effect.
  67313. * @param originalFromInput Post process which's input will be used for the merge.
  67314. * @param blurred Blurred highlights post process which's output will be used.
  67315. * @param weight Weight of the bloom to be added to the original input.
  67316. * @param options The required width/height ratio to downsize to before computing the render pass.
  67317. * @param camera The camera to apply the render pass to.
  67318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67319. * @param engine The engine which the post process will be applied. (default: current engine)
  67320. * @param reusable If the post process can be reused on the same frame. (default: false)
  67321. * @param textureType Type of textures used when performing the post process. (default: 0)
  67322. * @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)
  67323. */
  67324. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67325. /** Weight of the bloom to be added to the original input. */
  67326. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67327. }
  67328. }
  67329. declare module "babylonjs/PostProcesses/bloomEffect" {
  67330. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67332. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67333. import { Camera } from "babylonjs/Cameras/camera";
  67334. import { Scene } from "babylonjs/scene";
  67335. /**
  67336. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67337. */
  67338. export class BloomEffect extends PostProcessRenderEffect {
  67339. private bloomScale;
  67340. /**
  67341. * @hidden Internal
  67342. */
  67343. _effects: Array<PostProcess>;
  67344. /**
  67345. * @hidden Internal
  67346. */
  67347. _downscale: ExtractHighlightsPostProcess;
  67348. private _blurX;
  67349. private _blurY;
  67350. private _merge;
  67351. /**
  67352. * The luminance threshold to find bright areas of the image to bloom.
  67353. */
  67354. get threshold(): number;
  67355. set threshold(value: number);
  67356. /**
  67357. * The strength of the bloom.
  67358. */
  67359. get weight(): number;
  67360. set weight(value: number);
  67361. /**
  67362. * Specifies the size of the bloom blur kernel, relative to the final output size
  67363. */
  67364. get kernel(): number;
  67365. set kernel(value: number);
  67366. /**
  67367. * Creates a new instance of @see BloomEffect
  67368. * @param scene The scene the effect belongs to.
  67369. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67370. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67371. * @param bloomWeight The the strength of bloom.
  67372. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67373. * @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)
  67374. */
  67375. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67376. /**
  67377. * Disposes each of the internal effects for a given camera.
  67378. * @param camera The camera to dispose the effect on.
  67379. */
  67380. disposeEffects(camera: Camera): void;
  67381. /**
  67382. * @hidden Internal
  67383. */
  67384. _updateEffects(): void;
  67385. /**
  67386. * Internal
  67387. * @returns if all the contained post processes are ready.
  67388. * @hidden
  67389. */
  67390. _isReady(): boolean;
  67391. }
  67392. }
  67393. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67394. /** @hidden */
  67395. export var chromaticAberrationPixelShader: {
  67396. name: string;
  67397. shader: string;
  67398. };
  67399. }
  67400. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67401. import { Vector2 } from "babylonjs/Maths/math.vector";
  67402. import { Nullable } from "babylonjs/types";
  67403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67404. import { Camera } from "babylonjs/Cameras/camera";
  67405. import { Engine } from "babylonjs/Engines/engine";
  67406. import "babylonjs/Shaders/chromaticAberration.fragment";
  67407. /**
  67408. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67409. */
  67410. export class ChromaticAberrationPostProcess extends PostProcess {
  67411. /**
  67412. * The amount of seperation of rgb channels (default: 30)
  67413. */
  67414. aberrationAmount: number;
  67415. /**
  67416. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67417. */
  67418. radialIntensity: number;
  67419. /**
  67420. * 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))
  67421. */
  67422. direction: Vector2;
  67423. /**
  67424. * 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))
  67425. */
  67426. centerPosition: Vector2;
  67427. /**
  67428. * Creates a new instance ChromaticAberrationPostProcess
  67429. * @param name The name of the effect.
  67430. * @param screenWidth The width of the screen to apply the effect on.
  67431. * @param screenHeight The height of the screen to apply the effect on.
  67432. * @param options The required width/height ratio to downsize to before computing the render pass.
  67433. * @param camera The camera to apply the render pass to.
  67434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67435. * @param engine The engine which the post process will be applied. (default: current engine)
  67436. * @param reusable If the post process can be reused on the same frame. (default: false)
  67437. * @param textureType Type of textures used when performing the post process. (default: 0)
  67438. * @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)
  67439. */
  67440. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67441. }
  67442. }
  67443. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67444. /** @hidden */
  67445. export var circleOfConfusionPixelShader: {
  67446. name: string;
  67447. shader: string;
  67448. };
  67449. }
  67450. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67451. import { Nullable } from "babylonjs/types";
  67452. import { Engine } from "babylonjs/Engines/engine";
  67453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67454. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67455. import { Camera } from "babylonjs/Cameras/camera";
  67456. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67457. /**
  67458. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67459. */
  67460. export class CircleOfConfusionPostProcess extends PostProcess {
  67461. /**
  67462. * 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.
  67463. */
  67464. lensSize: number;
  67465. /**
  67466. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67467. */
  67468. fStop: number;
  67469. /**
  67470. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67471. */
  67472. focusDistance: number;
  67473. /**
  67474. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67475. */
  67476. focalLength: number;
  67477. private _depthTexture;
  67478. /**
  67479. * Creates a new instance CircleOfConfusionPostProcess
  67480. * @param name The name of the effect.
  67481. * @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.
  67482. * @param options The required width/height ratio to downsize to before computing the render pass.
  67483. * @param camera The camera to apply the render pass to.
  67484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67485. * @param engine The engine which the post process will be applied. (default: current engine)
  67486. * @param reusable If the post process can be reused on the same frame. (default: false)
  67487. * @param textureType Type of textures used when performing the post process. (default: 0)
  67488. * @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)
  67489. */
  67490. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67491. /**
  67492. * 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.
  67493. */
  67494. set depthTexture(value: RenderTargetTexture);
  67495. }
  67496. }
  67497. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67498. /** @hidden */
  67499. export var colorCorrectionPixelShader: {
  67500. name: string;
  67501. shader: string;
  67502. };
  67503. }
  67504. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67506. import { Engine } from "babylonjs/Engines/engine";
  67507. import { Camera } from "babylonjs/Cameras/camera";
  67508. import "babylonjs/Shaders/colorCorrection.fragment";
  67509. /**
  67510. *
  67511. * This post-process allows the modification of rendered colors by using
  67512. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67513. *
  67514. * The object needs to be provided an url to a texture containing the color
  67515. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67516. * Use an image editing software to tweak the LUT to match your needs.
  67517. *
  67518. * For an example of a color LUT, see here:
  67519. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67520. * For explanations on color grading, see here:
  67521. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67522. *
  67523. */
  67524. export class ColorCorrectionPostProcess extends PostProcess {
  67525. private _colorTableTexture;
  67526. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67527. }
  67528. }
  67529. declare module "babylonjs/Shaders/convolution.fragment" {
  67530. /** @hidden */
  67531. export var convolutionPixelShader: {
  67532. name: string;
  67533. shader: string;
  67534. };
  67535. }
  67536. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67537. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67538. import { Nullable } from "babylonjs/types";
  67539. import { Camera } from "babylonjs/Cameras/camera";
  67540. import { Engine } from "babylonjs/Engines/engine";
  67541. import "babylonjs/Shaders/convolution.fragment";
  67542. /**
  67543. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67544. * input texture to perform effects such as edge detection or sharpening
  67545. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67546. */
  67547. export class ConvolutionPostProcess extends PostProcess {
  67548. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67549. kernel: number[];
  67550. /**
  67551. * Creates a new instance ConvolutionPostProcess
  67552. * @param name The name of the effect.
  67553. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67554. * @param options The required width/height ratio to downsize to before computing the render pass.
  67555. * @param camera The camera to apply the render pass to.
  67556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67557. * @param engine The engine which the post process will be applied. (default: current engine)
  67558. * @param reusable If the post process can be reused on the same frame. (default: false)
  67559. * @param textureType Type of textures used when performing the post process. (default: 0)
  67560. */
  67561. constructor(name: string,
  67562. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67563. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67564. /**
  67565. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67566. */
  67567. static EdgeDetect0Kernel: number[];
  67568. /**
  67569. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67570. */
  67571. static EdgeDetect1Kernel: number[];
  67572. /**
  67573. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67574. */
  67575. static EdgeDetect2Kernel: number[];
  67576. /**
  67577. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67578. */
  67579. static SharpenKernel: number[];
  67580. /**
  67581. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67582. */
  67583. static EmbossKernel: number[];
  67584. /**
  67585. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67586. */
  67587. static GaussianKernel: number[];
  67588. }
  67589. }
  67590. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67591. import { Nullable } from "babylonjs/types";
  67592. import { Vector2 } from "babylonjs/Maths/math.vector";
  67593. import { Camera } from "babylonjs/Cameras/camera";
  67594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67595. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67596. import { Engine } from "babylonjs/Engines/engine";
  67597. import { Scene } from "babylonjs/scene";
  67598. /**
  67599. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67600. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67601. * based on samples that have a large difference in distance than the center pixel.
  67602. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67603. */
  67604. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67605. direction: Vector2;
  67606. /**
  67607. * Creates a new instance CircleOfConfusionPostProcess
  67608. * @param name The name of the effect.
  67609. * @param scene The scene the effect belongs to.
  67610. * @param direction The direction the blur should be applied.
  67611. * @param kernel The size of the kernel used to blur.
  67612. * @param options The required width/height ratio to downsize to before computing the render pass.
  67613. * @param camera The camera to apply the render pass to.
  67614. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67615. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67617. * @param engine The engine which the post process will be applied. (default: current engine)
  67618. * @param reusable If the post process can be reused on the same frame. (default: false)
  67619. * @param textureType Type of textures used when performing the post process. (default: 0)
  67620. * @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)
  67621. */
  67622. 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);
  67623. }
  67624. }
  67625. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67626. /** @hidden */
  67627. export var depthOfFieldMergePixelShader: {
  67628. name: string;
  67629. shader: string;
  67630. };
  67631. }
  67632. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67633. import { Nullable } from "babylonjs/types";
  67634. import { Camera } from "babylonjs/Cameras/camera";
  67635. import { Effect } from "babylonjs/Materials/effect";
  67636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67637. import { Engine } from "babylonjs/Engines/engine";
  67638. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67639. /**
  67640. * Options to be set when merging outputs from the default pipeline.
  67641. */
  67642. export class DepthOfFieldMergePostProcessOptions {
  67643. /**
  67644. * The original image to merge on top of
  67645. */
  67646. originalFromInput: PostProcess;
  67647. /**
  67648. * Parameters to perform the merge of the depth of field effect
  67649. */
  67650. depthOfField?: {
  67651. circleOfConfusion: PostProcess;
  67652. blurSteps: Array<PostProcess>;
  67653. };
  67654. /**
  67655. * Parameters to perform the merge of bloom effect
  67656. */
  67657. bloom?: {
  67658. blurred: PostProcess;
  67659. weight: number;
  67660. };
  67661. }
  67662. /**
  67663. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67664. */
  67665. export class DepthOfFieldMergePostProcess extends PostProcess {
  67666. private blurSteps;
  67667. /**
  67668. * Creates a new instance of DepthOfFieldMergePostProcess
  67669. * @param name The name of the effect.
  67670. * @param originalFromInput Post process which's input will be used for the merge.
  67671. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67672. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67673. * @param options The required width/height ratio to downsize to before computing the render pass.
  67674. * @param camera The camera to apply the render pass to.
  67675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67676. * @param engine The engine which the post process will be applied. (default: current engine)
  67677. * @param reusable If the post process can be reused on the same frame. (default: false)
  67678. * @param textureType Type of textures used when performing the post process. (default: 0)
  67679. * @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)
  67680. */
  67681. 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);
  67682. /**
  67683. * Updates the effect with the current post process compile time values and recompiles the shader.
  67684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67687. * @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
  67688. * @param onCompiled Called when the shader has been compiled.
  67689. * @param onError Called if there is an error when compiling a shader.
  67690. */
  67691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67692. }
  67693. }
  67694. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67695. import { Nullable } from "babylonjs/types";
  67696. import { Camera } from "babylonjs/Cameras/camera";
  67697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67698. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67699. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67700. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67701. import { Scene } from "babylonjs/scene";
  67702. /**
  67703. * Specifies the level of max blur that should be applied when using the depth of field effect
  67704. */
  67705. export enum DepthOfFieldEffectBlurLevel {
  67706. /**
  67707. * Subtle blur
  67708. */
  67709. Low = 0,
  67710. /**
  67711. * Medium blur
  67712. */
  67713. Medium = 1,
  67714. /**
  67715. * Large blur
  67716. */
  67717. High = 2
  67718. }
  67719. /**
  67720. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67721. */
  67722. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67723. private _circleOfConfusion;
  67724. /**
  67725. * @hidden Internal, blurs from high to low
  67726. */
  67727. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67728. private _depthOfFieldBlurY;
  67729. private _dofMerge;
  67730. /**
  67731. * @hidden Internal post processes in depth of field effect
  67732. */
  67733. _effects: Array<PostProcess>;
  67734. /**
  67735. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67736. */
  67737. set focalLength(value: number);
  67738. get focalLength(): number;
  67739. /**
  67740. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67741. */
  67742. set fStop(value: number);
  67743. get fStop(): number;
  67744. /**
  67745. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67746. */
  67747. set focusDistance(value: number);
  67748. get focusDistance(): number;
  67749. /**
  67750. * 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.
  67751. */
  67752. set lensSize(value: number);
  67753. get lensSize(): number;
  67754. /**
  67755. * Creates a new instance DepthOfFieldEffect
  67756. * @param scene The scene the effect belongs to.
  67757. * @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.
  67758. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67759. * @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)
  67760. */
  67761. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67762. /**
  67763. * Get the current class name of the current effet
  67764. * @returns "DepthOfFieldEffect"
  67765. */
  67766. getClassName(): string;
  67767. /**
  67768. * 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.
  67769. */
  67770. set depthTexture(value: RenderTargetTexture);
  67771. /**
  67772. * Disposes each of the internal effects for a given camera.
  67773. * @param camera The camera to dispose the effect on.
  67774. */
  67775. disposeEffects(camera: Camera): void;
  67776. /**
  67777. * @hidden Internal
  67778. */
  67779. _updateEffects(): void;
  67780. /**
  67781. * Internal
  67782. * @returns if all the contained post processes are ready.
  67783. * @hidden
  67784. */
  67785. _isReady(): boolean;
  67786. }
  67787. }
  67788. declare module "babylonjs/Shaders/displayPass.fragment" {
  67789. /** @hidden */
  67790. export var displayPassPixelShader: {
  67791. name: string;
  67792. shader: string;
  67793. };
  67794. }
  67795. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67796. import { Nullable } from "babylonjs/types";
  67797. import { Camera } from "babylonjs/Cameras/camera";
  67798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67799. import { Engine } from "babylonjs/Engines/engine";
  67800. import "babylonjs/Shaders/displayPass.fragment";
  67801. /**
  67802. * DisplayPassPostProcess which produces an output the same as it's input
  67803. */
  67804. export class DisplayPassPostProcess extends PostProcess {
  67805. /**
  67806. * Creates the DisplayPassPostProcess
  67807. * @param name The name of the effect.
  67808. * @param options The required width/height ratio to downsize to before computing the render pass.
  67809. * @param camera The camera to apply the render pass to.
  67810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67811. * @param engine The engine which the post process will be applied. (default: current engine)
  67812. * @param reusable If the post process can be reused on the same frame. (default: false)
  67813. */
  67814. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67815. }
  67816. }
  67817. declare module "babylonjs/Shaders/filter.fragment" {
  67818. /** @hidden */
  67819. export var filterPixelShader: {
  67820. name: string;
  67821. shader: string;
  67822. };
  67823. }
  67824. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67825. import { Nullable } from "babylonjs/types";
  67826. import { Matrix } from "babylonjs/Maths/math.vector";
  67827. import { Camera } from "babylonjs/Cameras/camera";
  67828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67829. import { Engine } from "babylonjs/Engines/engine";
  67830. import "babylonjs/Shaders/filter.fragment";
  67831. /**
  67832. * Applies a kernel filter to the image
  67833. */
  67834. export class FilterPostProcess extends PostProcess {
  67835. /** The matrix to be applied to the image */
  67836. kernelMatrix: Matrix;
  67837. /**
  67838. *
  67839. * @param name The name of the effect.
  67840. * @param kernelMatrix The matrix to be applied to the image
  67841. * @param options The required width/height ratio to downsize to before computing the render pass.
  67842. * @param camera The camera to apply the render pass to.
  67843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67844. * @param engine The engine which the post process will be applied. (default: current engine)
  67845. * @param reusable If the post process can be reused on the same frame. (default: false)
  67846. */
  67847. constructor(name: string,
  67848. /** The matrix to be applied to the image */
  67849. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67850. }
  67851. }
  67852. declare module "babylonjs/Shaders/fxaa.fragment" {
  67853. /** @hidden */
  67854. export var fxaaPixelShader: {
  67855. name: string;
  67856. shader: string;
  67857. };
  67858. }
  67859. declare module "babylonjs/Shaders/fxaa.vertex" {
  67860. /** @hidden */
  67861. export var fxaaVertexShader: {
  67862. name: string;
  67863. shader: string;
  67864. };
  67865. }
  67866. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67867. import { Nullable } from "babylonjs/types";
  67868. import { Camera } from "babylonjs/Cameras/camera";
  67869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67870. import { Engine } from "babylonjs/Engines/engine";
  67871. import "babylonjs/Shaders/fxaa.fragment";
  67872. import "babylonjs/Shaders/fxaa.vertex";
  67873. /**
  67874. * Fxaa post process
  67875. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67876. */
  67877. export class FxaaPostProcess extends PostProcess {
  67878. /** @hidden */
  67879. texelWidth: number;
  67880. /** @hidden */
  67881. texelHeight: number;
  67882. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67883. private _getDefines;
  67884. }
  67885. }
  67886. declare module "babylonjs/Shaders/grain.fragment" {
  67887. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67888. /** @hidden */
  67889. export var grainPixelShader: {
  67890. name: string;
  67891. shader: string;
  67892. };
  67893. }
  67894. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67895. import { Nullable } from "babylonjs/types";
  67896. import { Camera } from "babylonjs/Cameras/camera";
  67897. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67898. import { Engine } from "babylonjs/Engines/engine";
  67899. import "babylonjs/Shaders/grain.fragment";
  67900. /**
  67901. * The GrainPostProcess adds noise to the image at mid luminance levels
  67902. */
  67903. export class GrainPostProcess extends PostProcess {
  67904. /**
  67905. * The intensity of the grain added (default: 30)
  67906. */
  67907. intensity: number;
  67908. /**
  67909. * If the grain should be randomized on every frame
  67910. */
  67911. animated: boolean;
  67912. /**
  67913. * Creates a new instance of @see GrainPostProcess
  67914. * @param name The name of the effect.
  67915. * @param options The required width/height ratio to downsize to before computing the render pass.
  67916. * @param camera The camera to apply the render pass to.
  67917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67918. * @param engine The engine which the post process will be applied. (default: current engine)
  67919. * @param reusable If the post process can be reused on the same frame. (default: false)
  67920. * @param textureType Type of textures used when performing the post process. (default: 0)
  67921. * @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)
  67922. */
  67923. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67924. }
  67925. }
  67926. declare module "babylonjs/Shaders/highlights.fragment" {
  67927. /** @hidden */
  67928. export var highlightsPixelShader: {
  67929. name: string;
  67930. shader: string;
  67931. };
  67932. }
  67933. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67934. import { Nullable } from "babylonjs/types";
  67935. import { Camera } from "babylonjs/Cameras/camera";
  67936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67937. import { Engine } from "babylonjs/Engines/engine";
  67938. import "babylonjs/Shaders/highlights.fragment";
  67939. /**
  67940. * Extracts highlights from the image
  67941. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67942. */
  67943. export class HighlightsPostProcess extends PostProcess {
  67944. /**
  67945. * Extracts highlights from the image
  67946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67947. * @param name The name of the effect.
  67948. * @param options The required width/height ratio to downsize to before computing the render pass.
  67949. * @param camera The camera to apply the render pass to.
  67950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67951. * @param engine The engine which the post process will be applied. (default: current engine)
  67952. * @param reusable If the post process can be reused on the same frame. (default: false)
  67953. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67954. */
  67955. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67956. }
  67957. }
  67958. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67959. /** @hidden */
  67960. export var mrtFragmentDeclaration: {
  67961. name: string;
  67962. shader: string;
  67963. };
  67964. }
  67965. declare module "babylonjs/Shaders/geometry.fragment" {
  67966. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67967. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67968. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67969. /** @hidden */
  67970. export var geometryPixelShader: {
  67971. name: string;
  67972. shader: string;
  67973. };
  67974. }
  67975. declare module "babylonjs/Shaders/geometry.vertex" {
  67976. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67977. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67979. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67981. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67982. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67983. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67984. /** @hidden */
  67985. export var geometryVertexShader: {
  67986. name: string;
  67987. shader: string;
  67988. };
  67989. }
  67990. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67991. import { Matrix } from "babylonjs/Maths/math.vector";
  67992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67993. import { Mesh } from "babylonjs/Meshes/mesh";
  67994. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67995. import { Effect } from "babylonjs/Materials/effect";
  67996. import { Scene } from "babylonjs/scene";
  67997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67998. import "babylonjs/Shaders/geometry.fragment";
  67999. import "babylonjs/Shaders/geometry.vertex";
  68000. /** @hidden */
  68001. interface ISavedTransformationMatrix {
  68002. world: Matrix;
  68003. viewProjection: Matrix;
  68004. }
  68005. /**
  68006. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68007. */
  68008. export class GeometryBufferRenderer {
  68009. /**
  68010. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68011. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68012. */
  68013. static readonly POSITION_TEXTURE_TYPE: number;
  68014. /**
  68015. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68016. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68017. */
  68018. static readonly VELOCITY_TEXTURE_TYPE: number;
  68019. /**
  68020. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68021. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68022. */
  68023. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68024. /**
  68025. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68026. * in order to compute objects velocities when enableVelocity is set to "true"
  68027. * @hidden
  68028. */
  68029. _previousTransformationMatrices: {
  68030. [index: number]: ISavedTransformationMatrix;
  68031. };
  68032. /**
  68033. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68034. * in order to compute objects velocities when enableVelocity is set to "true"
  68035. * @hidden
  68036. */
  68037. _previousBonesTransformationMatrices: {
  68038. [index: number]: Float32Array;
  68039. };
  68040. /**
  68041. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68042. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68043. */
  68044. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68045. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68046. renderTransparentMeshes: boolean;
  68047. private _scene;
  68048. private _multiRenderTarget;
  68049. private _ratio;
  68050. private _enablePosition;
  68051. private _enableVelocity;
  68052. private _enableReflectivity;
  68053. private _positionIndex;
  68054. private _velocityIndex;
  68055. private _reflectivityIndex;
  68056. protected _effect: Effect;
  68057. protected _cachedDefines: string;
  68058. /**
  68059. * Set the render list (meshes to be rendered) used in the G buffer.
  68060. */
  68061. set renderList(meshes: Mesh[]);
  68062. /**
  68063. * Gets wether or not G buffer are supported by the running hardware.
  68064. * This requires draw buffer supports
  68065. */
  68066. get isSupported(): boolean;
  68067. /**
  68068. * Returns the index of the given texture type in the G-Buffer textures array
  68069. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68070. * @returns the index of the given texture type in the G-Buffer textures array
  68071. */
  68072. getTextureIndex(textureType: number): number;
  68073. /**
  68074. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68075. */
  68076. get enablePosition(): boolean;
  68077. /**
  68078. * Sets whether or not objects positions are enabled for the G buffer.
  68079. */
  68080. set enablePosition(enable: boolean);
  68081. /**
  68082. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68083. */
  68084. get enableVelocity(): boolean;
  68085. /**
  68086. * Sets wether or not objects velocities are enabled for the G buffer.
  68087. */
  68088. set enableVelocity(enable: boolean);
  68089. /**
  68090. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68091. */
  68092. get enableReflectivity(): boolean;
  68093. /**
  68094. * Sets wether or not objects roughness are enabled for the G buffer.
  68095. */
  68096. set enableReflectivity(enable: boolean);
  68097. /**
  68098. * Gets the scene associated with the buffer.
  68099. */
  68100. get scene(): Scene;
  68101. /**
  68102. * Gets the ratio used by the buffer during its creation.
  68103. * How big is the buffer related to the main canvas.
  68104. */
  68105. get ratio(): number;
  68106. /** @hidden */
  68107. static _SceneComponentInitialization: (scene: Scene) => void;
  68108. /**
  68109. * Creates a new G Buffer for the scene
  68110. * @param scene The scene the buffer belongs to
  68111. * @param ratio How big is the buffer related to the main canvas.
  68112. */
  68113. constructor(scene: Scene, ratio?: number);
  68114. /**
  68115. * Checks wether everything is ready to render a submesh to the G buffer.
  68116. * @param subMesh the submesh to check readiness for
  68117. * @param useInstances is the mesh drawn using instance or not
  68118. * @returns true if ready otherwise false
  68119. */
  68120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68121. /**
  68122. * Gets the current underlying G Buffer.
  68123. * @returns the buffer
  68124. */
  68125. getGBuffer(): MultiRenderTarget;
  68126. /**
  68127. * Gets the number of samples used to render the buffer (anti aliasing).
  68128. */
  68129. get samples(): number;
  68130. /**
  68131. * Sets the number of samples used to render the buffer (anti aliasing).
  68132. */
  68133. set samples(value: number);
  68134. /**
  68135. * Disposes the renderer and frees up associated resources.
  68136. */
  68137. dispose(): void;
  68138. protected _createRenderTargets(): void;
  68139. private _copyBonesTransformationMatrices;
  68140. }
  68141. }
  68142. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68143. import { Nullable } from "babylonjs/types";
  68144. import { Scene } from "babylonjs/scene";
  68145. import { ISceneComponent } from "babylonjs/sceneComponent";
  68146. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68147. module "babylonjs/scene" {
  68148. interface Scene {
  68149. /** @hidden (Backing field) */
  68150. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68151. /**
  68152. * Gets or Sets the current geometry buffer associated to the scene.
  68153. */
  68154. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68155. /**
  68156. * Enables a GeometryBufferRender and associates it with the scene
  68157. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68158. * @returns the GeometryBufferRenderer
  68159. */
  68160. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68161. /**
  68162. * Disables the GeometryBufferRender associated with the scene
  68163. */
  68164. disableGeometryBufferRenderer(): void;
  68165. }
  68166. }
  68167. /**
  68168. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68169. * in several rendering techniques.
  68170. */
  68171. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68172. /**
  68173. * The component name helpful to identify the component in the list of scene components.
  68174. */
  68175. readonly name: string;
  68176. /**
  68177. * The scene the component belongs to.
  68178. */
  68179. scene: Scene;
  68180. /**
  68181. * Creates a new instance of the component for the given scene
  68182. * @param scene Defines the scene to register the component in
  68183. */
  68184. constructor(scene: Scene);
  68185. /**
  68186. * Registers the component in a given scene
  68187. */
  68188. register(): void;
  68189. /**
  68190. * Rebuilds the elements related to this component in case of
  68191. * context lost for instance.
  68192. */
  68193. rebuild(): void;
  68194. /**
  68195. * Disposes the component and the associated ressources
  68196. */
  68197. dispose(): void;
  68198. private _gatherRenderTargets;
  68199. }
  68200. }
  68201. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68202. /** @hidden */
  68203. export var motionBlurPixelShader: {
  68204. name: string;
  68205. shader: string;
  68206. };
  68207. }
  68208. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68209. import { Nullable } from "babylonjs/types";
  68210. import { Camera } from "babylonjs/Cameras/camera";
  68211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68212. import { Scene } from "babylonjs/scene";
  68213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68214. import "babylonjs/Animations/animatable";
  68215. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68216. import "babylonjs/Shaders/motionBlur.fragment";
  68217. import { Engine } from "babylonjs/Engines/engine";
  68218. /**
  68219. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68220. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68221. * As an example, all you have to do is to create the post-process:
  68222. * var mb = new BABYLON.MotionBlurPostProcess(
  68223. * 'mb', // The name of the effect.
  68224. * scene, // The scene containing the objects to blur according to their velocity.
  68225. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68226. * camera // The camera to apply the render pass to.
  68227. * );
  68228. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68229. */
  68230. export class MotionBlurPostProcess extends PostProcess {
  68231. /**
  68232. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68233. */
  68234. motionStrength: number;
  68235. /**
  68236. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68237. */
  68238. get motionBlurSamples(): number;
  68239. /**
  68240. * Sets the number of iterations to be used for motion blur quality
  68241. */
  68242. set motionBlurSamples(samples: number);
  68243. private _motionBlurSamples;
  68244. private _geometryBufferRenderer;
  68245. /**
  68246. * Creates a new instance MotionBlurPostProcess
  68247. * @param name The name of the effect.
  68248. * @param scene The scene containing the objects to blur according to their velocity.
  68249. * @param options The required width/height ratio to downsize to before computing the render pass.
  68250. * @param camera The camera to apply the render pass to.
  68251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68252. * @param engine The engine which the post process will be applied. (default: current engine)
  68253. * @param reusable If the post process can be reused on the same frame. (default: false)
  68254. * @param textureType Type of textures used when performing the post process. (default: 0)
  68255. * @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)
  68256. */
  68257. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68258. /**
  68259. * Excludes the given skinned mesh from computing bones velocities.
  68260. * 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.
  68261. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68262. */
  68263. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68264. /**
  68265. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68266. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68267. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68268. */
  68269. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68270. /**
  68271. * Disposes the post process.
  68272. * @param camera The camera to dispose the post process on.
  68273. */
  68274. dispose(camera?: Camera): void;
  68275. }
  68276. }
  68277. declare module "babylonjs/Shaders/refraction.fragment" {
  68278. /** @hidden */
  68279. export var refractionPixelShader: {
  68280. name: string;
  68281. shader: string;
  68282. };
  68283. }
  68284. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68285. import { Color3 } from "babylonjs/Maths/math.color";
  68286. import { Camera } from "babylonjs/Cameras/camera";
  68287. import { Texture } from "babylonjs/Materials/Textures/texture";
  68288. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68289. import { Engine } from "babylonjs/Engines/engine";
  68290. import "babylonjs/Shaders/refraction.fragment";
  68291. /**
  68292. * Post process which applies a refractin texture
  68293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68294. */
  68295. export class RefractionPostProcess extends PostProcess {
  68296. /** the base color of the refraction (used to taint the rendering) */
  68297. color: Color3;
  68298. /** simulated refraction depth */
  68299. depth: number;
  68300. /** the coefficient of the base color (0 to remove base color tainting) */
  68301. colorLevel: number;
  68302. private _refTexture;
  68303. private _ownRefractionTexture;
  68304. /**
  68305. * Gets or sets the refraction texture
  68306. * Please note that you are responsible for disposing the texture if you set it manually
  68307. */
  68308. get refractionTexture(): Texture;
  68309. set refractionTexture(value: Texture);
  68310. /**
  68311. * Initializes the RefractionPostProcess
  68312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68313. * @param name The name of the effect.
  68314. * @param refractionTextureUrl Url of the refraction texture to use
  68315. * @param color the base color of the refraction (used to taint the rendering)
  68316. * @param depth simulated refraction depth
  68317. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68318. * @param camera The camera to apply the render pass to.
  68319. * @param options The required width/height ratio to downsize to before computing the render pass.
  68320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68321. * @param engine The engine which the post process will be applied. (default: current engine)
  68322. * @param reusable If the post process can be reused on the same frame. (default: false)
  68323. */
  68324. constructor(name: string, refractionTextureUrl: string,
  68325. /** the base color of the refraction (used to taint the rendering) */
  68326. color: Color3,
  68327. /** simulated refraction depth */
  68328. depth: number,
  68329. /** the coefficient of the base color (0 to remove base color tainting) */
  68330. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68331. /**
  68332. * Disposes of the post process
  68333. * @param camera Camera to dispose post process on
  68334. */
  68335. dispose(camera: Camera): void;
  68336. }
  68337. }
  68338. declare module "babylonjs/Shaders/sharpen.fragment" {
  68339. /** @hidden */
  68340. export var sharpenPixelShader: {
  68341. name: string;
  68342. shader: string;
  68343. };
  68344. }
  68345. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68346. import { Nullable } from "babylonjs/types";
  68347. import { Camera } from "babylonjs/Cameras/camera";
  68348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68349. import "babylonjs/Shaders/sharpen.fragment";
  68350. import { Engine } from "babylonjs/Engines/engine";
  68351. /**
  68352. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68353. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68354. */
  68355. export class SharpenPostProcess extends PostProcess {
  68356. /**
  68357. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68358. */
  68359. colorAmount: number;
  68360. /**
  68361. * How much sharpness should be applied (default: 0.3)
  68362. */
  68363. edgeAmount: number;
  68364. /**
  68365. * Creates a new instance ConvolutionPostProcess
  68366. * @param name The name of the effect.
  68367. * @param options The required width/height ratio to downsize to before computing the render pass.
  68368. * @param camera The camera to apply the render pass to.
  68369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68370. * @param engine The engine which the post process will be applied. (default: current engine)
  68371. * @param reusable If the post process can be reused on the same frame. (default: false)
  68372. * @param textureType Type of textures used when performing the post process. (default: 0)
  68373. * @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)
  68374. */
  68375. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68376. }
  68377. }
  68378. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68379. import { Nullable } from "babylonjs/types";
  68380. import { Camera } from "babylonjs/Cameras/camera";
  68381. import { Engine } from "babylonjs/Engines/engine";
  68382. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68383. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68384. /**
  68385. * PostProcessRenderPipeline
  68386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68387. */
  68388. export class PostProcessRenderPipeline {
  68389. private engine;
  68390. private _renderEffects;
  68391. private _renderEffectsForIsolatedPass;
  68392. /**
  68393. * List of inspectable custom properties (used by the Inspector)
  68394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68395. */
  68396. inspectableCustomProperties: IInspectable[];
  68397. /**
  68398. * @hidden
  68399. */
  68400. protected _cameras: Camera[];
  68401. /** @hidden */
  68402. _name: string;
  68403. /**
  68404. * Gets pipeline name
  68405. */
  68406. get name(): string;
  68407. /** Gets the list of attached cameras */
  68408. get cameras(): Camera[];
  68409. /**
  68410. * Initializes a PostProcessRenderPipeline
  68411. * @param engine engine to add the pipeline to
  68412. * @param name name of the pipeline
  68413. */
  68414. constructor(engine: Engine, name: string);
  68415. /**
  68416. * Gets the class name
  68417. * @returns "PostProcessRenderPipeline"
  68418. */
  68419. getClassName(): string;
  68420. /**
  68421. * If all the render effects in the pipeline are supported
  68422. */
  68423. get isSupported(): boolean;
  68424. /**
  68425. * Adds an effect to the pipeline
  68426. * @param renderEffect the effect to add
  68427. */
  68428. addEffect(renderEffect: PostProcessRenderEffect): void;
  68429. /** @hidden */
  68430. _rebuild(): void;
  68431. /** @hidden */
  68432. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68433. /** @hidden */
  68434. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68435. /** @hidden */
  68436. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68437. /** @hidden */
  68438. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68439. /** @hidden */
  68440. _attachCameras(cameras: Camera, unique: boolean): void;
  68441. /** @hidden */
  68442. _attachCameras(cameras: Camera[], unique: boolean): void;
  68443. /** @hidden */
  68444. _detachCameras(cameras: Camera): void;
  68445. /** @hidden */
  68446. _detachCameras(cameras: Nullable<Camera[]>): void;
  68447. /** @hidden */
  68448. _update(): void;
  68449. /** @hidden */
  68450. _reset(): void;
  68451. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68452. /**
  68453. * Disposes of the pipeline
  68454. */
  68455. dispose(): void;
  68456. }
  68457. }
  68458. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68459. import { Camera } from "babylonjs/Cameras/camera";
  68460. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68461. /**
  68462. * PostProcessRenderPipelineManager class
  68463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68464. */
  68465. export class PostProcessRenderPipelineManager {
  68466. private _renderPipelines;
  68467. /**
  68468. * Initializes a PostProcessRenderPipelineManager
  68469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68470. */
  68471. constructor();
  68472. /**
  68473. * Gets the list of supported render pipelines
  68474. */
  68475. get supportedPipelines(): PostProcessRenderPipeline[];
  68476. /**
  68477. * Adds a pipeline to the manager
  68478. * @param renderPipeline The pipeline to add
  68479. */
  68480. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68481. /**
  68482. * Attaches a camera to the pipeline
  68483. * @param renderPipelineName The name of the pipeline to attach to
  68484. * @param cameras the camera to attach
  68485. * @param unique if the camera can be attached multiple times to the pipeline
  68486. */
  68487. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68488. /**
  68489. * Detaches a camera from the pipeline
  68490. * @param renderPipelineName The name of the pipeline to detach from
  68491. * @param cameras the camera to detach
  68492. */
  68493. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68494. /**
  68495. * Enables an effect by name on a pipeline
  68496. * @param renderPipelineName the name of the pipeline to enable the effect in
  68497. * @param renderEffectName the name of the effect to enable
  68498. * @param cameras the cameras that the effect should be enabled on
  68499. */
  68500. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68501. /**
  68502. * Disables an effect by name on a pipeline
  68503. * @param renderPipelineName the name of the pipeline to disable the effect in
  68504. * @param renderEffectName the name of the effect to disable
  68505. * @param cameras the cameras that the effect should be disabled on
  68506. */
  68507. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68508. /**
  68509. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68510. */
  68511. update(): void;
  68512. /** @hidden */
  68513. _rebuild(): void;
  68514. /**
  68515. * Disposes of the manager and pipelines
  68516. */
  68517. dispose(): void;
  68518. }
  68519. }
  68520. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68521. import { ISceneComponent } from "babylonjs/sceneComponent";
  68522. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68523. import { Scene } from "babylonjs/scene";
  68524. module "babylonjs/scene" {
  68525. interface Scene {
  68526. /** @hidden (Backing field) */
  68527. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68528. /**
  68529. * Gets the postprocess render pipeline manager
  68530. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68531. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68532. */
  68533. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68534. }
  68535. }
  68536. /**
  68537. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68538. */
  68539. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68540. /**
  68541. * The component name helpfull to identify the component in the list of scene components.
  68542. */
  68543. readonly name: string;
  68544. /**
  68545. * The scene the component belongs to.
  68546. */
  68547. scene: Scene;
  68548. /**
  68549. * Creates a new instance of the component for the given scene
  68550. * @param scene Defines the scene to register the component in
  68551. */
  68552. constructor(scene: Scene);
  68553. /**
  68554. * Registers the component in a given scene
  68555. */
  68556. register(): void;
  68557. /**
  68558. * Rebuilds the elements related to this component in case of
  68559. * context lost for instance.
  68560. */
  68561. rebuild(): void;
  68562. /**
  68563. * Disposes the component and the associated ressources
  68564. */
  68565. dispose(): void;
  68566. private _gatherRenderTargets;
  68567. }
  68568. }
  68569. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68570. import { Nullable } from "babylonjs/types";
  68571. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68572. import { Camera } from "babylonjs/Cameras/camera";
  68573. import { IDisposable } from "babylonjs/scene";
  68574. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68575. import { Scene } from "babylonjs/scene";
  68576. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68577. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68578. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68579. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68580. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68581. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68582. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68583. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68584. import { Animation } from "babylonjs/Animations/animation";
  68585. /**
  68586. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68587. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68588. */
  68589. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68590. private _scene;
  68591. private _camerasToBeAttached;
  68592. /**
  68593. * ID of the sharpen post process,
  68594. */
  68595. private readonly SharpenPostProcessId;
  68596. /**
  68597. * @ignore
  68598. * ID of the image processing post process;
  68599. */
  68600. readonly ImageProcessingPostProcessId: string;
  68601. /**
  68602. * @ignore
  68603. * ID of the Fast Approximate Anti-Aliasing post process;
  68604. */
  68605. readonly FxaaPostProcessId: string;
  68606. /**
  68607. * ID of the chromatic aberration post process,
  68608. */
  68609. private readonly ChromaticAberrationPostProcessId;
  68610. /**
  68611. * ID of the grain post process
  68612. */
  68613. private readonly GrainPostProcessId;
  68614. /**
  68615. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68616. */
  68617. sharpen: SharpenPostProcess;
  68618. private _sharpenEffect;
  68619. private bloom;
  68620. /**
  68621. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68622. */
  68623. depthOfField: DepthOfFieldEffect;
  68624. /**
  68625. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68626. */
  68627. fxaa: FxaaPostProcess;
  68628. /**
  68629. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68630. */
  68631. imageProcessing: ImageProcessingPostProcess;
  68632. /**
  68633. * Chromatic aberration post process which will shift rgb colors in the image
  68634. */
  68635. chromaticAberration: ChromaticAberrationPostProcess;
  68636. private _chromaticAberrationEffect;
  68637. /**
  68638. * Grain post process which add noise to the image
  68639. */
  68640. grain: GrainPostProcess;
  68641. private _grainEffect;
  68642. /**
  68643. * Glow post process which adds a glow to emissive areas of the image
  68644. */
  68645. private _glowLayer;
  68646. /**
  68647. * Animations which can be used to tweak settings over a period of time
  68648. */
  68649. animations: Animation[];
  68650. private _imageProcessingConfigurationObserver;
  68651. private _sharpenEnabled;
  68652. private _bloomEnabled;
  68653. private _depthOfFieldEnabled;
  68654. private _depthOfFieldBlurLevel;
  68655. private _fxaaEnabled;
  68656. private _imageProcessingEnabled;
  68657. private _defaultPipelineTextureType;
  68658. private _bloomScale;
  68659. private _chromaticAberrationEnabled;
  68660. private _grainEnabled;
  68661. private _buildAllowed;
  68662. /**
  68663. * Gets active scene
  68664. */
  68665. get scene(): Scene;
  68666. /**
  68667. * Enable or disable the sharpen process from the pipeline
  68668. */
  68669. set sharpenEnabled(enabled: boolean);
  68670. get sharpenEnabled(): boolean;
  68671. private _resizeObserver;
  68672. private _hardwareScaleLevel;
  68673. private _bloomKernel;
  68674. /**
  68675. * Specifies the size of the bloom blur kernel, relative to the final output size
  68676. */
  68677. get bloomKernel(): number;
  68678. set bloomKernel(value: number);
  68679. /**
  68680. * Specifies the weight of the bloom in the final rendering
  68681. */
  68682. private _bloomWeight;
  68683. /**
  68684. * Specifies the luma threshold for the area that will be blurred by the bloom
  68685. */
  68686. private _bloomThreshold;
  68687. private _hdr;
  68688. /**
  68689. * The strength of the bloom.
  68690. */
  68691. set bloomWeight(value: number);
  68692. get bloomWeight(): number;
  68693. /**
  68694. * The strength of the bloom.
  68695. */
  68696. set bloomThreshold(value: number);
  68697. get bloomThreshold(): number;
  68698. /**
  68699. * The scale of the bloom, lower value will provide better performance.
  68700. */
  68701. set bloomScale(value: number);
  68702. get bloomScale(): number;
  68703. /**
  68704. * Enable or disable the bloom from the pipeline
  68705. */
  68706. set bloomEnabled(enabled: boolean);
  68707. get bloomEnabled(): boolean;
  68708. private _rebuildBloom;
  68709. /**
  68710. * If the depth of field is enabled.
  68711. */
  68712. get depthOfFieldEnabled(): boolean;
  68713. set depthOfFieldEnabled(enabled: boolean);
  68714. /**
  68715. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68716. */
  68717. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68718. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68719. /**
  68720. * If the anti aliasing is enabled.
  68721. */
  68722. set fxaaEnabled(enabled: boolean);
  68723. get fxaaEnabled(): boolean;
  68724. private _samples;
  68725. /**
  68726. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68727. */
  68728. set samples(sampleCount: number);
  68729. get samples(): number;
  68730. /**
  68731. * If image processing is enabled.
  68732. */
  68733. set imageProcessingEnabled(enabled: boolean);
  68734. get imageProcessingEnabled(): boolean;
  68735. /**
  68736. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68737. */
  68738. set glowLayerEnabled(enabled: boolean);
  68739. get glowLayerEnabled(): boolean;
  68740. /**
  68741. * Gets the glow layer (or null if not defined)
  68742. */
  68743. get glowLayer(): Nullable<GlowLayer>;
  68744. /**
  68745. * Enable or disable the chromaticAberration process from the pipeline
  68746. */
  68747. set chromaticAberrationEnabled(enabled: boolean);
  68748. get chromaticAberrationEnabled(): boolean;
  68749. /**
  68750. * Enable or disable the grain process from the pipeline
  68751. */
  68752. set grainEnabled(enabled: boolean);
  68753. get grainEnabled(): boolean;
  68754. /**
  68755. * @constructor
  68756. * @param name - The rendering pipeline name (default: "")
  68757. * @param hdr - If high dynamic range textures should be used (default: true)
  68758. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68759. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68760. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68761. */
  68762. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68763. /**
  68764. * Get the class name
  68765. * @returns "DefaultRenderingPipeline"
  68766. */
  68767. getClassName(): string;
  68768. /**
  68769. * Force the compilation of the entire pipeline.
  68770. */
  68771. prepare(): void;
  68772. private _hasCleared;
  68773. private _prevPostProcess;
  68774. private _prevPrevPostProcess;
  68775. private _setAutoClearAndTextureSharing;
  68776. private _depthOfFieldSceneObserver;
  68777. private _buildPipeline;
  68778. private _disposePostProcesses;
  68779. /**
  68780. * Adds a camera to the pipeline
  68781. * @param camera the camera to be added
  68782. */
  68783. addCamera(camera: Camera): void;
  68784. /**
  68785. * Removes a camera from the pipeline
  68786. * @param camera the camera to remove
  68787. */
  68788. removeCamera(camera: Camera): void;
  68789. /**
  68790. * Dispose of the pipeline and stop all post processes
  68791. */
  68792. dispose(): void;
  68793. /**
  68794. * Serialize the rendering pipeline (Used when exporting)
  68795. * @returns the serialized object
  68796. */
  68797. serialize(): any;
  68798. /**
  68799. * Parse the serialized pipeline
  68800. * @param source Source pipeline.
  68801. * @param scene The scene to load the pipeline to.
  68802. * @param rootUrl The URL of the serialized pipeline.
  68803. * @returns An instantiated pipeline from the serialized object.
  68804. */
  68805. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68806. }
  68807. }
  68808. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68809. /** @hidden */
  68810. export var lensHighlightsPixelShader: {
  68811. name: string;
  68812. shader: string;
  68813. };
  68814. }
  68815. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68816. /** @hidden */
  68817. export var depthOfFieldPixelShader: {
  68818. name: string;
  68819. shader: string;
  68820. };
  68821. }
  68822. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68823. import { Camera } from "babylonjs/Cameras/camera";
  68824. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68825. import { Scene } from "babylonjs/scene";
  68826. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68827. import "babylonjs/Shaders/chromaticAberration.fragment";
  68828. import "babylonjs/Shaders/lensHighlights.fragment";
  68829. import "babylonjs/Shaders/depthOfField.fragment";
  68830. /**
  68831. * BABYLON.JS Chromatic Aberration GLSL Shader
  68832. * Author: Olivier Guyot
  68833. * Separates very slightly R, G and B colors on the edges of the screen
  68834. * Inspired by Francois Tarlier & Martins Upitis
  68835. */
  68836. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68837. /**
  68838. * @ignore
  68839. * The chromatic aberration PostProcess id in the pipeline
  68840. */
  68841. LensChromaticAberrationEffect: string;
  68842. /**
  68843. * @ignore
  68844. * The highlights enhancing PostProcess id in the pipeline
  68845. */
  68846. HighlightsEnhancingEffect: string;
  68847. /**
  68848. * @ignore
  68849. * The depth-of-field PostProcess id in the pipeline
  68850. */
  68851. LensDepthOfFieldEffect: string;
  68852. private _scene;
  68853. private _depthTexture;
  68854. private _grainTexture;
  68855. private _chromaticAberrationPostProcess;
  68856. private _highlightsPostProcess;
  68857. private _depthOfFieldPostProcess;
  68858. private _edgeBlur;
  68859. private _grainAmount;
  68860. private _chromaticAberration;
  68861. private _distortion;
  68862. private _highlightsGain;
  68863. private _highlightsThreshold;
  68864. private _dofDistance;
  68865. private _dofAperture;
  68866. private _dofDarken;
  68867. private _dofPentagon;
  68868. private _blurNoise;
  68869. /**
  68870. * @constructor
  68871. *
  68872. * Effect parameters are as follow:
  68873. * {
  68874. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68875. * edge_blur: number; // from 0 to x (1 for realism)
  68876. * distortion: number; // from 0 to x (1 for realism)
  68877. * grain_amount: number; // from 0 to 1
  68878. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68879. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68880. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68881. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68882. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68883. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68884. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68885. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68886. * }
  68887. * Note: if an effect parameter is unset, effect is disabled
  68888. *
  68889. * @param name The rendering pipeline name
  68890. * @param parameters - An object containing all parameters (see above)
  68891. * @param scene The scene linked to this pipeline
  68892. * @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)
  68893. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68894. */
  68895. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68896. /**
  68897. * Get the class name
  68898. * @returns "LensRenderingPipeline"
  68899. */
  68900. getClassName(): string;
  68901. /**
  68902. * Gets associated scene
  68903. */
  68904. get scene(): Scene;
  68905. /**
  68906. * Gets or sets the edge blur
  68907. */
  68908. get edgeBlur(): number;
  68909. set edgeBlur(value: number);
  68910. /**
  68911. * Gets or sets the grain amount
  68912. */
  68913. get grainAmount(): number;
  68914. set grainAmount(value: number);
  68915. /**
  68916. * Gets or sets the chromatic aberration amount
  68917. */
  68918. get chromaticAberration(): number;
  68919. set chromaticAberration(value: number);
  68920. /**
  68921. * Gets or sets the depth of field aperture
  68922. */
  68923. get dofAperture(): number;
  68924. set dofAperture(value: number);
  68925. /**
  68926. * Gets or sets the edge distortion
  68927. */
  68928. get edgeDistortion(): number;
  68929. set edgeDistortion(value: number);
  68930. /**
  68931. * Gets or sets the depth of field distortion
  68932. */
  68933. get dofDistortion(): number;
  68934. set dofDistortion(value: number);
  68935. /**
  68936. * Gets or sets the darken out of focus amount
  68937. */
  68938. get darkenOutOfFocus(): number;
  68939. set darkenOutOfFocus(value: number);
  68940. /**
  68941. * Gets or sets a boolean indicating if blur noise is enabled
  68942. */
  68943. get blurNoise(): boolean;
  68944. set blurNoise(value: boolean);
  68945. /**
  68946. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68947. */
  68948. get pentagonBokeh(): boolean;
  68949. set pentagonBokeh(value: boolean);
  68950. /**
  68951. * Gets or sets the highlight grain amount
  68952. */
  68953. get highlightsGain(): number;
  68954. set highlightsGain(value: number);
  68955. /**
  68956. * Gets or sets the highlight threshold
  68957. */
  68958. get highlightsThreshold(): number;
  68959. set highlightsThreshold(value: number);
  68960. /**
  68961. * Sets the amount of blur at the edges
  68962. * @param amount blur amount
  68963. */
  68964. setEdgeBlur(amount: number): void;
  68965. /**
  68966. * Sets edge blur to 0
  68967. */
  68968. disableEdgeBlur(): void;
  68969. /**
  68970. * Sets the amout of grain
  68971. * @param amount Amount of grain
  68972. */
  68973. setGrainAmount(amount: number): void;
  68974. /**
  68975. * Set grain amount to 0
  68976. */
  68977. disableGrain(): void;
  68978. /**
  68979. * Sets the chromatic aberration amount
  68980. * @param amount amount of chromatic aberration
  68981. */
  68982. setChromaticAberration(amount: number): void;
  68983. /**
  68984. * Sets chromatic aberration amount to 0
  68985. */
  68986. disableChromaticAberration(): void;
  68987. /**
  68988. * Sets the EdgeDistortion amount
  68989. * @param amount amount of EdgeDistortion
  68990. */
  68991. setEdgeDistortion(amount: number): void;
  68992. /**
  68993. * Sets edge distortion to 0
  68994. */
  68995. disableEdgeDistortion(): void;
  68996. /**
  68997. * Sets the FocusDistance amount
  68998. * @param amount amount of FocusDistance
  68999. */
  69000. setFocusDistance(amount: number): void;
  69001. /**
  69002. * Disables depth of field
  69003. */
  69004. disableDepthOfField(): void;
  69005. /**
  69006. * Sets the Aperture amount
  69007. * @param amount amount of Aperture
  69008. */
  69009. setAperture(amount: number): void;
  69010. /**
  69011. * Sets the DarkenOutOfFocus amount
  69012. * @param amount amount of DarkenOutOfFocus
  69013. */
  69014. setDarkenOutOfFocus(amount: number): void;
  69015. private _pentagonBokehIsEnabled;
  69016. /**
  69017. * Creates a pentagon bokeh effect
  69018. */
  69019. enablePentagonBokeh(): void;
  69020. /**
  69021. * Disables the pentagon bokeh effect
  69022. */
  69023. disablePentagonBokeh(): void;
  69024. /**
  69025. * Enables noise blur
  69026. */
  69027. enableNoiseBlur(): void;
  69028. /**
  69029. * Disables noise blur
  69030. */
  69031. disableNoiseBlur(): void;
  69032. /**
  69033. * Sets the HighlightsGain amount
  69034. * @param amount amount of HighlightsGain
  69035. */
  69036. setHighlightsGain(amount: number): void;
  69037. /**
  69038. * Sets the HighlightsThreshold amount
  69039. * @param amount amount of HighlightsThreshold
  69040. */
  69041. setHighlightsThreshold(amount: number): void;
  69042. /**
  69043. * Disables highlights
  69044. */
  69045. disableHighlights(): void;
  69046. /**
  69047. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69048. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69049. */
  69050. dispose(disableDepthRender?: boolean): void;
  69051. private _createChromaticAberrationPostProcess;
  69052. private _createHighlightsPostProcess;
  69053. private _createDepthOfFieldPostProcess;
  69054. private _createGrainTexture;
  69055. }
  69056. }
  69057. declare module "babylonjs/Shaders/ssao2.fragment" {
  69058. /** @hidden */
  69059. export var ssao2PixelShader: {
  69060. name: string;
  69061. shader: string;
  69062. };
  69063. }
  69064. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69065. /** @hidden */
  69066. export var ssaoCombinePixelShader: {
  69067. name: string;
  69068. shader: string;
  69069. };
  69070. }
  69071. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69072. import { Camera } from "babylonjs/Cameras/camera";
  69073. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69074. import { Scene } from "babylonjs/scene";
  69075. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69076. import "babylonjs/Shaders/ssao2.fragment";
  69077. import "babylonjs/Shaders/ssaoCombine.fragment";
  69078. /**
  69079. * Render pipeline to produce ssao effect
  69080. */
  69081. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69082. /**
  69083. * @ignore
  69084. * The PassPostProcess id in the pipeline that contains the original scene color
  69085. */
  69086. SSAOOriginalSceneColorEffect: string;
  69087. /**
  69088. * @ignore
  69089. * The SSAO PostProcess id in the pipeline
  69090. */
  69091. SSAORenderEffect: string;
  69092. /**
  69093. * @ignore
  69094. * The horizontal blur PostProcess id in the pipeline
  69095. */
  69096. SSAOBlurHRenderEffect: string;
  69097. /**
  69098. * @ignore
  69099. * The vertical blur PostProcess id in the pipeline
  69100. */
  69101. SSAOBlurVRenderEffect: string;
  69102. /**
  69103. * @ignore
  69104. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69105. */
  69106. SSAOCombineRenderEffect: string;
  69107. /**
  69108. * The output strength of the SSAO post-process. Default value is 1.0.
  69109. */
  69110. totalStrength: number;
  69111. /**
  69112. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69113. */
  69114. maxZ: number;
  69115. /**
  69116. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69117. */
  69118. minZAspect: number;
  69119. private _samples;
  69120. /**
  69121. * Number of samples used for the SSAO calculations. Default value is 8
  69122. */
  69123. set samples(n: number);
  69124. get samples(): number;
  69125. private _textureSamples;
  69126. /**
  69127. * Number of samples to use for antialiasing
  69128. */
  69129. set textureSamples(n: number);
  69130. get textureSamples(): number;
  69131. /**
  69132. * Ratio object used for SSAO ratio and blur ratio
  69133. */
  69134. private _ratio;
  69135. /**
  69136. * Dynamically generated sphere sampler.
  69137. */
  69138. private _sampleSphere;
  69139. /**
  69140. * Blur filter offsets
  69141. */
  69142. private _samplerOffsets;
  69143. private _expensiveBlur;
  69144. /**
  69145. * If bilateral blur should be used
  69146. */
  69147. set expensiveBlur(b: boolean);
  69148. get expensiveBlur(): boolean;
  69149. /**
  69150. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69151. */
  69152. radius: number;
  69153. /**
  69154. * The base color of the SSAO post-process
  69155. * The final result is "base + ssao" between [0, 1]
  69156. */
  69157. base: number;
  69158. /**
  69159. * Support test.
  69160. */
  69161. static get IsSupported(): boolean;
  69162. private _scene;
  69163. private _depthTexture;
  69164. private _normalTexture;
  69165. private _randomTexture;
  69166. private _originalColorPostProcess;
  69167. private _ssaoPostProcess;
  69168. private _blurHPostProcess;
  69169. private _blurVPostProcess;
  69170. private _ssaoCombinePostProcess;
  69171. /**
  69172. * Gets active scene
  69173. */
  69174. get scene(): Scene;
  69175. /**
  69176. * @constructor
  69177. * @param name The rendering pipeline name
  69178. * @param scene The scene linked to this pipeline
  69179. * @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 }
  69180. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69181. */
  69182. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69183. /**
  69184. * Get the class name
  69185. * @returns "SSAO2RenderingPipeline"
  69186. */
  69187. getClassName(): string;
  69188. /**
  69189. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69190. */
  69191. dispose(disableGeometryBufferRenderer?: boolean): void;
  69192. private _createBlurPostProcess;
  69193. /** @hidden */
  69194. _rebuild(): void;
  69195. private _bits;
  69196. private _radicalInverse_VdC;
  69197. private _hammersley;
  69198. private _hemisphereSample_uniform;
  69199. private _generateHemisphere;
  69200. private _createSSAOPostProcess;
  69201. private _createSSAOCombinePostProcess;
  69202. private _createRandomTexture;
  69203. /**
  69204. * Serialize the rendering pipeline (Used when exporting)
  69205. * @returns the serialized object
  69206. */
  69207. serialize(): any;
  69208. /**
  69209. * Parse the serialized pipeline
  69210. * @param source Source pipeline.
  69211. * @param scene The scene to load the pipeline to.
  69212. * @param rootUrl The URL of the serialized pipeline.
  69213. * @returns An instantiated pipeline from the serialized object.
  69214. */
  69215. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69216. }
  69217. }
  69218. declare module "babylonjs/Shaders/ssao.fragment" {
  69219. /** @hidden */
  69220. export var ssaoPixelShader: {
  69221. name: string;
  69222. shader: string;
  69223. };
  69224. }
  69225. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69226. import { Camera } from "babylonjs/Cameras/camera";
  69227. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69228. import { Scene } from "babylonjs/scene";
  69229. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69230. import "babylonjs/Shaders/ssao.fragment";
  69231. import "babylonjs/Shaders/ssaoCombine.fragment";
  69232. /**
  69233. * Render pipeline to produce ssao effect
  69234. */
  69235. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69236. /**
  69237. * @ignore
  69238. * The PassPostProcess id in the pipeline that contains the original scene color
  69239. */
  69240. SSAOOriginalSceneColorEffect: string;
  69241. /**
  69242. * @ignore
  69243. * The SSAO PostProcess id in the pipeline
  69244. */
  69245. SSAORenderEffect: string;
  69246. /**
  69247. * @ignore
  69248. * The horizontal blur PostProcess id in the pipeline
  69249. */
  69250. SSAOBlurHRenderEffect: string;
  69251. /**
  69252. * @ignore
  69253. * The vertical blur PostProcess id in the pipeline
  69254. */
  69255. SSAOBlurVRenderEffect: string;
  69256. /**
  69257. * @ignore
  69258. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69259. */
  69260. SSAOCombineRenderEffect: string;
  69261. /**
  69262. * The output strength of the SSAO post-process. Default value is 1.0.
  69263. */
  69264. totalStrength: number;
  69265. /**
  69266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69267. */
  69268. radius: number;
  69269. /**
  69270. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69271. * Must not be equal to fallOff and superior to fallOff.
  69272. * Default value is 0.0075
  69273. */
  69274. area: number;
  69275. /**
  69276. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69277. * Must not be equal to area and inferior to area.
  69278. * Default value is 0.000001
  69279. */
  69280. fallOff: number;
  69281. /**
  69282. * The base color of the SSAO post-process
  69283. * The final result is "base + ssao" between [0, 1]
  69284. */
  69285. base: number;
  69286. private _scene;
  69287. private _depthTexture;
  69288. private _randomTexture;
  69289. private _originalColorPostProcess;
  69290. private _ssaoPostProcess;
  69291. private _blurHPostProcess;
  69292. private _blurVPostProcess;
  69293. private _ssaoCombinePostProcess;
  69294. private _firstUpdate;
  69295. /**
  69296. * Gets active scene
  69297. */
  69298. get scene(): Scene;
  69299. /**
  69300. * @constructor
  69301. * @param name - The rendering pipeline name
  69302. * @param scene - The scene linked to this pipeline
  69303. * @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 }
  69304. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69305. */
  69306. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69307. /**
  69308. * Get the class name
  69309. * @returns "SSAORenderingPipeline"
  69310. */
  69311. getClassName(): string;
  69312. /**
  69313. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69314. */
  69315. dispose(disableDepthRender?: boolean): void;
  69316. private _createBlurPostProcess;
  69317. /** @hidden */
  69318. _rebuild(): void;
  69319. private _createSSAOPostProcess;
  69320. private _createSSAOCombinePostProcess;
  69321. private _createRandomTexture;
  69322. }
  69323. }
  69324. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69325. /** @hidden */
  69326. export var screenSpaceReflectionPixelShader: {
  69327. name: string;
  69328. shader: string;
  69329. };
  69330. }
  69331. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69332. import { Nullable } from "babylonjs/types";
  69333. import { Camera } from "babylonjs/Cameras/camera";
  69334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69335. import { Scene } from "babylonjs/scene";
  69336. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69337. import { Engine } from "babylonjs/Engines/engine";
  69338. /**
  69339. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69340. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69341. */
  69342. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69343. /**
  69344. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69345. */
  69346. threshold: number;
  69347. /**
  69348. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69349. */
  69350. strength: number;
  69351. /**
  69352. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69353. */
  69354. reflectionSpecularFalloffExponent: number;
  69355. /**
  69356. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  69357. */
  69358. step: number;
  69359. /**
  69360. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69361. */
  69362. roughnessFactor: number;
  69363. private _geometryBufferRenderer;
  69364. private _enableSmoothReflections;
  69365. private _reflectionSamples;
  69366. private _smoothSteps;
  69367. /**
  69368. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69369. * @param name The name of the effect.
  69370. * @param scene The scene containing the objects to calculate reflections.
  69371. * @param options The required width/height ratio to downsize to before computing the render pass.
  69372. * @param camera The camera to apply the render pass to.
  69373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69374. * @param engine The engine which the post process will be applied. (default: current engine)
  69375. * @param reusable If the post process can be reused on the same frame. (default: false)
  69376. * @param textureType Type of textures used when performing the post process. (default: 0)
  69377. * @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)
  69378. */
  69379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69380. /**
  69381. * Gets wether or not smoothing reflections is enabled.
  69382. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69383. */
  69384. get enableSmoothReflections(): boolean;
  69385. /**
  69386. * Sets wether or not smoothing reflections is enabled.
  69387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69388. */
  69389. set enableSmoothReflections(enabled: boolean);
  69390. /**
  69391. * Gets the number of samples taken while computing reflections. More samples count is high,
  69392. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69393. */
  69394. get reflectionSamples(): number;
  69395. /**
  69396. * Sets the number of samples taken while computing reflections. More samples count is high,
  69397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69398. */
  69399. set reflectionSamples(samples: number);
  69400. /**
  69401. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69402. * more the post-process will require GPU power and can generate a drop in FPS.
  69403. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69404. */
  69405. get smoothSteps(): number;
  69406. set smoothSteps(steps: number);
  69407. private _updateEffectDefines;
  69408. }
  69409. }
  69410. declare module "babylonjs/Shaders/standard.fragment" {
  69411. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69412. /** @hidden */
  69413. export var standardPixelShader: {
  69414. name: string;
  69415. shader: string;
  69416. };
  69417. }
  69418. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69419. import { Nullable } from "babylonjs/types";
  69420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69421. import { Camera } from "babylonjs/Cameras/camera";
  69422. import { Texture } from "babylonjs/Materials/Textures/texture";
  69423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69424. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69425. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69426. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69427. import { IDisposable } from "babylonjs/scene";
  69428. import { SpotLight } from "babylonjs/Lights/spotLight";
  69429. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69430. import { Scene } from "babylonjs/scene";
  69431. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69432. import { Animation } from "babylonjs/Animations/animation";
  69433. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69434. import "babylonjs/Shaders/standard.fragment";
  69435. /**
  69436. * Standard rendering pipeline
  69437. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69438. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69439. */
  69440. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69441. /**
  69442. * Public members
  69443. */
  69444. /**
  69445. * Post-process which contains the original scene color before the pipeline applies all the effects
  69446. */
  69447. originalPostProcess: Nullable<PostProcess>;
  69448. /**
  69449. * Post-process used to down scale an image x4
  69450. */
  69451. downSampleX4PostProcess: Nullable<PostProcess>;
  69452. /**
  69453. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69454. */
  69455. brightPassPostProcess: Nullable<PostProcess>;
  69456. /**
  69457. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69458. */
  69459. blurHPostProcesses: PostProcess[];
  69460. /**
  69461. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69462. */
  69463. blurVPostProcesses: PostProcess[];
  69464. /**
  69465. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69466. */
  69467. textureAdderPostProcess: Nullable<PostProcess>;
  69468. /**
  69469. * Post-process used to create volumetric lighting effect
  69470. */
  69471. volumetricLightPostProcess: Nullable<PostProcess>;
  69472. /**
  69473. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69474. */
  69475. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69476. /**
  69477. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69478. */
  69479. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69480. /**
  69481. * Post-process used to merge the volumetric light effect and the real scene color
  69482. */
  69483. volumetricLightMergePostProces: Nullable<PostProcess>;
  69484. /**
  69485. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69486. */
  69487. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69488. /**
  69489. * Base post-process used to calculate the average luminance of the final image for HDR
  69490. */
  69491. luminancePostProcess: Nullable<PostProcess>;
  69492. /**
  69493. * Post-processes used to create down sample post-processes in order to get
  69494. * the average luminance of the final image for HDR
  69495. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69496. */
  69497. luminanceDownSamplePostProcesses: PostProcess[];
  69498. /**
  69499. * Post-process used to create a HDR effect (light adaptation)
  69500. */
  69501. hdrPostProcess: Nullable<PostProcess>;
  69502. /**
  69503. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69504. */
  69505. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69506. /**
  69507. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69508. */
  69509. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69510. /**
  69511. * Post-process used to merge the final HDR post-process and the real scene color
  69512. */
  69513. hdrFinalPostProcess: Nullable<PostProcess>;
  69514. /**
  69515. * Post-process used to create a lens flare effect
  69516. */
  69517. lensFlarePostProcess: Nullable<PostProcess>;
  69518. /**
  69519. * Post-process that merges the result of the lens flare post-process and the real scene color
  69520. */
  69521. lensFlareComposePostProcess: Nullable<PostProcess>;
  69522. /**
  69523. * Post-process used to create a motion blur effect
  69524. */
  69525. motionBlurPostProcess: Nullable<PostProcess>;
  69526. /**
  69527. * Post-process used to create a depth of field effect
  69528. */
  69529. depthOfFieldPostProcess: Nullable<PostProcess>;
  69530. /**
  69531. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69532. */
  69533. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69534. /**
  69535. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69536. */
  69537. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69538. /**
  69539. * Represents the brightness threshold in order to configure the illuminated surfaces
  69540. */
  69541. brightThreshold: number;
  69542. /**
  69543. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69544. */
  69545. blurWidth: number;
  69546. /**
  69547. * Sets if the blur for highlighted surfaces must be only horizontal
  69548. */
  69549. horizontalBlur: boolean;
  69550. /**
  69551. * Gets the overall exposure used by the pipeline
  69552. */
  69553. get exposure(): number;
  69554. /**
  69555. * Sets the overall exposure used by the pipeline
  69556. */
  69557. set exposure(value: number);
  69558. /**
  69559. * Texture used typically to simulate "dirty" on camera lens
  69560. */
  69561. lensTexture: Nullable<Texture>;
  69562. /**
  69563. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69564. */
  69565. volumetricLightCoefficient: number;
  69566. /**
  69567. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69568. */
  69569. volumetricLightPower: number;
  69570. /**
  69571. * Used the set the blur intensity to smooth the volumetric lights
  69572. */
  69573. volumetricLightBlurScale: number;
  69574. /**
  69575. * Light (spot or directional) used to generate the volumetric lights rays
  69576. * The source light must have a shadow generate so the pipeline can get its
  69577. * depth map
  69578. */
  69579. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69580. /**
  69581. * For eye adaptation, represents the minimum luminance the eye can see
  69582. */
  69583. hdrMinimumLuminance: number;
  69584. /**
  69585. * For eye adaptation, represents the decrease luminance speed
  69586. */
  69587. hdrDecreaseRate: number;
  69588. /**
  69589. * For eye adaptation, represents the increase luminance speed
  69590. */
  69591. hdrIncreaseRate: number;
  69592. /**
  69593. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69594. */
  69595. get hdrAutoExposure(): boolean;
  69596. /**
  69597. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69598. */
  69599. set hdrAutoExposure(value: boolean);
  69600. /**
  69601. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69602. */
  69603. lensColorTexture: Nullable<Texture>;
  69604. /**
  69605. * The overall strengh for the lens flare effect
  69606. */
  69607. lensFlareStrength: number;
  69608. /**
  69609. * Dispersion coefficient for lens flare ghosts
  69610. */
  69611. lensFlareGhostDispersal: number;
  69612. /**
  69613. * Main lens flare halo width
  69614. */
  69615. lensFlareHaloWidth: number;
  69616. /**
  69617. * Based on the lens distortion effect, defines how much the lens flare result
  69618. * is distorted
  69619. */
  69620. lensFlareDistortionStrength: number;
  69621. /**
  69622. * Configures the blur intensity used for for lens flare (halo)
  69623. */
  69624. lensFlareBlurWidth: number;
  69625. /**
  69626. * Lens star texture must be used to simulate rays on the flares and is available
  69627. * in the documentation
  69628. */
  69629. lensStarTexture: Nullable<Texture>;
  69630. /**
  69631. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69632. * flare effect by taking account of the dirt texture
  69633. */
  69634. lensFlareDirtTexture: Nullable<Texture>;
  69635. /**
  69636. * Represents the focal length for the depth of field effect
  69637. */
  69638. depthOfFieldDistance: number;
  69639. /**
  69640. * Represents the blur intensity for the blurred part of the depth of field effect
  69641. */
  69642. depthOfFieldBlurWidth: number;
  69643. /**
  69644. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69645. */
  69646. get motionStrength(): number;
  69647. /**
  69648. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69649. */
  69650. set motionStrength(strength: number);
  69651. /**
  69652. * Gets wether or not the motion blur post-process is object based or screen based.
  69653. */
  69654. get objectBasedMotionBlur(): boolean;
  69655. /**
  69656. * Sets wether or not the motion blur post-process should be object based or screen based
  69657. */
  69658. set objectBasedMotionBlur(value: boolean);
  69659. /**
  69660. * List of animations for the pipeline (IAnimatable implementation)
  69661. */
  69662. animations: Animation[];
  69663. /**
  69664. * Private members
  69665. */
  69666. private _scene;
  69667. private _currentDepthOfFieldSource;
  69668. private _basePostProcess;
  69669. private _fixedExposure;
  69670. private _currentExposure;
  69671. private _hdrAutoExposure;
  69672. private _hdrCurrentLuminance;
  69673. private _motionStrength;
  69674. private _isObjectBasedMotionBlur;
  69675. private _floatTextureType;
  69676. private _camerasToBeAttached;
  69677. private _ratio;
  69678. private _bloomEnabled;
  69679. private _depthOfFieldEnabled;
  69680. private _vlsEnabled;
  69681. private _lensFlareEnabled;
  69682. private _hdrEnabled;
  69683. private _motionBlurEnabled;
  69684. private _fxaaEnabled;
  69685. private _screenSpaceReflectionsEnabled;
  69686. private _motionBlurSamples;
  69687. private _volumetricLightStepsCount;
  69688. private _samples;
  69689. /**
  69690. * @ignore
  69691. * Specifies if the bloom pipeline is enabled
  69692. */
  69693. get BloomEnabled(): boolean;
  69694. set BloomEnabled(enabled: boolean);
  69695. /**
  69696. * @ignore
  69697. * Specifies if the depth of field pipeline is enabed
  69698. */
  69699. get DepthOfFieldEnabled(): boolean;
  69700. set DepthOfFieldEnabled(enabled: boolean);
  69701. /**
  69702. * @ignore
  69703. * Specifies if the lens flare pipeline is enabed
  69704. */
  69705. get LensFlareEnabled(): boolean;
  69706. set LensFlareEnabled(enabled: boolean);
  69707. /**
  69708. * @ignore
  69709. * Specifies if the HDR pipeline is enabled
  69710. */
  69711. get HDREnabled(): boolean;
  69712. set HDREnabled(enabled: boolean);
  69713. /**
  69714. * @ignore
  69715. * Specifies if the volumetric lights scattering effect is enabled
  69716. */
  69717. get VLSEnabled(): boolean;
  69718. set VLSEnabled(enabled: boolean);
  69719. /**
  69720. * @ignore
  69721. * Specifies if the motion blur effect is enabled
  69722. */
  69723. get MotionBlurEnabled(): boolean;
  69724. set MotionBlurEnabled(enabled: boolean);
  69725. /**
  69726. * Specifies if anti-aliasing is enabled
  69727. */
  69728. get fxaaEnabled(): boolean;
  69729. set fxaaEnabled(enabled: boolean);
  69730. /**
  69731. * Specifies if screen space reflections are enabled.
  69732. */
  69733. get screenSpaceReflectionsEnabled(): boolean;
  69734. set screenSpaceReflectionsEnabled(enabled: boolean);
  69735. /**
  69736. * Specifies the number of steps used to calculate the volumetric lights
  69737. * Typically in interval [50, 200]
  69738. */
  69739. get volumetricLightStepsCount(): number;
  69740. set volumetricLightStepsCount(count: number);
  69741. /**
  69742. * Specifies the number of samples used for the motion blur effect
  69743. * Typically in interval [16, 64]
  69744. */
  69745. get motionBlurSamples(): number;
  69746. set motionBlurSamples(samples: number);
  69747. /**
  69748. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69749. */
  69750. get samples(): number;
  69751. set samples(sampleCount: number);
  69752. /**
  69753. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69754. * @constructor
  69755. * @param name The rendering pipeline name
  69756. * @param scene The scene linked to this pipeline
  69757. * @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)
  69758. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69759. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69760. */
  69761. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69762. private _buildPipeline;
  69763. private _createDownSampleX4PostProcess;
  69764. private _createBrightPassPostProcess;
  69765. private _createBlurPostProcesses;
  69766. private _createTextureAdderPostProcess;
  69767. private _createVolumetricLightPostProcess;
  69768. private _createLuminancePostProcesses;
  69769. private _createHdrPostProcess;
  69770. private _createLensFlarePostProcess;
  69771. private _createDepthOfFieldPostProcess;
  69772. private _createMotionBlurPostProcess;
  69773. private _getDepthTexture;
  69774. private _disposePostProcesses;
  69775. /**
  69776. * Dispose of the pipeline and stop all post processes
  69777. */
  69778. dispose(): void;
  69779. /**
  69780. * Serialize the rendering pipeline (Used when exporting)
  69781. * @returns the serialized object
  69782. */
  69783. serialize(): any;
  69784. /**
  69785. * Parse the serialized pipeline
  69786. * @param source Source pipeline.
  69787. * @param scene The scene to load the pipeline to.
  69788. * @param rootUrl The URL of the serialized pipeline.
  69789. * @returns An instantiated pipeline from the serialized object.
  69790. */
  69791. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69792. /**
  69793. * Luminance steps
  69794. */
  69795. static LuminanceSteps: number;
  69796. }
  69797. }
  69798. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69799. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69800. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69801. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69802. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69803. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69804. }
  69805. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69806. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69807. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69808. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69809. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69810. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69811. }
  69812. declare module "babylonjs/Shaders/tonemap.fragment" {
  69813. /** @hidden */
  69814. export var tonemapPixelShader: {
  69815. name: string;
  69816. shader: string;
  69817. };
  69818. }
  69819. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69820. import { Camera } from "babylonjs/Cameras/camera";
  69821. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69822. import "babylonjs/Shaders/tonemap.fragment";
  69823. import { Engine } from "babylonjs/Engines/engine";
  69824. /** Defines operator used for tonemapping */
  69825. export enum TonemappingOperator {
  69826. /** Hable */
  69827. Hable = 0,
  69828. /** Reinhard */
  69829. Reinhard = 1,
  69830. /** HejiDawson */
  69831. HejiDawson = 2,
  69832. /** Photographic */
  69833. Photographic = 3
  69834. }
  69835. /**
  69836. * Defines a post process to apply tone mapping
  69837. */
  69838. export class TonemapPostProcess extends PostProcess {
  69839. private _operator;
  69840. /** Defines the required exposure adjustement */
  69841. exposureAdjustment: number;
  69842. /**
  69843. * Creates a new TonemapPostProcess
  69844. * @param name defines the name of the postprocess
  69845. * @param _operator defines the operator to use
  69846. * @param exposureAdjustment defines the required exposure adjustement
  69847. * @param camera defines the camera to use (can be null)
  69848. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69849. * @param engine defines the hosting engine (can be ignore if camera is set)
  69850. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69851. */
  69852. constructor(name: string, _operator: TonemappingOperator,
  69853. /** Defines the required exposure adjustement */
  69854. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69855. }
  69856. }
  69857. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69858. /** @hidden */
  69859. export var volumetricLightScatteringPixelShader: {
  69860. name: string;
  69861. shader: string;
  69862. };
  69863. }
  69864. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69865. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69868. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69870. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69871. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69872. /** @hidden */
  69873. export var volumetricLightScatteringPassVertexShader: {
  69874. name: string;
  69875. shader: string;
  69876. };
  69877. }
  69878. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69879. /** @hidden */
  69880. export var volumetricLightScatteringPassPixelShader: {
  69881. name: string;
  69882. shader: string;
  69883. };
  69884. }
  69885. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69886. import { Vector3 } from "babylonjs/Maths/math.vector";
  69887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69888. import { Mesh } from "babylonjs/Meshes/mesh";
  69889. import { Camera } from "babylonjs/Cameras/camera";
  69890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69891. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69892. import { Scene } from "babylonjs/scene";
  69893. import "babylonjs/Meshes/Builders/planeBuilder";
  69894. import "babylonjs/Shaders/depth.vertex";
  69895. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69896. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69897. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69898. import { Engine } from "babylonjs/Engines/engine";
  69899. /**
  69900. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69901. */
  69902. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69903. private _volumetricLightScatteringPass;
  69904. private _volumetricLightScatteringRTT;
  69905. private _viewPort;
  69906. private _screenCoordinates;
  69907. private _cachedDefines;
  69908. /**
  69909. * If not undefined, the mesh position is computed from the attached node position
  69910. */
  69911. attachedNode: {
  69912. position: Vector3;
  69913. };
  69914. /**
  69915. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69916. */
  69917. customMeshPosition: Vector3;
  69918. /**
  69919. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69920. */
  69921. useCustomMeshPosition: boolean;
  69922. /**
  69923. * If the post-process should inverse the light scattering direction
  69924. */
  69925. invert: boolean;
  69926. /**
  69927. * The internal mesh used by the post-process
  69928. */
  69929. mesh: Mesh;
  69930. /**
  69931. * @hidden
  69932. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69933. */
  69934. get useDiffuseColor(): boolean;
  69935. set useDiffuseColor(useDiffuseColor: boolean);
  69936. /**
  69937. * Array containing the excluded meshes not rendered in the internal pass
  69938. */
  69939. excludedMeshes: AbstractMesh[];
  69940. /**
  69941. * Controls the overall intensity of the post-process
  69942. */
  69943. exposure: number;
  69944. /**
  69945. * Dissipates each sample's contribution in range [0, 1]
  69946. */
  69947. decay: number;
  69948. /**
  69949. * Controls the overall intensity of each sample
  69950. */
  69951. weight: number;
  69952. /**
  69953. * Controls the density of each sample
  69954. */
  69955. density: number;
  69956. /**
  69957. * @constructor
  69958. * @param name The post-process name
  69959. * @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)
  69960. * @param camera The camera that the post-process will be attached to
  69961. * @param mesh The mesh used to create the light scattering
  69962. * @param samples The post-process quality, default 100
  69963. * @param samplingModeThe post-process filtering mode
  69964. * @param engine The babylon engine
  69965. * @param reusable If the post-process is reusable
  69966. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69967. */
  69968. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69969. /**
  69970. * Returns the string "VolumetricLightScatteringPostProcess"
  69971. * @returns "VolumetricLightScatteringPostProcess"
  69972. */
  69973. getClassName(): string;
  69974. private _isReady;
  69975. /**
  69976. * Sets the new light position for light scattering effect
  69977. * @param position The new custom light position
  69978. */
  69979. setCustomMeshPosition(position: Vector3): void;
  69980. /**
  69981. * Returns the light position for light scattering effect
  69982. * @return Vector3 The custom light position
  69983. */
  69984. getCustomMeshPosition(): Vector3;
  69985. /**
  69986. * Disposes the internal assets and detaches the post-process from the camera
  69987. */
  69988. dispose(camera: Camera): void;
  69989. /**
  69990. * Returns the render target texture used by the post-process
  69991. * @return the render target texture used by the post-process
  69992. */
  69993. getPass(): RenderTargetTexture;
  69994. private _meshExcluded;
  69995. private _createPass;
  69996. private _updateMeshScreenCoordinates;
  69997. /**
  69998. * Creates a default mesh for the Volumeric Light Scattering post-process
  69999. * @param name The mesh name
  70000. * @param scene The scene where to create the mesh
  70001. * @return the default mesh
  70002. */
  70003. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70004. }
  70005. }
  70006. declare module "babylonjs/PostProcesses/index" {
  70007. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70008. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70009. export * from "babylonjs/PostProcesses/bloomEffect";
  70010. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70011. export * from "babylonjs/PostProcesses/blurPostProcess";
  70012. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70013. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70014. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70015. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70016. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70017. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70018. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70019. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70020. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70021. export * from "babylonjs/PostProcesses/filterPostProcess";
  70022. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70023. export * from "babylonjs/PostProcesses/grainPostProcess";
  70024. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70025. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70026. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70027. export * from "babylonjs/PostProcesses/passPostProcess";
  70028. export * from "babylonjs/PostProcesses/postProcess";
  70029. export * from "babylonjs/PostProcesses/postProcessManager";
  70030. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70031. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70032. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70033. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70034. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70035. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70036. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70037. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70038. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70039. }
  70040. declare module "babylonjs/Probes/index" {
  70041. export * from "babylonjs/Probes/reflectionProbe";
  70042. }
  70043. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70044. import { Scene } from "babylonjs/scene";
  70045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70046. import { SmartArray } from "babylonjs/Misc/smartArray";
  70047. import { ISceneComponent } from "babylonjs/sceneComponent";
  70048. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70049. import "babylonjs/Meshes/Builders/boxBuilder";
  70050. import "babylonjs/Shaders/color.fragment";
  70051. import "babylonjs/Shaders/color.vertex";
  70052. import { Color3 } from "babylonjs/Maths/math.color";
  70053. module "babylonjs/scene" {
  70054. interface Scene {
  70055. /** @hidden (Backing field) */
  70056. _boundingBoxRenderer: BoundingBoxRenderer;
  70057. /** @hidden (Backing field) */
  70058. _forceShowBoundingBoxes: boolean;
  70059. /**
  70060. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70061. */
  70062. forceShowBoundingBoxes: boolean;
  70063. /**
  70064. * Gets the bounding box renderer associated with the scene
  70065. * @returns a BoundingBoxRenderer
  70066. */
  70067. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70068. }
  70069. }
  70070. module "babylonjs/Meshes/abstractMesh" {
  70071. interface AbstractMesh {
  70072. /** @hidden (Backing field) */
  70073. _showBoundingBox: boolean;
  70074. /**
  70075. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70076. */
  70077. showBoundingBox: boolean;
  70078. }
  70079. }
  70080. /**
  70081. * Component responsible of rendering the bounding box of the meshes in a scene.
  70082. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70083. */
  70084. export class BoundingBoxRenderer implements ISceneComponent {
  70085. /**
  70086. * The component name helpfull to identify the component in the list of scene components.
  70087. */
  70088. readonly name: string;
  70089. /**
  70090. * The scene the component belongs to.
  70091. */
  70092. scene: Scene;
  70093. /**
  70094. * Color of the bounding box lines placed in front of an object
  70095. */
  70096. frontColor: Color3;
  70097. /**
  70098. * Color of the bounding box lines placed behind an object
  70099. */
  70100. backColor: Color3;
  70101. /**
  70102. * Defines if the renderer should show the back lines or not
  70103. */
  70104. showBackLines: boolean;
  70105. /**
  70106. * @hidden
  70107. */
  70108. renderList: SmartArray<BoundingBox>;
  70109. private _colorShader;
  70110. private _vertexBuffers;
  70111. private _indexBuffer;
  70112. private _fillIndexBuffer;
  70113. private _fillIndexData;
  70114. /**
  70115. * Instantiates a new bounding box renderer in a scene.
  70116. * @param scene the scene the renderer renders in
  70117. */
  70118. constructor(scene: Scene);
  70119. /**
  70120. * Registers the component in a given scene
  70121. */
  70122. register(): void;
  70123. private _evaluateSubMesh;
  70124. private _activeMesh;
  70125. private _prepareRessources;
  70126. private _createIndexBuffer;
  70127. /**
  70128. * Rebuilds the elements related to this component in case of
  70129. * context lost for instance.
  70130. */
  70131. rebuild(): void;
  70132. /**
  70133. * @hidden
  70134. */
  70135. reset(): void;
  70136. /**
  70137. * Render the bounding boxes of a specific rendering group
  70138. * @param renderingGroupId defines the rendering group to render
  70139. */
  70140. render(renderingGroupId: number): void;
  70141. /**
  70142. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70143. * @param mesh Define the mesh to render the occlusion bounding box for
  70144. */
  70145. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70146. /**
  70147. * Dispose and release the resources attached to this renderer.
  70148. */
  70149. dispose(): void;
  70150. }
  70151. }
  70152. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70153. import { Nullable } from "babylonjs/types";
  70154. import { Scene } from "babylonjs/scene";
  70155. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70156. import { Camera } from "babylonjs/Cameras/camera";
  70157. import { ISceneComponent } from "babylonjs/sceneComponent";
  70158. module "babylonjs/scene" {
  70159. interface Scene {
  70160. /** @hidden (Backing field) */
  70161. _depthRenderer: {
  70162. [id: string]: DepthRenderer;
  70163. };
  70164. /**
  70165. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70166. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70167. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70168. * @returns the created depth renderer
  70169. */
  70170. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70171. /**
  70172. * Disables a depth renderer for a given camera
  70173. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70174. */
  70175. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70176. }
  70177. }
  70178. /**
  70179. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70180. * in several rendering techniques.
  70181. */
  70182. export class DepthRendererSceneComponent implements ISceneComponent {
  70183. /**
  70184. * The component name helpfull to identify the component in the list of scene components.
  70185. */
  70186. readonly name: string;
  70187. /**
  70188. * The scene the component belongs to.
  70189. */
  70190. scene: Scene;
  70191. /**
  70192. * Creates a new instance of the component for the given scene
  70193. * @param scene Defines the scene to register the component in
  70194. */
  70195. constructor(scene: Scene);
  70196. /**
  70197. * Registers the component in a given scene
  70198. */
  70199. register(): void;
  70200. /**
  70201. * Rebuilds the elements related to this component in case of
  70202. * context lost for instance.
  70203. */
  70204. rebuild(): void;
  70205. /**
  70206. * Disposes the component and the associated ressources
  70207. */
  70208. dispose(): void;
  70209. private _gatherRenderTargets;
  70210. private _gatherActiveCameraRenderTargets;
  70211. }
  70212. }
  70213. declare module "babylonjs/Shaders/outline.fragment" {
  70214. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70215. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70216. /** @hidden */
  70217. export var outlinePixelShader: {
  70218. name: string;
  70219. shader: string;
  70220. };
  70221. }
  70222. declare module "babylonjs/Shaders/outline.vertex" {
  70223. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70226. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70227. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70229. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70230. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70231. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70232. /** @hidden */
  70233. export var outlineVertexShader: {
  70234. name: string;
  70235. shader: string;
  70236. };
  70237. }
  70238. declare module "babylonjs/Rendering/outlineRenderer" {
  70239. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70240. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70241. import { Scene } from "babylonjs/scene";
  70242. import { ISceneComponent } from "babylonjs/sceneComponent";
  70243. import "babylonjs/Shaders/outline.fragment";
  70244. import "babylonjs/Shaders/outline.vertex";
  70245. module "babylonjs/scene" {
  70246. interface Scene {
  70247. /** @hidden */
  70248. _outlineRenderer: OutlineRenderer;
  70249. /**
  70250. * Gets the outline renderer associated with the scene
  70251. * @returns a OutlineRenderer
  70252. */
  70253. getOutlineRenderer(): OutlineRenderer;
  70254. }
  70255. }
  70256. module "babylonjs/Meshes/abstractMesh" {
  70257. interface AbstractMesh {
  70258. /** @hidden (Backing field) */
  70259. _renderOutline: boolean;
  70260. /**
  70261. * Gets or sets a boolean indicating if the outline must be rendered as well
  70262. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70263. */
  70264. renderOutline: boolean;
  70265. /** @hidden (Backing field) */
  70266. _renderOverlay: boolean;
  70267. /**
  70268. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70269. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70270. */
  70271. renderOverlay: boolean;
  70272. }
  70273. }
  70274. /**
  70275. * This class is responsible to draw bothe outline/overlay of meshes.
  70276. * It should not be used directly but through the available method on mesh.
  70277. */
  70278. export class OutlineRenderer implements ISceneComponent {
  70279. /**
  70280. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70281. */
  70282. private static _StencilReference;
  70283. /**
  70284. * The name of the component. Each component must have a unique name.
  70285. */
  70286. name: string;
  70287. /**
  70288. * The scene the component belongs to.
  70289. */
  70290. scene: Scene;
  70291. /**
  70292. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70293. */
  70294. zOffset: number;
  70295. private _engine;
  70296. private _effect;
  70297. private _cachedDefines;
  70298. private _savedDepthWrite;
  70299. /**
  70300. * Instantiates a new outline renderer. (There could be only one per scene).
  70301. * @param scene Defines the scene it belongs to
  70302. */
  70303. constructor(scene: Scene);
  70304. /**
  70305. * Register the component to one instance of a scene.
  70306. */
  70307. register(): void;
  70308. /**
  70309. * Rebuilds the elements related to this component in case of
  70310. * context lost for instance.
  70311. */
  70312. rebuild(): void;
  70313. /**
  70314. * Disposes the component and the associated ressources.
  70315. */
  70316. dispose(): void;
  70317. /**
  70318. * Renders the outline in the canvas.
  70319. * @param subMesh Defines the sumesh to render
  70320. * @param batch Defines the batch of meshes in case of instances
  70321. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70322. */
  70323. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70324. /**
  70325. * Returns whether or not the outline renderer is ready for a given submesh.
  70326. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70327. * @param subMesh Defines the submesh to check readyness for
  70328. * @param useInstances Defines wheter wee are trying to render instances or not
  70329. * @returns true if ready otherwise false
  70330. */
  70331. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70332. private _beforeRenderingMesh;
  70333. private _afterRenderingMesh;
  70334. }
  70335. }
  70336. declare module "babylonjs/Rendering/index" {
  70337. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70338. export * from "babylonjs/Rendering/depthRenderer";
  70339. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70340. export * from "babylonjs/Rendering/edgesRenderer";
  70341. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70342. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70343. export * from "babylonjs/Rendering/outlineRenderer";
  70344. export * from "babylonjs/Rendering/renderingGroup";
  70345. export * from "babylonjs/Rendering/renderingManager";
  70346. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70347. }
  70348. declare module "babylonjs/Sprites/ISprites" {
  70349. /**
  70350. * Defines the basic options interface of a Sprite Frame Source Size.
  70351. */
  70352. export interface ISpriteJSONSpriteSourceSize {
  70353. /**
  70354. * number of the original width of the Frame
  70355. */
  70356. w: number;
  70357. /**
  70358. * number of the original height of the Frame
  70359. */
  70360. h: number;
  70361. }
  70362. /**
  70363. * Defines the basic options interface of a Sprite Frame Data.
  70364. */
  70365. export interface ISpriteJSONSpriteFrameData {
  70366. /**
  70367. * number of the x offset of the Frame
  70368. */
  70369. x: number;
  70370. /**
  70371. * number of the y offset of the Frame
  70372. */
  70373. y: number;
  70374. /**
  70375. * number of the width of the Frame
  70376. */
  70377. w: number;
  70378. /**
  70379. * number of the height of the Frame
  70380. */
  70381. h: number;
  70382. }
  70383. /**
  70384. * Defines the basic options interface of a JSON Sprite.
  70385. */
  70386. export interface ISpriteJSONSprite {
  70387. /**
  70388. * string name of the Frame
  70389. */
  70390. filename: string;
  70391. /**
  70392. * ISpriteJSONSpriteFrame basic object of the frame data
  70393. */
  70394. frame: ISpriteJSONSpriteFrameData;
  70395. /**
  70396. * boolean to flag is the frame was rotated.
  70397. */
  70398. rotated: boolean;
  70399. /**
  70400. * boolean to flag is the frame was trimmed.
  70401. */
  70402. trimmed: boolean;
  70403. /**
  70404. * ISpriteJSONSpriteFrame basic object of the source data
  70405. */
  70406. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70407. /**
  70408. * ISpriteJSONSpriteFrame basic object of the source data
  70409. */
  70410. sourceSize: ISpriteJSONSpriteSourceSize;
  70411. }
  70412. /**
  70413. * Defines the basic options interface of a JSON atlas.
  70414. */
  70415. export interface ISpriteJSONAtlas {
  70416. /**
  70417. * Array of objects that contain the frame data.
  70418. */
  70419. frames: Array<ISpriteJSONSprite>;
  70420. /**
  70421. * object basic object containing the sprite meta data.
  70422. */
  70423. meta?: object;
  70424. }
  70425. }
  70426. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70427. /** @hidden */
  70428. export var spriteMapPixelShader: {
  70429. name: string;
  70430. shader: string;
  70431. };
  70432. }
  70433. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70434. /** @hidden */
  70435. export var spriteMapVertexShader: {
  70436. name: string;
  70437. shader: string;
  70438. };
  70439. }
  70440. declare module "babylonjs/Sprites/spriteMap" {
  70441. import { IDisposable, Scene } from "babylonjs/scene";
  70442. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70443. import { Texture } from "babylonjs/Materials/Textures/texture";
  70444. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70445. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70446. import "babylonjs/Meshes/Builders/planeBuilder";
  70447. import "babylonjs/Shaders/spriteMap.fragment";
  70448. import "babylonjs/Shaders/spriteMap.vertex";
  70449. /**
  70450. * Defines the basic options interface of a SpriteMap
  70451. */
  70452. export interface ISpriteMapOptions {
  70453. /**
  70454. * Vector2 of the number of cells in the grid.
  70455. */
  70456. stageSize?: Vector2;
  70457. /**
  70458. * Vector2 of the size of the output plane in World Units.
  70459. */
  70460. outputSize?: Vector2;
  70461. /**
  70462. * Vector3 of the position of the output plane in World Units.
  70463. */
  70464. outputPosition?: Vector3;
  70465. /**
  70466. * Vector3 of the rotation of the output plane.
  70467. */
  70468. outputRotation?: Vector3;
  70469. /**
  70470. * number of layers that the system will reserve in resources.
  70471. */
  70472. layerCount?: number;
  70473. /**
  70474. * number of max animation frames a single cell will reserve in resources.
  70475. */
  70476. maxAnimationFrames?: number;
  70477. /**
  70478. * number cell index of the base tile when the system compiles.
  70479. */
  70480. baseTile?: number;
  70481. /**
  70482. * boolean flip the sprite after its been repositioned by the framing data.
  70483. */
  70484. flipU?: boolean;
  70485. /**
  70486. * Vector3 scalar of the global RGB values of the SpriteMap.
  70487. */
  70488. colorMultiply?: Vector3;
  70489. }
  70490. /**
  70491. * Defines the IDisposable interface in order to be cleanable from resources.
  70492. */
  70493. export interface ISpriteMap extends IDisposable {
  70494. /**
  70495. * String name of the SpriteMap.
  70496. */
  70497. name: string;
  70498. /**
  70499. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70500. */
  70501. atlasJSON: ISpriteJSONAtlas;
  70502. /**
  70503. * Texture of the SpriteMap.
  70504. */
  70505. spriteSheet: Texture;
  70506. /**
  70507. * The parameters to initialize the SpriteMap with.
  70508. */
  70509. options: ISpriteMapOptions;
  70510. }
  70511. /**
  70512. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70513. */
  70514. export class SpriteMap implements ISpriteMap {
  70515. /** The Name of the spriteMap */
  70516. name: string;
  70517. /** The JSON file with the frame and meta data */
  70518. atlasJSON: ISpriteJSONAtlas;
  70519. /** The systems Sprite Sheet Texture */
  70520. spriteSheet: Texture;
  70521. /** Arguments passed with the Constructor */
  70522. options: ISpriteMapOptions;
  70523. /** Public Sprite Storage array, parsed from atlasJSON */
  70524. sprites: Array<ISpriteJSONSprite>;
  70525. /** Returns the Number of Sprites in the System */
  70526. get spriteCount(): number;
  70527. /** Returns the Position of Output Plane*/
  70528. get position(): Vector3;
  70529. /** Returns the Position of Output Plane*/
  70530. set position(v: Vector3);
  70531. /** Returns the Rotation of Output Plane*/
  70532. get rotation(): Vector3;
  70533. /** Returns the Rotation of Output Plane*/
  70534. set rotation(v: Vector3);
  70535. /** Sets the AnimationMap*/
  70536. get animationMap(): RawTexture;
  70537. /** Sets the AnimationMap*/
  70538. set animationMap(v: RawTexture);
  70539. /** Scene that the SpriteMap was created in */
  70540. private _scene;
  70541. /** Texture Buffer of Float32 that holds tile frame data*/
  70542. private _frameMap;
  70543. /** Texture Buffers of Float32 that holds tileMap data*/
  70544. private _tileMaps;
  70545. /** Texture Buffer of Float32 that holds Animation Data*/
  70546. private _animationMap;
  70547. /** Custom ShaderMaterial Central to the System*/
  70548. private _material;
  70549. /** Custom ShaderMaterial Central to the System*/
  70550. private _output;
  70551. /** Systems Time Ticker*/
  70552. private _time;
  70553. /**
  70554. * Creates a new SpriteMap
  70555. * @param name defines the SpriteMaps Name
  70556. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70557. * @param spriteSheet is the Texture that the Sprites are on.
  70558. * @param options a basic deployment configuration
  70559. * @param scene The Scene that the map is deployed on
  70560. */
  70561. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70562. /**
  70563. * Returns tileID location
  70564. * @returns Vector2 the cell position ID
  70565. */
  70566. getTileID(): Vector2;
  70567. /**
  70568. * Gets the UV location of the mouse over the SpriteMap.
  70569. * @returns Vector2 the UV position of the mouse interaction
  70570. */
  70571. getMousePosition(): Vector2;
  70572. /**
  70573. * Creates the "frame" texture Buffer
  70574. * -------------------------------------
  70575. * Structure of frames
  70576. * "filename": "Falling-Water-2.png",
  70577. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70578. * "rotated": true,
  70579. * "trimmed": true,
  70580. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70581. * "sourceSize": {"w":32,"h":32}
  70582. * @returns RawTexture of the frameMap
  70583. */
  70584. private _createFrameBuffer;
  70585. /**
  70586. * Creates the tileMap texture Buffer
  70587. * @param buffer normally and array of numbers, or a false to generate from scratch
  70588. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70589. * @returns RawTexture of the tileMap
  70590. */
  70591. private _createTileBuffer;
  70592. /**
  70593. * Modifies the data of the tileMaps
  70594. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70595. * @param pos is the iVector2 Coordinates of the Tile
  70596. * @param tile The SpriteIndex of the new Tile
  70597. */
  70598. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70599. /**
  70600. * Creates the animationMap texture Buffer
  70601. * @param buffer normally and array of numbers, or a false to generate from scratch
  70602. * @returns RawTexture of the animationMap
  70603. */
  70604. private _createTileAnimationBuffer;
  70605. /**
  70606. * Modifies the data of the animationMap
  70607. * @param cellID is the Index of the Sprite
  70608. * @param _frame is the target Animation frame
  70609. * @param toCell is the Target Index of the next frame of the animation
  70610. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70611. * @param speed is a global scalar of the time variable on the map.
  70612. */
  70613. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70614. /**
  70615. * Exports the .tilemaps file
  70616. */
  70617. saveTileMaps(): void;
  70618. /**
  70619. * Imports the .tilemaps file
  70620. * @param url of the .tilemaps file
  70621. */
  70622. loadTileMaps(url: string): void;
  70623. /**
  70624. * Release associated resources
  70625. */
  70626. dispose(): void;
  70627. }
  70628. }
  70629. declare module "babylonjs/Sprites/spritePackedManager" {
  70630. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70631. import { Scene } from "babylonjs/scene";
  70632. /**
  70633. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70634. * @see http://doc.babylonjs.com/babylon101/sprites
  70635. */
  70636. export class SpritePackedManager extends SpriteManager {
  70637. /** defines the packed manager's name */
  70638. name: string;
  70639. /**
  70640. * Creates a new sprite manager from a packed sprite sheet
  70641. * @param name defines the manager's name
  70642. * @param imgUrl defines the sprite sheet url
  70643. * @param capacity defines the maximum allowed number of sprites
  70644. * @param scene defines the hosting scene
  70645. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70646. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70647. * @param samplingMode defines the smapling mode to use with spritesheet
  70648. * @param fromPacked set to true; do not alter
  70649. */
  70650. constructor(
  70651. /** defines the packed manager's name */
  70652. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70653. }
  70654. }
  70655. declare module "babylonjs/Sprites/index" {
  70656. export * from "babylonjs/Sprites/sprite";
  70657. export * from "babylonjs/Sprites/ISprites";
  70658. export * from "babylonjs/Sprites/spriteManager";
  70659. export * from "babylonjs/Sprites/spriteMap";
  70660. export * from "babylonjs/Sprites/spritePackedManager";
  70661. export * from "babylonjs/Sprites/spriteSceneComponent";
  70662. }
  70663. declare module "babylonjs/States/index" {
  70664. export * from "babylonjs/States/alphaCullingState";
  70665. export * from "babylonjs/States/depthCullingState";
  70666. export * from "babylonjs/States/stencilState";
  70667. }
  70668. declare module "babylonjs/Misc/assetsManager" {
  70669. import { Scene } from "babylonjs/scene";
  70670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70671. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70672. import { Skeleton } from "babylonjs/Bones/skeleton";
  70673. import { Observable } from "babylonjs/Misc/observable";
  70674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70675. import { Texture } from "babylonjs/Materials/Textures/texture";
  70676. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70677. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70678. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70679. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70680. /**
  70681. * Defines the list of states available for a task inside a AssetsManager
  70682. */
  70683. export enum AssetTaskState {
  70684. /**
  70685. * Initialization
  70686. */
  70687. INIT = 0,
  70688. /**
  70689. * Running
  70690. */
  70691. RUNNING = 1,
  70692. /**
  70693. * Done
  70694. */
  70695. DONE = 2,
  70696. /**
  70697. * Error
  70698. */
  70699. ERROR = 3
  70700. }
  70701. /**
  70702. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70703. */
  70704. export abstract class AbstractAssetTask {
  70705. /**
  70706. * Task name
  70707. */ name: string;
  70708. /**
  70709. * Callback called when the task is successful
  70710. */
  70711. onSuccess: (task: any) => void;
  70712. /**
  70713. * Callback called when the task is not successful
  70714. */
  70715. onError: (task: any, message?: string, exception?: any) => void;
  70716. /**
  70717. * Creates a new AssetsManager
  70718. * @param name defines the name of the task
  70719. */
  70720. constructor(
  70721. /**
  70722. * Task name
  70723. */ name: string);
  70724. private _isCompleted;
  70725. private _taskState;
  70726. private _errorObject;
  70727. /**
  70728. * Get if the task is completed
  70729. */
  70730. get isCompleted(): boolean;
  70731. /**
  70732. * Gets the current state of the task
  70733. */
  70734. get taskState(): AssetTaskState;
  70735. /**
  70736. * Gets the current error object (if task is in error)
  70737. */
  70738. get errorObject(): {
  70739. message?: string;
  70740. exception?: any;
  70741. };
  70742. /**
  70743. * Internal only
  70744. * @hidden
  70745. */
  70746. _setErrorObject(message?: string, exception?: any): void;
  70747. /**
  70748. * Execute the current task
  70749. * @param scene defines the scene where you want your assets to be loaded
  70750. * @param onSuccess is a callback called when the task is successfully executed
  70751. * @param onError is a callback called if an error occurs
  70752. */
  70753. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70754. /**
  70755. * Execute the current task
  70756. * @param scene defines the scene where you want your assets to be loaded
  70757. * @param onSuccess is a callback called when the task is successfully executed
  70758. * @param onError is a callback called if an error occurs
  70759. */
  70760. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70761. /**
  70762. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70763. * This can be used with failed tasks that have the reason for failure fixed.
  70764. */
  70765. reset(): void;
  70766. private onErrorCallback;
  70767. private onDoneCallback;
  70768. }
  70769. /**
  70770. * Define the interface used by progress events raised during assets loading
  70771. */
  70772. export interface IAssetsProgressEvent {
  70773. /**
  70774. * Defines the number of remaining tasks to process
  70775. */
  70776. remainingCount: number;
  70777. /**
  70778. * Defines the total number of tasks
  70779. */
  70780. totalCount: number;
  70781. /**
  70782. * Defines the task that was just processed
  70783. */
  70784. task: AbstractAssetTask;
  70785. }
  70786. /**
  70787. * Class used to share progress information about assets loading
  70788. */
  70789. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70790. /**
  70791. * Defines the number of remaining tasks to process
  70792. */
  70793. remainingCount: number;
  70794. /**
  70795. * Defines the total number of tasks
  70796. */
  70797. totalCount: number;
  70798. /**
  70799. * Defines the task that was just processed
  70800. */
  70801. task: AbstractAssetTask;
  70802. /**
  70803. * Creates a AssetsProgressEvent
  70804. * @param remainingCount defines the number of remaining tasks to process
  70805. * @param totalCount defines the total number of tasks
  70806. * @param task defines the task that was just processed
  70807. */
  70808. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70809. }
  70810. /**
  70811. * Define a task used by AssetsManager to load meshes
  70812. */
  70813. export class MeshAssetTask extends AbstractAssetTask {
  70814. /**
  70815. * Defines the name of the task
  70816. */
  70817. name: string;
  70818. /**
  70819. * Defines the list of mesh's names you want to load
  70820. */
  70821. meshesNames: any;
  70822. /**
  70823. * Defines the root url to use as a base to load your meshes and associated resources
  70824. */
  70825. rootUrl: string;
  70826. /**
  70827. * Defines the filename of the scene to load from
  70828. */
  70829. sceneFilename: string;
  70830. /**
  70831. * Gets the list of loaded meshes
  70832. */
  70833. loadedMeshes: Array<AbstractMesh>;
  70834. /**
  70835. * Gets the list of loaded particle systems
  70836. */
  70837. loadedParticleSystems: Array<IParticleSystem>;
  70838. /**
  70839. * Gets the list of loaded skeletons
  70840. */
  70841. loadedSkeletons: Array<Skeleton>;
  70842. /**
  70843. * Gets the list of loaded animation groups
  70844. */
  70845. loadedAnimationGroups: Array<AnimationGroup>;
  70846. /**
  70847. * Callback called when the task is successful
  70848. */
  70849. onSuccess: (task: MeshAssetTask) => void;
  70850. /**
  70851. * Callback called when the task is successful
  70852. */
  70853. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70854. /**
  70855. * Creates a new MeshAssetTask
  70856. * @param name defines the name of the task
  70857. * @param meshesNames defines the list of mesh's names you want to load
  70858. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70859. * @param sceneFilename defines the filename of the scene to load from
  70860. */
  70861. constructor(
  70862. /**
  70863. * Defines the name of the task
  70864. */
  70865. name: string,
  70866. /**
  70867. * Defines the list of mesh's names you want to load
  70868. */
  70869. meshesNames: any,
  70870. /**
  70871. * Defines the root url to use as a base to load your meshes and associated resources
  70872. */
  70873. rootUrl: string,
  70874. /**
  70875. * Defines the filename of the scene to load from
  70876. */
  70877. sceneFilename: string);
  70878. /**
  70879. * Execute the current task
  70880. * @param scene defines the scene where you want your assets to be loaded
  70881. * @param onSuccess is a callback called when the task is successfully executed
  70882. * @param onError is a callback called if an error occurs
  70883. */
  70884. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70885. }
  70886. /**
  70887. * Define a task used by AssetsManager to load text content
  70888. */
  70889. export class TextFileAssetTask extends AbstractAssetTask {
  70890. /**
  70891. * Defines the name of the task
  70892. */
  70893. name: string;
  70894. /**
  70895. * Defines the location of the file to load
  70896. */
  70897. url: string;
  70898. /**
  70899. * Gets the loaded text string
  70900. */
  70901. text: string;
  70902. /**
  70903. * Callback called when the task is successful
  70904. */
  70905. onSuccess: (task: TextFileAssetTask) => void;
  70906. /**
  70907. * Callback called when the task is successful
  70908. */
  70909. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70910. /**
  70911. * Creates a new TextFileAssetTask object
  70912. * @param name defines the name of the task
  70913. * @param url defines the location of the file to load
  70914. */
  70915. constructor(
  70916. /**
  70917. * Defines the name of the task
  70918. */
  70919. name: string,
  70920. /**
  70921. * Defines the location of the file to load
  70922. */
  70923. url: string);
  70924. /**
  70925. * Execute the current task
  70926. * @param scene defines the scene where you want your assets to be loaded
  70927. * @param onSuccess is a callback called when the task is successfully executed
  70928. * @param onError is a callback called if an error occurs
  70929. */
  70930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70931. }
  70932. /**
  70933. * Define a task used by AssetsManager to load binary data
  70934. */
  70935. export class BinaryFileAssetTask extends AbstractAssetTask {
  70936. /**
  70937. * Defines the name of the task
  70938. */
  70939. name: string;
  70940. /**
  70941. * Defines the location of the file to load
  70942. */
  70943. url: string;
  70944. /**
  70945. * Gets the lodaded data (as an array buffer)
  70946. */
  70947. data: ArrayBuffer;
  70948. /**
  70949. * Callback called when the task is successful
  70950. */
  70951. onSuccess: (task: BinaryFileAssetTask) => void;
  70952. /**
  70953. * Callback called when the task is successful
  70954. */
  70955. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70956. /**
  70957. * Creates a new BinaryFileAssetTask object
  70958. * @param name defines the name of the new task
  70959. * @param url defines the location of the file to load
  70960. */
  70961. constructor(
  70962. /**
  70963. * Defines the name of the task
  70964. */
  70965. name: string,
  70966. /**
  70967. * Defines the location of the file to load
  70968. */
  70969. url: string);
  70970. /**
  70971. * Execute the current task
  70972. * @param scene defines the scene where you want your assets to be loaded
  70973. * @param onSuccess is a callback called when the task is successfully executed
  70974. * @param onError is a callback called if an error occurs
  70975. */
  70976. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70977. }
  70978. /**
  70979. * Define a task used by AssetsManager to load images
  70980. */
  70981. export class ImageAssetTask extends AbstractAssetTask {
  70982. /**
  70983. * Defines the name of the task
  70984. */
  70985. name: string;
  70986. /**
  70987. * Defines the location of the image to load
  70988. */
  70989. url: string;
  70990. /**
  70991. * Gets the loaded images
  70992. */
  70993. image: HTMLImageElement;
  70994. /**
  70995. * Callback called when the task is successful
  70996. */
  70997. onSuccess: (task: ImageAssetTask) => void;
  70998. /**
  70999. * Callback called when the task is successful
  71000. */
  71001. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71002. /**
  71003. * Creates a new ImageAssetTask
  71004. * @param name defines the name of the task
  71005. * @param url defines the location of the image to load
  71006. */
  71007. constructor(
  71008. /**
  71009. * Defines the name of the task
  71010. */
  71011. name: string,
  71012. /**
  71013. * Defines the location of the image to load
  71014. */
  71015. url: string);
  71016. /**
  71017. * Execute the current task
  71018. * @param scene defines the scene where you want your assets to be loaded
  71019. * @param onSuccess is a callback called when the task is successfully executed
  71020. * @param onError is a callback called if an error occurs
  71021. */
  71022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71023. }
  71024. /**
  71025. * Defines the interface used by texture loading tasks
  71026. */
  71027. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71028. /**
  71029. * Gets the loaded texture
  71030. */
  71031. texture: TEX;
  71032. }
  71033. /**
  71034. * Define a task used by AssetsManager to load 2D textures
  71035. */
  71036. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71037. /**
  71038. * Defines the name of the task
  71039. */
  71040. name: string;
  71041. /**
  71042. * Defines the location of the file to load
  71043. */
  71044. url: string;
  71045. /**
  71046. * Defines if mipmap should not be generated (default is false)
  71047. */
  71048. noMipmap?: boolean | undefined;
  71049. /**
  71050. * Defines if texture must be inverted on Y axis (default is false)
  71051. */
  71052. invertY?: boolean | undefined;
  71053. /**
  71054. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71055. */
  71056. samplingMode: number;
  71057. /**
  71058. * Gets the loaded texture
  71059. */
  71060. texture: Texture;
  71061. /**
  71062. * Callback called when the task is successful
  71063. */
  71064. onSuccess: (task: TextureAssetTask) => void;
  71065. /**
  71066. * Callback called when the task is successful
  71067. */
  71068. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71069. /**
  71070. * Creates a new TextureAssetTask object
  71071. * @param name defines the name of the task
  71072. * @param url defines the location of the file to load
  71073. * @param noMipmap defines if mipmap should not be generated (default is false)
  71074. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71075. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71076. */
  71077. constructor(
  71078. /**
  71079. * Defines the name of the task
  71080. */
  71081. name: string,
  71082. /**
  71083. * Defines the location of the file to load
  71084. */
  71085. url: string,
  71086. /**
  71087. * Defines if mipmap should not be generated (default is false)
  71088. */
  71089. noMipmap?: boolean | undefined,
  71090. /**
  71091. * Defines if texture must be inverted on Y axis (default is false)
  71092. */
  71093. invertY?: boolean | undefined,
  71094. /**
  71095. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71096. */
  71097. samplingMode?: number);
  71098. /**
  71099. * Execute the current task
  71100. * @param scene defines the scene where you want your assets to be loaded
  71101. * @param onSuccess is a callback called when the task is successfully executed
  71102. * @param onError is a callback called if an error occurs
  71103. */
  71104. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71105. }
  71106. /**
  71107. * Define a task used by AssetsManager to load cube textures
  71108. */
  71109. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71110. /**
  71111. * Defines the name of the task
  71112. */
  71113. name: string;
  71114. /**
  71115. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71116. */
  71117. url: string;
  71118. /**
  71119. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71120. */
  71121. extensions?: string[] | undefined;
  71122. /**
  71123. * Defines if mipmaps should not be generated (default is false)
  71124. */
  71125. noMipmap?: boolean | undefined;
  71126. /**
  71127. * Defines the explicit list of files (undefined by default)
  71128. */
  71129. files?: string[] | undefined;
  71130. /**
  71131. * Gets the loaded texture
  71132. */
  71133. texture: CubeTexture;
  71134. /**
  71135. * Callback called when the task is successful
  71136. */
  71137. onSuccess: (task: CubeTextureAssetTask) => void;
  71138. /**
  71139. * Callback called when the task is successful
  71140. */
  71141. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71142. /**
  71143. * Creates a new CubeTextureAssetTask
  71144. * @param name defines the name of the task
  71145. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71146. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71147. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71148. * @param files defines the explicit list of files (undefined by default)
  71149. */
  71150. constructor(
  71151. /**
  71152. * Defines the name of the task
  71153. */
  71154. name: string,
  71155. /**
  71156. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71157. */
  71158. url: string,
  71159. /**
  71160. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71161. */
  71162. extensions?: string[] | undefined,
  71163. /**
  71164. * Defines if mipmaps should not be generated (default is false)
  71165. */
  71166. noMipmap?: boolean | undefined,
  71167. /**
  71168. * Defines the explicit list of files (undefined by default)
  71169. */
  71170. files?: string[] | undefined);
  71171. /**
  71172. * Execute the current task
  71173. * @param scene defines the scene where you want your assets to be loaded
  71174. * @param onSuccess is a callback called when the task is successfully executed
  71175. * @param onError is a callback called if an error occurs
  71176. */
  71177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71178. }
  71179. /**
  71180. * Define a task used by AssetsManager to load HDR cube textures
  71181. */
  71182. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71183. /**
  71184. * Defines the name of the task
  71185. */
  71186. name: string;
  71187. /**
  71188. * Defines the location of the file to load
  71189. */
  71190. url: string;
  71191. /**
  71192. * Defines the desired size (the more it increases the longer the generation will be)
  71193. */
  71194. size: number;
  71195. /**
  71196. * Defines if mipmaps should not be generated (default is false)
  71197. */
  71198. noMipmap: boolean;
  71199. /**
  71200. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71201. */
  71202. generateHarmonics: boolean;
  71203. /**
  71204. * 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)
  71205. */
  71206. gammaSpace: boolean;
  71207. /**
  71208. * Internal Use Only
  71209. */
  71210. reserved: boolean;
  71211. /**
  71212. * Gets the loaded texture
  71213. */
  71214. texture: HDRCubeTexture;
  71215. /**
  71216. * Callback called when the task is successful
  71217. */
  71218. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71219. /**
  71220. * Callback called when the task is successful
  71221. */
  71222. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71223. /**
  71224. * Creates a new HDRCubeTextureAssetTask object
  71225. * @param name defines the name of the task
  71226. * @param url defines the location of the file to load
  71227. * @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.
  71228. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71229. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71230. * @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)
  71231. * @param reserved Internal use only
  71232. */
  71233. constructor(
  71234. /**
  71235. * Defines the name of the task
  71236. */
  71237. name: string,
  71238. /**
  71239. * Defines the location of the file to load
  71240. */
  71241. url: string,
  71242. /**
  71243. * Defines the desired size (the more it increases the longer the generation will be)
  71244. */
  71245. size: number,
  71246. /**
  71247. * Defines if mipmaps should not be generated (default is false)
  71248. */
  71249. noMipmap?: boolean,
  71250. /**
  71251. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71252. */
  71253. generateHarmonics?: boolean,
  71254. /**
  71255. * 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)
  71256. */
  71257. gammaSpace?: boolean,
  71258. /**
  71259. * Internal Use Only
  71260. */
  71261. reserved?: boolean);
  71262. /**
  71263. * Execute the current task
  71264. * @param scene defines the scene where you want your assets to be loaded
  71265. * @param onSuccess is a callback called when the task is successfully executed
  71266. * @param onError is a callback called if an error occurs
  71267. */
  71268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71269. }
  71270. /**
  71271. * Define a task used by AssetsManager to load Equirectangular cube textures
  71272. */
  71273. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71274. /**
  71275. * Defines the name of the task
  71276. */
  71277. name: string;
  71278. /**
  71279. * Defines the location of the file to load
  71280. */
  71281. url: string;
  71282. /**
  71283. * Defines the desired size (the more it increases the longer the generation will be)
  71284. */
  71285. size: number;
  71286. /**
  71287. * Defines if mipmaps should not be generated (default is false)
  71288. */
  71289. noMipmap: boolean;
  71290. /**
  71291. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71292. * but the standard material would require them in Gamma space) (default is true)
  71293. */
  71294. gammaSpace: boolean;
  71295. /**
  71296. * Gets the loaded texture
  71297. */
  71298. texture: EquiRectangularCubeTexture;
  71299. /**
  71300. * Callback called when the task is successful
  71301. */
  71302. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71303. /**
  71304. * Callback called when the task is successful
  71305. */
  71306. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71307. /**
  71308. * Creates a new EquiRectangularCubeTextureAssetTask object
  71309. * @param name defines the name of the task
  71310. * @param url defines the location of the file to load
  71311. * @param size defines the desired size (the more it increases the longer the generation will be)
  71312. * If the size is omitted this implies you are using a preprocessed cubemap.
  71313. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71314. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71315. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71316. * (default is true)
  71317. */
  71318. constructor(
  71319. /**
  71320. * Defines the name of the task
  71321. */
  71322. name: string,
  71323. /**
  71324. * Defines the location of the file to load
  71325. */
  71326. url: string,
  71327. /**
  71328. * Defines the desired size (the more it increases the longer the generation will be)
  71329. */
  71330. size: number,
  71331. /**
  71332. * Defines if mipmaps should not be generated (default is false)
  71333. */
  71334. noMipmap?: boolean,
  71335. /**
  71336. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71337. * but the standard material would require them in Gamma space) (default is true)
  71338. */
  71339. gammaSpace?: boolean);
  71340. /**
  71341. * Execute the current task
  71342. * @param scene defines the scene where you want your assets to be loaded
  71343. * @param onSuccess is a callback called when the task is successfully executed
  71344. * @param onError is a callback called if an error occurs
  71345. */
  71346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71347. }
  71348. /**
  71349. * This class can be used to easily import assets into a scene
  71350. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71351. */
  71352. export class AssetsManager {
  71353. private _scene;
  71354. private _isLoading;
  71355. protected _tasks: AbstractAssetTask[];
  71356. protected _waitingTasksCount: number;
  71357. protected _totalTasksCount: number;
  71358. /**
  71359. * Callback called when all tasks are processed
  71360. */
  71361. onFinish: (tasks: AbstractAssetTask[]) => void;
  71362. /**
  71363. * Callback called when a task is successful
  71364. */
  71365. onTaskSuccess: (task: AbstractAssetTask) => void;
  71366. /**
  71367. * Callback called when a task had an error
  71368. */
  71369. onTaskError: (task: AbstractAssetTask) => void;
  71370. /**
  71371. * Callback called when a task is done (whatever the result is)
  71372. */
  71373. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71374. /**
  71375. * Observable called when all tasks are processed
  71376. */
  71377. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71378. /**
  71379. * Observable called when a task had an error
  71380. */
  71381. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71382. /**
  71383. * Observable called when all tasks were executed
  71384. */
  71385. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71386. /**
  71387. * Observable called when a task is done (whatever the result is)
  71388. */
  71389. onProgressObservable: Observable<IAssetsProgressEvent>;
  71390. /**
  71391. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71393. */
  71394. useDefaultLoadingScreen: boolean;
  71395. /**
  71396. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71397. * when all assets have been downloaded.
  71398. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71399. */
  71400. autoHideLoadingUI: boolean;
  71401. /**
  71402. * Creates a new AssetsManager
  71403. * @param scene defines the scene to work on
  71404. */
  71405. constructor(scene: Scene);
  71406. /**
  71407. * Add a MeshAssetTask to the list of active tasks
  71408. * @param taskName defines the name of the new task
  71409. * @param meshesNames defines the name of meshes to load
  71410. * @param rootUrl defines the root url to use to locate files
  71411. * @param sceneFilename defines the filename of the scene file
  71412. * @returns a new MeshAssetTask object
  71413. */
  71414. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71415. /**
  71416. * Add a TextFileAssetTask to the list of active tasks
  71417. * @param taskName defines the name of the new task
  71418. * @param url defines the url of the file to load
  71419. * @returns a new TextFileAssetTask object
  71420. */
  71421. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71422. /**
  71423. * Add a BinaryFileAssetTask to the list of active tasks
  71424. * @param taskName defines the name of the new task
  71425. * @param url defines the url of the file to load
  71426. * @returns a new BinaryFileAssetTask object
  71427. */
  71428. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71429. /**
  71430. * Add a ImageAssetTask to the list of active tasks
  71431. * @param taskName defines the name of the new task
  71432. * @param url defines the url of the file to load
  71433. * @returns a new ImageAssetTask object
  71434. */
  71435. addImageTask(taskName: string, url: string): ImageAssetTask;
  71436. /**
  71437. * Add a TextureAssetTask to the list of active tasks
  71438. * @param taskName defines the name of the new task
  71439. * @param url defines the url of the file to load
  71440. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71441. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71442. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71443. * @returns a new TextureAssetTask object
  71444. */
  71445. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71446. /**
  71447. * Add a CubeTextureAssetTask to the list of active tasks
  71448. * @param taskName defines the name of the new task
  71449. * @param url defines the url of the file to load
  71450. * @param extensions defines the extension to use to load the cube map (can be null)
  71451. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71452. * @param files defines the list of files to load (can be null)
  71453. * @returns a new CubeTextureAssetTask object
  71454. */
  71455. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71456. /**
  71457. *
  71458. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71459. * @param taskName defines the name of the new task
  71460. * @param url defines the url of the file to load
  71461. * @param size defines the size you want for the cubemap (can be null)
  71462. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71463. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71464. * @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)
  71465. * @param reserved Internal use only
  71466. * @returns a new HDRCubeTextureAssetTask object
  71467. */
  71468. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71469. /**
  71470. *
  71471. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71472. * @param taskName defines the name of the new task
  71473. * @param url defines the url of the file to load
  71474. * @param size defines the size you want for the cubemap (can be null)
  71475. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71476. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71477. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71478. * @returns a new EquiRectangularCubeTextureAssetTask object
  71479. */
  71480. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71481. /**
  71482. * Remove a task from the assets manager.
  71483. * @param task the task to remove
  71484. */
  71485. removeTask(task: AbstractAssetTask): void;
  71486. private _decreaseWaitingTasksCount;
  71487. private _runTask;
  71488. /**
  71489. * Reset the AssetsManager and remove all tasks
  71490. * @return the current instance of the AssetsManager
  71491. */
  71492. reset(): AssetsManager;
  71493. /**
  71494. * Start the loading process
  71495. * @return the current instance of the AssetsManager
  71496. */
  71497. load(): AssetsManager;
  71498. /**
  71499. * Start the loading process as an async operation
  71500. * @return a promise returning the list of failed tasks
  71501. */
  71502. loadAsync(): Promise<void>;
  71503. }
  71504. }
  71505. declare module "babylonjs/Misc/deferred" {
  71506. /**
  71507. * Wrapper class for promise with external resolve and reject.
  71508. */
  71509. export class Deferred<T> {
  71510. /**
  71511. * The promise associated with this deferred object.
  71512. */
  71513. readonly promise: Promise<T>;
  71514. private _resolve;
  71515. private _reject;
  71516. /**
  71517. * The resolve method of the promise associated with this deferred object.
  71518. */
  71519. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71520. /**
  71521. * The reject method of the promise associated with this deferred object.
  71522. */
  71523. get reject(): (reason?: any) => void;
  71524. /**
  71525. * Constructor for this deferred object.
  71526. */
  71527. constructor();
  71528. }
  71529. }
  71530. declare module "babylonjs/Misc/meshExploder" {
  71531. import { Mesh } from "babylonjs/Meshes/mesh";
  71532. /**
  71533. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71534. */
  71535. export class MeshExploder {
  71536. private _centerMesh;
  71537. private _meshes;
  71538. private _meshesOrigins;
  71539. private _toCenterVectors;
  71540. private _scaledDirection;
  71541. private _newPosition;
  71542. private _centerPosition;
  71543. /**
  71544. * Explodes meshes from a center mesh.
  71545. * @param meshes The meshes to explode.
  71546. * @param centerMesh The mesh to be center of explosion.
  71547. */
  71548. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71549. private _setCenterMesh;
  71550. /**
  71551. * Get class name
  71552. * @returns "MeshExploder"
  71553. */
  71554. getClassName(): string;
  71555. /**
  71556. * "Exploded meshes"
  71557. * @returns Array of meshes with the centerMesh at index 0.
  71558. */
  71559. getMeshes(): Array<Mesh>;
  71560. /**
  71561. * Explodes meshes giving a specific direction
  71562. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71563. */
  71564. explode(direction?: number): void;
  71565. }
  71566. }
  71567. declare module "babylonjs/Misc/filesInput" {
  71568. import { Engine } from "babylonjs/Engines/engine";
  71569. import { Scene } from "babylonjs/scene";
  71570. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71571. /**
  71572. * Class used to help managing file picking and drag'n'drop
  71573. */
  71574. export class FilesInput {
  71575. /**
  71576. * List of files ready to be loaded
  71577. */
  71578. static get FilesToLoad(): {
  71579. [key: string]: File;
  71580. };
  71581. /**
  71582. * Callback called when a file is processed
  71583. */
  71584. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71585. private _engine;
  71586. private _currentScene;
  71587. private _sceneLoadedCallback;
  71588. private _progressCallback;
  71589. private _additionalRenderLoopLogicCallback;
  71590. private _textureLoadingCallback;
  71591. private _startingProcessingFilesCallback;
  71592. private _onReloadCallback;
  71593. private _errorCallback;
  71594. private _elementToMonitor;
  71595. private _sceneFileToLoad;
  71596. private _filesToLoad;
  71597. /**
  71598. * Creates a new FilesInput
  71599. * @param engine defines the rendering engine
  71600. * @param scene defines the hosting scene
  71601. * @param sceneLoadedCallback callback called when scene is loaded
  71602. * @param progressCallback callback called to track progress
  71603. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71604. * @param textureLoadingCallback callback called when a texture is loading
  71605. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71606. * @param onReloadCallback callback called when a reload is requested
  71607. * @param errorCallback callback call if an error occurs
  71608. */
  71609. 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);
  71610. private _dragEnterHandler;
  71611. private _dragOverHandler;
  71612. private _dropHandler;
  71613. /**
  71614. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71615. * @param elementToMonitor defines the DOM element to track
  71616. */
  71617. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71618. /**
  71619. * Release all associated resources
  71620. */
  71621. dispose(): void;
  71622. private renderFunction;
  71623. private drag;
  71624. private drop;
  71625. private _traverseFolder;
  71626. private _processFiles;
  71627. /**
  71628. * Load files from a drop event
  71629. * @param event defines the drop event to use as source
  71630. */
  71631. loadFiles(event: any): void;
  71632. private _processReload;
  71633. /**
  71634. * Reload the current scene from the loaded files
  71635. */
  71636. reload(): void;
  71637. }
  71638. }
  71639. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71640. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71641. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71642. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71643. }
  71644. declare module "babylonjs/Misc/sceneOptimizer" {
  71645. import { Scene, IDisposable } from "babylonjs/scene";
  71646. import { Observable } from "babylonjs/Misc/observable";
  71647. /**
  71648. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71650. */
  71651. export class SceneOptimization {
  71652. /**
  71653. * Defines the priority of this optimization (0 by default which means first in the list)
  71654. */
  71655. priority: number;
  71656. /**
  71657. * Gets a string describing the action executed by the current optimization
  71658. * @returns description string
  71659. */
  71660. getDescription(): string;
  71661. /**
  71662. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71663. * @param scene defines the current scene where to apply this optimization
  71664. * @param optimizer defines the current optimizer
  71665. * @returns true if everything that can be done was applied
  71666. */
  71667. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71668. /**
  71669. * Creates the SceneOptimization object
  71670. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71671. * @param desc defines the description associated with the optimization
  71672. */
  71673. constructor(
  71674. /**
  71675. * Defines the priority of this optimization (0 by default which means first in the list)
  71676. */
  71677. priority?: number);
  71678. }
  71679. /**
  71680. * Defines an optimization used to reduce the size of render target textures
  71681. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71682. */
  71683. export class TextureOptimization extends SceneOptimization {
  71684. /**
  71685. * Defines the priority of this optimization (0 by default which means first in the list)
  71686. */
  71687. priority: number;
  71688. /**
  71689. * 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
  71690. */
  71691. maximumSize: number;
  71692. /**
  71693. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71694. */
  71695. step: number;
  71696. /**
  71697. * Gets a string describing the action executed by the current optimization
  71698. * @returns description string
  71699. */
  71700. getDescription(): string;
  71701. /**
  71702. * Creates the TextureOptimization object
  71703. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71704. * @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
  71705. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71706. */
  71707. constructor(
  71708. /**
  71709. * Defines the priority of this optimization (0 by default which means first in the list)
  71710. */
  71711. priority?: number,
  71712. /**
  71713. * 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
  71714. */
  71715. maximumSize?: number,
  71716. /**
  71717. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71718. */
  71719. step?: number);
  71720. /**
  71721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71722. * @param scene defines the current scene where to apply this optimization
  71723. * @param optimizer defines the current optimizer
  71724. * @returns true if everything that can be done was applied
  71725. */
  71726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71727. }
  71728. /**
  71729. * Defines an optimization used to increase or decrease the rendering resolution
  71730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71731. */
  71732. export class HardwareScalingOptimization extends SceneOptimization {
  71733. /**
  71734. * Defines the priority of this optimization (0 by default which means first in the list)
  71735. */
  71736. priority: number;
  71737. /**
  71738. * Defines the maximum scale to use (2 by default)
  71739. */
  71740. maximumScale: number;
  71741. /**
  71742. * Defines the step to use between two passes (0.5 by default)
  71743. */
  71744. step: number;
  71745. private _currentScale;
  71746. private _directionOffset;
  71747. /**
  71748. * Gets a string describing the action executed by the current optimization
  71749. * @return description string
  71750. */
  71751. getDescription(): string;
  71752. /**
  71753. * Creates the HardwareScalingOptimization object
  71754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71755. * @param maximumScale defines the maximum scale to use (2 by default)
  71756. * @param step defines the step to use between two passes (0.5 by default)
  71757. */
  71758. constructor(
  71759. /**
  71760. * Defines the priority of this optimization (0 by default which means first in the list)
  71761. */
  71762. priority?: number,
  71763. /**
  71764. * Defines the maximum scale to use (2 by default)
  71765. */
  71766. maximumScale?: number,
  71767. /**
  71768. * Defines the step to use between two passes (0.5 by default)
  71769. */
  71770. step?: number);
  71771. /**
  71772. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71773. * @param scene defines the current scene where to apply this optimization
  71774. * @param optimizer defines the current optimizer
  71775. * @returns true if everything that can be done was applied
  71776. */
  71777. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71778. }
  71779. /**
  71780. * Defines an optimization used to remove shadows
  71781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71782. */
  71783. export class ShadowsOptimization extends SceneOptimization {
  71784. /**
  71785. * Gets a string describing the action executed by the current optimization
  71786. * @return description string
  71787. */
  71788. getDescription(): string;
  71789. /**
  71790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71791. * @param scene defines the current scene where to apply this optimization
  71792. * @param optimizer defines the current optimizer
  71793. * @returns true if everything that can be done was applied
  71794. */
  71795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71796. }
  71797. /**
  71798. * Defines an optimization used to turn post-processes off
  71799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71800. */
  71801. export class PostProcessesOptimization extends SceneOptimization {
  71802. /**
  71803. * Gets a string describing the action executed by the current optimization
  71804. * @return description string
  71805. */
  71806. getDescription(): string;
  71807. /**
  71808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71809. * @param scene defines the current scene where to apply this optimization
  71810. * @param optimizer defines the current optimizer
  71811. * @returns true if everything that can be done was applied
  71812. */
  71813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71814. }
  71815. /**
  71816. * Defines an optimization used to turn lens flares off
  71817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71818. */
  71819. export class LensFlaresOptimization extends SceneOptimization {
  71820. /**
  71821. * Gets a string describing the action executed by the current optimization
  71822. * @return description string
  71823. */
  71824. getDescription(): string;
  71825. /**
  71826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71827. * @param scene defines the current scene where to apply this optimization
  71828. * @param optimizer defines the current optimizer
  71829. * @returns true if everything that can be done was applied
  71830. */
  71831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71832. }
  71833. /**
  71834. * Defines an optimization based on user defined callback.
  71835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71836. */
  71837. export class CustomOptimization extends SceneOptimization {
  71838. /**
  71839. * Callback called to apply the custom optimization.
  71840. */
  71841. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71842. /**
  71843. * Callback called to get custom description
  71844. */
  71845. onGetDescription: () => string;
  71846. /**
  71847. * Gets a string describing the action executed by the current optimization
  71848. * @returns description string
  71849. */
  71850. getDescription(): string;
  71851. /**
  71852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71853. * @param scene defines the current scene where to apply this optimization
  71854. * @param optimizer defines the current optimizer
  71855. * @returns true if everything that can be done was applied
  71856. */
  71857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71858. }
  71859. /**
  71860. * Defines an optimization used to turn particles off
  71861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71862. */
  71863. export class ParticlesOptimization extends SceneOptimization {
  71864. /**
  71865. * Gets a string describing the action executed by the current optimization
  71866. * @return description string
  71867. */
  71868. getDescription(): string;
  71869. /**
  71870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71871. * @param scene defines the current scene where to apply this optimization
  71872. * @param optimizer defines the current optimizer
  71873. * @returns true if everything that can be done was applied
  71874. */
  71875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71876. }
  71877. /**
  71878. * Defines an optimization used to turn render targets off
  71879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71880. */
  71881. export class RenderTargetsOptimization extends SceneOptimization {
  71882. /**
  71883. * Gets a string describing the action executed by the current optimization
  71884. * @return description string
  71885. */
  71886. getDescription(): string;
  71887. /**
  71888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71889. * @param scene defines the current scene where to apply this optimization
  71890. * @param optimizer defines the current optimizer
  71891. * @returns true if everything that can be done was applied
  71892. */
  71893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71894. }
  71895. /**
  71896. * Defines an optimization used to merge meshes with compatible materials
  71897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71898. */
  71899. export class MergeMeshesOptimization extends SceneOptimization {
  71900. private static _UpdateSelectionTree;
  71901. /**
  71902. * Gets or sets a boolean which defines if optimization octree has to be updated
  71903. */
  71904. static get UpdateSelectionTree(): boolean;
  71905. /**
  71906. * Gets or sets a boolean which defines if optimization octree has to be updated
  71907. */
  71908. static set UpdateSelectionTree(value: boolean);
  71909. /**
  71910. * Gets a string describing the action executed by the current optimization
  71911. * @return description string
  71912. */
  71913. getDescription(): string;
  71914. private _canBeMerged;
  71915. /**
  71916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71917. * @param scene defines the current scene where to apply this optimization
  71918. * @param optimizer defines the current optimizer
  71919. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71920. * @returns true if everything that can be done was applied
  71921. */
  71922. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71923. }
  71924. /**
  71925. * Defines a list of options used by SceneOptimizer
  71926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71927. */
  71928. export class SceneOptimizerOptions {
  71929. /**
  71930. * Defines the target frame rate to reach (60 by default)
  71931. */
  71932. targetFrameRate: number;
  71933. /**
  71934. * Defines the interval between two checkes (2000ms by default)
  71935. */
  71936. trackerDuration: number;
  71937. /**
  71938. * Gets the list of optimizations to apply
  71939. */
  71940. optimizations: SceneOptimization[];
  71941. /**
  71942. * Creates a new list of options used by SceneOptimizer
  71943. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71944. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71945. */
  71946. constructor(
  71947. /**
  71948. * Defines the target frame rate to reach (60 by default)
  71949. */
  71950. targetFrameRate?: number,
  71951. /**
  71952. * Defines the interval between two checkes (2000ms by default)
  71953. */
  71954. trackerDuration?: number);
  71955. /**
  71956. * Add a new optimization
  71957. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71958. * @returns the current SceneOptimizerOptions
  71959. */
  71960. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71961. /**
  71962. * Add a new custom optimization
  71963. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71964. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71965. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71966. * @returns the current SceneOptimizerOptions
  71967. */
  71968. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71969. /**
  71970. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71971. * @param targetFrameRate defines the target frame rate (60 by default)
  71972. * @returns a SceneOptimizerOptions object
  71973. */
  71974. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71975. /**
  71976. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71977. * @param targetFrameRate defines the target frame rate (60 by default)
  71978. * @returns a SceneOptimizerOptions object
  71979. */
  71980. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71981. /**
  71982. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71983. * @param targetFrameRate defines the target frame rate (60 by default)
  71984. * @returns a SceneOptimizerOptions object
  71985. */
  71986. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71987. }
  71988. /**
  71989. * Class used to run optimizations in order to reach a target frame rate
  71990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71991. */
  71992. export class SceneOptimizer implements IDisposable {
  71993. private _isRunning;
  71994. private _options;
  71995. private _scene;
  71996. private _currentPriorityLevel;
  71997. private _targetFrameRate;
  71998. private _trackerDuration;
  71999. private _currentFrameRate;
  72000. private _sceneDisposeObserver;
  72001. private _improvementMode;
  72002. /**
  72003. * Defines an observable called when the optimizer reaches the target frame rate
  72004. */
  72005. onSuccessObservable: Observable<SceneOptimizer>;
  72006. /**
  72007. * Defines an observable called when the optimizer enables an optimization
  72008. */
  72009. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72010. /**
  72011. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72012. */
  72013. onFailureObservable: Observable<SceneOptimizer>;
  72014. /**
  72015. * Gets a boolean indicating if the optimizer is in improvement mode
  72016. */
  72017. get isInImprovementMode(): boolean;
  72018. /**
  72019. * Gets the current priority level (0 at start)
  72020. */
  72021. get currentPriorityLevel(): number;
  72022. /**
  72023. * Gets the current frame rate checked by the SceneOptimizer
  72024. */
  72025. get currentFrameRate(): number;
  72026. /**
  72027. * Gets or sets the current target frame rate (60 by default)
  72028. */
  72029. get targetFrameRate(): number;
  72030. /**
  72031. * Gets or sets the current target frame rate (60 by default)
  72032. */
  72033. set targetFrameRate(value: number);
  72034. /**
  72035. * Gets or sets the current interval between two checks (every 2000ms by default)
  72036. */
  72037. get trackerDuration(): number;
  72038. /**
  72039. * Gets or sets the current interval between two checks (every 2000ms by default)
  72040. */
  72041. set trackerDuration(value: number);
  72042. /**
  72043. * Gets the list of active optimizations
  72044. */
  72045. get optimizations(): SceneOptimization[];
  72046. /**
  72047. * Creates a new SceneOptimizer
  72048. * @param scene defines the scene to work on
  72049. * @param options defines the options to use with the SceneOptimizer
  72050. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72051. * @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)
  72052. */
  72053. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72054. /**
  72055. * Stops the current optimizer
  72056. */
  72057. stop(): void;
  72058. /**
  72059. * Reset the optimizer to initial step (current priority level = 0)
  72060. */
  72061. reset(): void;
  72062. /**
  72063. * Start the optimizer. By default it will try to reach a specific framerate
  72064. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72065. */
  72066. start(): void;
  72067. private _checkCurrentState;
  72068. /**
  72069. * Release all resources
  72070. */
  72071. dispose(): void;
  72072. /**
  72073. * Helper function to create a SceneOptimizer with one single line of code
  72074. * @param scene defines the scene to work on
  72075. * @param options defines the options to use with the SceneOptimizer
  72076. * @param onSuccess defines a callback to call on success
  72077. * @param onFailure defines a callback to call on failure
  72078. * @returns the new SceneOptimizer object
  72079. */
  72080. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72081. }
  72082. }
  72083. declare module "babylonjs/Misc/sceneSerializer" {
  72084. import { Scene } from "babylonjs/scene";
  72085. /**
  72086. * Class used to serialize a scene into a string
  72087. */
  72088. export class SceneSerializer {
  72089. /**
  72090. * Clear cache used by a previous serialization
  72091. */
  72092. static ClearCache(): void;
  72093. /**
  72094. * Serialize a scene into a JSON compatible object
  72095. * @param scene defines the scene to serialize
  72096. * @returns a JSON compatible object
  72097. */
  72098. static Serialize(scene: Scene): any;
  72099. /**
  72100. * Serialize a mesh into a JSON compatible object
  72101. * @param toSerialize defines the mesh to serialize
  72102. * @param withParents defines if parents must be serialized as well
  72103. * @param withChildren defines if children must be serialized as well
  72104. * @returns a JSON compatible object
  72105. */
  72106. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72107. }
  72108. }
  72109. declare module "babylonjs/Misc/textureTools" {
  72110. import { Texture } from "babylonjs/Materials/Textures/texture";
  72111. /**
  72112. * Class used to host texture specific utilities
  72113. */
  72114. export class TextureTools {
  72115. /**
  72116. * Uses the GPU to create a copy texture rescaled at a given size
  72117. * @param texture Texture to copy from
  72118. * @param width defines the desired width
  72119. * @param height defines the desired height
  72120. * @param useBilinearMode defines if bilinear mode has to be used
  72121. * @return the generated texture
  72122. */
  72123. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72124. }
  72125. }
  72126. declare module "babylonjs/Misc/videoRecorder" {
  72127. import { Nullable } from "babylonjs/types";
  72128. import { Engine } from "babylonjs/Engines/engine";
  72129. /**
  72130. * This represents the different options available for the video capture.
  72131. */
  72132. export interface VideoRecorderOptions {
  72133. /** Defines the mime type of the video. */
  72134. mimeType: string;
  72135. /** Defines the FPS the video should be recorded at. */
  72136. fps: number;
  72137. /** Defines the chunk size for the recording data. */
  72138. recordChunckSize: number;
  72139. /** The audio tracks to attach to the recording. */
  72140. audioTracks?: MediaStreamTrack[];
  72141. }
  72142. /**
  72143. * This can help with recording videos from BabylonJS.
  72144. * This is based on the available WebRTC functionalities of the browser.
  72145. *
  72146. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72147. */
  72148. export class VideoRecorder {
  72149. private static readonly _defaultOptions;
  72150. /**
  72151. * Returns whether or not the VideoRecorder is available in your browser.
  72152. * @param engine Defines the Babylon Engine.
  72153. * @returns true if supported otherwise false.
  72154. */
  72155. static IsSupported(engine: Engine): boolean;
  72156. private readonly _options;
  72157. private _canvas;
  72158. private _mediaRecorder;
  72159. private _recordedChunks;
  72160. private _fileName;
  72161. private _resolve;
  72162. private _reject;
  72163. /**
  72164. * True when a recording is already in progress.
  72165. */
  72166. get isRecording(): boolean;
  72167. /**
  72168. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72169. * @param engine Defines the BabylonJS Engine you wish to record.
  72170. * @param options Defines options that can be used to customize the capture.
  72171. */
  72172. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72173. /**
  72174. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72175. */
  72176. stopRecording(): void;
  72177. /**
  72178. * Starts recording the canvas for a max duration specified in parameters.
  72179. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72180. * If null no automatic download will start and you can rely on the promise to get the data back.
  72181. * @param maxDuration Defines the maximum recording time in seconds.
  72182. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72183. * @return A promise callback at the end of the recording with the video data in Blob.
  72184. */
  72185. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72186. /**
  72187. * Releases internal resources used during the recording.
  72188. */
  72189. dispose(): void;
  72190. private _handleDataAvailable;
  72191. private _handleError;
  72192. private _handleStop;
  72193. }
  72194. }
  72195. declare module "babylonjs/Misc/screenshotTools" {
  72196. import { Camera } from "babylonjs/Cameras/camera";
  72197. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72198. import { Engine } from "babylonjs/Engines/engine";
  72199. /**
  72200. * Class containing a set of static utilities functions for screenshots
  72201. */
  72202. export class ScreenshotTools {
  72203. /**
  72204. * Captures a screenshot of the current rendering
  72205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72206. * @param engine defines the rendering engine
  72207. * @param camera defines the source camera
  72208. * @param size This parameter can be set to a single number or to an object with the
  72209. * following (optional) properties: precision, width, height. If a single number is passed,
  72210. * it will be used for both width and height. If an object is passed, the screenshot size
  72211. * will be derived from the parameters. The precision property is a multiplier allowing
  72212. * rendering at a higher or lower resolution
  72213. * @param successCallback defines the callback receives a single parameter which contains the
  72214. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72215. * src parameter of an <img> to display it
  72216. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72217. * Check your browser for supported MIME types
  72218. */
  72219. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72220. /**
  72221. * Captures a screenshot of the current rendering
  72222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72223. * @param engine defines the rendering engine
  72224. * @param camera defines the source camera
  72225. * @param size This parameter can be set to a single number or to an object with the
  72226. * following (optional) properties: precision, width, height. If a single number is passed,
  72227. * it will be used for both width and height. If an object is passed, the screenshot size
  72228. * will be derived from the parameters. The precision property is a multiplier allowing
  72229. * rendering at a higher or lower resolution
  72230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72231. * Check your browser for supported MIME types
  72232. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72233. * to the src parameter of an <img> to display it
  72234. */
  72235. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72236. /**
  72237. * Generates an image screenshot from the specified camera.
  72238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72239. * @param engine The engine to use for rendering
  72240. * @param camera The camera to use for rendering
  72241. * @param size This parameter can be set to a single number or to an object with the
  72242. * following (optional) properties: precision, width, height. If a single number is passed,
  72243. * it will be used for both width and height. If an object is passed, the screenshot size
  72244. * will be derived from the parameters. The precision property is a multiplier allowing
  72245. * rendering at a higher or lower resolution
  72246. * @param successCallback The callback receives a single parameter which contains the
  72247. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72248. * src parameter of an <img> to display it
  72249. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72250. * Check your browser for supported MIME types
  72251. * @param samples Texture samples (default: 1)
  72252. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72253. * @param fileName A name for for the downloaded file.
  72254. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72255. */
  72256. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72257. /**
  72258. * Generates an image screenshot from the specified camera.
  72259. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72260. * @param engine The engine to use for rendering
  72261. * @param camera The camera to use for rendering
  72262. * @param size This parameter can be set to a single number or to an object with the
  72263. * following (optional) properties: precision, width, height. If a single number is passed,
  72264. * it will be used for both width and height. If an object is passed, the screenshot size
  72265. * will be derived from the parameters. The precision property is a multiplier allowing
  72266. * rendering at a higher or lower resolution
  72267. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72268. * Check your browser for supported MIME types
  72269. * @param samples Texture samples (default: 1)
  72270. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72271. * @param fileName A name for for the downloaded file.
  72272. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72273. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72274. * to the src parameter of an <img> to display it
  72275. */
  72276. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72277. /**
  72278. * Gets height and width for screenshot size
  72279. * @private
  72280. */
  72281. private static _getScreenshotSize;
  72282. }
  72283. }
  72284. declare module "babylonjs/Misc/dataReader" {
  72285. /**
  72286. * Interface for a data buffer
  72287. */
  72288. export interface IDataBuffer {
  72289. /**
  72290. * Reads bytes from the data buffer.
  72291. * @param byteOffset The byte offset to read
  72292. * @param byteLength The byte length to read
  72293. * @returns A promise that resolves when the bytes are read
  72294. */
  72295. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72296. /**
  72297. * The byte length of the buffer.
  72298. */
  72299. readonly byteLength: number;
  72300. }
  72301. /**
  72302. * Utility class for reading from a data buffer
  72303. */
  72304. export class DataReader {
  72305. /**
  72306. * The data buffer associated with this data reader.
  72307. */
  72308. readonly buffer: IDataBuffer;
  72309. /**
  72310. * The current byte offset from the beginning of the data buffer.
  72311. */
  72312. byteOffset: number;
  72313. private _dataView;
  72314. private _dataByteOffset;
  72315. /**
  72316. * Constructor
  72317. * @param buffer The buffer to read
  72318. */
  72319. constructor(buffer: IDataBuffer);
  72320. /**
  72321. * Loads the given byte length.
  72322. * @param byteLength The byte length to load
  72323. * @returns A promise that resolves when the load is complete
  72324. */
  72325. loadAsync(byteLength: number): Promise<void>;
  72326. /**
  72327. * Read a unsigned 32-bit integer from the currently loaded data range.
  72328. * @returns The 32-bit integer read
  72329. */
  72330. readUint32(): number;
  72331. /**
  72332. * Read a byte array from the currently loaded data range.
  72333. * @param byteLength The byte length to read
  72334. * @returns The byte array read
  72335. */
  72336. readUint8Array(byteLength: number): Uint8Array;
  72337. /**
  72338. * Read a string from the currently loaded data range.
  72339. * @param byteLength The byte length to read
  72340. * @returns The string read
  72341. */
  72342. readString(byteLength: number): string;
  72343. /**
  72344. * Skips the given byte length the currently loaded data range.
  72345. * @param byteLength The byte length to skip
  72346. */
  72347. skipBytes(byteLength: number): void;
  72348. }
  72349. }
  72350. declare module "babylonjs/Misc/index" {
  72351. export * from "babylonjs/Misc/andOrNotEvaluator";
  72352. export * from "babylonjs/Misc/assetsManager";
  72353. export * from "babylonjs/Misc/basis";
  72354. export * from "babylonjs/Misc/dds";
  72355. export * from "babylonjs/Misc/decorators";
  72356. export * from "babylonjs/Misc/deferred";
  72357. export * from "babylonjs/Misc/environmentTextureTools";
  72358. export * from "babylonjs/Misc/meshExploder";
  72359. export * from "babylonjs/Misc/filesInput";
  72360. export * from "babylonjs/Misc/HighDynamicRange/index";
  72361. export * from "babylonjs/Misc/khronosTextureContainer";
  72362. export * from "babylonjs/Misc/observable";
  72363. export * from "babylonjs/Misc/performanceMonitor";
  72364. export * from "babylonjs/Misc/promise";
  72365. export * from "babylonjs/Misc/sceneOptimizer";
  72366. export * from "babylonjs/Misc/sceneSerializer";
  72367. export * from "babylonjs/Misc/smartArray";
  72368. export * from "babylonjs/Misc/stringDictionary";
  72369. export * from "babylonjs/Misc/tags";
  72370. export * from "babylonjs/Misc/textureTools";
  72371. export * from "babylonjs/Misc/tga";
  72372. export * from "babylonjs/Misc/tools";
  72373. export * from "babylonjs/Misc/videoRecorder";
  72374. export * from "babylonjs/Misc/virtualJoystick";
  72375. export * from "babylonjs/Misc/workerPool";
  72376. export * from "babylonjs/Misc/logger";
  72377. export * from "babylonjs/Misc/typeStore";
  72378. export * from "babylonjs/Misc/filesInputStore";
  72379. export * from "babylonjs/Misc/deepCopier";
  72380. export * from "babylonjs/Misc/pivotTools";
  72381. export * from "babylonjs/Misc/precisionDate";
  72382. export * from "babylonjs/Misc/screenshotTools";
  72383. export * from "babylonjs/Misc/typeStore";
  72384. export * from "babylonjs/Misc/webRequest";
  72385. export * from "babylonjs/Misc/iInspectable";
  72386. export * from "babylonjs/Misc/brdfTextureTools";
  72387. export * from "babylonjs/Misc/rgbdTextureTools";
  72388. export * from "babylonjs/Misc/gradients";
  72389. export * from "babylonjs/Misc/perfCounter";
  72390. export * from "babylonjs/Misc/fileRequest";
  72391. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72392. export * from "babylonjs/Misc/retryStrategy";
  72393. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72394. export * from "babylonjs/Misc/canvasGenerator";
  72395. export * from "babylonjs/Misc/fileTools";
  72396. export * from "babylonjs/Misc/stringTools";
  72397. export * from "babylonjs/Misc/dataReader";
  72398. export * from "babylonjs/Misc/minMaxReducer";
  72399. export * from "babylonjs/Misc/depthReducer";
  72400. }
  72401. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72402. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72403. import { Observable } from "babylonjs/Misc/observable";
  72404. import { Matrix } from "babylonjs/Maths/math.vector";
  72405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72406. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72407. /**
  72408. * Options used for hit testing
  72409. */
  72410. export interface IWebXRHitTestOptions {
  72411. /**
  72412. * Only test when user interacted with the scene. Default - hit test every frame
  72413. */
  72414. testOnPointerDownOnly?: boolean;
  72415. /**
  72416. * The node to use to transform the local results to world coordinates
  72417. */
  72418. worldParentNode?: TransformNode;
  72419. }
  72420. /**
  72421. * Interface defining the babylon result of raycasting/hit-test
  72422. */
  72423. export interface IWebXRHitResult {
  72424. /**
  72425. * The native hit test result
  72426. */
  72427. xrHitResult: XRHitResult;
  72428. /**
  72429. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72430. */
  72431. transformationMatrix: Matrix;
  72432. }
  72433. /**
  72434. * The currently-working hit-test module.
  72435. * Hit test (or raycasting) is used to interact with the real world.
  72436. * For further information read here - https://github.com/immersive-web/hit-test
  72437. */
  72438. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72439. /**
  72440. * options to use when constructing this feature
  72441. */
  72442. readonly options: IWebXRHitTestOptions;
  72443. /**
  72444. * The module's name
  72445. */
  72446. static readonly Name: string;
  72447. /**
  72448. * The (Babylon) version of this module.
  72449. * This is an integer representing the implementation version.
  72450. * This number does not correspond to the webxr specs version
  72451. */
  72452. static readonly Version: number;
  72453. /**
  72454. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72455. * @param event the (select) event to use to select with
  72456. * @param referenceSpace the reference space to use for this hit test
  72457. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72458. */
  72459. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72460. /**
  72461. * execute a hit test with an XR Ray
  72462. *
  72463. * @param xrSession a native xrSession that will execute this hit test
  72464. * @param xrRay the ray (position and direction) to use for raycasting
  72465. * @param referenceSpace native XR reference space to use for the hit-test
  72466. * @param filter filter function that will filter the results
  72467. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72468. */
  72469. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72470. /**
  72471. * Triggered when new babylon (transformed) hit test results are available
  72472. */
  72473. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72474. private _onSelectEnabled;
  72475. /**
  72476. * Creates a new instance of the (legacy version) hit test feature
  72477. * @param _xrSessionManager an instance of WebXRSessionManager
  72478. * @param options options to use when constructing this feature
  72479. */
  72480. constructor(_xrSessionManager: WebXRSessionManager,
  72481. /**
  72482. * options to use when constructing this feature
  72483. */
  72484. options?: IWebXRHitTestOptions);
  72485. /**
  72486. * Populated with the last native XR Hit Results
  72487. */
  72488. lastNativeXRHitResults: XRHitResult[];
  72489. /**
  72490. * attach this feature
  72491. * Will usually be called by the features manager
  72492. *
  72493. * @returns true if successful.
  72494. */
  72495. attach(): boolean;
  72496. /**
  72497. * detach this feature.
  72498. * Will usually be called by the features manager
  72499. *
  72500. * @returns true if successful.
  72501. */
  72502. detach(): boolean;
  72503. private _onHitTestResults;
  72504. private _origin;
  72505. private _direction;
  72506. private _mat;
  72507. protected _onXRFrame(frame: XRFrame): void;
  72508. private _onSelect;
  72509. /**
  72510. * Dispose this feature and all of the resources attached
  72511. */
  72512. dispose(): void;
  72513. }
  72514. }
  72515. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72516. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72517. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72518. import { Observable } from "babylonjs/Misc/observable";
  72519. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72520. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72521. /**
  72522. * Options used in the plane detector module
  72523. */
  72524. export interface IWebXRPlaneDetectorOptions {
  72525. /**
  72526. * The node to use to transform the local results to world coordinates
  72527. */
  72528. worldParentNode?: TransformNode;
  72529. }
  72530. /**
  72531. * A babylon interface for a webxr plane.
  72532. * A Plane is actually a polygon, built from N points in space
  72533. *
  72534. * Supported in chrome 79, not supported in canary 81 ATM
  72535. */
  72536. export interface IWebXRPlane {
  72537. /**
  72538. * a babylon-assigned ID for this polygon
  72539. */
  72540. id: number;
  72541. /**
  72542. * the native xr-plane object
  72543. */
  72544. xrPlane: XRPlane;
  72545. /**
  72546. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72547. */
  72548. polygonDefinition: Array<Vector3>;
  72549. /**
  72550. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72551. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72552. */
  72553. transformationMatrix: Matrix;
  72554. }
  72555. /**
  72556. * The plane detector is used to detect planes in the real world when in AR
  72557. * For more information see https://github.com/immersive-web/real-world-geometry/
  72558. */
  72559. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72560. private _options;
  72561. /**
  72562. * The module's name
  72563. */
  72564. static readonly Name: string;
  72565. /**
  72566. * The (Babylon) version of this module.
  72567. * This is an integer representing the implementation version.
  72568. * This number does not correspond to the webxr specs version
  72569. */
  72570. static readonly Version: number;
  72571. /**
  72572. * Observers registered here will be executed when a new plane was added to the session
  72573. */
  72574. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72575. /**
  72576. * Observers registered here will be executed when a plane is no longer detected in the session
  72577. */
  72578. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72579. /**
  72580. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72581. * This can execute N times every frame
  72582. */
  72583. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72584. private _enabled;
  72585. private _detectedPlanes;
  72586. private _lastFrameDetected;
  72587. /**
  72588. * construct a new Plane Detector
  72589. * @param _xrSessionManager an instance of xr Session manager
  72590. * @param _options configuration to use when constructing this feature
  72591. */
  72592. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72593. private _init;
  72594. protected _onXRFrame(frame: XRFrame): void;
  72595. /**
  72596. * Dispose this feature and all of the resources attached
  72597. */
  72598. dispose(): void;
  72599. private _updatePlaneWithXRPlane;
  72600. /**
  72601. * avoiding using Array.find for global support.
  72602. * @param xrPlane the plane to find in the array
  72603. */
  72604. private findIndexInPlaneArray;
  72605. }
  72606. }
  72607. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72608. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72609. import { Observable } from "babylonjs/Misc/observable";
  72610. import { Matrix } from "babylonjs/Maths/math.vector";
  72611. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72612. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72613. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72614. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72615. /**
  72616. * Configuration options of the anchor system
  72617. */
  72618. export interface IWebXRAnchorSystemOptions {
  72619. /**
  72620. * a node that will be used to convert local to world coordinates
  72621. */
  72622. worldParentNode?: TransformNode;
  72623. /**
  72624. * should the anchor system use plane detection.
  72625. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72626. */
  72627. usePlaneDetection?: boolean;
  72628. /**
  72629. * Should a new anchor be added every time a select event is triggered
  72630. */
  72631. addAnchorOnSelect?: boolean;
  72632. }
  72633. /**
  72634. * A babylon container for an XR Anchor
  72635. */
  72636. export interface IWebXRAnchor {
  72637. /**
  72638. * A babylon-assigned ID for this anchor
  72639. */
  72640. id: number;
  72641. /**
  72642. * The native anchor object
  72643. */
  72644. xrAnchor: XRAnchor;
  72645. /**
  72646. * Transformation matrix to apply to an object attached to this anchor
  72647. */
  72648. transformationMatrix: Matrix;
  72649. }
  72650. /**
  72651. * An implementation of the anchor system of WebXR.
  72652. * Note that the current documented implementation is not available in any browser. Future implementations
  72653. * will use the frame to create an anchor and not the session or a detected plane
  72654. * For further information see https://github.com/immersive-web/anchors/
  72655. */
  72656. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72657. private _options;
  72658. /**
  72659. * The module's name
  72660. */
  72661. static readonly Name: string;
  72662. /**
  72663. * The (Babylon) version of this module.
  72664. * This is an integer representing the implementation version.
  72665. * This number does not correspond to the webxr specs version
  72666. */
  72667. static readonly Version: number;
  72668. /**
  72669. * Observers registered here will be executed when a new anchor was added to the session
  72670. */
  72671. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72672. /**
  72673. * Observers registered here will be executed when an existing anchor updates
  72674. * This can execute N times every frame
  72675. */
  72676. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72677. /**
  72678. * Observers registered here will be executed when an anchor was removed from the session
  72679. */
  72680. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72681. private _planeDetector;
  72682. private _hitTestModule;
  72683. private _enabled;
  72684. private _trackedAnchors;
  72685. private _lastFrameDetected;
  72686. /**
  72687. * constructs a new anchor system
  72688. * @param _xrSessionManager an instance of WebXRSessionManager
  72689. * @param _options configuration object for this feature
  72690. */
  72691. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72692. /**
  72693. * set the plane detector to use in order to create anchors from frames
  72694. * @param planeDetector the plane-detector module to use
  72695. * @param enable enable plane-anchors. default is true
  72696. */
  72697. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72698. /**
  72699. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72700. * @param hitTestModule the hit-test module to use.
  72701. */
  72702. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72703. /**
  72704. * attach this feature
  72705. * Will usually be called by the features manager
  72706. *
  72707. * @returns true if successful.
  72708. */
  72709. attach(): boolean;
  72710. /**
  72711. * detach this feature.
  72712. * Will usually be called by the features manager
  72713. *
  72714. * @returns true if successful.
  72715. */
  72716. detach(): boolean;
  72717. /**
  72718. * Dispose this feature and all of the resources attached
  72719. */
  72720. dispose(): void;
  72721. protected _onXRFrame(frame: XRFrame): void;
  72722. private _onSelect;
  72723. /**
  72724. * Add anchor at a specific XR point.
  72725. *
  72726. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72727. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72728. * @returns a promise the fulfills when the anchor was created
  72729. */
  72730. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72731. private _updateAnchorWithXRFrame;
  72732. /**
  72733. * avoiding using Array.find for global support.
  72734. * @param xrAnchor the plane to find in the array
  72735. */
  72736. private _findIndexInAnchorArray;
  72737. }
  72738. }
  72739. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72740. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72742. import { Observable } from "babylonjs/Misc/observable";
  72743. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72744. /**
  72745. * Options interface for the background remover plugin
  72746. */
  72747. export interface IWebXRBackgroundRemoverOptions {
  72748. /**
  72749. * don't disable the environment helper
  72750. */
  72751. ignoreEnvironmentHelper?: boolean;
  72752. /**
  72753. * flags to configure the removal of the environment helper.
  72754. * If not set, the entire background will be removed. If set, flags should be set as well.
  72755. */
  72756. environmentHelperRemovalFlags?: {
  72757. /**
  72758. * Should the skybox be removed (default false)
  72759. */
  72760. skyBox?: boolean;
  72761. /**
  72762. * Should the ground be removed (default false)
  72763. */
  72764. ground?: boolean;
  72765. };
  72766. /**
  72767. * Further background meshes to disable when entering AR
  72768. */
  72769. backgroundMeshes?: AbstractMesh[];
  72770. }
  72771. /**
  72772. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72773. */
  72774. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72775. /**
  72776. * read-only options to be used in this module
  72777. */
  72778. readonly options: IWebXRBackgroundRemoverOptions;
  72779. /**
  72780. * The module's name
  72781. */
  72782. static readonly Name: string;
  72783. /**
  72784. * The (Babylon) version of this module.
  72785. * This is an integer representing the implementation version.
  72786. * This number does not correspond to the webxr specs version
  72787. */
  72788. static readonly Version: number;
  72789. /**
  72790. * registered observers will be triggered when the background state changes
  72791. */
  72792. onBackgroundStateChangedObservable: Observable<boolean>;
  72793. /**
  72794. * constructs a new background remover module
  72795. * @param _xrSessionManager the session manager for this module
  72796. * @param options read-only options to be used in this module
  72797. */
  72798. constructor(_xrSessionManager: WebXRSessionManager,
  72799. /**
  72800. * read-only options to be used in this module
  72801. */
  72802. options?: IWebXRBackgroundRemoverOptions);
  72803. /**
  72804. * attach this feature
  72805. * Will usually be called by the features manager
  72806. *
  72807. * @returns true if successful.
  72808. */
  72809. attach(): boolean;
  72810. /**
  72811. * detach this feature.
  72812. * Will usually be called by the features manager
  72813. *
  72814. * @returns true if successful.
  72815. */
  72816. detach(): boolean;
  72817. private _setBackgroundState;
  72818. /**
  72819. * Dispose this feature and all of the resources attached
  72820. */
  72821. dispose(): void;
  72822. protected _onXRFrame(_xrFrame: XRFrame): void;
  72823. }
  72824. }
  72825. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72826. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72827. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72828. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72829. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72831. import { Nullable } from "babylonjs/types";
  72832. /**
  72833. * Options for the controller physics feature
  72834. */
  72835. export class IWebXRControllerPhysicsOptions {
  72836. /**
  72837. * the xr input to use with this pointer selection
  72838. */
  72839. xrInput: WebXRInput;
  72840. /**
  72841. * The physics properties of the future impostors
  72842. */
  72843. physicsProperties?: {
  72844. /**
  72845. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72846. * Note that this requires a physics engine that supports mesh impostors!
  72847. */
  72848. useControllerMesh?: boolean;
  72849. /**
  72850. * The type of impostor to create. Default is sphere
  72851. */
  72852. impostorType?: number;
  72853. /**
  72854. * the size of the impostor. Defaults to 10cm
  72855. */
  72856. impostorSize?: number | {
  72857. width: number;
  72858. height: number;
  72859. depth: number;
  72860. };
  72861. /**
  72862. * Friction definitions
  72863. */
  72864. friction?: number;
  72865. /**
  72866. * Restitution
  72867. */
  72868. restitution?: number;
  72869. };
  72870. /**
  72871. * Should the headset get its own impostor
  72872. */
  72873. enableHeadsetImpostor?: boolean;
  72874. /**
  72875. * Optional parameters for the headset impostor
  72876. */
  72877. headsetImpostorParams?: {
  72878. /**
  72879. * The type of impostor to create. Default is sphere
  72880. */
  72881. impostorType: number;
  72882. /**
  72883. * the size of the impostor. Defaults to 10cm
  72884. */
  72885. impostorSize?: number | {
  72886. width: number;
  72887. height: number;
  72888. depth: number;
  72889. };
  72890. /**
  72891. * Friction definitions
  72892. */
  72893. friction?: number;
  72894. /**
  72895. * Restitution
  72896. */
  72897. restitution?: number;
  72898. };
  72899. }
  72900. /**
  72901. * Add physics impostor to your webxr controllers,
  72902. * including naive calculation of their linear and angular velocity
  72903. */
  72904. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72905. private readonly _options;
  72906. /**
  72907. * The module's name
  72908. */
  72909. static readonly Name: string;
  72910. /**
  72911. * The (Babylon) version of this module.
  72912. * This is an integer representing the implementation version.
  72913. * This number does not correspond to the webxr specs version
  72914. */
  72915. static readonly Version: number;
  72916. private _lastTimestamp;
  72917. private _delta;
  72918. private _controllers;
  72919. private _headsetImpostor?;
  72920. private _headsetMesh?;
  72921. private _tmpVector;
  72922. private _tmpQuaternion;
  72923. /**
  72924. * Construct a new Controller Physics Feature
  72925. * @param _xrSessionManager the corresponding xr session manager
  72926. * @param _options options to create this feature with
  72927. */
  72928. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72929. /**
  72930. * Update the physics properties provided in the constructor
  72931. * @param newProperties the new properties object
  72932. */
  72933. setPhysicsProperties(newProperties: {
  72934. impostorType?: number;
  72935. impostorSize?: number | {
  72936. width: number;
  72937. height: number;
  72938. depth: number;
  72939. };
  72940. friction?: number;
  72941. restitution?: number;
  72942. }): void;
  72943. /**
  72944. * Get the physics impostor of a specific controller.
  72945. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72946. * @param controller the controller or the controller id of which to get the impostor
  72947. * @returns the impostor or null
  72948. */
  72949. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72950. /**
  72951. * Get the headset impostor, if enabled
  72952. * @returns the impostor
  72953. */
  72954. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72955. /**
  72956. * attach this feature
  72957. * Will usually be called by the features manager
  72958. *
  72959. * @returns true if successful.
  72960. */
  72961. attach(): boolean;
  72962. /**
  72963. * detach this feature.
  72964. * Will usually be called by the features manager
  72965. *
  72966. * @returns true if successful.
  72967. */
  72968. detach(): boolean;
  72969. /**
  72970. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72971. * @param xrController the controller to add
  72972. */
  72973. addController(xrController: WebXRInputSource): void;
  72974. private _debugMode;
  72975. /**
  72976. * @hidden
  72977. * enable debugging - will show console outputs and the impostor mesh
  72978. */
  72979. _enablePhysicsDebug(): void;
  72980. private _attachController;
  72981. private _detachController;
  72982. protected _onXRFrame(_xrFrame: any): void;
  72983. }
  72984. }
  72985. declare module "babylonjs/XR/features/index" {
  72986. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72987. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72988. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72989. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72990. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72991. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72992. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72993. }
  72994. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72995. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72997. import { Scene } from "babylonjs/scene";
  72998. /**
  72999. * The motion controller class for all microsoft mixed reality controllers
  73000. */
  73001. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73002. /**
  73003. * The base url used to load the left and right controller models
  73004. */
  73005. static MODEL_BASE_URL: string;
  73006. /**
  73007. * The name of the left controller model file
  73008. */
  73009. static MODEL_LEFT_FILENAME: string;
  73010. /**
  73011. * The name of the right controller model file
  73012. */
  73013. static MODEL_RIGHT_FILENAME: string;
  73014. profileId: string;
  73015. protected readonly _mapping: {
  73016. defaultButton: {
  73017. "valueNodeName": string;
  73018. "unpressedNodeName": string;
  73019. "pressedNodeName": string;
  73020. };
  73021. defaultAxis: {
  73022. "valueNodeName": string;
  73023. "minNodeName": string;
  73024. "maxNodeName": string;
  73025. };
  73026. buttons: {
  73027. "xr-standard-trigger": {
  73028. "rootNodeName": string;
  73029. "componentProperty": string;
  73030. "states": string[];
  73031. };
  73032. "xr-standard-squeeze": {
  73033. "rootNodeName": string;
  73034. "componentProperty": string;
  73035. "states": string[];
  73036. };
  73037. "xr-standard-touchpad": {
  73038. "rootNodeName": string;
  73039. "labelAnchorNodeName": string;
  73040. "touchPointNodeName": string;
  73041. };
  73042. "xr-standard-thumbstick": {
  73043. "rootNodeName": string;
  73044. "componentProperty": string;
  73045. "states": string[];
  73046. };
  73047. };
  73048. axes: {
  73049. "xr-standard-touchpad": {
  73050. "x-axis": {
  73051. "rootNodeName": string;
  73052. };
  73053. "y-axis": {
  73054. "rootNodeName": string;
  73055. };
  73056. };
  73057. "xr-standard-thumbstick": {
  73058. "x-axis": {
  73059. "rootNodeName": string;
  73060. };
  73061. "y-axis": {
  73062. "rootNodeName": string;
  73063. };
  73064. };
  73065. };
  73066. };
  73067. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73068. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73069. protected _getFilenameAndPath(): {
  73070. filename: string;
  73071. path: string;
  73072. };
  73073. protected _updateModel(): void;
  73074. protected _getModelLoadingConstraints(): boolean;
  73075. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73076. }
  73077. }
  73078. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73079. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73081. import { Scene } from "babylonjs/scene";
  73082. /**
  73083. * The motion controller class for oculus touch (quest, rift).
  73084. * This class supports legacy mapping as well the standard xr mapping
  73085. */
  73086. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73087. private _forceLegacyControllers;
  73088. /**
  73089. * The base url used to load the left and right controller models
  73090. */
  73091. static MODEL_BASE_URL: string;
  73092. /**
  73093. * The name of the left controller model file
  73094. */
  73095. static MODEL_LEFT_FILENAME: string;
  73096. /**
  73097. * The name of the right controller model file
  73098. */
  73099. static MODEL_RIGHT_FILENAME: string;
  73100. /**
  73101. * Base Url for the Quest controller model.
  73102. */
  73103. static QUEST_MODEL_BASE_URL: string;
  73104. profileId: string;
  73105. private _modelRootNode;
  73106. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73107. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73108. protected _getFilenameAndPath(): {
  73109. filename: string;
  73110. path: string;
  73111. };
  73112. /**
  73113. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73114. * between the touch and touch 2.
  73115. */
  73116. private _isQuest;
  73117. protected _updateModel(): void;
  73118. protected _getModelLoadingConstraints(): boolean;
  73119. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73120. }
  73121. }
  73122. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73123. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73124. import { Scene } from "babylonjs/scene";
  73125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73126. /**
  73127. * The motion controller class for the standard HTC-Vive controllers
  73128. */
  73129. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73130. /**
  73131. * The base url used to load the left and right controller models
  73132. */
  73133. static MODEL_BASE_URL: string;
  73134. /**
  73135. * File name for the controller model.
  73136. */
  73137. static MODEL_FILENAME: string;
  73138. profileId: string;
  73139. private _modelRootNode;
  73140. /**
  73141. * Create a new Vive motion controller object
  73142. * @param scene the scene to use to create this controller
  73143. * @param gamepadObject the corresponding gamepad object
  73144. * @param handness the handness of the controller
  73145. */
  73146. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73147. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73148. protected _getFilenameAndPath(): {
  73149. filename: string;
  73150. path: string;
  73151. };
  73152. protected _updateModel(): void;
  73153. protected _getModelLoadingConstraints(): boolean;
  73154. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73155. }
  73156. }
  73157. declare module "babylonjs/XR/motionController/index" {
  73158. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73159. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73160. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73161. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73162. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73163. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73164. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73165. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73166. }
  73167. declare module "babylonjs/XR/index" {
  73168. export * from "babylonjs/XR/webXRCamera";
  73169. export * from "babylonjs/XR/webXREnterExitUI";
  73170. export * from "babylonjs/XR/webXRExperienceHelper";
  73171. export * from "babylonjs/XR/webXRInput";
  73172. export * from "babylonjs/XR/webXRInputSource";
  73173. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73174. export * from "babylonjs/XR/webXRTypes";
  73175. export * from "babylonjs/XR/webXRSessionManager";
  73176. export * from "babylonjs/XR/webXRDefaultExperience";
  73177. export * from "babylonjs/XR/webXRFeaturesManager";
  73178. export * from "babylonjs/XR/features/index";
  73179. export * from "babylonjs/XR/motionController/index";
  73180. }
  73181. declare module "babylonjs/index" {
  73182. export * from "babylonjs/abstractScene";
  73183. export * from "babylonjs/Actions/index";
  73184. export * from "babylonjs/Animations/index";
  73185. export * from "babylonjs/assetContainer";
  73186. export * from "babylonjs/Audio/index";
  73187. export * from "babylonjs/Behaviors/index";
  73188. export * from "babylonjs/Bones/index";
  73189. export * from "babylonjs/Cameras/index";
  73190. export * from "babylonjs/Collisions/index";
  73191. export * from "babylonjs/Culling/index";
  73192. export * from "babylonjs/Debug/index";
  73193. export * from "babylonjs/Engines/index";
  73194. export * from "babylonjs/Events/index";
  73195. export * from "babylonjs/Gamepads/index";
  73196. export * from "babylonjs/Gizmos/index";
  73197. export * from "babylonjs/Helpers/index";
  73198. export * from "babylonjs/Instrumentation/index";
  73199. export * from "babylonjs/Layers/index";
  73200. export * from "babylonjs/LensFlares/index";
  73201. export * from "babylonjs/Lights/index";
  73202. export * from "babylonjs/Loading/index";
  73203. export * from "babylonjs/Materials/index";
  73204. export * from "babylonjs/Maths/index";
  73205. export * from "babylonjs/Meshes/index";
  73206. export * from "babylonjs/Morph/index";
  73207. export * from "babylonjs/Navigation/index";
  73208. export * from "babylonjs/node";
  73209. export * from "babylonjs/Offline/index";
  73210. export * from "babylonjs/Particles/index";
  73211. export * from "babylonjs/Physics/index";
  73212. export * from "babylonjs/PostProcesses/index";
  73213. export * from "babylonjs/Probes/index";
  73214. export * from "babylonjs/Rendering/index";
  73215. export * from "babylonjs/scene";
  73216. export * from "babylonjs/sceneComponent";
  73217. export * from "babylonjs/Sprites/index";
  73218. export * from "babylonjs/States/index";
  73219. export * from "babylonjs/Misc/index";
  73220. export * from "babylonjs/XR/index";
  73221. export * from "babylonjs/types";
  73222. }
  73223. declare module "babylonjs/Animations/pathCursor" {
  73224. import { Vector3 } from "babylonjs/Maths/math.vector";
  73225. import { Path2 } from "babylonjs/Maths/math.path";
  73226. /**
  73227. * A cursor which tracks a point on a path
  73228. */
  73229. export class PathCursor {
  73230. private path;
  73231. /**
  73232. * Stores path cursor callbacks for when an onchange event is triggered
  73233. */
  73234. private _onchange;
  73235. /**
  73236. * The value of the path cursor
  73237. */
  73238. value: number;
  73239. /**
  73240. * The animation array of the path cursor
  73241. */
  73242. animations: Animation[];
  73243. /**
  73244. * Initializes the path cursor
  73245. * @param path The path to track
  73246. */
  73247. constructor(path: Path2);
  73248. /**
  73249. * Gets the cursor point on the path
  73250. * @returns A point on the path cursor at the cursor location
  73251. */
  73252. getPoint(): Vector3;
  73253. /**
  73254. * Moves the cursor ahead by the step amount
  73255. * @param step The amount to move the cursor forward
  73256. * @returns This path cursor
  73257. */
  73258. moveAhead(step?: number): PathCursor;
  73259. /**
  73260. * Moves the cursor behind by the step amount
  73261. * @param step The amount to move the cursor back
  73262. * @returns This path cursor
  73263. */
  73264. moveBack(step?: number): PathCursor;
  73265. /**
  73266. * Moves the cursor by the step amount
  73267. * If the step amount is greater than one, an exception is thrown
  73268. * @param step The amount to move the cursor
  73269. * @returns This path cursor
  73270. */
  73271. move(step: number): PathCursor;
  73272. /**
  73273. * Ensures that the value is limited between zero and one
  73274. * @returns This path cursor
  73275. */
  73276. private ensureLimits;
  73277. /**
  73278. * Runs onchange callbacks on change (used by the animation engine)
  73279. * @returns This path cursor
  73280. */
  73281. private raiseOnChange;
  73282. /**
  73283. * Executes a function on change
  73284. * @param f A path cursor onchange callback
  73285. * @returns This path cursor
  73286. */
  73287. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73288. }
  73289. }
  73290. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73291. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73292. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73293. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73294. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73295. }
  73296. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73297. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73298. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73299. }
  73300. declare module "babylonjs/Engines/Processors/index" {
  73301. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73302. export * from "babylonjs/Engines/Processors/Expressions/index";
  73303. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73304. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73305. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73306. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73307. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73308. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73309. }
  73310. declare module "babylonjs/Legacy/legacy" {
  73311. import * as Babylon from "babylonjs/index";
  73312. export * from "babylonjs/index";
  73313. }
  73314. declare module "babylonjs/Shaders/blur.fragment" {
  73315. /** @hidden */
  73316. export var blurPixelShader: {
  73317. name: string;
  73318. shader: string;
  73319. };
  73320. }
  73321. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73322. /** @hidden */
  73323. export var pointCloudVertexDeclaration: {
  73324. name: string;
  73325. shader: string;
  73326. };
  73327. }
  73328. declare module "babylonjs" {
  73329. export * from "babylonjs/Legacy/legacy";
  73330. }
  73331. declare module BABYLON {
  73332. /** Alias type for value that can be null */
  73333. export type Nullable<T> = T | null;
  73334. /**
  73335. * Alias type for number that are floats
  73336. * @ignorenaming
  73337. */
  73338. export type float = number;
  73339. /**
  73340. * Alias type for number that are doubles.
  73341. * @ignorenaming
  73342. */
  73343. export type double = number;
  73344. /**
  73345. * Alias type for number that are integer
  73346. * @ignorenaming
  73347. */
  73348. export type int = number;
  73349. /** Alias type for number array or Float32Array */
  73350. export type FloatArray = number[] | Float32Array;
  73351. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73352. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73353. /**
  73354. * Alias for types that can be used by a Buffer or VertexBuffer.
  73355. */
  73356. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73357. /**
  73358. * Alias type for primitive types
  73359. * @ignorenaming
  73360. */
  73361. type Primitive = undefined | null | boolean | string | number | Function;
  73362. /**
  73363. * Type modifier to make all the properties of an object Readonly
  73364. */
  73365. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73366. /**
  73367. * Type modifier to make all the properties of an object Readonly recursively
  73368. */
  73369. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73370. /**
  73371. * Type modifier to make object properties readonly.
  73372. */
  73373. export type DeepImmutableObject<T> = {
  73374. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73375. };
  73376. /** @hidden */
  73377. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73378. }
  73379. }
  73380. declare module BABYLON {
  73381. /**
  73382. * A class serves as a medium between the observable and its observers
  73383. */
  73384. export class EventState {
  73385. /**
  73386. * Create a new EventState
  73387. * @param mask defines the mask associated with this state
  73388. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73389. * @param target defines the original target of the state
  73390. * @param currentTarget defines the current target of the state
  73391. */
  73392. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73393. /**
  73394. * Initialize the current event state
  73395. * @param mask defines the mask associated with this state
  73396. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73397. * @param target defines the original target of the state
  73398. * @param currentTarget defines the current target of the state
  73399. * @returns the current event state
  73400. */
  73401. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73402. /**
  73403. * An Observer can set this property to true to prevent subsequent observers of being notified
  73404. */
  73405. skipNextObservers: boolean;
  73406. /**
  73407. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73408. */
  73409. mask: number;
  73410. /**
  73411. * The object that originally notified the event
  73412. */
  73413. target?: any;
  73414. /**
  73415. * The current object in the bubbling phase
  73416. */
  73417. currentTarget?: any;
  73418. /**
  73419. * This will be populated with the return value of the last function that was executed.
  73420. * If it is the first function in the callback chain it will be the event data.
  73421. */
  73422. lastReturnValue?: any;
  73423. }
  73424. /**
  73425. * Represent an Observer registered to a given Observable object.
  73426. */
  73427. export class Observer<T> {
  73428. /**
  73429. * Defines the callback to call when the observer is notified
  73430. */
  73431. callback: (eventData: T, eventState: EventState) => void;
  73432. /**
  73433. * Defines the mask of the observer (used to filter notifications)
  73434. */
  73435. mask: number;
  73436. /**
  73437. * Defines the current scope used to restore the JS context
  73438. */
  73439. scope: any;
  73440. /** @hidden */
  73441. _willBeUnregistered: boolean;
  73442. /**
  73443. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73444. */
  73445. unregisterOnNextCall: boolean;
  73446. /**
  73447. * Creates a new observer
  73448. * @param callback defines the callback to call when the observer is notified
  73449. * @param mask defines the mask of the observer (used to filter notifications)
  73450. * @param scope defines the current scope used to restore the JS context
  73451. */
  73452. constructor(
  73453. /**
  73454. * Defines the callback to call when the observer is notified
  73455. */
  73456. callback: (eventData: T, eventState: EventState) => void,
  73457. /**
  73458. * Defines the mask of the observer (used to filter notifications)
  73459. */
  73460. mask: number,
  73461. /**
  73462. * Defines the current scope used to restore the JS context
  73463. */
  73464. scope?: any);
  73465. }
  73466. /**
  73467. * Represent a list of observers registered to multiple Observables object.
  73468. */
  73469. export class MultiObserver<T> {
  73470. private _observers;
  73471. private _observables;
  73472. /**
  73473. * Release associated resources
  73474. */
  73475. dispose(): void;
  73476. /**
  73477. * Raise a callback when one of the observable will notify
  73478. * @param observables defines a list of observables to watch
  73479. * @param callback defines the callback to call on notification
  73480. * @param mask defines the mask used to filter notifications
  73481. * @param scope defines the current scope used to restore the JS context
  73482. * @returns the new MultiObserver
  73483. */
  73484. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73485. }
  73486. /**
  73487. * The Observable class is a simple implementation of the Observable pattern.
  73488. *
  73489. * 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.
  73490. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73491. * 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).
  73492. * 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.
  73493. */
  73494. export class Observable<T> {
  73495. private _observers;
  73496. private _eventState;
  73497. private _onObserverAdded;
  73498. /**
  73499. * Gets the list of observers
  73500. */
  73501. get observers(): Array<Observer<T>>;
  73502. /**
  73503. * Creates a new observable
  73504. * @param onObserverAdded defines a callback to call when a new observer is added
  73505. */
  73506. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73507. /**
  73508. * Create a new Observer with the specified callback
  73509. * @param callback the callback that will be executed for that Observer
  73510. * @param mask the mask used to filter observers
  73511. * @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.
  73512. * @param scope optional scope for the callback to be called from
  73513. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73514. * @returns the new observer created for the callback
  73515. */
  73516. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73517. /**
  73518. * Create a new Observer with the specified callback and unregisters after the next notification
  73519. * @param callback the callback that will be executed for that Observer
  73520. * @returns the new observer created for the callback
  73521. */
  73522. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73523. /**
  73524. * Remove an Observer from the Observable object
  73525. * @param observer the instance of the Observer to remove
  73526. * @returns false if it doesn't belong to this Observable
  73527. */
  73528. remove(observer: Nullable<Observer<T>>): boolean;
  73529. /**
  73530. * Remove a callback from the Observable object
  73531. * @param callback the callback to remove
  73532. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73533. * @returns false if it doesn't belong to this Observable
  73534. */
  73535. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73536. private _deferUnregister;
  73537. private _remove;
  73538. /**
  73539. * Moves the observable to the top of the observer list making it get called first when notified
  73540. * @param observer the observer to move
  73541. */
  73542. makeObserverTopPriority(observer: Observer<T>): void;
  73543. /**
  73544. * Moves the observable to the bottom of the observer list making it get called last when notified
  73545. * @param observer the observer to move
  73546. */
  73547. makeObserverBottomPriority(observer: Observer<T>): void;
  73548. /**
  73549. * Notify all Observers by calling their respective callback with the given data
  73550. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73551. * @param eventData defines the data to send to all observers
  73552. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73553. * @param target defines the original target of the state
  73554. * @param currentTarget defines the current target of the state
  73555. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73556. */
  73557. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73558. /**
  73559. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73560. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73561. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73562. * and it is crucial that all callbacks will be executed.
  73563. * The order of the callbacks is kept, callbacks are not executed parallel.
  73564. *
  73565. * @param eventData The data to be sent to each callback
  73566. * @param mask is used to filter observers defaults to -1
  73567. * @param target defines the callback target (see EventState)
  73568. * @param currentTarget defines he current object in the bubbling phase
  73569. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73570. */
  73571. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73572. /**
  73573. * Notify a specific observer
  73574. * @param observer defines the observer to notify
  73575. * @param eventData defines the data to be sent to each callback
  73576. * @param mask is used to filter observers defaults to -1
  73577. */
  73578. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73579. /**
  73580. * Gets a boolean indicating if the observable has at least one observer
  73581. * @returns true is the Observable has at least one Observer registered
  73582. */
  73583. hasObservers(): boolean;
  73584. /**
  73585. * Clear the list of observers
  73586. */
  73587. clear(): void;
  73588. /**
  73589. * Clone the current observable
  73590. * @returns a new observable
  73591. */
  73592. clone(): Observable<T>;
  73593. /**
  73594. * Does this observable handles observer registered with a given mask
  73595. * @param mask defines the mask to be tested
  73596. * @return whether or not one observer registered with the given mask is handeled
  73597. **/
  73598. hasSpecificMask(mask?: number): boolean;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73604. * Babylon.js
  73605. */
  73606. export class DomManagement {
  73607. /**
  73608. * Checks if the window object exists
  73609. * @returns true if the window object exists
  73610. */
  73611. static IsWindowObjectExist(): boolean;
  73612. /**
  73613. * Checks if the navigator object exists
  73614. * @returns true if the navigator object exists
  73615. */
  73616. static IsNavigatorAvailable(): boolean;
  73617. /**
  73618. * Extracts text content from a DOM element hierarchy
  73619. * @param element defines the root element
  73620. * @returns a string
  73621. */
  73622. static GetDOMTextContent(element: HTMLElement): string;
  73623. }
  73624. }
  73625. declare module BABYLON {
  73626. /**
  73627. * Logger used througouht the application to allow configuration of
  73628. * the log level required for the messages.
  73629. */
  73630. export class Logger {
  73631. /**
  73632. * No log
  73633. */
  73634. static readonly NoneLogLevel: number;
  73635. /**
  73636. * Only message logs
  73637. */
  73638. static readonly MessageLogLevel: number;
  73639. /**
  73640. * Only warning logs
  73641. */
  73642. static readonly WarningLogLevel: number;
  73643. /**
  73644. * Only error logs
  73645. */
  73646. static readonly ErrorLogLevel: number;
  73647. /**
  73648. * All logs
  73649. */
  73650. static readonly AllLogLevel: number;
  73651. private static _LogCache;
  73652. /**
  73653. * Gets a value indicating the number of loading errors
  73654. * @ignorenaming
  73655. */
  73656. static errorsCount: number;
  73657. /**
  73658. * Callback called when a new log is added
  73659. */
  73660. static OnNewCacheEntry: (entry: string) => void;
  73661. private static _AddLogEntry;
  73662. private static _FormatMessage;
  73663. private static _LogDisabled;
  73664. private static _LogEnabled;
  73665. private static _WarnDisabled;
  73666. private static _WarnEnabled;
  73667. private static _ErrorDisabled;
  73668. private static _ErrorEnabled;
  73669. /**
  73670. * Log a message to the console
  73671. */
  73672. static Log: (message: string) => void;
  73673. /**
  73674. * Write a warning message to the console
  73675. */
  73676. static Warn: (message: string) => void;
  73677. /**
  73678. * Write an error message to the console
  73679. */
  73680. static Error: (message: string) => void;
  73681. /**
  73682. * Gets current log cache (list of logs)
  73683. */
  73684. static get LogCache(): string;
  73685. /**
  73686. * Clears the log cache
  73687. */
  73688. static ClearLogCache(): void;
  73689. /**
  73690. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73691. */
  73692. static set LogLevels(level: number);
  73693. }
  73694. }
  73695. declare module BABYLON {
  73696. /** @hidden */
  73697. export class _TypeStore {
  73698. /** @hidden */
  73699. static RegisteredTypes: {
  73700. [key: string]: Object;
  73701. };
  73702. /** @hidden */
  73703. static GetClass(fqdn: string): any;
  73704. }
  73705. }
  73706. declare module BABYLON {
  73707. /**
  73708. * Helper to manipulate strings
  73709. */
  73710. export class StringTools {
  73711. /**
  73712. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73713. * @param str Source string
  73714. * @param suffix Suffix to search for in the source string
  73715. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73716. */
  73717. static EndsWith(str: string, suffix: string): boolean;
  73718. /**
  73719. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73720. * @param str Source string
  73721. * @param suffix Suffix to search for in the source string
  73722. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73723. */
  73724. static StartsWith(str: string, suffix: string): boolean;
  73725. /**
  73726. * Decodes a buffer into a string
  73727. * @param buffer The buffer to decode
  73728. * @returns The decoded string
  73729. */
  73730. static Decode(buffer: Uint8Array | Uint16Array): string;
  73731. /**
  73732. * Encode a buffer to a base64 string
  73733. * @param buffer defines the buffer to encode
  73734. * @returns the encoded string
  73735. */
  73736. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73737. }
  73738. }
  73739. declare module BABYLON {
  73740. /**
  73741. * Class containing a set of static utilities functions for deep copy.
  73742. */
  73743. export class DeepCopier {
  73744. /**
  73745. * Tries to copy an object by duplicating every property
  73746. * @param source defines the source object
  73747. * @param destination defines the target object
  73748. * @param doNotCopyList defines a list of properties to avoid
  73749. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73750. */
  73751. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73752. }
  73753. }
  73754. declare module BABYLON {
  73755. /**
  73756. * Class containing a set of static utilities functions for precision date
  73757. */
  73758. export class PrecisionDate {
  73759. /**
  73760. * Gets either window.performance.now() if supported or Date.now() else
  73761. */
  73762. static get Now(): number;
  73763. }
  73764. }
  73765. declare module BABYLON {
  73766. /** @hidden */
  73767. export class _DevTools {
  73768. static WarnImport(name: string): string;
  73769. }
  73770. }
  73771. declare module BABYLON {
  73772. /**
  73773. * Interface used to define the mechanism to get data from the network
  73774. */
  73775. export interface IWebRequest {
  73776. /**
  73777. * Returns client's response url
  73778. */
  73779. responseURL: string;
  73780. /**
  73781. * Returns client's status
  73782. */
  73783. status: number;
  73784. /**
  73785. * Returns client's status as a text
  73786. */
  73787. statusText: string;
  73788. }
  73789. }
  73790. declare module BABYLON {
  73791. /**
  73792. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73793. */
  73794. export class WebRequest implements IWebRequest {
  73795. private _xhr;
  73796. /**
  73797. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73798. * i.e. when loading files, where the server/service expects an Authorization header
  73799. */
  73800. static CustomRequestHeaders: {
  73801. [key: string]: string;
  73802. };
  73803. /**
  73804. * Add callback functions in this array to update all the requests before they get sent to the network
  73805. */
  73806. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73807. private _injectCustomRequestHeaders;
  73808. /**
  73809. * Gets or sets a function to be called when loading progress changes
  73810. */
  73811. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73812. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73813. /**
  73814. * Returns client's state
  73815. */
  73816. get readyState(): number;
  73817. /**
  73818. * Returns client's status
  73819. */
  73820. get status(): number;
  73821. /**
  73822. * Returns client's status as a text
  73823. */
  73824. get statusText(): string;
  73825. /**
  73826. * Returns client's response
  73827. */
  73828. get response(): any;
  73829. /**
  73830. * Returns client's response url
  73831. */
  73832. get responseURL(): string;
  73833. /**
  73834. * Returns client's response as text
  73835. */
  73836. get responseText(): string;
  73837. /**
  73838. * Gets or sets the expected response type
  73839. */
  73840. get responseType(): XMLHttpRequestResponseType;
  73841. set responseType(value: XMLHttpRequestResponseType);
  73842. /** @hidden */
  73843. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73844. /** @hidden */
  73845. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73846. /**
  73847. * Cancels any network activity
  73848. */
  73849. abort(): void;
  73850. /**
  73851. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73852. * @param body defines an optional request body
  73853. */
  73854. send(body?: Document | BodyInit | null): void;
  73855. /**
  73856. * Sets the request method, request URL
  73857. * @param method defines the method to use (GET, POST, etc..)
  73858. * @param url defines the url to connect with
  73859. */
  73860. open(method: string, url: string): void;
  73861. /**
  73862. * Sets the value of a request header.
  73863. * @param name The name of the header whose value is to be set
  73864. * @param value The value to set as the body of the header
  73865. */
  73866. setRequestHeader(name: string, value: string): void;
  73867. /**
  73868. * Get the string containing the text of a particular header's value.
  73869. * @param name The name of the header
  73870. * @returns The string containing the text of the given header name
  73871. */
  73872. getResponseHeader(name: string): Nullable<string>;
  73873. }
  73874. }
  73875. declare module BABYLON {
  73876. /**
  73877. * File request interface
  73878. */
  73879. export interface IFileRequest {
  73880. /**
  73881. * Raised when the request is complete (success or error).
  73882. */
  73883. onCompleteObservable: Observable<IFileRequest>;
  73884. /**
  73885. * Aborts the request for a file.
  73886. */
  73887. abort: () => void;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * Define options used to create a render target texture
  73893. */
  73894. export class RenderTargetCreationOptions {
  73895. /**
  73896. * Specifies is mipmaps must be generated
  73897. */
  73898. generateMipMaps?: boolean;
  73899. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73900. generateDepthBuffer?: boolean;
  73901. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73902. generateStencilBuffer?: boolean;
  73903. /** Defines texture type (int by default) */
  73904. type?: number;
  73905. /** Defines sampling mode (trilinear by default) */
  73906. samplingMode?: number;
  73907. /** Defines format (RGBA by default) */
  73908. format?: number;
  73909. }
  73910. }
  73911. declare module BABYLON {
  73912. /** Defines the cross module used constants to avoid circular dependncies */
  73913. export class Constants {
  73914. /** Defines that alpha blending is disabled */
  73915. static readonly ALPHA_DISABLE: number;
  73916. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73917. static readonly ALPHA_ADD: number;
  73918. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73919. static readonly ALPHA_COMBINE: number;
  73920. /** Defines that alpha blending is DEST - SRC * DEST */
  73921. static readonly ALPHA_SUBTRACT: number;
  73922. /** Defines that alpha blending is SRC * DEST */
  73923. static readonly ALPHA_MULTIPLY: number;
  73924. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73925. static readonly ALPHA_MAXIMIZED: number;
  73926. /** Defines that alpha blending is SRC + DEST */
  73927. static readonly ALPHA_ONEONE: number;
  73928. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73929. static readonly ALPHA_PREMULTIPLIED: number;
  73930. /**
  73931. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73932. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73933. */
  73934. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73935. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73936. static readonly ALPHA_INTERPOLATE: number;
  73937. /**
  73938. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73939. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73940. */
  73941. static readonly ALPHA_SCREENMODE: number;
  73942. /**
  73943. * Defines that alpha blending is SRC + DST
  73944. * Alpha will be set to SRC ALPHA + DST ALPHA
  73945. */
  73946. static readonly ALPHA_ONEONE_ONEONE: number;
  73947. /**
  73948. * Defines that alpha blending is SRC * DST ALPHA + DST
  73949. * Alpha will be set to 0
  73950. */
  73951. static readonly ALPHA_ALPHATOCOLOR: number;
  73952. /**
  73953. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73954. */
  73955. static readonly ALPHA_REVERSEONEMINUS: number;
  73956. /**
  73957. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73958. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73959. */
  73960. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73961. /**
  73962. * Defines that alpha blending is SRC + DST
  73963. * Alpha will be set to SRC ALPHA
  73964. */
  73965. static readonly ALPHA_ONEONE_ONEZERO: number;
  73966. /**
  73967. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73968. * Alpha will be set to DST ALPHA
  73969. */
  73970. static readonly ALPHA_EXCLUSION: number;
  73971. /** Defines that alpha blending equation a SUM */
  73972. static readonly ALPHA_EQUATION_ADD: number;
  73973. /** Defines that alpha blending equation a SUBSTRACTION */
  73974. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73975. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73976. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73977. /** Defines that alpha blending equation a MAX operation */
  73978. static readonly ALPHA_EQUATION_MAX: number;
  73979. /** Defines that alpha blending equation a MIN operation */
  73980. static readonly ALPHA_EQUATION_MIN: number;
  73981. /**
  73982. * Defines that alpha blending equation a DARKEN operation:
  73983. * It takes the min of the src and sums the alpha channels.
  73984. */
  73985. static readonly ALPHA_EQUATION_DARKEN: number;
  73986. /** Defines that the ressource is not delayed*/
  73987. static readonly DELAYLOADSTATE_NONE: number;
  73988. /** Defines that the ressource was successfully delay loaded */
  73989. static readonly DELAYLOADSTATE_LOADED: number;
  73990. /** Defines that the ressource is currently delay loading */
  73991. static readonly DELAYLOADSTATE_LOADING: number;
  73992. /** Defines that the ressource is delayed and has not started loading */
  73993. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73994. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73995. static readonly NEVER: number;
  73996. /** 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 */
  73997. static readonly ALWAYS: number;
  73998. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73999. static readonly LESS: number;
  74000. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74001. static readonly EQUAL: number;
  74002. /** 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 */
  74003. static readonly LEQUAL: number;
  74004. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74005. static readonly GREATER: number;
  74006. /** 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 */
  74007. static readonly GEQUAL: number;
  74008. /** 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 */
  74009. static readonly NOTEQUAL: number;
  74010. /** Passed to stencilOperation to specify that stencil value must be kept */
  74011. static readonly KEEP: number;
  74012. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74013. static readonly REPLACE: number;
  74014. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74015. static readonly INCR: number;
  74016. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74017. static readonly DECR: number;
  74018. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74019. static readonly INVERT: number;
  74020. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74021. static readonly INCR_WRAP: number;
  74022. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74023. static readonly DECR_WRAP: number;
  74024. /** Texture is not repeating outside of 0..1 UVs */
  74025. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74026. /** Texture is repeating outside of 0..1 UVs */
  74027. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74028. /** Texture is repeating and mirrored */
  74029. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74030. /** ALPHA */
  74031. static readonly TEXTUREFORMAT_ALPHA: number;
  74032. /** LUMINANCE */
  74033. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74034. /** LUMINANCE_ALPHA */
  74035. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74036. /** RGB */
  74037. static readonly TEXTUREFORMAT_RGB: number;
  74038. /** RGBA */
  74039. static readonly TEXTUREFORMAT_RGBA: number;
  74040. /** RED */
  74041. static readonly TEXTUREFORMAT_RED: number;
  74042. /** RED (2nd reference) */
  74043. static readonly TEXTUREFORMAT_R: number;
  74044. /** RG */
  74045. static readonly TEXTUREFORMAT_RG: number;
  74046. /** RED_INTEGER */
  74047. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74048. /** RED_INTEGER (2nd reference) */
  74049. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74050. /** RG_INTEGER */
  74051. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74052. /** RGB_INTEGER */
  74053. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74054. /** RGBA_INTEGER */
  74055. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74056. /** UNSIGNED_BYTE */
  74057. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74058. /** UNSIGNED_BYTE (2nd reference) */
  74059. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74060. /** FLOAT */
  74061. static readonly TEXTURETYPE_FLOAT: number;
  74062. /** HALF_FLOAT */
  74063. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74064. /** BYTE */
  74065. static readonly TEXTURETYPE_BYTE: number;
  74066. /** SHORT */
  74067. static readonly TEXTURETYPE_SHORT: number;
  74068. /** UNSIGNED_SHORT */
  74069. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74070. /** INT */
  74071. static readonly TEXTURETYPE_INT: number;
  74072. /** UNSIGNED_INT */
  74073. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74074. /** UNSIGNED_SHORT_4_4_4_4 */
  74075. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74076. /** UNSIGNED_SHORT_5_5_5_1 */
  74077. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74078. /** UNSIGNED_SHORT_5_6_5 */
  74079. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74080. /** UNSIGNED_INT_2_10_10_10_REV */
  74081. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74082. /** UNSIGNED_INT_24_8 */
  74083. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74084. /** UNSIGNED_INT_10F_11F_11F_REV */
  74085. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74086. /** UNSIGNED_INT_5_9_9_9_REV */
  74087. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74088. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74089. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74090. /** nearest is mag = nearest and min = nearest and no mip */
  74091. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74092. /** mag = nearest and min = nearest and mip = none */
  74093. static readonly TEXTURE_NEAREST_NEAREST: number;
  74094. /** Bilinear is mag = linear and min = linear and no mip */
  74095. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74096. /** mag = linear and min = linear and mip = none */
  74097. static readonly TEXTURE_LINEAR_LINEAR: number;
  74098. /** Trilinear is mag = linear and min = linear and mip = linear */
  74099. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74100. /** Trilinear is mag = linear and min = linear and mip = linear */
  74101. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74102. /** mag = nearest and min = nearest and mip = nearest */
  74103. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74104. /** mag = nearest and min = linear and mip = nearest */
  74105. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74106. /** mag = nearest and min = linear and mip = linear */
  74107. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74108. /** mag = nearest and min = linear and mip = none */
  74109. static readonly TEXTURE_NEAREST_LINEAR: number;
  74110. /** nearest is mag = nearest and min = nearest and mip = linear */
  74111. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74112. /** mag = linear and min = nearest and mip = nearest */
  74113. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74114. /** mag = linear and min = nearest and mip = linear */
  74115. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74117. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74118. /** mag = linear and min = nearest and mip = none */
  74119. static readonly TEXTURE_LINEAR_NEAREST: number;
  74120. /** Explicit coordinates mode */
  74121. static readonly TEXTURE_EXPLICIT_MODE: number;
  74122. /** Spherical coordinates mode */
  74123. static readonly TEXTURE_SPHERICAL_MODE: number;
  74124. /** Planar coordinates mode */
  74125. static readonly TEXTURE_PLANAR_MODE: number;
  74126. /** Cubic coordinates mode */
  74127. static readonly TEXTURE_CUBIC_MODE: number;
  74128. /** Projection coordinates mode */
  74129. static readonly TEXTURE_PROJECTION_MODE: number;
  74130. /** Skybox coordinates mode */
  74131. static readonly TEXTURE_SKYBOX_MODE: number;
  74132. /** Inverse Cubic coordinates mode */
  74133. static readonly TEXTURE_INVCUBIC_MODE: number;
  74134. /** Equirectangular coordinates mode */
  74135. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74136. /** Equirectangular Fixed coordinates mode */
  74137. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74138. /** Equirectangular Fixed Mirrored coordinates mode */
  74139. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74140. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74141. static readonly SCALEMODE_FLOOR: number;
  74142. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74143. static readonly SCALEMODE_NEAREST: number;
  74144. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74145. static readonly SCALEMODE_CEILING: number;
  74146. /**
  74147. * The dirty texture flag value
  74148. */
  74149. static readonly MATERIAL_TextureDirtyFlag: number;
  74150. /**
  74151. * The dirty light flag value
  74152. */
  74153. static readonly MATERIAL_LightDirtyFlag: number;
  74154. /**
  74155. * The dirty fresnel flag value
  74156. */
  74157. static readonly MATERIAL_FresnelDirtyFlag: number;
  74158. /**
  74159. * The dirty attribute flag value
  74160. */
  74161. static readonly MATERIAL_AttributesDirtyFlag: number;
  74162. /**
  74163. * The dirty misc flag value
  74164. */
  74165. static readonly MATERIAL_MiscDirtyFlag: number;
  74166. /**
  74167. * The all dirty flag value
  74168. */
  74169. static readonly MATERIAL_AllDirtyFlag: number;
  74170. /**
  74171. * Returns the triangle fill mode
  74172. */
  74173. static readonly MATERIAL_TriangleFillMode: number;
  74174. /**
  74175. * Returns the wireframe mode
  74176. */
  74177. static readonly MATERIAL_WireFrameFillMode: number;
  74178. /**
  74179. * Returns the point fill mode
  74180. */
  74181. static readonly MATERIAL_PointFillMode: number;
  74182. /**
  74183. * Returns the point list draw mode
  74184. */
  74185. static readonly MATERIAL_PointListDrawMode: number;
  74186. /**
  74187. * Returns the line list draw mode
  74188. */
  74189. static readonly MATERIAL_LineListDrawMode: number;
  74190. /**
  74191. * Returns the line loop draw mode
  74192. */
  74193. static readonly MATERIAL_LineLoopDrawMode: number;
  74194. /**
  74195. * Returns the line strip draw mode
  74196. */
  74197. static readonly MATERIAL_LineStripDrawMode: number;
  74198. /**
  74199. * Returns the triangle strip draw mode
  74200. */
  74201. static readonly MATERIAL_TriangleStripDrawMode: number;
  74202. /**
  74203. * Returns the triangle fan draw mode
  74204. */
  74205. static readonly MATERIAL_TriangleFanDrawMode: number;
  74206. /**
  74207. * Stores the clock-wise side orientation
  74208. */
  74209. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74210. /**
  74211. * Stores the counter clock-wise side orientation
  74212. */
  74213. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74214. /**
  74215. * Nothing
  74216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74217. */
  74218. static readonly ACTION_NothingTrigger: number;
  74219. /**
  74220. * On pick
  74221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74222. */
  74223. static readonly ACTION_OnPickTrigger: number;
  74224. /**
  74225. * On left pick
  74226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74227. */
  74228. static readonly ACTION_OnLeftPickTrigger: number;
  74229. /**
  74230. * On right pick
  74231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74232. */
  74233. static readonly ACTION_OnRightPickTrigger: number;
  74234. /**
  74235. * On center pick
  74236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74237. */
  74238. static readonly ACTION_OnCenterPickTrigger: number;
  74239. /**
  74240. * On pick down
  74241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74242. */
  74243. static readonly ACTION_OnPickDownTrigger: number;
  74244. /**
  74245. * On double pick
  74246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74247. */
  74248. static readonly ACTION_OnDoublePickTrigger: number;
  74249. /**
  74250. * On pick up
  74251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74252. */
  74253. static readonly ACTION_OnPickUpTrigger: number;
  74254. /**
  74255. * On pick out.
  74256. * This trigger will only be raised if you also declared a OnPickDown
  74257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74258. */
  74259. static readonly ACTION_OnPickOutTrigger: number;
  74260. /**
  74261. * On long press
  74262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74263. */
  74264. static readonly ACTION_OnLongPressTrigger: number;
  74265. /**
  74266. * On pointer over
  74267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74268. */
  74269. static readonly ACTION_OnPointerOverTrigger: number;
  74270. /**
  74271. * On pointer out
  74272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74273. */
  74274. static readonly ACTION_OnPointerOutTrigger: number;
  74275. /**
  74276. * On every frame
  74277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74278. */
  74279. static readonly ACTION_OnEveryFrameTrigger: number;
  74280. /**
  74281. * On intersection enter
  74282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74283. */
  74284. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74285. /**
  74286. * On intersection exit
  74287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74288. */
  74289. static readonly ACTION_OnIntersectionExitTrigger: number;
  74290. /**
  74291. * On key down
  74292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74293. */
  74294. static readonly ACTION_OnKeyDownTrigger: number;
  74295. /**
  74296. * On key up
  74297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74298. */
  74299. static readonly ACTION_OnKeyUpTrigger: number;
  74300. /**
  74301. * Billboard mode will only apply to Y axis
  74302. */
  74303. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74304. /**
  74305. * Billboard mode will apply to all axes
  74306. */
  74307. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74308. /**
  74309. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74310. */
  74311. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74312. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74313. * Test order :
  74314. * Is the bounding sphere outside the frustum ?
  74315. * If not, are the bounding box vertices outside the frustum ?
  74316. * It not, then the cullable object is in the frustum.
  74317. */
  74318. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74319. /** Culling strategy : Bounding Sphere Only.
  74320. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74321. * It's also less accurate than the standard because some not visible objects can still be selected.
  74322. * Test : is the bounding sphere outside the frustum ?
  74323. * If not, then the cullable object is in the frustum.
  74324. */
  74325. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74326. /** Culling strategy : Optimistic Inclusion.
  74327. * This in an inclusion test first, then the standard exclusion test.
  74328. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74329. * 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.
  74330. * Anyway, it's as accurate as the standard strategy.
  74331. * Test :
  74332. * Is the cullable object bounding sphere center in the frustum ?
  74333. * If not, apply the default culling strategy.
  74334. */
  74335. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74336. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74337. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74338. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74339. * 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.
  74340. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74341. * Test :
  74342. * Is the cullable object bounding sphere center in the frustum ?
  74343. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74344. */
  74345. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74346. /**
  74347. * No logging while loading
  74348. */
  74349. static readonly SCENELOADER_NO_LOGGING: number;
  74350. /**
  74351. * Minimal logging while loading
  74352. */
  74353. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74354. /**
  74355. * Summary logging while loading
  74356. */
  74357. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74358. /**
  74359. * Detailled logging while loading
  74360. */
  74361. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74362. }
  74363. }
  74364. declare module BABYLON {
  74365. /**
  74366. * This represents the required contract to create a new type of texture loader.
  74367. */
  74368. export interface IInternalTextureLoader {
  74369. /**
  74370. * Defines wether the loader supports cascade loading the different faces.
  74371. */
  74372. supportCascades: boolean;
  74373. /**
  74374. * This returns if the loader support the current file information.
  74375. * @param extension defines the file extension of the file being loaded
  74376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74377. * @param fallback defines the fallback internal texture if any
  74378. * @param isBase64 defines whether the texture is encoded as a base64
  74379. * @param isBuffer defines whether the texture data are stored as a buffer
  74380. * @returns true if the loader can load the specified file
  74381. */
  74382. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74383. /**
  74384. * Transform the url before loading if required.
  74385. * @param rootUrl the url of the texture
  74386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74387. * @returns the transformed texture
  74388. */
  74389. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74390. /**
  74391. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74392. * @param rootUrl the url of the texture
  74393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74394. * @returns the fallback texture
  74395. */
  74396. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74397. /**
  74398. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74399. * @param data contains the texture data
  74400. * @param texture defines the BabylonJS internal texture
  74401. * @param createPolynomials will be true if polynomials have been requested
  74402. * @param onLoad defines the callback to trigger once the texture is ready
  74403. * @param onError defines the callback to trigger in case of error
  74404. */
  74405. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74406. /**
  74407. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74408. * @param data contains the texture data
  74409. * @param texture defines the BabylonJS internal texture
  74410. * @param callback defines the method to call once ready to upload
  74411. */
  74412. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74413. }
  74414. }
  74415. declare module BABYLON {
  74416. /**
  74417. * Class used to store and describe the pipeline context associated with an effect
  74418. */
  74419. export interface IPipelineContext {
  74420. /**
  74421. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74422. */
  74423. isAsync: boolean;
  74424. /**
  74425. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74426. */
  74427. isReady: boolean;
  74428. /** @hidden */
  74429. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /**
  74434. * Class used to store gfx data (like WebGLBuffer)
  74435. */
  74436. export class DataBuffer {
  74437. /**
  74438. * Gets or sets the number of objects referencing this buffer
  74439. */
  74440. references: number;
  74441. /** Gets or sets the size of the underlying buffer */
  74442. capacity: number;
  74443. /**
  74444. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74445. */
  74446. is32Bits: boolean;
  74447. /**
  74448. * Gets the underlying buffer
  74449. */
  74450. get underlyingResource(): any;
  74451. }
  74452. }
  74453. declare module BABYLON {
  74454. /** @hidden */
  74455. export interface IShaderProcessor {
  74456. attributeProcessor?: (attribute: string) => string;
  74457. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74458. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74459. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74460. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74461. lineProcessor?: (line: string, isFragment: boolean) => string;
  74462. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74463. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74464. }
  74465. }
  74466. declare module BABYLON {
  74467. /** @hidden */
  74468. export interface ProcessingOptions {
  74469. defines: string[];
  74470. indexParameters: any;
  74471. isFragment: boolean;
  74472. shouldUseHighPrecisionShader: boolean;
  74473. supportsUniformBuffers: boolean;
  74474. shadersRepository: string;
  74475. includesShadersStore: {
  74476. [key: string]: string;
  74477. };
  74478. processor?: IShaderProcessor;
  74479. version: string;
  74480. platformName: string;
  74481. lookForClosingBracketForUniformBuffer?: boolean;
  74482. }
  74483. }
  74484. declare module BABYLON {
  74485. /** @hidden */
  74486. export class ShaderCodeNode {
  74487. line: string;
  74488. children: ShaderCodeNode[];
  74489. additionalDefineKey?: string;
  74490. additionalDefineValue?: string;
  74491. isValid(preprocessors: {
  74492. [key: string]: string;
  74493. }): boolean;
  74494. process(preprocessors: {
  74495. [key: string]: string;
  74496. }, options: ProcessingOptions): string;
  74497. }
  74498. }
  74499. declare module BABYLON {
  74500. /** @hidden */
  74501. export class ShaderCodeCursor {
  74502. private _lines;
  74503. lineIndex: number;
  74504. get currentLine(): string;
  74505. get canRead(): boolean;
  74506. set lines(value: string[]);
  74507. }
  74508. }
  74509. declare module BABYLON {
  74510. /** @hidden */
  74511. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74512. process(preprocessors: {
  74513. [key: string]: string;
  74514. }, options: ProcessingOptions): string;
  74515. }
  74516. }
  74517. declare module BABYLON {
  74518. /** @hidden */
  74519. export class ShaderDefineExpression {
  74520. isTrue(preprocessors: {
  74521. [key: string]: string;
  74522. }): boolean;
  74523. }
  74524. }
  74525. declare module BABYLON {
  74526. /** @hidden */
  74527. export class ShaderCodeTestNode extends ShaderCodeNode {
  74528. testExpression: ShaderDefineExpression;
  74529. isValid(preprocessors: {
  74530. [key: string]: string;
  74531. }): boolean;
  74532. }
  74533. }
  74534. declare module BABYLON {
  74535. /** @hidden */
  74536. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74537. define: string;
  74538. not: boolean;
  74539. constructor(define: string, not?: boolean);
  74540. isTrue(preprocessors: {
  74541. [key: string]: string;
  74542. }): boolean;
  74543. }
  74544. }
  74545. declare module BABYLON {
  74546. /** @hidden */
  74547. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74548. leftOperand: ShaderDefineExpression;
  74549. rightOperand: ShaderDefineExpression;
  74550. isTrue(preprocessors: {
  74551. [key: string]: string;
  74552. }): boolean;
  74553. }
  74554. }
  74555. declare module BABYLON {
  74556. /** @hidden */
  74557. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74558. leftOperand: ShaderDefineExpression;
  74559. rightOperand: ShaderDefineExpression;
  74560. isTrue(preprocessors: {
  74561. [key: string]: string;
  74562. }): boolean;
  74563. }
  74564. }
  74565. declare module BABYLON {
  74566. /** @hidden */
  74567. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74568. define: string;
  74569. operand: string;
  74570. testValue: string;
  74571. constructor(define: string, operand: string, testValue: string);
  74572. isTrue(preprocessors: {
  74573. [key: string]: string;
  74574. }): boolean;
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /**
  74579. * Class used to enable access to offline support
  74580. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74581. */
  74582. export interface IOfflineProvider {
  74583. /**
  74584. * Gets a boolean indicating if scene must be saved in the database
  74585. */
  74586. enableSceneOffline: boolean;
  74587. /**
  74588. * Gets a boolean indicating if textures must be saved in the database
  74589. */
  74590. enableTexturesOffline: boolean;
  74591. /**
  74592. * Open the offline support and make it available
  74593. * @param successCallback defines the callback to call on success
  74594. * @param errorCallback defines the callback to call on error
  74595. */
  74596. open(successCallback: () => void, errorCallback: () => void): void;
  74597. /**
  74598. * Loads an image from the offline support
  74599. * @param url defines the url to load from
  74600. * @param image defines the target DOM image
  74601. */
  74602. loadImage(url: string, image: HTMLImageElement): void;
  74603. /**
  74604. * Loads a file from offline support
  74605. * @param url defines the URL to load from
  74606. * @param sceneLoaded defines a callback to call on success
  74607. * @param progressCallBack defines a callback to call when progress changed
  74608. * @param errorCallback defines a callback to call on error
  74609. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74610. */
  74611. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74612. }
  74613. }
  74614. declare module BABYLON {
  74615. /**
  74616. * Class used to help managing file picking and drag'n'drop
  74617. * File Storage
  74618. */
  74619. export class FilesInputStore {
  74620. /**
  74621. * List of files ready to be loaded
  74622. */
  74623. static FilesToLoad: {
  74624. [key: string]: File;
  74625. };
  74626. }
  74627. }
  74628. declare module BABYLON {
  74629. /**
  74630. * Class used to define a retry strategy when error happens while loading assets
  74631. */
  74632. export class RetryStrategy {
  74633. /**
  74634. * Function used to defines an exponential back off strategy
  74635. * @param maxRetries defines the maximum number of retries (3 by default)
  74636. * @param baseInterval defines the interval between retries
  74637. * @returns the strategy function to use
  74638. */
  74639. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74640. }
  74641. }
  74642. declare module BABYLON {
  74643. /**
  74644. * @ignore
  74645. * Application error to support additional information when loading a file
  74646. */
  74647. export abstract class BaseError extends Error {
  74648. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74649. }
  74650. }
  74651. declare module BABYLON {
  74652. /** @ignore */
  74653. export class LoadFileError extends BaseError {
  74654. request?: WebRequest;
  74655. file?: File;
  74656. /**
  74657. * Creates a new LoadFileError
  74658. * @param message defines the message of the error
  74659. * @param request defines the optional web request
  74660. * @param file defines the optional file
  74661. */
  74662. constructor(message: string, object?: WebRequest | File);
  74663. }
  74664. /** @ignore */
  74665. export class RequestFileError extends BaseError {
  74666. request: WebRequest;
  74667. /**
  74668. * Creates a new LoadFileError
  74669. * @param message defines the message of the error
  74670. * @param request defines the optional web request
  74671. */
  74672. constructor(message: string, request: WebRequest);
  74673. }
  74674. /** @ignore */
  74675. export class ReadFileError extends BaseError {
  74676. file: File;
  74677. /**
  74678. * Creates a new ReadFileError
  74679. * @param message defines the message of the error
  74680. * @param file defines the optional file
  74681. */
  74682. constructor(message: string, file: File);
  74683. }
  74684. /**
  74685. * @hidden
  74686. */
  74687. export class FileTools {
  74688. /**
  74689. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74690. */
  74691. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74692. /**
  74693. * Gets or sets the base URL to use to load assets
  74694. */
  74695. static BaseUrl: string;
  74696. /**
  74697. * Default behaviour for cors in the application.
  74698. * It can be a string if the expected behavior is identical in the entire app.
  74699. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74700. */
  74701. static CorsBehavior: string | ((url: string | string[]) => string);
  74702. /**
  74703. * Gets or sets a function used to pre-process url before using them to load assets
  74704. */
  74705. static PreprocessUrl: (url: string) => string;
  74706. /**
  74707. * Removes unwanted characters from an url
  74708. * @param url defines the url to clean
  74709. * @returns the cleaned url
  74710. */
  74711. private static _CleanUrl;
  74712. /**
  74713. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74714. * @param url define the url we are trying
  74715. * @param element define the dom element where to configure the cors policy
  74716. */
  74717. static SetCorsBehavior(url: string | string[], element: {
  74718. crossOrigin: string | null;
  74719. }): void;
  74720. /**
  74721. * Loads an image as an HTMLImageElement.
  74722. * @param input url string, ArrayBuffer, or Blob to load
  74723. * @param onLoad callback called when the image successfully loads
  74724. * @param onError callback called when the image fails to load
  74725. * @param offlineProvider offline provider for caching
  74726. * @param mimeType optional mime type
  74727. * @returns the HTMLImageElement of the loaded image
  74728. */
  74729. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  74730. /**
  74731. * Reads a file from a File object
  74732. * @param file defines the file to load
  74733. * @param onSuccess defines the callback to call when data is loaded
  74734. * @param onProgress defines the callback to call during loading process
  74735. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74736. * @param onError defines the callback to call when an error occurs
  74737. * @returns a file request object
  74738. */
  74739. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74740. /**
  74741. * Loads a file from a url
  74742. * @param url url to load
  74743. * @param onSuccess callback called when the file successfully loads
  74744. * @param onProgress callback called while file is loading (if the server supports this mode)
  74745. * @param offlineProvider defines the offline provider for caching
  74746. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74747. * @param onError callback called when the file fails to load
  74748. * @returns a file request object
  74749. */
  74750. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74751. /**
  74752. * Loads a file
  74753. * @param url url to load
  74754. * @param onSuccess callback called when the file successfully loads
  74755. * @param onProgress callback called while file is loading (if the server supports this mode)
  74756. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74757. * @param onError callback called when the file fails to load
  74758. * @param onOpened callback called when the web request is opened
  74759. * @returns a file request object
  74760. */
  74761. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  74762. /**
  74763. * Checks if the loaded document was accessed via `file:`-Protocol.
  74764. * @returns boolean
  74765. */
  74766. static IsFileURL(): boolean;
  74767. }
  74768. }
  74769. declare module BABYLON {
  74770. /** @hidden */
  74771. export class ShaderProcessor {
  74772. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74773. private static _ProcessPrecision;
  74774. private static _ExtractOperation;
  74775. private static _BuildSubExpression;
  74776. private static _BuildExpression;
  74777. private static _MoveCursorWithinIf;
  74778. private static _MoveCursor;
  74779. private static _EvaluatePreProcessors;
  74780. private static _PreparePreProcessors;
  74781. private static _ProcessShaderConversion;
  74782. private static _ProcessIncludes;
  74783. /**
  74784. * Loads a file from a url
  74785. * @param url url to load
  74786. * @param onSuccess callback called when the file successfully loads
  74787. * @param onProgress callback called while file is loading (if the server supports this mode)
  74788. * @param offlineProvider defines the offline provider for caching
  74789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74790. * @param onError callback called when the file fails to load
  74791. * @returns a file request object
  74792. * @hidden
  74793. */
  74794. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74795. }
  74796. }
  74797. declare module BABYLON {
  74798. /**
  74799. * @hidden
  74800. */
  74801. export interface IColor4Like {
  74802. r: float;
  74803. g: float;
  74804. b: float;
  74805. a: float;
  74806. }
  74807. /**
  74808. * @hidden
  74809. */
  74810. export interface IColor3Like {
  74811. r: float;
  74812. g: float;
  74813. b: float;
  74814. }
  74815. /**
  74816. * @hidden
  74817. */
  74818. export interface IVector4Like {
  74819. x: float;
  74820. y: float;
  74821. z: float;
  74822. w: float;
  74823. }
  74824. /**
  74825. * @hidden
  74826. */
  74827. export interface IVector3Like {
  74828. x: float;
  74829. y: float;
  74830. z: float;
  74831. }
  74832. /**
  74833. * @hidden
  74834. */
  74835. export interface IVector2Like {
  74836. x: float;
  74837. y: float;
  74838. }
  74839. /**
  74840. * @hidden
  74841. */
  74842. export interface IMatrixLike {
  74843. toArray(): DeepImmutable<Float32Array>;
  74844. updateFlag: int;
  74845. }
  74846. /**
  74847. * @hidden
  74848. */
  74849. export interface IViewportLike {
  74850. x: float;
  74851. y: float;
  74852. width: float;
  74853. height: float;
  74854. }
  74855. /**
  74856. * @hidden
  74857. */
  74858. export interface IPlaneLike {
  74859. normal: IVector3Like;
  74860. d: float;
  74861. normalize(): void;
  74862. }
  74863. }
  74864. declare module BABYLON {
  74865. /**
  74866. * Interface used to define common properties for effect fallbacks
  74867. */
  74868. export interface IEffectFallbacks {
  74869. /**
  74870. * Removes the defines that should be removed when falling back.
  74871. * @param currentDefines defines the current define statements for the shader.
  74872. * @param effect defines the current effect we try to compile
  74873. * @returns The resulting defines with defines of the current rank removed.
  74874. */
  74875. reduce(currentDefines: string, effect: Effect): string;
  74876. /**
  74877. * Removes the fallback from the bound mesh.
  74878. */
  74879. unBindMesh(): void;
  74880. /**
  74881. * Checks to see if more fallbacks are still availible.
  74882. */
  74883. hasMoreFallbacks: boolean;
  74884. }
  74885. }
  74886. declare module BABYLON {
  74887. /**
  74888. * Class used to evalaute queries containing `and` and `or` operators
  74889. */
  74890. export class AndOrNotEvaluator {
  74891. /**
  74892. * Evaluate a query
  74893. * @param query defines the query to evaluate
  74894. * @param evaluateCallback defines the callback used to filter result
  74895. * @returns true if the query matches
  74896. */
  74897. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74898. private static _HandleParenthesisContent;
  74899. private static _SimplifyNegation;
  74900. }
  74901. }
  74902. declare module BABYLON {
  74903. /**
  74904. * Class used to store custom tags
  74905. */
  74906. export class Tags {
  74907. /**
  74908. * Adds support for tags on the given object
  74909. * @param obj defines the object to use
  74910. */
  74911. static EnableFor(obj: any): void;
  74912. /**
  74913. * Removes tags support
  74914. * @param obj defines the object to use
  74915. */
  74916. static DisableFor(obj: any): void;
  74917. /**
  74918. * Gets a boolean indicating if the given object has tags
  74919. * @param obj defines the object to use
  74920. * @returns a boolean
  74921. */
  74922. static HasTags(obj: any): boolean;
  74923. /**
  74924. * Gets the tags available on a given object
  74925. * @param obj defines the object to use
  74926. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74927. * @returns the tags
  74928. */
  74929. static GetTags(obj: any, asString?: boolean): any;
  74930. /**
  74931. * Adds tags to an object
  74932. * @param obj defines the object to use
  74933. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74934. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74935. */
  74936. static AddTagsTo(obj: any, tagsString: string): void;
  74937. /**
  74938. * @hidden
  74939. */
  74940. static _AddTagTo(obj: any, tag: string): void;
  74941. /**
  74942. * Removes specific tags from a specific object
  74943. * @param obj defines the object to use
  74944. * @param tagsString defines the tags to remove
  74945. */
  74946. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74947. /**
  74948. * @hidden
  74949. */
  74950. static _RemoveTagFrom(obj: any, tag: string): void;
  74951. /**
  74952. * Defines if tags hosted on an object match a given query
  74953. * @param obj defines the object to use
  74954. * @param tagsQuery defines the tag query
  74955. * @returns a boolean
  74956. */
  74957. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74958. }
  74959. }
  74960. declare module BABYLON {
  74961. /**
  74962. * Scalar computation library
  74963. */
  74964. export class Scalar {
  74965. /**
  74966. * Two pi constants convenient for computation.
  74967. */
  74968. static TwoPi: number;
  74969. /**
  74970. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74971. * @param a number
  74972. * @param b number
  74973. * @param epsilon (default = 1.401298E-45)
  74974. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74975. */
  74976. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74977. /**
  74978. * Returns a string : the upper case translation of the number i to hexadecimal.
  74979. * @param i number
  74980. * @returns the upper case translation of the number i to hexadecimal.
  74981. */
  74982. static ToHex(i: number): string;
  74983. /**
  74984. * Returns -1 if value is negative and +1 is value is positive.
  74985. * @param value the value
  74986. * @returns the value itself if it's equal to zero.
  74987. */
  74988. static Sign(value: number): number;
  74989. /**
  74990. * Returns the value itself if it's between min and max.
  74991. * Returns min if the value is lower than min.
  74992. * Returns max if the value is greater than max.
  74993. * @param value the value to clmap
  74994. * @param min the min value to clamp to (default: 0)
  74995. * @param max the max value to clamp to (default: 1)
  74996. * @returns the clamped value
  74997. */
  74998. static Clamp(value: number, min?: number, max?: number): number;
  74999. /**
  75000. * the log2 of value.
  75001. * @param value the value to compute log2 of
  75002. * @returns the log2 of value.
  75003. */
  75004. static Log2(value: number): number;
  75005. /**
  75006. * Loops the value, so that it is never larger than length and never smaller than 0.
  75007. *
  75008. * This is similar to the modulo operator but it works with floating point numbers.
  75009. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75010. * With t = 5 and length = 2.5, the result would be 0.0.
  75011. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75012. * @param value the value
  75013. * @param length the length
  75014. * @returns the looped value
  75015. */
  75016. static Repeat(value: number, length: number): number;
  75017. /**
  75018. * Normalize the value between 0.0 and 1.0 using min and max values
  75019. * @param value value to normalize
  75020. * @param min max to normalize between
  75021. * @param max min to normalize between
  75022. * @returns the normalized value
  75023. */
  75024. static Normalize(value: number, min: number, max: number): number;
  75025. /**
  75026. * Denormalize the value from 0.0 and 1.0 using min and max values
  75027. * @param normalized value to denormalize
  75028. * @param min max to denormalize between
  75029. * @param max min to denormalize between
  75030. * @returns the denormalized value
  75031. */
  75032. static Denormalize(normalized: number, min: number, max: number): number;
  75033. /**
  75034. * Calculates the shortest difference between two given angles given in degrees.
  75035. * @param current current angle in degrees
  75036. * @param target target angle in degrees
  75037. * @returns the delta
  75038. */
  75039. static DeltaAngle(current: number, target: number): number;
  75040. /**
  75041. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75042. * @param tx value
  75043. * @param length length
  75044. * @returns The returned value will move back and forth between 0 and length
  75045. */
  75046. static PingPong(tx: number, length: number): number;
  75047. /**
  75048. * Interpolates between min and max with smoothing at the limits.
  75049. *
  75050. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75051. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75052. * @param from from
  75053. * @param to to
  75054. * @param tx value
  75055. * @returns the smooth stepped value
  75056. */
  75057. static SmoothStep(from: number, to: number, tx: number): number;
  75058. /**
  75059. * Moves a value current towards target.
  75060. *
  75061. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75062. * Negative values of maxDelta pushes the value away from target.
  75063. * @param current current value
  75064. * @param target target value
  75065. * @param maxDelta max distance to move
  75066. * @returns resulting value
  75067. */
  75068. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75069. /**
  75070. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75071. *
  75072. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75073. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75074. * @param current current value
  75075. * @param target target value
  75076. * @param maxDelta max distance to move
  75077. * @returns resulting angle
  75078. */
  75079. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75080. /**
  75081. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75082. * @param start start value
  75083. * @param end target value
  75084. * @param amount amount to lerp between
  75085. * @returns the lerped value
  75086. */
  75087. static Lerp(start: number, end: number, amount: number): number;
  75088. /**
  75089. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75090. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75091. * @param start start value
  75092. * @param end target value
  75093. * @param amount amount to lerp between
  75094. * @returns the lerped value
  75095. */
  75096. static LerpAngle(start: number, end: number, amount: number): number;
  75097. /**
  75098. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75099. * @param a start value
  75100. * @param b target value
  75101. * @param value value between a and b
  75102. * @returns the inverseLerp value
  75103. */
  75104. static InverseLerp(a: number, b: number, value: number): number;
  75105. /**
  75106. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75107. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75108. * @param value1 spline value
  75109. * @param tangent1 spline value
  75110. * @param value2 spline value
  75111. * @param tangent2 spline value
  75112. * @param amount input value
  75113. * @returns hermite result
  75114. */
  75115. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75116. /**
  75117. * Returns a random float number between and min and max values
  75118. * @param min min value of random
  75119. * @param max max value of random
  75120. * @returns random value
  75121. */
  75122. static RandomRange(min: number, max: number): number;
  75123. /**
  75124. * This function returns percentage of a number in a given range.
  75125. *
  75126. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75127. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75128. * @param number to convert to percentage
  75129. * @param min min range
  75130. * @param max max range
  75131. * @returns the percentage
  75132. */
  75133. static RangeToPercent(number: number, min: number, max: number): number;
  75134. /**
  75135. * This function returns number that corresponds to the percentage in a given range.
  75136. *
  75137. * PercentToRange(0.34,0,100) will return 34.
  75138. * @param percent to convert to number
  75139. * @param min min range
  75140. * @param max max range
  75141. * @returns the number
  75142. */
  75143. static PercentToRange(percent: number, min: number, max: number): number;
  75144. /**
  75145. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75146. * @param angle The angle to normalize in radian.
  75147. * @return The converted angle.
  75148. */
  75149. static NormalizeRadians(angle: number): number;
  75150. }
  75151. }
  75152. declare module BABYLON {
  75153. /**
  75154. * Constant used to convert a value to gamma space
  75155. * @ignorenaming
  75156. */
  75157. export const ToGammaSpace: number;
  75158. /**
  75159. * Constant used to convert a value to linear space
  75160. * @ignorenaming
  75161. */
  75162. export const ToLinearSpace = 2.2;
  75163. /**
  75164. * Constant used to define the minimal number value in Babylon.js
  75165. * @ignorenaming
  75166. */
  75167. let Epsilon: number;
  75168. }
  75169. declare module BABYLON {
  75170. /**
  75171. * Class used to represent a viewport on screen
  75172. */
  75173. export class Viewport {
  75174. /** viewport left coordinate */
  75175. x: number;
  75176. /** viewport top coordinate */
  75177. y: number;
  75178. /**viewport width */
  75179. width: number;
  75180. /** viewport height */
  75181. height: number;
  75182. /**
  75183. * Creates a Viewport object located at (x, y) and sized (width, height)
  75184. * @param x defines viewport left coordinate
  75185. * @param y defines viewport top coordinate
  75186. * @param width defines the viewport width
  75187. * @param height defines the viewport height
  75188. */
  75189. constructor(
  75190. /** viewport left coordinate */
  75191. x: number,
  75192. /** viewport top coordinate */
  75193. y: number,
  75194. /**viewport width */
  75195. width: number,
  75196. /** viewport height */
  75197. height: number);
  75198. /**
  75199. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75200. * @param renderWidth defines the rendering width
  75201. * @param renderHeight defines the rendering height
  75202. * @returns a new Viewport
  75203. */
  75204. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75205. /**
  75206. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75207. * @param renderWidth defines the rendering width
  75208. * @param renderHeight defines the rendering height
  75209. * @param ref defines the target viewport
  75210. * @returns the current viewport
  75211. */
  75212. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75213. /**
  75214. * Returns a new Viewport copied from the current one
  75215. * @returns a new Viewport
  75216. */
  75217. clone(): Viewport;
  75218. }
  75219. }
  75220. declare module BABYLON {
  75221. /**
  75222. * Class containing a set of static utilities functions for arrays.
  75223. */
  75224. export class ArrayTools {
  75225. /**
  75226. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75227. * @param size the number of element to construct and put in the array
  75228. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75229. * @returns a new array filled with new objects
  75230. */
  75231. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75232. }
  75233. }
  75234. declare module BABYLON {
  75235. /**
  75236. * Class representing a vector containing 2 coordinates
  75237. */
  75238. export class Vector2 {
  75239. /** defines the first coordinate */
  75240. x: number;
  75241. /** defines the second coordinate */
  75242. y: number;
  75243. /**
  75244. * Creates a new Vector2 from the given x and y coordinates
  75245. * @param x defines the first coordinate
  75246. * @param y defines the second coordinate
  75247. */
  75248. constructor(
  75249. /** defines the first coordinate */
  75250. x?: number,
  75251. /** defines the second coordinate */
  75252. y?: number);
  75253. /**
  75254. * Gets a string with the Vector2 coordinates
  75255. * @returns a string with the Vector2 coordinates
  75256. */
  75257. toString(): string;
  75258. /**
  75259. * Gets class name
  75260. * @returns the string "Vector2"
  75261. */
  75262. getClassName(): string;
  75263. /**
  75264. * Gets current vector hash code
  75265. * @returns the Vector2 hash code as a number
  75266. */
  75267. getHashCode(): number;
  75268. /**
  75269. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75270. * @param array defines the source array
  75271. * @param index defines the offset in source array
  75272. * @returns the current Vector2
  75273. */
  75274. toArray(array: FloatArray, index?: number): Vector2;
  75275. /**
  75276. * Copy the current vector to an array
  75277. * @returns a new array with 2 elements: the Vector2 coordinates.
  75278. */
  75279. asArray(): number[];
  75280. /**
  75281. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75282. * @param source defines the source Vector2
  75283. * @returns the current updated Vector2
  75284. */
  75285. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75286. /**
  75287. * Sets the Vector2 coordinates with the given floats
  75288. * @param x defines the first coordinate
  75289. * @param y defines the second coordinate
  75290. * @returns the current updated Vector2
  75291. */
  75292. copyFromFloats(x: number, y: number): Vector2;
  75293. /**
  75294. * Sets the Vector2 coordinates with the given floats
  75295. * @param x defines the first coordinate
  75296. * @param y defines the second coordinate
  75297. * @returns the current updated Vector2
  75298. */
  75299. set(x: number, y: number): Vector2;
  75300. /**
  75301. * Add another vector with the current one
  75302. * @param otherVector defines the other vector
  75303. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75304. */
  75305. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75306. /**
  75307. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75308. * @param otherVector defines the other vector
  75309. * @param result defines the target vector
  75310. * @returns the unmodified current Vector2
  75311. */
  75312. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75313. /**
  75314. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75315. * @param otherVector defines the other vector
  75316. * @returns the current updated Vector2
  75317. */
  75318. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75319. /**
  75320. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75321. * @param otherVector defines the other vector
  75322. * @returns a new Vector2
  75323. */
  75324. addVector3(otherVector: Vector3): Vector2;
  75325. /**
  75326. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75327. * @param otherVector defines the other vector
  75328. * @returns a new Vector2
  75329. */
  75330. subtract(otherVector: Vector2): Vector2;
  75331. /**
  75332. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75333. * @param otherVector defines the other vector
  75334. * @param result defines the target vector
  75335. * @returns the unmodified current Vector2
  75336. */
  75337. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75338. /**
  75339. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75340. * @param otherVector defines the other vector
  75341. * @returns the current updated Vector2
  75342. */
  75343. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75344. /**
  75345. * Multiplies in place the current Vector2 coordinates by the given ones
  75346. * @param otherVector defines the other vector
  75347. * @returns the current updated Vector2
  75348. */
  75349. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75350. /**
  75351. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75352. * @param otherVector defines the other vector
  75353. * @returns a new Vector2
  75354. */
  75355. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75356. /**
  75357. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75358. * @param otherVector defines the other vector
  75359. * @param result defines the target vector
  75360. * @returns the unmodified current Vector2
  75361. */
  75362. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75363. /**
  75364. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75365. * @param x defines the first coordinate
  75366. * @param y defines the second coordinate
  75367. * @returns a new Vector2
  75368. */
  75369. multiplyByFloats(x: number, y: number): Vector2;
  75370. /**
  75371. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75372. * @param otherVector defines the other vector
  75373. * @returns a new Vector2
  75374. */
  75375. divide(otherVector: Vector2): Vector2;
  75376. /**
  75377. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75378. * @param otherVector defines the other vector
  75379. * @param result defines the target vector
  75380. * @returns the unmodified current Vector2
  75381. */
  75382. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75383. /**
  75384. * Divides the current Vector2 coordinates by the given ones
  75385. * @param otherVector defines the other vector
  75386. * @returns the current updated Vector2
  75387. */
  75388. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75389. /**
  75390. * Gets a new Vector2 with current Vector2 negated coordinates
  75391. * @returns a new Vector2
  75392. */
  75393. negate(): Vector2;
  75394. /**
  75395. * Negate this vector in place
  75396. * @returns this
  75397. */
  75398. negateInPlace(): Vector2;
  75399. /**
  75400. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75401. * @param result defines the Vector3 object where to store the result
  75402. * @returns the current Vector2
  75403. */
  75404. negateToRef(result: Vector2): Vector2;
  75405. /**
  75406. * Multiply the Vector2 coordinates by scale
  75407. * @param scale defines the scaling factor
  75408. * @returns the current updated Vector2
  75409. */
  75410. scaleInPlace(scale: number): Vector2;
  75411. /**
  75412. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75413. * @param scale defines the scaling factor
  75414. * @returns a new Vector2
  75415. */
  75416. scale(scale: number): Vector2;
  75417. /**
  75418. * Scale the current Vector2 values by a factor to a given Vector2
  75419. * @param scale defines the scale factor
  75420. * @param result defines the Vector2 object where to store the result
  75421. * @returns the unmodified current Vector2
  75422. */
  75423. scaleToRef(scale: number, result: Vector2): Vector2;
  75424. /**
  75425. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75426. * @param scale defines the scale factor
  75427. * @param result defines the Vector2 object where to store the result
  75428. * @returns the unmodified current Vector2
  75429. */
  75430. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75431. /**
  75432. * Gets a boolean if two vectors are equals
  75433. * @param otherVector defines the other vector
  75434. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75435. */
  75436. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75437. /**
  75438. * Gets a boolean if two vectors are equals (using an epsilon value)
  75439. * @param otherVector defines the other vector
  75440. * @param epsilon defines the minimal distance to consider equality
  75441. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75442. */
  75443. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75444. /**
  75445. * Gets a new Vector2 from current Vector2 floored values
  75446. * @returns a new Vector2
  75447. */
  75448. floor(): Vector2;
  75449. /**
  75450. * Gets a new Vector2 from current Vector2 floored values
  75451. * @returns a new Vector2
  75452. */
  75453. fract(): Vector2;
  75454. /**
  75455. * Gets the length of the vector
  75456. * @returns the vector length (float)
  75457. */
  75458. length(): number;
  75459. /**
  75460. * Gets the vector squared length
  75461. * @returns the vector squared length (float)
  75462. */
  75463. lengthSquared(): number;
  75464. /**
  75465. * Normalize the vector
  75466. * @returns the current updated Vector2
  75467. */
  75468. normalize(): Vector2;
  75469. /**
  75470. * Gets a new Vector2 copied from the Vector2
  75471. * @returns a new Vector2
  75472. */
  75473. clone(): Vector2;
  75474. /**
  75475. * Gets a new Vector2(0, 0)
  75476. * @returns a new Vector2
  75477. */
  75478. static Zero(): Vector2;
  75479. /**
  75480. * Gets a new Vector2(1, 1)
  75481. * @returns a new Vector2
  75482. */
  75483. static One(): Vector2;
  75484. /**
  75485. * Gets a new Vector2 set from the given index element of the given array
  75486. * @param array defines the data source
  75487. * @param offset defines the offset in the data source
  75488. * @returns a new Vector2
  75489. */
  75490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75491. /**
  75492. * Sets "result" from the given index element of the given array
  75493. * @param array defines the data source
  75494. * @param offset defines the offset in the data source
  75495. * @param result defines the target vector
  75496. */
  75497. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75498. /**
  75499. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75500. * @param value1 defines 1st point of control
  75501. * @param value2 defines 2nd point of control
  75502. * @param value3 defines 3rd point of control
  75503. * @param value4 defines 4th point of control
  75504. * @param amount defines the interpolation factor
  75505. * @returns a new Vector2
  75506. */
  75507. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75508. /**
  75509. * 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".
  75510. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75511. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75512. * @param value defines the value to clamp
  75513. * @param min defines the lower limit
  75514. * @param max defines the upper limit
  75515. * @returns a new Vector2
  75516. */
  75517. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75518. /**
  75519. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75520. * @param value1 defines the 1st control point
  75521. * @param tangent1 defines the outgoing tangent
  75522. * @param value2 defines the 2nd control point
  75523. * @param tangent2 defines the incoming tangent
  75524. * @param amount defines the interpolation factor
  75525. * @returns a new Vector2
  75526. */
  75527. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75528. /**
  75529. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75530. * @param start defines the start vector
  75531. * @param end defines the end vector
  75532. * @param amount defines the interpolation factor
  75533. * @returns a new Vector2
  75534. */
  75535. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75536. /**
  75537. * Gets the dot product of the vector "left" and the vector "right"
  75538. * @param left defines first vector
  75539. * @param right defines second vector
  75540. * @returns the dot product (float)
  75541. */
  75542. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75543. /**
  75544. * Returns a new Vector2 equal to the normalized given vector
  75545. * @param vector defines the vector to normalize
  75546. * @returns a new Vector2
  75547. */
  75548. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75549. /**
  75550. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75551. * @param left defines 1st vector
  75552. * @param right defines 2nd vector
  75553. * @returns a new Vector2
  75554. */
  75555. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75556. /**
  75557. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75558. * @param left defines 1st vector
  75559. * @param right defines 2nd vector
  75560. * @returns a new Vector2
  75561. */
  75562. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75563. /**
  75564. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75565. * @param vector defines the vector to transform
  75566. * @param transformation defines the matrix to apply
  75567. * @returns a new Vector2
  75568. */
  75569. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75570. /**
  75571. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75572. * @param vector defines the vector to transform
  75573. * @param transformation defines the matrix to apply
  75574. * @param result defines the target vector
  75575. */
  75576. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75577. /**
  75578. * Determines if a given vector is included in a triangle
  75579. * @param p defines the vector to test
  75580. * @param p0 defines 1st triangle point
  75581. * @param p1 defines 2nd triangle point
  75582. * @param p2 defines 3rd triangle point
  75583. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75584. */
  75585. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75586. /**
  75587. * Gets the distance between the vectors "value1" and "value2"
  75588. * @param value1 defines first vector
  75589. * @param value2 defines second vector
  75590. * @returns the distance between vectors
  75591. */
  75592. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75593. /**
  75594. * Returns the squared distance between the vectors "value1" and "value2"
  75595. * @param value1 defines first vector
  75596. * @param value2 defines second vector
  75597. * @returns the squared distance between vectors
  75598. */
  75599. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75600. /**
  75601. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75602. * @param value1 defines first vector
  75603. * @param value2 defines second vector
  75604. * @returns a new Vector2
  75605. */
  75606. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75607. /**
  75608. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75609. * @param p defines the middle point
  75610. * @param segA defines one point of the segment
  75611. * @param segB defines the other point of the segment
  75612. * @returns the shortest distance
  75613. */
  75614. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75615. }
  75616. /**
  75617. * Class used to store (x,y,z) vector representation
  75618. * A Vector3 is the main object used in 3D geometry
  75619. * It can represent etiher the coordinates of a point the space, either a direction
  75620. * Reminder: js uses a left handed forward facing system
  75621. */
  75622. export class Vector3 {
  75623. /**
  75624. * Defines the first coordinates (on X axis)
  75625. */
  75626. x: number;
  75627. /**
  75628. * Defines the second coordinates (on Y axis)
  75629. */
  75630. y: number;
  75631. /**
  75632. * Defines the third coordinates (on Z axis)
  75633. */
  75634. z: number;
  75635. private static _UpReadOnly;
  75636. private static _ZeroReadOnly;
  75637. /**
  75638. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75639. * @param x defines the first coordinates (on X axis)
  75640. * @param y defines the second coordinates (on Y axis)
  75641. * @param z defines the third coordinates (on Z axis)
  75642. */
  75643. constructor(
  75644. /**
  75645. * Defines the first coordinates (on X axis)
  75646. */
  75647. x?: number,
  75648. /**
  75649. * Defines the second coordinates (on Y axis)
  75650. */
  75651. y?: number,
  75652. /**
  75653. * Defines the third coordinates (on Z axis)
  75654. */
  75655. z?: number);
  75656. /**
  75657. * Creates a string representation of the Vector3
  75658. * @returns a string with the Vector3 coordinates.
  75659. */
  75660. toString(): string;
  75661. /**
  75662. * Gets the class name
  75663. * @returns the string "Vector3"
  75664. */
  75665. getClassName(): string;
  75666. /**
  75667. * Creates the Vector3 hash code
  75668. * @returns a number which tends to be unique between Vector3 instances
  75669. */
  75670. getHashCode(): number;
  75671. /**
  75672. * Creates an array containing three elements : the coordinates of the Vector3
  75673. * @returns a new array of numbers
  75674. */
  75675. asArray(): number[];
  75676. /**
  75677. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75678. * @param array defines the destination array
  75679. * @param index defines the offset in the destination array
  75680. * @returns the current Vector3
  75681. */
  75682. toArray(array: FloatArray, index?: number): Vector3;
  75683. /**
  75684. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75685. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75686. */
  75687. toQuaternion(): Quaternion;
  75688. /**
  75689. * Adds the given vector to the current Vector3
  75690. * @param otherVector defines the second operand
  75691. * @returns the current updated Vector3
  75692. */
  75693. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75694. /**
  75695. * Adds the given coordinates to the current Vector3
  75696. * @param x defines the x coordinate of the operand
  75697. * @param y defines the y coordinate of the operand
  75698. * @param z defines the z coordinate of the operand
  75699. * @returns the current updated Vector3
  75700. */
  75701. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75702. /**
  75703. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75704. * @param otherVector defines the second operand
  75705. * @returns the resulting Vector3
  75706. */
  75707. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75708. /**
  75709. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75710. * @param otherVector defines the second operand
  75711. * @param result defines the Vector3 object where to store the result
  75712. * @returns the current Vector3
  75713. */
  75714. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75715. /**
  75716. * Subtract the given vector from the current Vector3
  75717. * @param otherVector defines the second operand
  75718. * @returns the current updated Vector3
  75719. */
  75720. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75721. /**
  75722. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75723. * @param otherVector defines the second operand
  75724. * @returns the resulting Vector3
  75725. */
  75726. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75727. /**
  75728. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75729. * @param otherVector defines the second operand
  75730. * @param result defines the Vector3 object where to store the result
  75731. * @returns the current Vector3
  75732. */
  75733. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75734. /**
  75735. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75736. * @param x defines the x coordinate of the operand
  75737. * @param y defines the y coordinate of the operand
  75738. * @param z defines the z coordinate of the operand
  75739. * @returns the resulting Vector3
  75740. */
  75741. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75742. /**
  75743. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75744. * @param x defines the x coordinate of the operand
  75745. * @param y defines the y coordinate of the operand
  75746. * @param z defines the z coordinate of the operand
  75747. * @param result defines the Vector3 object where to store the result
  75748. * @returns the current Vector3
  75749. */
  75750. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75751. /**
  75752. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75753. * @returns a new Vector3
  75754. */
  75755. negate(): Vector3;
  75756. /**
  75757. * Negate this vector in place
  75758. * @returns this
  75759. */
  75760. negateInPlace(): Vector3;
  75761. /**
  75762. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75763. * @param result defines the Vector3 object where to store the result
  75764. * @returns the current Vector3
  75765. */
  75766. negateToRef(result: Vector3): Vector3;
  75767. /**
  75768. * Multiplies the Vector3 coordinates by the float "scale"
  75769. * @param scale defines the multiplier factor
  75770. * @returns the current updated Vector3
  75771. */
  75772. scaleInPlace(scale: number): Vector3;
  75773. /**
  75774. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75775. * @param scale defines the multiplier factor
  75776. * @returns a new Vector3
  75777. */
  75778. scale(scale: number): Vector3;
  75779. /**
  75780. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75781. * @param scale defines the multiplier factor
  75782. * @param result defines the Vector3 object where to store the result
  75783. * @returns the current Vector3
  75784. */
  75785. scaleToRef(scale: number, result: Vector3): Vector3;
  75786. /**
  75787. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75788. * @param scale defines the scale factor
  75789. * @param result defines the Vector3 object where to store the result
  75790. * @returns the unmodified current Vector3
  75791. */
  75792. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75793. /**
  75794. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75795. * @param otherVector defines the second operand
  75796. * @returns true if both vectors are equals
  75797. */
  75798. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75799. /**
  75800. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75801. * @param otherVector defines the second operand
  75802. * @param epsilon defines the minimal distance to define values as equals
  75803. * @returns true if both vectors are distant less than epsilon
  75804. */
  75805. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75806. /**
  75807. * Returns true if the current Vector3 coordinates equals the given floats
  75808. * @param x defines the x coordinate of the operand
  75809. * @param y defines the y coordinate of the operand
  75810. * @param z defines the z coordinate of the operand
  75811. * @returns true if both vectors are equals
  75812. */
  75813. equalsToFloats(x: number, y: number, z: number): boolean;
  75814. /**
  75815. * Multiplies the current Vector3 coordinates by the given ones
  75816. * @param otherVector defines the second operand
  75817. * @returns the current updated Vector3
  75818. */
  75819. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75820. /**
  75821. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75822. * @param otherVector defines the second operand
  75823. * @returns the new Vector3
  75824. */
  75825. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75826. /**
  75827. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75828. * @param otherVector defines the second operand
  75829. * @param result defines the Vector3 object where to store the result
  75830. * @returns the current Vector3
  75831. */
  75832. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75833. /**
  75834. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75835. * @param x defines the x coordinate of the operand
  75836. * @param y defines the y coordinate of the operand
  75837. * @param z defines the z coordinate of the operand
  75838. * @returns the new Vector3
  75839. */
  75840. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75841. /**
  75842. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75843. * @param otherVector defines the second operand
  75844. * @returns the new Vector3
  75845. */
  75846. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75847. /**
  75848. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75849. * @param otherVector defines the second operand
  75850. * @param result defines the Vector3 object where to store the result
  75851. * @returns the current Vector3
  75852. */
  75853. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75854. /**
  75855. * Divides the current Vector3 coordinates by the given ones.
  75856. * @param otherVector defines the second operand
  75857. * @returns the current updated Vector3
  75858. */
  75859. divideInPlace(otherVector: Vector3): Vector3;
  75860. /**
  75861. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75862. * @param other defines the second operand
  75863. * @returns the current updated Vector3
  75864. */
  75865. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75866. /**
  75867. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75868. * @param other defines the second operand
  75869. * @returns the current updated Vector3
  75870. */
  75871. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75872. /**
  75873. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75874. * @param x defines the x coordinate of the operand
  75875. * @param y defines the y coordinate of the operand
  75876. * @param z defines the z coordinate of the operand
  75877. * @returns the current updated Vector3
  75878. */
  75879. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75880. /**
  75881. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75882. * @param x defines the x coordinate of the operand
  75883. * @param y defines the y coordinate of the operand
  75884. * @param z defines the z coordinate of the operand
  75885. * @returns the current updated Vector3
  75886. */
  75887. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75888. /**
  75889. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75890. * Check if is non uniform within a certain amount of decimal places to account for this
  75891. * @param epsilon the amount the values can differ
  75892. * @returns if the the vector is non uniform to a certain number of decimal places
  75893. */
  75894. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75895. /**
  75896. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75897. */
  75898. get isNonUniform(): boolean;
  75899. /**
  75900. * Gets a new Vector3 from current Vector3 floored values
  75901. * @returns a new Vector3
  75902. */
  75903. floor(): Vector3;
  75904. /**
  75905. * Gets a new Vector3 from current Vector3 floored values
  75906. * @returns a new Vector3
  75907. */
  75908. fract(): Vector3;
  75909. /**
  75910. * Gets the length of the Vector3
  75911. * @returns the length of the Vector3
  75912. */
  75913. length(): number;
  75914. /**
  75915. * Gets the squared length of the Vector3
  75916. * @returns squared length of the Vector3
  75917. */
  75918. lengthSquared(): number;
  75919. /**
  75920. * Normalize the current Vector3.
  75921. * Please note that this is an in place operation.
  75922. * @returns the current updated Vector3
  75923. */
  75924. normalize(): Vector3;
  75925. /**
  75926. * Reorders the x y z properties of the vector in place
  75927. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75928. * @returns the current updated vector
  75929. */
  75930. reorderInPlace(order: string): this;
  75931. /**
  75932. * Rotates the vector around 0,0,0 by a quaternion
  75933. * @param quaternion the rotation quaternion
  75934. * @param result vector to store the result
  75935. * @returns the resulting vector
  75936. */
  75937. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75938. /**
  75939. * Rotates a vector around a given point
  75940. * @param quaternion the rotation quaternion
  75941. * @param point the point to rotate around
  75942. * @param result vector to store the result
  75943. * @returns the resulting vector
  75944. */
  75945. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75946. /**
  75947. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75948. * The cross product is then orthogonal to both current and "other"
  75949. * @param other defines the right operand
  75950. * @returns the cross product
  75951. */
  75952. cross(other: Vector3): Vector3;
  75953. /**
  75954. * Normalize the current Vector3 with the given input length.
  75955. * Please note that this is an in place operation.
  75956. * @param len the length of the vector
  75957. * @returns the current updated Vector3
  75958. */
  75959. normalizeFromLength(len: number): Vector3;
  75960. /**
  75961. * Normalize the current Vector3 to a new vector
  75962. * @returns the new Vector3
  75963. */
  75964. normalizeToNew(): Vector3;
  75965. /**
  75966. * Normalize the current Vector3 to the reference
  75967. * @param reference define the Vector3 to update
  75968. * @returns the updated Vector3
  75969. */
  75970. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75971. /**
  75972. * Creates a new Vector3 copied from the current Vector3
  75973. * @returns the new Vector3
  75974. */
  75975. clone(): Vector3;
  75976. /**
  75977. * Copies the given vector coordinates to the current Vector3 ones
  75978. * @param source defines the source Vector3
  75979. * @returns the current updated Vector3
  75980. */
  75981. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75982. /**
  75983. * Copies the given floats to the current Vector3 coordinates
  75984. * @param x defines the x coordinate of the operand
  75985. * @param y defines the y coordinate of the operand
  75986. * @param z defines the z coordinate of the operand
  75987. * @returns the current updated Vector3
  75988. */
  75989. copyFromFloats(x: number, y: number, z: number): Vector3;
  75990. /**
  75991. * Copies the given floats to the current Vector3 coordinates
  75992. * @param x defines the x coordinate of the operand
  75993. * @param y defines the y coordinate of the operand
  75994. * @param z defines the z coordinate of the operand
  75995. * @returns the current updated Vector3
  75996. */
  75997. set(x: number, y: number, z: number): Vector3;
  75998. /**
  75999. * Copies the given float to the current Vector3 coordinates
  76000. * @param v defines the x, y and z coordinates of the operand
  76001. * @returns the current updated Vector3
  76002. */
  76003. setAll(v: number): Vector3;
  76004. /**
  76005. * Get the clip factor between two vectors
  76006. * @param vector0 defines the first operand
  76007. * @param vector1 defines the second operand
  76008. * @param axis defines the axis to use
  76009. * @param size defines the size along the axis
  76010. * @returns the clip factor
  76011. */
  76012. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76013. /**
  76014. * Get angle between two vectors
  76015. * @param vector0 angle between vector0 and vector1
  76016. * @param vector1 angle between vector0 and vector1
  76017. * @param normal direction of the normal
  76018. * @return the angle between vector0 and vector1
  76019. */
  76020. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76021. /**
  76022. * Returns a new Vector3 set from the index "offset" of the given array
  76023. * @param array defines the source array
  76024. * @param offset defines the offset in the source array
  76025. * @returns the new Vector3
  76026. */
  76027. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76028. /**
  76029. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76030. * @param array defines the source array
  76031. * @param offset defines the offset in the source array
  76032. * @returns the new Vector3
  76033. * @deprecated Please use FromArray instead.
  76034. */
  76035. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76036. /**
  76037. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76038. * @param array defines the source array
  76039. * @param offset defines the offset in the source array
  76040. * @param result defines the Vector3 where to store the result
  76041. */
  76042. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76043. /**
  76044. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76045. * @param array defines the source array
  76046. * @param offset defines the offset in the source array
  76047. * @param result defines the Vector3 where to store the result
  76048. * @deprecated Please use FromArrayToRef instead.
  76049. */
  76050. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76051. /**
  76052. * Sets the given vector "result" with the given floats.
  76053. * @param x defines the x coordinate of the source
  76054. * @param y defines the y coordinate of the source
  76055. * @param z defines the z coordinate of the source
  76056. * @param result defines the Vector3 where to store the result
  76057. */
  76058. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76059. /**
  76060. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76061. * @returns a new empty Vector3
  76062. */
  76063. static Zero(): Vector3;
  76064. /**
  76065. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76066. * @returns a new unit Vector3
  76067. */
  76068. static One(): Vector3;
  76069. /**
  76070. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76071. * @returns a new up Vector3
  76072. */
  76073. static Up(): Vector3;
  76074. /**
  76075. * Gets a up Vector3 that must not be updated
  76076. */
  76077. static get UpReadOnly(): DeepImmutable<Vector3>;
  76078. /**
  76079. * Gets a zero Vector3 that must not be updated
  76080. */
  76081. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76082. /**
  76083. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76084. * @returns a new down Vector3
  76085. */
  76086. static Down(): Vector3;
  76087. /**
  76088. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76089. * @returns a new forward Vector3
  76090. */
  76091. static Forward(): Vector3;
  76092. /**
  76093. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76094. * @returns a new forward Vector3
  76095. */
  76096. static Backward(): Vector3;
  76097. /**
  76098. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76099. * @returns a new right Vector3
  76100. */
  76101. static Right(): Vector3;
  76102. /**
  76103. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76104. * @returns a new left Vector3
  76105. */
  76106. static Left(): Vector3;
  76107. /**
  76108. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76109. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76110. * @param vector defines the Vector3 to transform
  76111. * @param transformation defines the transformation matrix
  76112. * @returns the transformed Vector3
  76113. */
  76114. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76115. /**
  76116. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76117. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76118. * @param vector defines the Vector3 to transform
  76119. * @param transformation defines the transformation matrix
  76120. * @param result defines the Vector3 where to store the result
  76121. */
  76122. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76123. /**
  76124. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76125. * This method computes tranformed coordinates only, not transformed direction vectors
  76126. * @param x define the x coordinate of the source vector
  76127. * @param y define the y coordinate of the source vector
  76128. * @param z define the z coordinate of the source vector
  76129. * @param transformation defines the transformation matrix
  76130. * @param result defines the Vector3 where to store the result
  76131. */
  76132. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76133. /**
  76134. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76135. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76136. * @param vector defines the Vector3 to transform
  76137. * @param transformation defines the transformation matrix
  76138. * @returns the new Vector3
  76139. */
  76140. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76141. /**
  76142. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76143. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76144. * @param vector defines the Vector3 to transform
  76145. * @param transformation defines the transformation matrix
  76146. * @param result defines the Vector3 where to store the result
  76147. */
  76148. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76149. /**
  76150. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76151. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76152. * @param x define the x coordinate of the source vector
  76153. * @param y define the y coordinate of the source vector
  76154. * @param z define the z coordinate of the source vector
  76155. * @param transformation defines the transformation matrix
  76156. * @param result defines the Vector3 where to store the result
  76157. */
  76158. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76159. /**
  76160. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76161. * @param value1 defines the first control point
  76162. * @param value2 defines the second control point
  76163. * @param value3 defines the third control point
  76164. * @param value4 defines the fourth control point
  76165. * @param amount defines the amount on the spline to use
  76166. * @returns the new Vector3
  76167. */
  76168. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76169. /**
  76170. * 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"
  76171. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76172. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76173. * @param value defines the current value
  76174. * @param min defines the lower range value
  76175. * @param max defines the upper range value
  76176. * @returns the new Vector3
  76177. */
  76178. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76179. /**
  76180. * 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"
  76181. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76182. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76183. * @param value defines the current value
  76184. * @param min defines the lower range value
  76185. * @param max defines the upper range value
  76186. * @param result defines the Vector3 where to store the result
  76187. */
  76188. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76189. /**
  76190. * Checks if a given vector is inside a specific range
  76191. * @param v defines the vector to test
  76192. * @param min defines the minimum range
  76193. * @param max defines the maximum range
  76194. */
  76195. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76196. /**
  76197. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76198. * @param value1 defines the first control point
  76199. * @param tangent1 defines the first tangent vector
  76200. * @param value2 defines the second control point
  76201. * @param tangent2 defines the second tangent vector
  76202. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76203. * @returns the new Vector3
  76204. */
  76205. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76206. /**
  76207. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76208. * @param start defines the start value
  76209. * @param end defines the end value
  76210. * @param amount max defines amount between both (between 0 and 1)
  76211. * @returns the new Vector3
  76212. */
  76213. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76214. /**
  76215. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76216. * @param start defines the start value
  76217. * @param end defines the end value
  76218. * @param amount max defines amount between both (between 0 and 1)
  76219. * @param result defines the Vector3 where to store the result
  76220. */
  76221. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76222. /**
  76223. * Returns the dot product (float) between the vectors "left" and "right"
  76224. * @param left defines the left operand
  76225. * @param right defines the right operand
  76226. * @returns the dot product
  76227. */
  76228. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76229. /**
  76230. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76231. * The cross product is then orthogonal to both "left" and "right"
  76232. * @param left defines the left operand
  76233. * @param right defines the right operand
  76234. * @returns the cross product
  76235. */
  76236. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76237. /**
  76238. * Sets the given vector "result" with the cross product of "left" and "right"
  76239. * The cross product is then orthogonal to both "left" and "right"
  76240. * @param left defines the left operand
  76241. * @param right defines the right operand
  76242. * @param result defines the Vector3 where to store the result
  76243. */
  76244. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76245. /**
  76246. * Returns a new Vector3 as the normalization of the given vector
  76247. * @param vector defines the Vector3 to normalize
  76248. * @returns the new Vector3
  76249. */
  76250. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76251. /**
  76252. * Sets the given vector "result" with the normalization of the given first vector
  76253. * @param vector defines the Vector3 to normalize
  76254. * @param result defines the Vector3 where to store the result
  76255. */
  76256. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76257. /**
  76258. * Project a Vector3 onto screen space
  76259. * @param vector defines the Vector3 to project
  76260. * @param world defines the world matrix to use
  76261. * @param transform defines the transform (view x projection) matrix to use
  76262. * @param viewport defines the screen viewport to use
  76263. * @returns the new Vector3
  76264. */
  76265. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76266. /** @hidden */
  76267. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76268. /**
  76269. * Unproject from screen space to object space
  76270. * @param source defines the screen space Vector3 to use
  76271. * @param viewportWidth defines the current width of the viewport
  76272. * @param viewportHeight defines the current height of the viewport
  76273. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76274. * @param transform defines the transform (view x projection) matrix to use
  76275. * @returns the new Vector3
  76276. */
  76277. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76278. /**
  76279. * Unproject from screen space to object space
  76280. * @param source defines the screen space Vector3 to use
  76281. * @param viewportWidth defines the current width of the viewport
  76282. * @param viewportHeight defines the current height of the viewport
  76283. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76284. * @param view defines the view matrix to use
  76285. * @param projection defines the projection matrix to use
  76286. * @returns the new Vector3
  76287. */
  76288. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76289. /**
  76290. * Unproject from screen space to object space
  76291. * @param source defines the screen space Vector3 to use
  76292. * @param viewportWidth defines the current width of the viewport
  76293. * @param viewportHeight defines the current height of the viewport
  76294. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76295. * @param view defines the view matrix to use
  76296. * @param projection defines the projection matrix to use
  76297. * @param result defines the Vector3 where to store the result
  76298. */
  76299. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76300. /**
  76301. * Unproject from screen space to object space
  76302. * @param sourceX defines the screen space x coordinate to use
  76303. * @param sourceY defines the screen space y coordinate to use
  76304. * @param sourceZ defines the screen space z coordinate to use
  76305. * @param viewportWidth defines the current width of the viewport
  76306. * @param viewportHeight defines the current height of the viewport
  76307. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76308. * @param view defines the view matrix to use
  76309. * @param projection defines the projection matrix to use
  76310. * @param result defines the Vector3 where to store the result
  76311. */
  76312. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76313. /**
  76314. * Gets the minimal coordinate values between two Vector3
  76315. * @param left defines the first operand
  76316. * @param right defines the second operand
  76317. * @returns the new Vector3
  76318. */
  76319. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76320. /**
  76321. * Gets the maximal coordinate values between two Vector3
  76322. * @param left defines the first operand
  76323. * @param right defines the second operand
  76324. * @returns the new Vector3
  76325. */
  76326. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76327. /**
  76328. * Returns the distance between the vectors "value1" and "value2"
  76329. * @param value1 defines the first operand
  76330. * @param value2 defines the second operand
  76331. * @returns the distance
  76332. */
  76333. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76334. /**
  76335. * Returns the squared distance between the vectors "value1" and "value2"
  76336. * @param value1 defines the first operand
  76337. * @param value2 defines the second operand
  76338. * @returns the squared distance
  76339. */
  76340. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76341. /**
  76342. * Returns a new Vector3 located at the center between "value1" and "value2"
  76343. * @param value1 defines the first operand
  76344. * @param value2 defines the second operand
  76345. * @returns the new Vector3
  76346. */
  76347. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76348. /**
  76349. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76350. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76351. * to something in order to rotate it from its local system to the given target system
  76352. * Note: axis1, axis2 and axis3 are normalized during this operation
  76353. * @param axis1 defines the first axis
  76354. * @param axis2 defines the second axis
  76355. * @param axis3 defines the third axis
  76356. * @returns a new Vector3
  76357. */
  76358. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76359. /**
  76360. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76361. * @param axis1 defines the first axis
  76362. * @param axis2 defines the second axis
  76363. * @param axis3 defines the third axis
  76364. * @param ref defines the Vector3 where to store the result
  76365. */
  76366. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76367. }
  76368. /**
  76369. * Vector4 class created for EulerAngle class conversion to Quaternion
  76370. */
  76371. export class Vector4 {
  76372. /** x value of the vector */
  76373. x: number;
  76374. /** y value of the vector */
  76375. y: number;
  76376. /** z value of the vector */
  76377. z: number;
  76378. /** w value of the vector */
  76379. w: number;
  76380. /**
  76381. * Creates a Vector4 object from the given floats.
  76382. * @param x x value of the vector
  76383. * @param y y value of the vector
  76384. * @param z z value of the vector
  76385. * @param w w value of the vector
  76386. */
  76387. constructor(
  76388. /** x value of the vector */
  76389. x: number,
  76390. /** y value of the vector */
  76391. y: number,
  76392. /** z value of the vector */
  76393. z: number,
  76394. /** w value of the vector */
  76395. w: number);
  76396. /**
  76397. * Returns the string with the Vector4 coordinates.
  76398. * @returns a string containing all the vector values
  76399. */
  76400. toString(): string;
  76401. /**
  76402. * Returns the string "Vector4".
  76403. * @returns "Vector4"
  76404. */
  76405. getClassName(): string;
  76406. /**
  76407. * Returns the Vector4 hash code.
  76408. * @returns a unique hash code
  76409. */
  76410. getHashCode(): number;
  76411. /**
  76412. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76413. * @returns the resulting array
  76414. */
  76415. asArray(): number[];
  76416. /**
  76417. * Populates the given array from the given index with the Vector4 coordinates.
  76418. * @param array array to populate
  76419. * @param index index of the array to start at (default: 0)
  76420. * @returns the Vector4.
  76421. */
  76422. toArray(array: FloatArray, index?: number): Vector4;
  76423. /**
  76424. * Adds the given vector to the current Vector4.
  76425. * @param otherVector the vector to add
  76426. * @returns the updated Vector4.
  76427. */
  76428. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76429. /**
  76430. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76431. * @param otherVector the vector to add
  76432. * @returns the resulting vector
  76433. */
  76434. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76435. /**
  76436. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76437. * @param otherVector the vector to add
  76438. * @param result the vector to store the result
  76439. * @returns the current Vector4.
  76440. */
  76441. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76442. /**
  76443. * Subtract in place the given vector from the current Vector4.
  76444. * @param otherVector the vector to subtract
  76445. * @returns the updated Vector4.
  76446. */
  76447. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76448. /**
  76449. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76450. * @param otherVector the vector to add
  76451. * @returns the new vector with the result
  76452. */
  76453. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76454. /**
  76455. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76456. * @param otherVector the vector to subtract
  76457. * @param result the vector to store the result
  76458. * @returns the current Vector4.
  76459. */
  76460. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76461. /**
  76462. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76463. */
  76464. /**
  76465. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76466. * @param x value to subtract
  76467. * @param y value to subtract
  76468. * @param z value to subtract
  76469. * @param w value to subtract
  76470. * @returns new vector containing the result
  76471. */
  76472. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76473. /**
  76474. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76475. * @param x value to subtract
  76476. * @param y value to subtract
  76477. * @param z value to subtract
  76478. * @param w value to subtract
  76479. * @param result the vector to store the result in
  76480. * @returns the current Vector4.
  76481. */
  76482. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76483. /**
  76484. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76485. * @returns a new vector with the negated values
  76486. */
  76487. negate(): Vector4;
  76488. /**
  76489. * Negate this vector in place
  76490. * @returns this
  76491. */
  76492. negateInPlace(): Vector4;
  76493. /**
  76494. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76495. * @param result defines the Vector3 object where to store the result
  76496. * @returns the current Vector4
  76497. */
  76498. negateToRef(result: Vector4): Vector4;
  76499. /**
  76500. * Multiplies the current Vector4 coordinates by scale (float).
  76501. * @param scale the number to scale with
  76502. * @returns the updated Vector4.
  76503. */
  76504. scaleInPlace(scale: number): Vector4;
  76505. /**
  76506. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76507. * @param scale the number to scale with
  76508. * @returns a new vector with the result
  76509. */
  76510. scale(scale: number): Vector4;
  76511. /**
  76512. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76513. * @param scale the number to scale with
  76514. * @param result a vector to store the result in
  76515. * @returns the current Vector4.
  76516. */
  76517. scaleToRef(scale: number, result: Vector4): Vector4;
  76518. /**
  76519. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76520. * @param scale defines the scale factor
  76521. * @param result defines the Vector4 object where to store the result
  76522. * @returns the unmodified current Vector4
  76523. */
  76524. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76525. /**
  76526. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76527. * @param otherVector the vector to compare against
  76528. * @returns true if they are equal
  76529. */
  76530. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76531. /**
  76532. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76533. * @param otherVector vector to compare against
  76534. * @param epsilon (Default: very small number)
  76535. * @returns true if they are equal
  76536. */
  76537. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76538. /**
  76539. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76540. * @param x x value to compare against
  76541. * @param y y value to compare against
  76542. * @param z z value to compare against
  76543. * @param w w value to compare against
  76544. * @returns true if equal
  76545. */
  76546. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76547. /**
  76548. * Multiplies in place the current Vector4 by the given one.
  76549. * @param otherVector vector to multiple with
  76550. * @returns the updated Vector4.
  76551. */
  76552. multiplyInPlace(otherVector: Vector4): Vector4;
  76553. /**
  76554. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76555. * @param otherVector vector to multiple with
  76556. * @returns resulting new vector
  76557. */
  76558. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76559. /**
  76560. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76561. * @param otherVector vector to multiple with
  76562. * @param result vector to store the result
  76563. * @returns the current Vector4.
  76564. */
  76565. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76566. /**
  76567. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76568. * @param x x value multiply with
  76569. * @param y y value multiply with
  76570. * @param z z value multiply with
  76571. * @param w w value multiply with
  76572. * @returns resulting new vector
  76573. */
  76574. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76575. /**
  76576. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76577. * @param otherVector vector to devide with
  76578. * @returns resulting new vector
  76579. */
  76580. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76581. /**
  76582. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76583. * @param otherVector vector to devide with
  76584. * @param result vector to store the result
  76585. * @returns the current Vector4.
  76586. */
  76587. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76588. /**
  76589. * Divides the current Vector3 coordinates by the given ones.
  76590. * @param otherVector vector to devide with
  76591. * @returns the updated Vector3.
  76592. */
  76593. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76594. /**
  76595. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76596. * @param other defines the second operand
  76597. * @returns the current updated Vector4
  76598. */
  76599. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76600. /**
  76601. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76602. * @param other defines the second operand
  76603. * @returns the current updated Vector4
  76604. */
  76605. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76606. /**
  76607. * Gets a new Vector4 from current Vector4 floored values
  76608. * @returns a new Vector4
  76609. */
  76610. floor(): Vector4;
  76611. /**
  76612. * Gets a new Vector4 from current Vector3 floored values
  76613. * @returns a new Vector4
  76614. */
  76615. fract(): Vector4;
  76616. /**
  76617. * Returns the Vector4 length (float).
  76618. * @returns the length
  76619. */
  76620. length(): number;
  76621. /**
  76622. * Returns the Vector4 squared length (float).
  76623. * @returns the length squared
  76624. */
  76625. lengthSquared(): number;
  76626. /**
  76627. * Normalizes in place the Vector4.
  76628. * @returns the updated Vector4.
  76629. */
  76630. normalize(): Vector4;
  76631. /**
  76632. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76633. * @returns this converted to a new vector3
  76634. */
  76635. toVector3(): Vector3;
  76636. /**
  76637. * Returns a new Vector4 copied from the current one.
  76638. * @returns the new cloned vector
  76639. */
  76640. clone(): Vector4;
  76641. /**
  76642. * Updates the current Vector4 with the given one coordinates.
  76643. * @param source the source vector to copy from
  76644. * @returns the updated Vector4.
  76645. */
  76646. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76647. /**
  76648. * Updates the current Vector4 coordinates with the given floats.
  76649. * @param x float to copy from
  76650. * @param y float to copy from
  76651. * @param z float to copy from
  76652. * @param w float to copy from
  76653. * @returns the updated Vector4.
  76654. */
  76655. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76656. /**
  76657. * Updates the current Vector4 coordinates with the given floats.
  76658. * @param x float to set from
  76659. * @param y float to set from
  76660. * @param z float to set from
  76661. * @param w float to set from
  76662. * @returns the updated Vector4.
  76663. */
  76664. set(x: number, y: number, z: number, w: number): Vector4;
  76665. /**
  76666. * Copies the given float to the current Vector3 coordinates
  76667. * @param v defines the x, y, z and w coordinates of the operand
  76668. * @returns the current updated Vector3
  76669. */
  76670. setAll(v: number): Vector4;
  76671. /**
  76672. * Returns a new Vector4 set from the starting index of the given array.
  76673. * @param array the array to pull values from
  76674. * @param offset the offset into the array to start at
  76675. * @returns the new vector
  76676. */
  76677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76678. /**
  76679. * Updates the given vector "result" from the starting index of the given array.
  76680. * @param array the array to pull values from
  76681. * @param offset the offset into the array to start at
  76682. * @param result the vector to store the result in
  76683. */
  76684. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76685. /**
  76686. * Updates the given vector "result" from the starting index of the given Float32Array.
  76687. * @param array the array to pull values from
  76688. * @param offset the offset into the array to start at
  76689. * @param result the vector to store the result in
  76690. */
  76691. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76692. /**
  76693. * Updates the given vector "result" coordinates from the given floats.
  76694. * @param x float to set from
  76695. * @param y float to set from
  76696. * @param z float to set from
  76697. * @param w float to set from
  76698. * @param result the vector to the floats in
  76699. */
  76700. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76701. /**
  76702. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76703. * @returns the new vector
  76704. */
  76705. static Zero(): Vector4;
  76706. /**
  76707. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76708. * @returns the new vector
  76709. */
  76710. static One(): Vector4;
  76711. /**
  76712. * Returns a new normalized Vector4 from the given one.
  76713. * @param vector the vector to normalize
  76714. * @returns the vector
  76715. */
  76716. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76717. /**
  76718. * Updates the given vector "result" from the normalization of the given one.
  76719. * @param vector the vector to normalize
  76720. * @param result the vector to store the result in
  76721. */
  76722. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76723. /**
  76724. * Returns a vector with the minimum values from the left and right vectors
  76725. * @param left left vector to minimize
  76726. * @param right right vector to minimize
  76727. * @returns a new vector with the minimum of the left and right vector values
  76728. */
  76729. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76730. /**
  76731. * Returns a vector with the maximum values from the left and right vectors
  76732. * @param left left vector to maximize
  76733. * @param right right vector to maximize
  76734. * @returns a new vector with the maximum of the left and right vector values
  76735. */
  76736. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76737. /**
  76738. * Returns the distance (float) between the vectors "value1" and "value2".
  76739. * @param value1 value to calulate the distance between
  76740. * @param value2 value to calulate the distance between
  76741. * @return the distance between the two vectors
  76742. */
  76743. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76744. /**
  76745. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76746. * @param value1 value to calulate the distance between
  76747. * @param value2 value to calulate the distance between
  76748. * @return the distance between the two vectors squared
  76749. */
  76750. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76751. /**
  76752. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76753. * @param value1 value to calulate the center between
  76754. * @param value2 value to calulate the center between
  76755. * @return the center between the two vectors
  76756. */
  76757. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76758. /**
  76759. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76760. * This methods computes transformed normalized direction vectors only.
  76761. * @param vector the vector to transform
  76762. * @param transformation the transformation matrix to apply
  76763. * @returns the new vector
  76764. */
  76765. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76766. /**
  76767. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76768. * This methods computes transformed normalized direction vectors only.
  76769. * @param vector the vector to transform
  76770. * @param transformation the transformation matrix to apply
  76771. * @param result the vector to store the result in
  76772. */
  76773. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76774. /**
  76775. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76776. * This methods computes transformed normalized direction vectors only.
  76777. * @param x value to transform
  76778. * @param y value to transform
  76779. * @param z value to transform
  76780. * @param w value to transform
  76781. * @param transformation the transformation matrix to apply
  76782. * @param result the vector to store the results in
  76783. */
  76784. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76785. /**
  76786. * Creates a new Vector4 from a Vector3
  76787. * @param source defines the source data
  76788. * @param w defines the 4th component (default is 0)
  76789. * @returns a new Vector4
  76790. */
  76791. static FromVector3(source: Vector3, w?: number): Vector4;
  76792. }
  76793. /**
  76794. * Class used to store quaternion data
  76795. * @see https://en.wikipedia.org/wiki/Quaternion
  76796. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76797. */
  76798. export class Quaternion {
  76799. /** defines the first component (0 by default) */
  76800. x: number;
  76801. /** defines the second component (0 by default) */
  76802. y: number;
  76803. /** defines the third component (0 by default) */
  76804. z: number;
  76805. /** defines the fourth component (1.0 by default) */
  76806. w: number;
  76807. /**
  76808. * Creates a new Quaternion from the given floats
  76809. * @param x defines the first component (0 by default)
  76810. * @param y defines the second component (0 by default)
  76811. * @param z defines the third component (0 by default)
  76812. * @param w defines the fourth component (1.0 by default)
  76813. */
  76814. constructor(
  76815. /** defines the first component (0 by default) */
  76816. x?: number,
  76817. /** defines the second component (0 by default) */
  76818. y?: number,
  76819. /** defines the third component (0 by default) */
  76820. z?: number,
  76821. /** defines the fourth component (1.0 by default) */
  76822. w?: number);
  76823. /**
  76824. * Gets a string representation for the current quaternion
  76825. * @returns a string with the Quaternion coordinates
  76826. */
  76827. toString(): string;
  76828. /**
  76829. * Gets the class name of the quaternion
  76830. * @returns the string "Quaternion"
  76831. */
  76832. getClassName(): string;
  76833. /**
  76834. * Gets a hash code for this quaternion
  76835. * @returns the quaternion hash code
  76836. */
  76837. getHashCode(): number;
  76838. /**
  76839. * Copy the quaternion to an array
  76840. * @returns a new array populated with 4 elements from the quaternion coordinates
  76841. */
  76842. asArray(): number[];
  76843. /**
  76844. * Check if two quaternions are equals
  76845. * @param otherQuaternion defines the second operand
  76846. * @return true if the current quaternion and the given one coordinates are strictly equals
  76847. */
  76848. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76849. /**
  76850. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76851. * @param otherQuaternion defines the other quaternion
  76852. * @param epsilon defines the minimal distance to consider equality
  76853. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76854. */
  76855. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76856. /**
  76857. * Clone the current quaternion
  76858. * @returns a new quaternion copied from the current one
  76859. */
  76860. clone(): Quaternion;
  76861. /**
  76862. * Copy a quaternion to the current one
  76863. * @param other defines the other quaternion
  76864. * @returns the updated current quaternion
  76865. */
  76866. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76867. /**
  76868. * Updates the current quaternion with the given float coordinates
  76869. * @param x defines the x coordinate
  76870. * @param y defines the y coordinate
  76871. * @param z defines the z coordinate
  76872. * @param w defines the w coordinate
  76873. * @returns the updated current quaternion
  76874. */
  76875. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76876. /**
  76877. * Updates the current quaternion from the given float coordinates
  76878. * @param x defines the x coordinate
  76879. * @param y defines the y coordinate
  76880. * @param z defines the z coordinate
  76881. * @param w defines the w coordinate
  76882. * @returns the updated current quaternion
  76883. */
  76884. set(x: number, y: number, z: number, w: number): Quaternion;
  76885. /**
  76886. * Adds two quaternions
  76887. * @param other defines the second operand
  76888. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76889. */
  76890. add(other: DeepImmutable<Quaternion>): Quaternion;
  76891. /**
  76892. * Add a quaternion to the current one
  76893. * @param other defines the quaternion to add
  76894. * @returns the current quaternion
  76895. */
  76896. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76897. /**
  76898. * Subtract two quaternions
  76899. * @param other defines the second operand
  76900. * @returns a new quaternion as the subtraction result of the given one from the current one
  76901. */
  76902. subtract(other: Quaternion): Quaternion;
  76903. /**
  76904. * Multiplies the current quaternion by a scale factor
  76905. * @param value defines the scale factor
  76906. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76907. */
  76908. scale(value: number): Quaternion;
  76909. /**
  76910. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76911. * @param scale defines the scale factor
  76912. * @param result defines the Quaternion object where to store the result
  76913. * @returns the unmodified current quaternion
  76914. */
  76915. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76916. /**
  76917. * Multiplies in place the current quaternion by a scale factor
  76918. * @param value defines the scale factor
  76919. * @returns the current modified quaternion
  76920. */
  76921. scaleInPlace(value: number): Quaternion;
  76922. /**
  76923. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76924. * @param scale defines the scale factor
  76925. * @param result defines the Quaternion object where to store the result
  76926. * @returns the unmodified current quaternion
  76927. */
  76928. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76929. /**
  76930. * Multiplies two quaternions
  76931. * @param q1 defines the second operand
  76932. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76933. */
  76934. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76935. /**
  76936. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76937. * @param q1 defines the second operand
  76938. * @param result defines the target quaternion
  76939. * @returns the current quaternion
  76940. */
  76941. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76942. /**
  76943. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76944. * @param q1 defines the second operand
  76945. * @returns the currentupdated quaternion
  76946. */
  76947. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76948. /**
  76949. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76950. * @param ref defines the target quaternion
  76951. * @returns the current quaternion
  76952. */
  76953. conjugateToRef(ref: Quaternion): Quaternion;
  76954. /**
  76955. * Conjugates in place (1-q) the current quaternion
  76956. * @returns the current updated quaternion
  76957. */
  76958. conjugateInPlace(): Quaternion;
  76959. /**
  76960. * Conjugates in place (1-q) the current quaternion
  76961. * @returns a new quaternion
  76962. */
  76963. conjugate(): Quaternion;
  76964. /**
  76965. * Gets length of current quaternion
  76966. * @returns the quaternion length (float)
  76967. */
  76968. length(): number;
  76969. /**
  76970. * Normalize in place the current quaternion
  76971. * @returns the current updated quaternion
  76972. */
  76973. normalize(): Quaternion;
  76974. /**
  76975. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76976. * @param order is a reserved parameter and is ignore for now
  76977. * @returns a new Vector3 containing the Euler angles
  76978. */
  76979. toEulerAngles(order?: string): Vector3;
  76980. /**
  76981. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76982. * @param result defines the vector which will be filled with the Euler angles
  76983. * @param order is a reserved parameter and is ignore for now
  76984. * @returns the current unchanged quaternion
  76985. */
  76986. toEulerAnglesToRef(result: Vector3): Quaternion;
  76987. /**
  76988. * Updates the given rotation matrix with the current quaternion values
  76989. * @param result defines the target matrix
  76990. * @returns the current unchanged quaternion
  76991. */
  76992. toRotationMatrix(result: Matrix): Quaternion;
  76993. /**
  76994. * Updates the current quaternion from the given rotation matrix values
  76995. * @param matrix defines the source matrix
  76996. * @returns the current updated quaternion
  76997. */
  76998. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76999. /**
  77000. * Creates a new quaternion from a rotation matrix
  77001. * @param matrix defines the source matrix
  77002. * @returns a new quaternion created from the given rotation matrix values
  77003. */
  77004. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77005. /**
  77006. * Updates the given quaternion with the given rotation matrix values
  77007. * @param matrix defines the source matrix
  77008. * @param result defines the target quaternion
  77009. */
  77010. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77011. /**
  77012. * Returns the dot product (float) between the quaternions "left" and "right"
  77013. * @param left defines the left operand
  77014. * @param right defines the right operand
  77015. * @returns the dot product
  77016. */
  77017. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77018. /**
  77019. * Checks if the two quaternions are close to each other
  77020. * @param quat0 defines the first quaternion to check
  77021. * @param quat1 defines the second quaternion to check
  77022. * @returns true if the two quaternions are close to each other
  77023. */
  77024. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77025. /**
  77026. * Creates an empty quaternion
  77027. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77028. */
  77029. static Zero(): Quaternion;
  77030. /**
  77031. * Inverse a given quaternion
  77032. * @param q defines the source quaternion
  77033. * @returns a new quaternion as the inverted current quaternion
  77034. */
  77035. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77036. /**
  77037. * Inverse a given quaternion
  77038. * @param q defines the source quaternion
  77039. * @param result the quaternion the result will be stored in
  77040. * @returns the result quaternion
  77041. */
  77042. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77043. /**
  77044. * Creates an identity quaternion
  77045. * @returns the identity quaternion
  77046. */
  77047. static Identity(): Quaternion;
  77048. /**
  77049. * Gets a boolean indicating if the given quaternion is identity
  77050. * @param quaternion defines the quaternion to check
  77051. * @returns true if the quaternion is identity
  77052. */
  77053. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77054. /**
  77055. * Creates a quaternion from a rotation around an axis
  77056. * @param axis defines the axis to use
  77057. * @param angle defines the angle to use
  77058. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77059. */
  77060. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77061. /**
  77062. * Creates a rotation around an axis and stores it into the given quaternion
  77063. * @param axis defines the axis to use
  77064. * @param angle defines the angle to use
  77065. * @param result defines the target quaternion
  77066. * @returns the target quaternion
  77067. */
  77068. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77069. /**
  77070. * Creates a new quaternion from data stored into an array
  77071. * @param array defines the data source
  77072. * @param offset defines the offset in the source array where the data starts
  77073. * @returns a new quaternion
  77074. */
  77075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77076. /**
  77077. * Create a quaternion from Euler rotation angles
  77078. * @param x Pitch
  77079. * @param y Yaw
  77080. * @param z Roll
  77081. * @returns the new Quaternion
  77082. */
  77083. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77084. /**
  77085. * Updates a quaternion from Euler rotation angles
  77086. * @param x Pitch
  77087. * @param y Yaw
  77088. * @param z Roll
  77089. * @param result the quaternion to store the result
  77090. * @returns the updated quaternion
  77091. */
  77092. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77093. /**
  77094. * Create a quaternion from Euler rotation vector
  77095. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77096. * @returns the new Quaternion
  77097. */
  77098. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77099. /**
  77100. * Updates a quaternion from Euler rotation vector
  77101. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77102. * @param result the quaternion to store the result
  77103. * @returns the updated quaternion
  77104. */
  77105. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77106. /**
  77107. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77108. * @param yaw defines the rotation around Y axis
  77109. * @param pitch defines the rotation around X axis
  77110. * @param roll defines the rotation around Z axis
  77111. * @returns the new quaternion
  77112. */
  77113. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77114. /**
  77115. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77116. * @param yaw defines the rotation around Y axis
  77117. * @param pitch defines the rotation around X axis
  77118. * @param roll defines the rotation around Z axis
  77119. * @param result defines the target quaternion
  77120. */
  77121. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77122. /**
  77123. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77124. * @param alpha defines the rotation around first axis
  77125. * @param beta defines the rotation around second axis
  77126. * @param gamma defines the rotation around third axis
  77127. * @returns the new quaternion
  77128. */
  77129. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77130. /**
  77131. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77132. * @param alpha defines the rotation around first axis
  77133. * @param beta defines the rotation around second axis
  77134. * @param gamma defines the rotation around third axis
  77135. * @param result defines the target quaternion
  77136. */
  77137. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77138. /**
  77139. * 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)
  77140. * @param axis1 defines the first axis
  77141. * @param axis2 defines the second axis
  77142. * @param axis3 defines the third axis
  77143. * @returns the new quaternion
  77144. */
  77145. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77146. /**
  77147. * 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
  77148. * @param axis1 defines the first axis
  77149. * @param axis2 defines the second axis
  77150. * @param axis3 defines the third axis
  77151. * @param ref defines the target quaternion
  77152. */
  77153. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77154. /**
  77155. * Interpolates between two quaternions
  77156. * @param left defines first quaternion
  77157. * @param right defines second quaternion
  77158. * @param amount defines the gradient to use
  77159. * @returns the new interpolated quaternion
  77160. */
  77161. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77162. /**
  77163. * Interpolates between two quaternions and stores it into a target quaternion
  77164. * @param left defines first quaternion
  77165. * @param right defines second quaternion
  77166. * @param amount defines the gradient to use
  77167. * @param result defines the target quaternion
  77168. */
  77169. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77170. /**
  77171. * Interpolate between two quaternions using Hermite interpolation
  77172. * @param value1 defines first quaternion
  77173. * @param tangent1 defines the incoming tangent
  77174. * @param value2 defines second quaternion
  77175. * @param tangent2 defines the outgoing tangent
  77176. * @param amount defines the target quaternion
  77177. * @returns the new interpolated quaternion
  77178. */
  77179. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77180. }
  77181. /**
  77182. * Class used to store matrix data (4x4)
  77183. */
  77184. export class Matrix {
  77185. private static _updateFlagSeed;
  77186. private static _identityReadOnly;
  77187. private _isIdentity;
  77188. private _isIdentityDirty;
  77189. private _isIdentity3x2;
  77190. private _isIdentity3x2Dirty;
  77191. /**
  77192. * Gets the update flag of the matrix which is an unique number for the matrix.
  77193. * It will be incremented every time the matrix data change.
  77194. * You can use it to speed the comparison between two versions of the same matrix.
  77195. */
  77196. updateFlag: number;
  77197. private readonly _m;
  77198. /**
  77199. * Gets the internal data of the matrix
  77200. */
  77201. get m(): DeepImmutable<Float32Array>;
  77202. /** @hidden */
  77203. _markAsUpdated(): void;
  77204. /** @hidden */
  77205. private _updateIdentityStatus;
  77206. /**
  77207. * Creates an empty matrix (filled with zeros)
  77208. */
  77209. constructor();
  77210. /**
  77211. * Check if the current matrix is identity
  77212. * @returns true is the matrix is the identity matrix
  77213. */
  77214. isIdentity(): boolean;
  77215. /**
  77216. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77217. * @returns true is the matrix is the identity matrix
  77218. */
  77219. isIdentityAs3x2(): boolean;
  77220. /**
  77221. * Gets the determinant of the matrix
  77222. * @returns the matrix determinant
  77223. */
  77224. determinant(): number;
  77225. /**
  77226. * Returns the matrix as a Float32Array
  77227. * @returns the matrix underlying array
  77228. */
  77229. toArray(): DeepImmutable<Float32Array>;
  77230. /**
  77231. * Returns the matrix as a Float32Array
  77232. * @returns the matrix underlying array.
  77233. */
  77234. asArray(): DeepImmutable<Float32Array>;
  77235. /**
  77236. * Inverts the current matrix in place
  77237. * @returns the current inverted matrix
  77238. */
  77239. invert(): Matrix;
  77240. /**
  77241. * Sets all the matrix elements to zero
  77242. * @returns the current matrix
  77243. */
  77244. reset(): Matrix;
  77245. /**
  77246. * Adds the current matrix with a second one
  77247. * @param other defines the matrix to add
  77248. * @returns a new matrix as the addition of the current matrix and the given one
  77249. */
  77250. add(other: DeepImmutable<Matrix>): Matrix;
  77251. /**
  77252. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77253. * @param other defines the matrix to add
  77254. * @param result defines the target matrix
  77255. * @returns the current matrix
  77256. */
  77257. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77258. /**
  77259. * Adds in place the given matrix to the current matrix
  77260. * @param other defines the second operand
  77261. * @returns the current updated matrix
  77262. */
  77263. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77264. /**
  77265. * Sets the given matrix to the current inverted Matrix
  77266. * @param other defines the target matrix
  77267. * @returns the unmodified current matrix
  77268. */
  77269. invertToRef(other: Matrix): Matrix;
  77270. /**
  77271. * add a value at the specified position in the current Matrix
  77272. * @param index the index of the value within the matrix. between 0 and 15.
  77273. * @param value the value to be added
  77274. * @returns the current updated matrix
  77275. */
  77276. addAtIndex(index: number, value: number): Matrix;
  77277. /**
  77278. * mutiply the specified position in the current Matrix by a value
  77279. * @param index the index of the value within the matrix. between 0 and 15.
  77280. * @param value the value to be added
  77281. * @returns the current updated matrix
  77282. */
  77283. multiplyAtIndex(index: number, value: number): Matrix;
  77284. /**
  77285. * Inserts the translation vector (using 3 floats) in the current matrix
  77286. * @param x defines the 1st component of the translation
  77287. * @param y defines the 2nd component of the translation
  77288. * @param z defines the 3rd component of the translation
  77289. * @returns the current updated matrix
  77290. */
  77291. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77292. /**
  77293. * Adds the translation vector (using 3 floats) in the current matrix
  77294. * @param x defines the 1st component of the translation
  77295. * @param y defines the 2nd component of the translation
  77296. * @param z defines the 3rd component of the translation
  77297. * @returns the current updated matrix
  77298. */
  77299. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77300. /**
  77301. * Inserts the translation vector in the current matrix
  77302. * @param vector3 defines the translation to insert
  77303. * @returns the current updated matrix
  77304. */
  77305. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77306. /**
  77307. * Gets the translation value of the current matrix
  77308. * @returns a new Vector3 as the extracted translation from the matrix
  77309. */
  77310. getTranslation(): Vector3;
  77311. /**
  77312. * Fill a Vector3 with the extracted translation from the matrix
  77313. * @param result defines the Vector3 where to store the translation
  77314. * @returns the current matrix
  77315. */
  77316. getTranslationToRef(result: Vector3): Matrix;
  77317. /**
  77318. * Remove rotation and scaling part from the matrix
  77319. * @returns the updated matrix
  77320. */
  77321. removeRotationAndScaling(): Matrix;
  77322. /**
  77323. * Multiply two matrices
  77324. * @param other defines the second operand
  77325. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77326. */
  77327. multiply(other: DeepImmutable<Matrix>): Matrix;
  77328. /**
  77329. * Copy the current matrix from the given one
  77330. * @param other defines the source matrix
  77331. * @returns the current updated matrix
  77332. */
  77333. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77334. /**
  77335. * Populates the given array from the starting index with the current matrix values
  77336. * @param array defines the target array
  77337. * @param offset defines the offset in the target array where to start storing values
  77338. * @returns the current matrix
  77339. */
  77340. copyToArray(array: Float32Array, offset?: number): Matrix;
  77341. /**
  77342. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77343. * @param other defines the second operand
  77344. * @param result defines the matrix where to store the multiplication
  77345. * @returns the current matrix
  77346. */
  77347. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77348. /**
  77349. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77350. * @param other defines the second operand
  77351. * @param result defines the array where to store the multiplication
  77352. * @param offset defines the offset in the target array where to start storing values
  77353. * @returns the current matrix
  77354. */
  77355. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77356. /**
  77357. * Check equality between this matrix and a second one
  77358. * @param value defines the second matrix to compare
  77359. * @returns true is the current matrix and the given one values are strictly equal
  77360. */
  77361. equals(value: DeepImmutable<Matrix>): boolean;
  77362. /**
  77363. * Clone the current matrix
  77364. * @returns a new matrix from the current matrix
  77365. */
  77366. clone(): Matrix;
  77367. /**
  77368. * Returns the name of the current matrix class
  77369. * @returns the string "Matrix"
  77370. */
  77371. getClassName(): string;
  77372. /**
  77373. * Gets the hash code of the current matrix
  77374. * @returns the hash code
  77375. */
  77376. getHashCode(): number;
  77377. /**
  77378. * Decomposes the current Matrix into a translation, rotation and scaling components
  77379. * @param scale defines the scale vector3 given as a reference to update
  77380. * @param rotation defines the rotation quaternion given as a reference to update
  77381. * @param translation defines the translation vector3 given as a reference to update
  77382. * @returns true if operation was successful
  77383. */
  77384. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77385. /**
  77386. * Gets specific row of the matrix
  77387. * @param index defines the number of the row to get
  77388. * @returns the index-th row of the current matrix as a new Vector4
  77389. */
  77390. getRow(index: number): Nullable<Vector4>;
  77391. /**
  77392. * Sets the index-th row of the current matrix to the vector4 values
  77393. * @param index defines the number of the row to set
  77394. * @param row defines the target vector4
  77395. * @returns the updated current matrix
  77396. */
  77397. setRow(index: number, row: Vector4): Matrix;
  77398. /**
  77399. * Compute the transpose of the matrix
  77400. * @returns the new transposed matrix
  77401. */
  77402. transpose(): Matrix;
  77403. /**
  77404. * Compute the transpose of the matrix and store it in a given matrix
  77405. * @param result defines the target matrix
  77406. * @returns the current matrix
  77407. */
  77408. transposeToRef(result: Matrix): Matrix;
  77409. /**
  77410. * Sets the index-th row of the current matrix with the given 4 x float values
  77411. * @param index defines the row index
  77412. * @param x defines the x component to set
  77413. * @param y defines the y component to set
  77414. * @param z defines the z component to set
  77415. * @param w defines the w component to set
  77416. * @returns the updated current matrix
  77417. */
  77418. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77419. /**
  77420. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77421. * @param scale defines the scale factor
  77422. * @returns a new matrix
  77423. */
  77424. scale(scale: number): Matrix;
  77425. /**
  77426. * Scale the current matrix values by a factor to a given result matrix
  77427. * @param scale defines the scale factor
  77428. * @param result defines the matrix to store the result
  77429. * @returns the current matrix
  77430. */
  77431. scaleToRef(scale: number, result: Matrix): Matrix;
  77432. /**
  77433. * Scale the current matrix values by a factor and add the result to a given matrix
  77434. * @param scale defines the scale factor
  77435. * @param result defines the Matrix to store the result
  77436. * @returns the current matrix
  77437. */
  77438. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77439. /**
  77440. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77441. * @param ref matrix to store the result
  77442. */
  77443. toNormalMatrix(ref: Matrix): void;
  77444. /**
  77445. * Gets only rotation part of the current matrix
  77446. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77447. */
  77448. getRotationMatrix(): Matrix;
  77449. /**
  77450. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77451. * @param result defines the target matrix to store data to
  77452. * @returns the current matrix
  77453. */
  77454. getRotationMatrixToRef(result: Matrix): Matrix;
  77455. /**
  77456. * Toggles model matrix from being right handed to left handed in place and vice versa
  77457. */
  77458. toggleModelMatrixHandInPlace(): void;
  77459. /**
  77460. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77461. */
  77462. toggleProjectionMatrixHandInPlace(): void;
  77463. /**
  77464. * Creates a matrix from an array
  77465. * @param array defines the source array
  77466. * @param offset defines an offset in the source array
  77467. * @returns a new Matrix set from the starting index of the given array
  77468. */
  77469. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77470. /**
  77471. * Copy the content of an array into a given matrix
  77472. * @param array defines the source array
  77473. * @param offset defines an offset in the source array
  77474. * @param result defines the target matrix
  77475. */
  77476. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77477. /**
  77478. * Stores an array into a matrix after having multiplied each component by a given factor
  77479. * @param array defines the source array
  77480. * @param offset defines the offset in the source array
  77481. * @param scale defines the scaling factor
  77482. * @param result defines the target matrix
  77483. */
  77484. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77485. /**
  77486. * Gets an identity matrix that must not be updated
  77487. */
  77488. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77489. /**
  77490. * Stores a list of values (16) inside a given matrix
  77491. * @param initialM11 defines 1st value of 1st row
  77492. * @param initialM12 defines 2nd value of 1st row
  77493. * @param initialM13 defines 3rd value of 1st row
  77494. * @param initialM14 defines 4th value of 1st row
  77495. * @param initialM21 defines 1st value of 2nd row
  77496. * @param initialM22 defines 2nd value of 2nd row
  77497. * @param initialM23 defines 3rd value of 2nd row
  77498. * @param initialM24 defines 4th value of 2nd row
  77499. * @param initialM31 defines 1st value of 3rd row
  77500. * @param initialM32 defines 2nd value of 3rd row
  77501. * @param initialM33 defines 3rd value of 3rd row
  77502. * @param initialM34 defines 4th value of 3rd row
  77503. * @param initialM41 defines 1st value of 4th row
  77504. * @param initialM42 defines 2nd value of 4th row
  77505. * @param initialM43 defines 3rd value of 4th row
  77506. * @param initialM44 defines 4th value of 4th row
  77507. * @param result defines the target matrix
  77508. */
  77509. 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;
  77510. /**
  77511. * Creates new matrix from a list of values (16)
  77512. * @param initialM11 defines 1st value of 1st row
  77513. * @param initialM12 defines 2nd value of 1st row
  77514. * @param initialM13 defines 3rd value of 1st row
  77515. * @param initialM14 defines 4th value of 1st row
  77516. * @param initialM21 defines 1st value of 2nd row
  77517. * @param initialM22 defines 2nd value of 2nd row
  77518. * @param initialM23 defines 3rd value of 2nd row
  77519. * @param initialM24 defines 4th value of 2nd row
  77520. * @param initialM31 defines 1st value of 3rd row
  77521. * @param initialM32 defines 2nd value of 3rd row
  77522. * @param initialM33 defines 3rd value of 3rd row
  77523. * @param initialM34 defines 4th value of 3rd row
  77524. * @param initialM41 defines 1st value of 4th row
  77525. * @param initialM42 defines 2nd value of 4th row
  77526. * @param initialM43 defines 3rd value of 4th row
  77527. * @param initialM44 defines 4th value of 4th row
  77528. * @returns the new matrix
  77529. */
  77530. 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;
  77531. /**
  77532. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77533. * @param scale defines the scale vector3
  77534. * @param rotation defines the rotation quaternion
  77535. * @param translation defines the translation vector3
  77536. * @returns a new matrix
  77537. */
  77538. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77539. /**
  77540. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77541. * @param scale defines the scale vector3
  77542. * @param rotation defines the rotation quaternion
  77543. * @param translation defines the translation vector3
  77544. * @param result defines the target matrix
  77545. */
  77546. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77547. /**
  77548. * Creates a new identity matrix
  77549. * @returns a new identity matrix
  77550. */
  77551. static Identity(): Matrix;
  77552. /**
  77553. * Creates a new identity matrix and stores the result in a given matrix
  77554. * @param result defines the target matrix
  77555. */
  77556. static IdentityToRef(result: Matrix): void;
  77557. /**
  77558. * Creates a new zero matrix
  77559. * @returns a new zero matrix
  77560. */
  77561. static Zero(): Matrix;
  77562. /**
  77563. * Creates a new rotation matrix for "angle" radians around the X axis
  77564. * @param angle defines the angle (in radians) to use
  77565. * @return the new matrix
  77566. */
  77567. static RotationX(angle: number): Matrix;
  77568. /**
  77569. * Creates a new matrix as the invert of a given matrix
  77570. * @param source defines the source matrix
  77571. * @returns the new matrix
  77572. */
  77573. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77574. /**
  77575. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77576. * @param angle defines the angle (in radians) to use
  77577. * @param result defines the target matrix
  77578. */
  77579. static RotationXToRef(angle: number, result: Matrix): void;
  77580. /**
  77581. * Creates a new rotation matrix for "angle" radians around the Y axis
  77582. * @param angle defines the angle (in radians) to use
  77583. * @return the new matrix
  77584. */
  77585. static RotationY(angle: number): Matrix;
  77586. /**
  77587. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77588. * @param angle defines the angle (in radians) to use
  77589. * @param result defines the target matrix
  77590. */
  77591. static RotationYToRef(angle: number, result: Matrix): void;
  77592. /**
  77593. * Creates a new rotation matrix for "angle" radians around the Z axis
  77594. * @param angle defines the angle (in radians) to use
  77595. * @return the new matrix
  77596. */
  77597. static RotationZ(angle: number): Matrix;
  77598. /**
  77599. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77600. * @param angle defines the angle (in radians) to use
  77601. * @param result defines the target matrix
  77602. */
  77603. static RotationZToRef(angle: number, result: Matrix): void;
  77604. /**
  77605. * Creates a new rotation matrix for "angle" radians around the given axis
  77606. * @param axis defines the axis to use
  77607. * @param angle defines the angle (in radians) to use
  77608. * @return the new matrix
  77609. */
  77610. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77611. /**
  77612. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77613. * @param axis defines the axis to use
  77614. * @param angle defines the angle (in radians) to use
  77615. * @param result defines the target matrix
  77616. */
  77617. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77618. /**
  77619. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77620. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77621. * @param from defines the vector to align
  77622. * @param to defines the vector to align to
  77623. * @param result defines the target matrix
  77624. */
  77625. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77626. /**
  77627. * Creates a rotation matrix
  77628. * @param yaw defines the yaw angle in radians (Y axis)
  77629. * @param pitch defines the pitch angle in radians (X axis)
  77630. * @param roll defines the roll angle in radians (X axis)
  77631. * @returns the new rotation matrix
  77632. */
  77633. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77634. /**
  77635. * Creates a rotation matrix and stores it in a given matrix
  77636. * @param yaw defines the yaw angle in radians (Y axis)
  77637. * @param pitch defines the pitch angle in radians (X axis)
  77638. * @param roll defines the roll angle in radians (X axis)
  77639. * @param result defines the target matrix
  77640. */
  77641. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77642. /**
  77643. * Creates a scaling matrix
  77644. * @param x defines the scale factor on X axis
  77645. * @param y defines the scale factor on Y axis
  77646. * @param z defines the scale factor on Z axis
  77647. * @returns the new matrix
  77648. */
  77649. static Scaling(x: number, y: number, z: number): Matrix;
  77650. /**
  77651. * Creates a scaling matrix and stores it in a given matrix
  77652. * @param x defines the scale factor on X axis
  77653. * @param y defines the scale factor on Y axis
  77654. * @param z defines the scale factor on Z axis
  77655. * @param result defines the target matrix
  77656. */
  77657. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77658. /**
  77659. * Creates a translation matrix
  77660. * @param x defines the translation on X axis
  77661. * @param y defines the translation on Y axis
  77662. * @param z defines the translationon Z axis
  77663. * @returns the new matrix
  77664. */
  77665. static Translation(x: number, y: number, z: number): Matrix;
  77666. /**
  77667. * Creates a translation matrix and stores it in a given matrix
  77668. * @param x defines the translation on X axis
  77669. * @param y defines the translation on Y axis
  77670. * @param z defines the translationon Z axis
  77671. * @param result defines the target matrix
  77672. */
  77673. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77674. /**
  77675. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77676. * @param startValue defines the start value
  77677. * @param endValue defines the end value
  77678. * @param gradient defines the gradient factor
  77679. * @returns the new matrix
  77680. */
  77681. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77682. /**
  77683. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77684. * @param startValue defines the start value
  77685. * @param endValue defines the end value
  77686. * @param gradient defines the gradient factor
  77687. * @param result defines the Matrix object where to store data
  77688. */
  77689. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77690. /**
  77691. * Builds a new matrix whose values are computed by:
  77692. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77693. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77694. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77695. * @param startValue defines the first matrix
  77696. * @param endValue defines the second matrix
  77697. * @param gradient defines the gradient between the two matrices
  77698. * @returns the new matrix
  77699. */
  77700. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77701. /**
  77702. * Update a matrix to values which are computed by:
  77703. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77704. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77705. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77706. * @param startValue defines the first matrix
  77707. * @param endValue defines the second matrix
  77708. * @param gradient defines the gradient between the two matrices
  77709. * @param result defines the target matrix
  77710. */
  77711. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77712. /**
  77713. * 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"
  77714. * This function works in left handed mode
  77715. * @param eye defines the final position of the entity
  77716. * @param target defines where the entity should look at
  77717. * @param up defines the up vector for the entity
  77718. * @returns the new matrix
  77719. */
  77720. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77721. /**
  77722. * 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".
  77723. * This function works in left handed mode
  77724. * @param eye defines the final position of the entity
  77725. * @param target defines where the entity should look at
  77726. * @param up defines the up vector for the entity
  77727. * @param result defines the target matrix
  77728. */
  77729. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77730. /**
  77731. * 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"
  77732. * This function works in right handed mode
  77733. * @param eye defines the final position of the entity
  77734. * @param target defines where the entity should look at
  77735. * @param up defines the up vector for the entity
  77736. * @returns the new matrix
  77737. */
  77738. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77739. /**
  77740. * 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".
  77741. * This function works in right handed mode
  77742. * @param eye defines the final position of the entity
  77743. * @param target defines where the entity should look at
  77744. * @param up defines the up vector for the entity
  77745. * @param result defines the target matrix
  77746. */
  77747. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77748. /**
  77749. * Create a left-handed orthographic projection matrix
  77750. * @param width defines the viewport width
  77751. * @param height defines the viewport height
  77752. * @param znear defines the near clip plane
  77753. * @param zfar defines the far clip plane
  77754. * @returns a new matrix as a left-handed orthographic projection matrix
  77755. */
  77756. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77757. /**
  77758. * Store a left-handed orthographic projection to a given matrix
  77759. * @param width defines the viewport width
  77760. * @param height defines the viewport height
  77761. * @param znear defines the near clip plane
  77762. * @param zfar defines the far clip plane
  77763. * @param result defines the target matrix
  77764. */
  77765. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77766. /**
  77767. * Create a left-handed orthographic projection matrix
  77768. * @param left defines the viewport left coordinate
  77769. * @param right defines the viewport right coordinate
  77770. * @param bottom defines the viewport bottom coordinate
  77771. * @param top defines the viewport top coordinate
  77772. * @param znear defines the near clip plane
  77773. * @param zfar defines the far clip plane
  77774. * @returns a new matrix as a left-handed orthographic projection matrix
  77775. */
  77776. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77777. /**
  77778. * Stores a left-handed orthographic projection into a given matrix
  77779. * @param left defines the viewport left coordinate
  77780. * @param right defines the viewport right coordinate
  77781. * @param bottom defines the viewport bottom coordinate
  77782. * @param top defines the viewport top coordinate
  77783. * @param znear defines the near clip plane
  77784. * @param zfar defines the far clip plane
  77785. * @param result defines the target matrix
  77786. */
  77787. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77788. /**
  77789. * Creates a right-handed orthographic projection matrix
  77790. * @param left defines the viewport left coordinate
  77791. * @param right defines the viewport right coordinate
  77792. * @param bottom defines the viewport bottom coordinate
  77793. * @param top defines the viewport top coordinate
  77794. * @param znear defines the near clip plane
  77795. * @param zfar defines the far clip plane
  77796. * @returns a new matrix as a right-handed orthographic projection matrix
  77797. */
  77798. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77799. /**
  77800. * Stores a right-handed orthographic projection into a given matrix
  77801. * @param left defines the viewport left coordinate
  77802. * @param right defines the viewport right coordinate
  77803. * @param bottom defines the viewport bottom coordinate
  77804. * @param top defines the viewport top coordinate
  77805. * @param znear defines the near clip plane
  77806. * @param zfar defines the far clip plane
  77807. * @param result defines the target matrix
  77808. */
  77809. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77810. /**
  77811. * Creates a left-handed perspective projection matrix
  77812. * @param width defines the viewport width
  77813. * @param height defines the viewport height
  77814. * @param znear defines the near clip plane
  77815. * @param zfar defines the far clip plane
  77816. * @returns a new matrix as a left-handed perspective projection matrix
  77817. */
  77818. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77819. /**
  77820. * Creates a left-handed perspective projection matrix
  77821. * @param fov defines the horizontal field of view
  77822. * @param aspect defines the aspect ratio
  77823. * @param znear defines the near clip plane
  77824. * @param zfar defines the far clip plane
  77825. * @returns a new matrix as a left-handed perspective projection matrix
  77826. */
  77827. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77828. /**
  77829. * Stores a left-handed perspective projection into a given matrix
  77830. * @param fov defines the horizontal field of view
  77831. * @param aspect defines the aspect ratio
  77832. * @param znear defines the near clip plane
  77833. * @param zfar defines the far clip plane
  77834. * @param result defines the target matrix
  77835. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77836. */
  77837. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77838. /**
  77839. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77840. * @param fov defines the horizontal field of view
  77841. * @param aspect defines the aspect ratio
  77842. * @param znear defines the near clip plane
  77843. * @param zfar not used as infinity is used as far clip
  77844. * @param result defines the target matrix
  77845. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77846. */
  77847. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77848. /**
  77849. * Creates a right-handed perspective projection matrix
  77850. * @param fov defines the horizontal field of view
  77851. * @param aspect defines the aspect ratio
  77852. * @param znear defines the near clip plane
  77853. * @param zfar defines the far clip plane
  77854. * @returns a new matrix as a right-handed perspective projection matrix
  77855. */
  77856. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77857. /**
  77858. * Stores a right-handed perspective projection into a given matrix
  77859. * @param fov defines the horizontal field of view
  77860. * @param aspect defines the aspect ratio
  77861. * @param znear defines the near clip plane
  77862. * @param zfar defines the far clip plane
  77863. * @param result defines the target matrix
  77864. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77865. */
  77866. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77867. /**
  77868. * Stores a right-handed perspective projection into a given matrix
  77869. * @param fov defines the horizontal field of view
  77870. * @param aspect defines the aspect ratio
  77871. * @param znear defines the near clip plane
  77872. * @param zfar not used as infinity is used as far clip
  77873. * @param result defines the target matrix
  77874. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77875. */
  77876. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77877. /**
  77878. * Stores a perspective projection for WebVR info a given matrix
  77879. * @param fov defines the field of view
  77880. * @param znear defines the near clip plane
  77881. * @param zfar defines the far clip plane
  77882. * @param result defines the target matrix
  77883. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77884. */
  77885. static PerspectiveFovWebVRToRef(fov: {
  77886. upDegrees: number;
  77887. downDegrees: number;
  77888. leftDegrees: number;
  77889. rightDegrees: number;
  77890. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77891. /**
  77892. * Computes a complete transformation matrix
  77893. * @param viewport defines the viewport to use
  77894. * @param world defines the world matrix
  77895. * @param view defines the view matrix
  77896. * @param projection defines the projection matrix
  77897. * @param zmin defines the near clip plane
  77898. * @param zmax defines the far clip plane
  77899. * @returns the transformation matrix
  77900. */
  77901. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77902. /**
  77903. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77904. * @param matrix defines the matrix to use
  77905. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77906. */
  77907. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77908. /**
  77909. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77910. * @param matrix defines the matrix to use
  77911. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77912. */
  77913. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77914. /**
  77915. * Compute the transpose of a given matrix
  77916. * @param matrix defines the matrix to transpose
  77917. * @returns the new matrix
  77918. */
  77919. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77920. /**
  77921. * Compute the transpose of a matrix and store it in a target matrix
  77922. * @param matrix defines the matrix to transpose
  77923. * @param result defines the target matrix
  77924. */
  77925. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77926. /**
  77927. * Computes a reflection matrix from a plane
  77928. * @param plane defines the reflection plane
  77929. * @returns a new matrix
  77930. */
  77931. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77932. /**
  77933. * Computes a reflection matrix from a plane
  77934. * @param plane defines the reflection plane
  77935. * @param result defines the target matrix
  77936. */
  77937. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77938. /**
  77939. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77940. * @param xaxis defines the value of the 1st axis
  77941. * @param yaxis defines the value of the 2nd axis
  77942. * @param zaxis defines the value of the 3rd axis
  77943. * @param result defines the target matrix
  77944. */
  77945. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77946. /**
  77947. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77948. * @param quat defines the quaternion to use
  77949. * @param result defines the target matrix
  77950. */
  77951. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77952. }
  77953. /**
  77954. * @hidden
  77955. */
  77956. export class TmpVectors {
  77957. static Vector2: Vector2[];
  77958. static Vector3: Vector3[];
  77959. static Vector4: Vector4[];
  77960. static Quaternion: Quaternion[];
  77961. static Matrix: Matrix[];
  77962. }
  77963. }
  77964. declare module BABYLON {
  77965. /**
  77966. * Defines potential orientation for back face culling
  77967. */
  77968. export enum Orientation {
  77969. /**
  77970. * Clockwise
  77971. */
  77972. CW = 0,
  77973. /** Counter clockwise */
  77974. CCW = 1
  77975. }
  77976. /** Class used to represent a Bezier curve */
  77977. export class BezierCurve {
  77978. /**
  77979. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77980. * @param t defines the time
  77981. * @param x1 defines the left coordinate on X axis
  77982. * @param y1 defines the left coordinate on Y axis
  77983. * @param x2 defines the right coordinate on X axis
  77984. * @param y2 defines the right coordinate on Y axis
  77985. * @returns the interpolated value
  77986. */
  77987. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77988. }
  77989. /**
  77990. * Defines angle representation
  77991. */
  77992. export class Angle {
  77993. private _radians;
  77994. /**
  77995. * Creates an Angle object of "radians" radians (float).
  77996. * @param radians the angle in radians
  77997. */
  77998. constructor(radians: number);
  77999. /**
  78000. * Get value in degrees
  78001. * @returns the Angle value in degrees (float)
  78002. */
  78003. degrees(): number;
  78004. /**
  78005. * Get value in radians
  78006. * @returns the Angle value in radians (float)
  78007. */
  78008. radians(): number;
  78009. /**
  78010. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78011. * @param a defines first vector
  78012. * @param b defines second vector
  78013. * @returns a new Angle
  78014. */
  78015. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78016. /**
  78017. * Gets a new Angle object from the given float in radians
  78018. * @param radians defines the angle value in radians
  78019. * @returns a new Angle
  78020. */
  78021. static FromRadians(radians: number): Angle;
  78022. /**
  78023. * Gets a new Angle object from the given float in degrees
  78024. * @param degrees defines the angle value in degrees
  78025. * @returns a new Angle
  78026. */
  78027. static FromDegrees(degrees: number): Angle;
  78028. }
  78029. /**
  78030. * This represents an arc in a 2d space.
  78031. */
  78032. export class Arc2 {
  78033. /** Defines the start point of the arc */
  78034. startPoint: Vector2;
  78035. /** Defines the mid point of the arc */
  78036. midPoint: Vector2;
  78037. /** Defines the end point of the arc */
  78038. endPoint: Vector2;
  78039. /**
  78040. * Defines the center point of the arc.
  78041. */
  78042. centerPoint: Vector2;
  78043. /**
  78044. * Defines the radius of the arc.
  78045. */
  78046. radius: number;
  78047. /**
  78048. * Defines the angle of the arc (from mid point to end point).
  78049. */
  78050. angle: Angle;
  78051. /**
  78052. * Defines the start angle of the arc (from start point to middle point).
  78053. */
  78054. startAngle: Angle;
  78055. /**
  78056. * Defines the orientation of the arc (clock wise/counter clock wise).
  78057. */
  78058. orientation: Orientation;
  78059. /**
  78060. * Creates an Arc object from the three given points : start, middle and end.
  78061. * @param startPoint Defines the start point of the arc
  78062. * @param midPoint Defines the midlle point of the arc
  78063. * @param endPoint Defines the end point of the arc
  78064. */
  78065. constructor(
  78066. /** Defines the start point of the arc */
  78067. startPoint: Vector2,
  78068. /** Defines the mid point of the arc */
  78069. midPoint: Vector2,
  78070. /** Defines the end point of the arc */
  78071. endPoint: Vector2);
  78072. }
  78073. /**
  78074. * Represents a 2D path made up of multiple 2D points
  78075. */
  78076. export class Path2 {
  78077. private _points;
  78078. private _length;
  78079. /**
  78080. * If the path start and end point are the same
  78081. */
  78082. closed: boolean;
  78083. /**
  78084. * Creates a Path2 object from the starting 2D coordinates x and y.
  78085. * @param x the starting points x value
  78086. * @param y the starting points y value
  78087. */
  78088. constructor(x: number, y: number);
  78089. /**
  78090. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78091. * @param x the added points x value
  78092. * @param y the added points y value
  78093. * @returns the updated Path2.
  78094. */
  78095. addLineTo(x: number, y: number): Path2;
  78096. /**
  78097. * 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.
  78098. * @param midX middle point x value
  78099. * @param midY middle point y value
  78100. * @param endX end point x value
  78101. * @param endY end point y value
  78102. * @param numberOfSegments (default: 36)
  78103. * @returns the updated Path2.
  78104. */
  78105. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78106. /**
  78107. * Closes the Path2.
  78108. * @returns the Path2.
  78109. */
  78110. close(): Path2;
  78111. /**
  78112. * Gets the sum of the distance between each sequential point in the path
  78113. * @returns the Path2 total length (float).
  78114. */
  78115. length(): number;
  78116. /**
  78117. * Gets the points which construct the path
  78118. * @returns the Path2 internal array of points.
  78119. */
  78120. getPoints(): Vector2[];
  78121. /**
  78122. * Retreives the point at the distance aways from the starting point
  78123. * @param normalizedLengthPosition the length along the path to retreive the point from
  78124. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78125. */
  78126. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78127. /**
  78128. * Creates a new path starting from an x and y position
  78129. * @param x starting x value
  78130. * @param y starting y value
  78131. * @returns a new Path2 starting at the coordinates (x, y).
  78132. */
  78133. static StartingAt(x: number, y: number): Path2;
  78134. }
  78135. /**
  78136. * Represents a 3D path made up of multiple 3D points
  78137. */
  78138. export class Path3D {
  78139. /**
  78140. * an array of Vector3, the curve axis of the Path3D
  78141. */
  78142. path: Vector3[];
  78143. private _curve;
  78144. private _distances;
  78145. private _tangents;
  78146. private _normals;
  78147. private _binormals;
  78148. private _raw;
  78149. private _alignTangentsWithPath;
  78150. private readonly _pointAtData;
  78151. /**
  78152. * new Path3D(path, normal, raw)
  78153. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78154. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78155. * @param path an array of Vector3, the curve axis of the Path3D
  78156. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78157. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78158. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78159. */
  78160. constructor(
  78161. /**
  78162. * an array of Vector3, the curve axis of the Path3D
  78163. */
  78164. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78165. /**
  78166. * Returns the Path3D array of successive Vector3 designing its curve.
  78167. * @returns the Path3D array of successive Vector3 designing its curve.
  78168. */
  78169. getCurve(): Vector3[];
  78170. /**
  78171. * Returns the Path3D array of successive Vector3 designing its curve.
  78172. * @returns the Path3D array of successive Vector3 designing its curve.
  78173. */
  78174. getPoints(): Vector3[];
  78175. /**
  78176. * @returns the computed length (float) of the path.
  78177. */
  78178. length(): number;
  78179. /**
  78180. * Returns an array populated with tangent vectors on each Path3D curve point.
  78181. * @returns an array populated with tangent vectors on each Path3D curve point.
  78182. */
  78183. getTangents(): Vector3[];
  78184. /**
  78185. * Returns an array populated with normal vectors on each Path3D curve point.
  78186. * @returns an array populated with normal vectors on each Path3D curve point.
  78187. */
  78188. getNormals(): Vector3[];
  78189. /**
  78190. * Returns an array populated with binormal vectors on each Path3D curve point.
  78191. * @returns an array populated with binormal vectors on each Path3D curve point.
  78192. */
  78193. getBinormals(): Vector3[];
  78194. /**
  78195. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78196. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78197. */
  78198. getDistances(): number[];
  78199. /**
  78200. * Returns an interpolated point along this path
  78201. * @param position the position of the point along this path, from 0.0 to 1.0
  78202. * @returns a new Vector3 as the point
  78203. */
  78204. getPointAt(position: number): Vector3;
  78205. /**
  78206. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78207. * @param position the position of the point along this path, from 0.0 to 1.0
  78208. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78209. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78210. */
  78211. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78212. /**
  78213. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78214. * @param position the position of the point along this path, from 0.0 to 1.0
  78215. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78216. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78217. */
  78218. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78219. /**
  78220. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78221. * @param position the position of the point along this path, from 0.0 to 1.0
  78222. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78223. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78224. */
  78225. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78226. /**
  78227. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78228. * @param position the position of the point along this path, from 0.0 to 1.0
  78229. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78230. */
  78231. getDistanceAt(position: number): number;
  78232. /**
  78233. * Returns the array index of the previous point of an interpolated point along this path
  78234. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78235. * @returns the array index
  78236. */
  78237. getPreviousPointIndexAt(position: number): number;
  78238. /**
  78239. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  78240. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78241. * @returns the sub position
  78242. */
  78243. getSubPositionAt(position: number): number;
  78244. /**
  78245. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78246. * @param target the vector of which to get the closest position to
  78247. * @returns the position of the closest virtual point on this path to the target vector
  78248. */
  78249. getClosestPositionTo(target: Vector3): number;
  78250. /**
  78251. * Returns a sub path (slice) of this path
  78252. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  78253. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  78254. * @returns a sub path (slice) of this path
  78255. */
  78256. slice(start?: number, end?: number): Path3D;
  78257. /**
  78258. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78259. * @param path path which all values are copied into the curves points
  78260. * @param firstNormal which should be projected onto the curve
  78261. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78262. * @returns the same object updated.
  78263. */
  78264. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78265. private _compute;
  78266. private _getFirstNonNullVector;
  78267. private _getLastNonNullVector;
  78268. private _normalVector;
  78269. /**
  78270. * Updates the point at data for an interpolated point along this curve
  78271. * @param position the position of the point along this curve, from 0.0 to 1.0
  78272. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78273. * @returns the (updated) point at data
  78274. */
  78275. private _updatePointAtData;
  78276. /**
  78277. * Updates the point at data from the specified parameters
  78278. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78279. * @param point the interpolated point
  78280. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78281. */
  78282. private _setPointAtData;
  78283. /**
  78284. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78285. */
  78286. private _updateInterpolationMatrix;
  78287. }
  78288. /**
  78289. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78290. * A Curve3 is designed from a series of successive Vector3.
  78291. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78292. */
  78293. export class Curve3 {
  78294. private _points;
  78295. private _length;
  78296. /**
  78297. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78298. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78299. * @param v1 (Vector3) the control point
  78300. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78301. * @param nbPoints (integer) the wanted number of points in the curve
  78302. * @returns the created Curve3
  78303. */
  78304. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78305. /**
  78306. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78307. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78308. * @param v1 (Vector3) the first control point
  78309. * @param v2 (Vector3) the second control point
  78310. * @param v3 (Vector3) the end point of the Cubic Bezier
  78311. * @param nbPoints (integer) the wanted number of points in the curve
  78312. * @returns the created Curve3
  78313. */
  78314. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78315. /**
  78316. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78317. * @param p1 (Vector3) the origin point of the Hermite Spline
  78318. * @param t1 (Vector3) the tangent vector at the origin point
  78319. * @param p2 (Vector3) the end point of the Hermite Spline
  78320. * @param t2 (Vector3) the tangent vector at the end point
  78321. * @param nbPoints (integer) the wanted number of points in the curve
  78322. * @returns the created Curve3
  78323. */
  78324. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78325. /**
  78326. * Returns a Curve3 object along a CatmullRom Spline curve :
  78327. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78328. * @param nbPoints (integer) the wanted number of points between each curve control points
  78329. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78330. * @returns the created Curve3
  78331. */
  78332. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78333. /**
  78334. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78335. * A Curve3 is designed from a series of successive Vector3.
  78336. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78337. * @param points points which make up the curve
  78338. */
  78339. constructor(points: Vector3[]);
  78340. /**
  78341. * @returns the Curve3 stored array of successive Vector3
  78342. */
  78343. getPoints(): Vector3[];
  78344. /**
  78345. * @returns the computed length (float) of the curve.
  78346. */
  78347. length(): number;
  78348. /**
  78349. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78350. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78351. * curveA and curveB keep unchanged.
  78352. * @param curve the curve to continue from this curve
  78353. * @returns the newly constructed curve
  78354. */
  78355. continue(curve: DeepImmutable<Curve3>): Curve3;
  78356. private _computeLength;
  78357. }
  78358. }
  78359. declare module BABYLON {
  78360. /**
  78361. * This represents the main contract an easing function should follow.
  78362. * Easing functions are used throughout the animation system.
  78363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78364. */
  78365. export interface IEasingFunction {
  78366. /**
  78367. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78368. * of the easing function.
  78369. * The link below provides some of the most common examples of easing functions.
  78370. * @see https://easings.net/
  78371. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78372. * @returns the corresponding value on the curve defined by the easing function
  78373. */
  78374. ease(gradient: number): number;
  78375. }
  78376. /**
  78377. * Base class used for every default easing function.
  78378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78379. */
  78380. export class EasingFunction implements IEasingFunction {
  78381. /**
  78382. * Interpolation follows the mathematical formula associated with the easing function.
  78383. */
  78384. static readonly EASINGMODE_EASEIN: number;
  78385. /**
  78386. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78387. */
  78388. static readonly EASINGMODE_EASEOUT: number;
  78389. /**
  78390. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78391. */
  78392. static readonly EASINGMODE_EASEINOUT: number;
  78393. private _easingMode;
  78394. /**
  78395. * Sets the easing mode of the current function.
  78396. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78397. */
  78398. setEasingMode(easingMode: number): void;
  78399. /**
  78400. * Gets the current easing mode.
  78401. * @returns the easing mode
  78402. */
  78403. getEasingMode(): number;
  78404. /**
  78405. * @hidden
  78406. */
  78407. easeInCore(gradient: number): number;
  78408. /**
  78409. * Given an input gradient between 0 and 1, this returns the corresponding value
  78410. * of the easing function.
  78411. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78412. * @returns the corresponding value on the curve defined by the easing function
  78413. */
  78414. ease(gradient: number): number;
  78415. }
  78416. /**
  78417. * Easing function with a circle shape (see link below).
  78418. * @see https://easings.net/#easeInCirc
  78419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78420. */
  78421. export class CircleEase extends EasingFunction implements IEasingFunction {
  78422. /** @hidden */
  78423. easeInCore(gradient: number): number;
  78424. }
  78425. /**
  78426. * Easing function with a ease back shape (see link below).
  78427. * @see https://easings.net/#easeInBack
  78428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78429. */
  78430. export class BackEase extends EasingFunction implements IEasingFunction {
  78431. /** Defines the amplitude of the function */
  78432. amplitude: number;
  78433. /**
  78434. * Instantiates a back ease easing
  78435. * @see https://easings.net/#easeInBack
  78436. * @param amplitude Defines the amplitude of the function
  78437. */
  78438. constructor(
  78439. /** Defines the amplitude of the function */
  78440. amplitude?: number);
  78441. /** @hidden */
  78442. easeInCore(gradient: number): number;
  78443. }
  78444. /**
  78445. * Easing function with a bouncing shape (see link below).
  78446. * @see https://easings.net/#easeInBounce
  78447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78448. */
  78449. export class BounceEase extends EasingFunction implements IEasingFunction {
  78450. /** Defines the number of bounces */
  78451. bounces: number;
  78452. /** Defines the amplitude of the bounce */
  78453. bounciness: number;
  78454. /**
  78455. * Instantiates a bounce easing
  78456. * @see https://easings.net/#easeInBounce
  78457. * @param bounces Defines the number of bounces
  78458. * @param bounciness Defines the amplitude of the bounce
  78459. */
  78460. constructor(
  78461. /** Defines the number of bounces */
  78462. bounces?: number,
  78463. /** Defines the amplitude of the bounce */
  78464. bounciness?: number);
  78465. /** @hidden */
  78466. easeInCore(gradient: number): number;
  78467. }
  78468. /**
  78469. * Easing function with a power of 3 shape (see link below).
  78470. * @see https://easings.net/#easeInCubic
  78471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78472. */
  78473. export class CubicEase extends EasingFunction implements IEasingFunction {
  78474. /** @hidden */
  78475. easeInCore(gradient: number): number;
  78476. }
  78477. /**
  78478. * Easing function with an elastic shape (see link below).
  78479. * @see https://easings.net/#easeInElastic
  78480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78481. */
  78482. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78483. /** Defines the number of oscillations*/
  78484. oscillations: number;
  78485. /** Defines the amplitude of the oscillations*/
  78486. springiness: number;
  78487. /**
  78488. * Instantiates an elastic easing function
  78489. * @see https://easings.net/#easeInElastic
  78490. * @param oscillations Defines the number of oscillations
  78491. * @param springiness Defines the amplitude of the oscillations
  78492. */
  78493. constructor(
  78494. /** Defines the number of oscillations*/
  78495. oscillations?: number,
  78496. /** Defines the amplitude of the oscillations*/
  78497. springiness?: number);
  78498. /** @hidden */
  78499. easeInCore(gradient: number): number;
  78500. }
  78501. /**
  78502. * Easing function with an exponential shape (see link below).
  78503. * @see https://easings.net/#easeInExpo
  78504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78505. */
  78506. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78507. /** Defines the exponent of the function */
  78508. exponent: number;
  78509. /**
  78510. * Instantiates an exponential easing function
  78511. * @see https://easings.net/#easeInExpo
  78512. * @param exponent Defines the exponent of the function
  78513. */
  78514. constructor(
  78515. /** Defines the exponent of the function */
  78516. exponent?: number);
  78517. /** @hidden */
  78518. easeInCore(gradient: number): number;
  78519. }
  78520. /**
  78521. * Easing function with a power shape (see link below).
  78522. * @see https://easings.net/#easeInQuad
  78523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78524. */
  78525. export class PowerEase extends EasingFunction implements IEasingFunction {
  78526. /** Defines the power of the function */
  78527. power: number;
  78528. /**
  78529. * Instantiates an power base easing function
  78530. * @see https://easings.net/#easeInQuad
  78531. * @param power Defines the power of the function
  78532. */
  78533. constructor(
  78534. /** Defines the power of the function */
  78535. power?: number);
  78536. /** @hidden */
  78537. easeInCore(gradient: number): number;
  78538. }
  78539. /**
  78540. * Easing function with a power of 2 shape (see link below).
  78541. * @see https://easings.net/#easeInQuad
  78542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78543. */
  78544. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78545. /** @hidden */
  78546. easeInCore(gradient: number): number;
  78547. }
  78548. /**
  78549. * Easing function with a power of 4 shape (see link below).
  78550. * @see https://easings.net/#easeInQuart
  78551. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78552. */
  78553. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78554. /** @hidden */
  78555. easeInCore(gradient: number): number;
  78556. }
  78557. /**
  78558. * Easing function with a power of 5 shape (see link below).
  78559. * @see https://easings.net/#easeInQuint
  78560. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78561. */
  78562. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78563. /** @hidden */
  78564. easeInCore(gradient: number): number;
  78565. }
  78566. /**
  78567. * Easing function with a sin shape (see link below).
  78568. * @see https://easings.net/#easeInSine
  78569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78570. */
  78571. export class SineEase extends EasingFunction implements IEasingFunction {
  78572. /** @hidden */
  78573. easeInCore(gradient: number): number;
  78574. }
  78575. /**
  78576. * Easing function with a bezier shape (see link below).
  78577. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78579. */
  78580. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78581. /** Defines the x component of the start tangent in the bezier curve */
  78582. x1: number;
  78583. /** Defines the y component of the start tangent in the bezier curve */
  78584. y1: number;
  78585. /** Defines the x component of the end tangent in the bezier curve */
  78586. x2: number;
  78587. /** Defines the y component of the end tangent in the bezier curve */
  78588. y2: number;
  78589. /**
  78590. * Instantiates a bezier function
  78591. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78592. * @param x1 Defines the x component of the start tangent in the bezier curve
  78593. * @param y1 Defines the y component of the start tangent in the bezier curve
  78594. * @param x2 Defines the x component of the end tangent in the bezier curve
  78595. * @param y2 Defines the y component of the end tangent in the bezier curve
  78596. */
  78597. constructor(
  78598. /** Defines the x component of the start tangent in the bezier curve */
  78599. x1?: number,
  78600. /** Defines the y component of the start tangent in the bezier curve */
  78601. y1?: number,
  78602. /** Defines the x component of the end tangent in the bezier curve */
  78603. x2?: number,
  78604. /** Defines the y component of the end tangent in the bezier curve */
  78605. y2?: number);
  78606. /** @hidden */
  78607. easeInCore(gradient: number): number;
  78608. }
  78609. }
  78610. declare module BABYLON {
  78611. /**
  78612. * Class used to hold a RBG color
  78613. */
  78614. export class Color3 {
  78615. /**
  78616. * Defines the red component (between 0 and 1, default is 0)
  78617. */
  78618. r: number;
  78619. /**
  78620. * Defines the green component (between 0 and 1, default is 0)
  78621. */
  78622. g: number;
  78623. /**
  78624. * Defines the blue component (between 0 and 1, default is 0)
  78625. */
  78626. b: number;
  78627. /**
  78628. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78629. * @param r defines the red component (between 0 and 1, default is 0)
  78630. * @param g defines the green component (between 0 and 1, default is 0)
  78631. * @param b defines the blue component (between 0 and 1, default is 0)
  78632. */
  78633. constructor(
  78634. /**
  78635. * Defines the red component (between 0 and 1, default is 0)
  78636. */
  78637. r?: number,
  78638. /**
  78639. * Defines the green component (between 0 and 1, default is 0)
  78640. */
  78641. g?: number,
  78642. /**
  78643. * Defines the blue component (between 0 and 1, default is 0)
  78644. */
  78645. b?: number);
  78646. /**
  78647. * Creates a string with the Color3 current values
  78648. * @returns the string representation of the Color3 object
  78649. */
  78650. toString(): string;
  78651. /**
  78652. * Returns the string "Color3"
  78653. * @returns "Color3"
  78654. */
  78655. getClassName(): string;
  78656. /**
  78657. * Compute the Color3 hash code
  78658. * @returns an unique number that can be used to hash Color3 objects
  78659. */
  78660. getHashCode(): number;
  78661. /**
  78662. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78663. * @param array defines the array where to store the r,g,b components
  78664. * @param index defines an optional index in the target array to define where to start storing values
  78665. * @returns the current Color3 object
  78666. */
  78667. toArray(array: FloatArray, index?: number): Color3;
  78668. /**
  78669. * Returns a new Color4 object from the current Color3 and the given alpha
  78670. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78671. * @returns a new Color4 object
  78672. */
  78673. toColor4(alpha?: number): Color4;
  78674. /**
  78675. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78676. * @returns the new array
  78677. */
  78678. asArray(): number[];
  78679. /**
  78680. * Returns the luminance value
  78681. * @returns a float value
  78682. */
  78683. toLuminance(): number;
  78684. /**
  78685. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78686. * @param otherColor defines the second operand
  78687. * @returns the new Color3 object
  78688. */
  78689. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78690. /**
  78691. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78692. * @param otherColor defines the second operand
  78693. * @param result defines the Color3 object where to store the result
  78694. * @returns the current Color3
  78695. */
  78696. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78697. /**
  78698. * Determines equality between Color3 objects
  78699. * @param otherColor defines the second operand
  78700. * @returns true if the rgb values are equal to the given ones
  78701. */
  78702. equals(otherColor: DeepImmutable<Color3>): boolean;
  78703. /**
  78704. * Determines equality between the current Color3 object and a set of r,b,g values
  78705. * @param r defines the red component to check
  78706. * @param g defines the green component to check
  78707. * @param b defines the blue component to check
  78708. * @returns true if the rgb values are equal to the given ones
  78709. */
  78710. equalsFloats(r: number, g: number, b: number): boolean;
  78711. /**
  78712. * Multiplies in place each rgb value by scale
  78713. * @param scale defines the scaling factor
  78714. * @returns the updated Color3
  78715. */
  78716. scale(scale: number): Color3;
  78717. /**
  78718. * Multiplies the rgb values by scale and stores the result into "result"
  78719. * @param scale defines the scaling factor
  78720. * @param result defines the Color3 object where to store the result
  78721. * @returns the unmodified current Color3
  78722. */
  78723. scaleToRef(scale: number, result: Color3): Color3;
  78724. /**
  78725. * Scale the current Color3 values by a factor and add the result to a given Color3
  78726. * @param scale defines the scale factor
  78727. * @param result defines color to store the result into
  78728. * @returns the unmodified current Color3
  78729. */
  78730. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78731. /**
  78732. * Clamps the rgb values by the min and max values and stores the result into "result"
  78733. * @param min defines minimum clamping value (default is 0)
  78734. * @param max defines maximum clamping value (default is 1)
  78735. * @param result defines color to store the result into
  78736. * @returns the original Color3
  78737. */
  78738. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78739. /**
  78740. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78741. * @param otherColor defines the second operand
  78742. * @returns the new Color3
  78743. */
  78744. add(otherColor: DeepImmutable<Color3>): Color3;
  78745. /**
  78746. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78747. * @param otherColor defines the second operand
  78748. * @param result defines Color3 object to store the result into
  78749. * @returns the unmodified current Color3
  78750. */
  78751. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78752. /**
  78753. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78754. * @param otherColor defines the second operand
  78755. * @returns the new Color3
  78756. */
  78757. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78758. /**
  78759. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78760. * @param otherColor defines the second operand
  78761. * @param result defines Color3 object to store the result into
  78762. * @returns the unmodified current Color3
  78763. */
  78764. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78765. /**
  78766. * Copy the current object
  78767. * @returns a new Color3 copied the current one
  78768. */
  78769. clone(): Color3;
  78770. /**
  78771. * Copies the rgb values from the source in the current Color3
  78772. * @param source defines the source Color3 object
  78773. * @returns the updated Color3 object
  78774. */
  78775. copyFrom(source: DeepImmutable<Color3>): Color3;
  78776. /**
  78777. * Updates the Color3 rgb values from the given floats
  78778. * @param r defines the red component to read from
  78779. * @param g defines the green component to read from
  78780. * @param b defines the blue component to read from
  78781. * @returns the current Color3 object
  78782. */
  78783. copyFromFloats(r: number, g: number, b: number): Color3;
  78784. /**
  78785. * Updates the Color3 rgb values from the given floats
  78786. * @param r defines the red component to read from
  78787. * @param g defines the green component to read from
  78788. * @param b defines the blue component to read from
  78789. * @returns the current Color3 object
  78790. */
  78791. set(r: number, g: number, b: number): Color3;
  78792. /**
  78793. * Compute the Color3 hexadecimal code as a string
  78794. * @returns a string containing the hexadecimal representation of the Color3 object
  78795. */
  78796. toHexString(): string;
  78797. /**
  78798. * Computes a new Color3 converted from the current one to linear space
  78799. * @returns a new Color3 object
  78800. */
  78801. toLinearSpace(): Color3;
  78802. /**
  78803. * Converts current color in rgb space to HSV values
  78804. * @returns a new color3 representing the HSV values
  78805. */
  78806. toHSV(): Color3;
  78807. /**
  78808. * Converts current color in rgb space to HSV values
  78809. * @param result defines the Color3 where to store the HSV values
  78810. */
  78811. toHSVToRef(result: Color3): void;
  78812. /**
  78813. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78814. * @param convertedColor defines the Color3 object where to store the linear space version
  78815. * @returns the unmodified Color3
  78816. */
  78817. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78818. /**
  78819. * Computes a new Color3 converted from the current one to gamma space
  78820. * @returns a new Color3 object
  78821. */
  78822. toGammaSpace(): Color3;
  78823. /**
  78824. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78825. * @param convertedColor defines the Color3 object where to store the gamma space version
  78826. * @returns the unmodified Color3
  78827. */
  78828. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78829. private static _BlackReadOnly;
  78830. /**
  78831. * Convert Hue, saturation and value to a Color3 (RGB)
  78832. * @param hue defines the hue
  78833. * @param saturation defines the saturation
  78834. * @param value defines the value
  78835. * @param result defines the Color3 where to store the RGB values
  78836. */
  78837. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78838. /**
  78839. * Creates a new Color3 from the string containing valid hexadecimal values
  78840. * @param hex defines a string containing valid hexadecimal values
  78841. * @returns a new Color3 object
  78842. */
  78843. static FromHexString(hex: string): Color3;
  78844. /**
  78845. * Creates a new Color3 from the starting index of the given array
  78846. * @param array defines the source array
  78847. * @param offset defines an offset in the source array
  78848. * @returns a new Color3 object
  78849. */
  78850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78851. /**
  78852. * Creates a new Color3 from integer values (< 256)
  78853. * @param r defines the red component to read from (value between 0 and 255)
  78854. * @param g defines the green component to read from (value between 0 and 255)
  78855. * @param b defines the blue component to read from (value between 0 and 255)
  78856. * @returns a new Color3 object
  78857. */
  78858. static FromInts(r: number, g: number, b: number): Color3;
  78859. /**
  78860. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78861. * @param start defines the start Color3 value
  78862. * @param end defines the end Color3 value
  78863. * @param amount defines the gradient value between start and end
  78864. * @returns a new Color3 object
  78865. */
  78866. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78867. /**
  78868. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78869. * @param left defines the start value
  78870. * @param right defines the end value
  78871. * @param amount defines the gradient factor
  78872. * @param result defines the Color3 object where to store the result
  78873. */
  78874. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78875. /**
  78876. * Returns a Color3 value containing a red color
  78877. * @returns a new Color3 object
  78878. */
  78879. static Red(): Color3;
  78880. /**
  78881. * Returns a Color3 value containing a green color
  78882. * @returns a new Color3 object
  78883. */
  78884. static Green(): Color3;
  78885. /**
  78886. * Returns a Color3 value containing a blue color
  78887. * @returns a new Color3 object
  78888. */
  78889. static Blue(): Color3;
  78890. /**
  78891. * Returns a Color3 value containing a black color
  78892. * @returns a new Color3 object
  78893. */
  78894. static Black(): Color3;
  78895. /**
  78896. * Gets a Color3 value containing a black color that must not be updated
  78897. */
  78898. static get BlackReadOnly(): DeepImmutable<Color3>;
  78899. /**
  78900. * Returns a Color3 value containing a white color
  78901. * @returns a new Color3 object
  78902. */
  78903. static White(): Color3;
  78904. /**
  78905. * Returns a Color3 value containing a purple color
  78906. * @returns a new Color3 object
  78907. */
  78908. static Purple(): Color3;
  78909. /**
  78910. * Returns a Color3 value containing a magenta color
  78911. * @returns a new Color3 object
  78912. */
  78913. static Magenta(): Color3;
  78914. /**
  78915. * Returns a Color3 value containing a yellow color
  78916. * @returns a new Color3 object
  78917. */
  78918. static Yellow(): Color3;
  78919. /**
  78920. * Returns a Color3 value containing a gray color
  78921. * @returns a new Color3 object
  78922. */
  78923. static Gray(): Color3;
  78924. /**
  78925. * Returns a Color3 value containing a teal color
  78926. * @returns a new Color3 object
  78927. */
  78928. static Teal(): Color3;
  78929. /**
  78930. * Returns a Color3 value containing a random color
  78931. * @returns a new Color3 object
  78932. */
  78933. static Random(): Color3;
  78934. }
  78935. /**
  78936. * Class used to hold a RBGA color
  78937. */
  78938. export class Color4 {
  78939. /**
  78940. * Defines the red component (between 0 and 1, default is 0)
  78941. */
  78942. r: number;
  78943. /**
  78944. * Defines the green component (between 0 and 1, default is 0)
  78945. */
  78946. g: number;
  78947. /**
  78948. * Defines the blue component (between 0 and 1, default is 0)
  78949. */
  78950. b: number;
  78951. /**
  78952. * Defines the alpha component (between 0 and 1, default is 1)
  78953. */
  78954. a: number;
  78955. /**
  78956. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78957. * @param r defines the red component (between 0 and 1, default is 0)
  78958. * @param g defines the green component (between 0 and 1, default is 0)
  78959. * @param b defines the blue component (between 0 and 1, default is 0)
  78960. * @param a defines the alpha component (between 0 and 1, default is 1)
  78961. */
  78962. constructor(
  78963. /**
  78964. * Defines the red component (between 0 and 1, default is 0)
  78965. */
  78966. r?: number,
  78967. /**
  78968. * Defines the green component (between 0 and 1, default is 0)
  78969. */
  78970. g?: number,
  78971. /**
  78972. * Defines the blue component (between 0 and 1, default is 0)
  78973. */
  78974. b?: number,
  78975. /**
  78976. * Defines the alpha component (between 0 and 1, default is 1)
  78977. */
  78978. a?: number);
  78979. /**
  78980. * Adds in place the given Color4 values to the current Color4 object
  78981. * @param right defines the second operand
  78982. * @returns the current updated Color4 object
  78983. */
  78984. addInPlace(right: DeepImmutable<Color4>): Color4;
  78985. /**
  78986. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78987. * @returns the new array
  78988. */
  78989. asArray(): number[];
  78990. /**
  78991. * Stores from the starting index in the given array the Color4 successive values
  78992. * @param array defines the array where to store the r,g,b components
  78993. * @param index defines an optional index in the target array to define where to start storing values
  78994. * @returns the current Color4 object
  78995. */
  78996. toArray(array: number[], index?: number): Color4;
  78997. /**
  78998. * Determines equality between Color4 objects
  78999. * @param otherColor defines the second operand
  79000. * @returns true if the rgba values are equal to the given ones
  79001. */
  79002. equals(otherColor: DeepImmutable<Color4>): boolean;
  79003. /**
  79004. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79005. * @param right defines the second operand
  79006. * @returns a new Color4 object
  79007. */
  79008. add(right: DeepImmutable<Color4>): Color4;
  79009. /**
  79010. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79011. * @param right defines the second operand
  79012. * @returns a new Color4 object
  79013. */
  79014. subtract(right: DeepImmutable<Color4>): Color4;
  79015. /**
  79016. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79017. * @param right defines the second operand
  79018. * @param result defines the Color4 object where to store the result
  79019. * @returns the current Color4 object
  79020. */
  79021. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79022. /**
  79023. * Creates a new Color4 with the current Color4 values multiplied by scale
  79024. * @param scale defines the scaling factor to apply
  79025. * @returns a new Color4 object
  79026. */
  79027. scale(scale: number): Color4;
  79028. /**
  79029. * Multiplies the current Color4 values by scale and stores the result in "result"
  79030. * @param scale defines the scaling factor to apply
  79031. * @param result defines the Color4 object where to store the result
  79032. * @returns the current unmodified Color4
  79033. */
  79034. scaleToRef(scale: number, result: Color4): Color4;
  79035. /**
  79036. * Scale the current Color4 values by a factor and add the result to a given Color4
  79037. * @param scale defines the scale factor
  79038. * @param result defines the Color4 object where to store the result
  79039. * @returns the unmodified current Color4
  79040. */
  79041. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79042. /**
  79043. * Clamps the rgb values by the min and max values and stores the result into "result"
  79044. * @param min defines minimum clamping value (default is 0)
  79045. * @param max defines maximum clamping value (default is 1)
  79046. * @param result defines color to store the result into.
  79047. * @returns the cuurent Color4
  79048. */
  79049. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79050. /**
  79051. * Multipy an Color4 value by another and return a new Color4 object
  79052. * @param color defines the Color4 value to multiply by
  79053. * @returns a new Color4 object
  79054. */
  79055. multiply(color: Color4): Color4;
  79056. /**
  79057. * Multipy a Color4 value by another and push the result in a reference value
  79058. * @param color defines the Color4 value to multiply by
  79059. * @param result defines the Color4 to fill the result in
  79060. * @returns the result Color4
  79061. */
  79062. multiplyToRef(color: Color4, result: Color4): Color4;
  79063. /**
  79064. * Creates a string with the Color4 current values
  79065. * @returns the string representation of the Color4 object
  79066. */
  79067. toString(): string;
  79068. /**
  79069. * Returns the string "Color4"
  79070. * @returns "Color4"
  79071. */
  79072. getClassName(): string;
  79073. /**
  79074. * Compute the Color4 hash code
  79075. * @returns an unique number that can be used to hash Color4 objects
  79076. */
  79077. getHashCode(): number;
  79078. /**
  79079. * Creates a new Color4 copied from the current one
  79080. * @returns a new Color4 object
  79081. */
  79082. clone(): Color4;
  79083. /**
  79084. * Copies the given Color4 values into the current one
  79085. * @param source defines the source Color4 object
  79086. * @returns the current updated Color4 object
  79087. */
  79088. copyFrom(source: Color4): Color4;
  79089. /**
  79090. * Copies the given float values into the current one
  79091. * @param r defines the red component to read from
  79092. * @param g defines the green component to read from
  79093. * @param b defines the blue component to read from
  79094. * @param a defines the alpha component to read from
  79095. * @returns the current updated Color4 object
  79096. */
  79097. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79098. /**
  79099. * Copies the given float values into the current one
  79100. * @param r defines the red component to read from
  79101. * @param g defines the green component to read from
  79102. * @param b defines the blue component to read from
  79103. * @param a defines the alpha component to read from
  79104. * @returns the current updated Color4 object
  79105. */
  79106. set(r: number, g: number, b: number, a: number): Color4;
  79107. /**
  79108. * Compute the Color4 hexadecimal code as a string
  79109. * @returns a string containing the hexadecimal representation of the Color4 object
  79110. */
  79111. toHexString(): string;
  79112. /**
  79113. * Computes a new Color4 converted from the current one to linear space
  79114. * @returns a new Color4 object
  79115. */
  79116. toLinearSpace(): Color4;
  79117. /**
  79118. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79119. * @param convertedColor defines the Color4 object where to store the linear space version
  79120. * @returns the unmodified Color4
  79121. */
  79122. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79123. /**
  79124. * Computes a new Color4 converted from the current one to gamma space
  79125. * @returns a new Color4 object
  79126. */
  79127. toGammaSpace(): Color4;
  79128. /**
  79129. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79130. * @param convertedColor defines the Color4 object where to store the gamma space version
  79131. * @returns the unmodified Color4
  79132. */
  79133. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79134. /**
  79135. * Creates a new Color4 from the string containing valid hexadecimal values
  79136. * @param hex defines a string containing valid hexadecimal values
  79137. * @returns a new Color4 object
  79138. */
  79139. static FromHexString(hex: string): Color4;
  79140. /**
  79141. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79142. * @param left defines the start value
  79143. * @param right defines the end value
  79144. * @param amount defines the gradient factor
  79145. * @returns a new Color4 object
  79146. */
  79147. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79148. /**
  79149. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79150. * @param left defines the start value
  79151. * @param right defines the end value
  79152. * @param amount defines the gradient factor
  79153. * @param result defines the Color4 object where to store data
  79154. */
  79155. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79156. /**
  79157. * Creates a new Color4 from a Color3 and an alpha value
  79158. * @param color3 defines the source Color3 to read from
  79159. * @param alpha defines the alpha component (1.0 by default)
  79160. * @returns a new Color4 object
  79161. */
  79162. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79163. /**
  79164. * Creates a new Color4 from the starting index element of the given array
  79165. * @param array defines the source array to read from
  79166. * @param offset defines the offset in the source array
  79167. * @returns a new Color4 object
  79168. */
  79169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79170. /**
  79171. * Creates a new Color3 from integer values (< 256)
  79172. * @param r defines the red component to read from (value between 0 and 255)
  79173. * @param g defines the green component to read from (value between 0 and 255)
  79174. * @param b defines the blue component to read from (value between 0 and 255)
  79175. * @param a defines the alpha component to read from (value between 0 and 255)
  79176. * @returns a new Color3 object
  79177. */
  79178. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79179. /**
  79180. * Check the content of a given array and convert it to an array containing RGBA data
  79181. * If the original array was already containing count * 4 values then it is returned directly
  79182. * @param colors defines the array to check
  79183. * @param count defines the number of RGBA data to expect
  79184. * @returns an array containing count * 4 values (RGBA)
  79185. */
  79186. static CheckColors4(colors: number[], count: number): number[];
  79187. }
  79188. /**
  79189. * @hidden
  79190. */
  79191. export class TmpColors {
  79192. static Color3: Color3[];
  79193. static Color4: Color4[];
  79194. }
  79195. }
  79196. declare module BABYLON {
  79197. /**
  79198. * Defines an interface which represents an animation key frame
  79199. */
  79200. export interface IAnimationKey {
  79201. /**
  79202. * Frame of the key frame
  79203. */
  79204. frame: number;
  79205. /**
  79206. * Value at the specifies key frame
  79207. */
  79208. value: any;
  79209. /**
  79210. * The input tangent for the cubic hermite spline
  79211. */
  79212. inTangent?: any;
  79213. /**
  79214. * The output tangent for the cubic hermite spline
  79215. */
  79216. outTangent?: any;
  79217. /**
  79218. * The animation interpolation type
  79219. */
  79220. interpolation?: AnimationKeyInterpolation;
  79221. }
  79222. /**
  79223. * Enum for the animation key frame interpolation type
  79224. */
  79225. export enum AnimationKeyInterpolation {
  79226. /**
  79227. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79228. */
  79229. STEP = 1
  79230. }
  79231. }
  79232. declare module BABYLON {
  79233. /**
  79234. * Represents the range of an animation
  79235. */
  79236. export class AnimationRange {
  79237. /**The name of the animation range**/
  79238. name: string;
  79239. /**The starting frame of the animation */
  79240. from: number;
  79241. /**The ending frame of the animation*/
  79242. to: number;
  79243. /**
  79244. * Initializes the range of an animation
  79245. * @param name The name of the animation range
  79246. * @param from The starting frame of the animation
  79247. * @param to The ending frame of the animation
  79248. */
  79249. constructor(
  79250. /**The name of the animation range**/
  79251. name: string,
  79252. /**The starting frame of the animation */
  79253. from: number,
  79254. /**The ending frame of the animation*/
  79255. to: number);
  79256. /**
  79257. * Makes a copy of the animation range
  79258. * @returns A copy of the animation range
  79259. */
  79260. clone(): AnimationRange;
  79261. }
  79262. }
  79263. declare module BABYLON {
  79264. /**
  79265. * Composed of a frame, and an action function
  79266. */
  79267. export class AnimationEvent {
  79268. /** The frame for which the event is triggered **/
  79269. frame: number;
  79270. /** The event to perform when triggered **/
  79271. action: (currentFrame: number) => void;
  79272. /** Specifies if the event should be triggered only once**/
  79273. onlyOnce?: boolean | undefined;
  79274. /**
  79275. * Specifies if the animation event is done
  79276. */
  79277. isDone: boolean;
  79278. /**
  79279. * Initializes the animation event
  79280. * @param frame The frame for which the event is triggered
  79281. * @param action The event to perform when triggered
  79282. * @param onlyOnce Specifies if the event should be triggered only once
  79283. */
  79284. constructor(
  79285. /** The frame for which the event is triggered **/
  79286. frame: number,
  79287. /** The event to perform when triggered **/
  79288. action: (currentFrame: number) => void,
  79289. /** Specifies if the event should be triggered only once**/
  79290. onlyOnce?: boolean | undefined);
  79291. /** @hidden */
  79292. _clone(): AnimationEvent;
  79293. }
  79294. }
  79295. declare module BABYLON {
  79296. /**
  79297. * Interface used to define a behavior
  79298. */
  79299. export interface Behavior<T> {
  79300. /** gets or sets behavior's name */
  79301. name: string;
  79302. /**
  79303. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79304. */
  79305. init(): void;
  79306. /**
  79307. * Called when the behavior is attached to a target
  79308. * @param target defines the target where the behavior is attached to
  79309. */
  79310. attach(target: T): void;
  79311. /**
  79312. * Called when the behavior is detached from its target
  79313. */
  79314. detach(): void;
  79315. }
  79316. /**
  79317. * Interface implemented by classes supporting behaviors
  79318. */
  79319. export interface IBehaviorAware<T> {
  79320. /**
  79321. * Attach a behavior
  79322. * @param behavior defines the behavior to attach
  79323. * @returns the current host
  79324. */
  79325. addBehavior(behavior: Behavior<T>): T;
  79326. /**
  79327. * Remove a behavior from the current object
  79328. * @param behavior defines the behavior to detach
  79329. * @returns the current host
  79330. */
  79331. removeBehavior(behavior: Behavior<T>): T;
  79332. /**
  79333. * Gets a behavior using its name to search
  79334. * @param name defines the name to search
  79335. * @returns the behavior or null if not found
  79336. */
  79337. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79338. }
  79339. }
  79340. declare module BABYLON {
  79341. /**
  79342. * Defines an array and its length.
  79343. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79344. */
  79345. export interface ISmartArrayLike<T> {
  79346. /**
  79347. * The data of the array.
  79348. */
  79349. data: Array<T>;
  79350. /**
  79351. * The active length of the array.
  79352. */
  79353. length: number;
  79354. }
  79355. /**
  79356. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79357. */
  79358. export class SmartArray<T> implements ISmartArrayLike<T> {
  79359. /**
  79360. * The full set of data from the array.
  79361. */
  79362. data: Array<T>;
  79363. /**
  79364. * The active length of the array.
  79365. */
  79366. length: number;
  79367. protected _id: number;
  79368. /**
  79369. * Instantiates a Smart Array.
  79370. * @param capacity defines the default capacity of the array.
  79371. */
  79372. constructor(capacity: number);
  79373. /**
  79374. * Pushes a value at the end of the active data.
  79375. * @param value defines the object to push in the array.
  79376. */
  79377. push(value: T): void;
  79378. /**
  79379. * Iterates over the active data and apply the lambda to them.
  79380. * @param func defines the action to apply on each value.
  79381. */
  79382. forEach(func: (content: T) => void): void;
  79383. /**
  79384. * Sorts the full sets of data.
  79385. * @param compareFn defines the comparison function to apply.
  79386. */
  79387. sort(compareFn: (a: T, b: T) => number): void;
  79388. /**
  79389. * Resets the active data to an empty array.
  79390. */
  79391. reset(): void;
  79392. /**
  79393. * Releases all the data from the array as well as the array.
  79394. */
  79395. dispose(): void;
  79396. /**
  79397. * Concats the active data with a given array.
  79398. * @param array defines the data to concatenate with.
  79399. */
  79400. concat(array: any): void;
  79401. /**
  79402. * Returns the position of a value in the active data.
  79403. * @param value defines the value to find the index for
  79404. * @returns the index if found in the active data otherwise -1
  79405. */
  79406. indexOf(value: T): number;
  79407. /**
  79408. * Returns whether an element is part of the active data.
  79409. * @param value defines the value to look for
  79410. * @returns true if found in the active data otherwise false
  79411. */
  79412. contains(value: T): boolean;
  79413. private static _GlobalId;
  79414. }
  79415. /**
  79416. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79417. * The data in this array can only be present once
  79418. */
  79419. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79420. private _duplicateId;
  79421. /**
  79422. * Pushes a value at the end of the active data.
  79423. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79424. * @param value defines the object to push in the array.
  79425. */
  79426. push(value: T): void;
  79427. /**
  79428. * Pushes a value at the end of the active data.
  79429. * If the data is already present, it won t be added again
  79430. * @param value defines the object to push in the array.
  79431. * @returns true if added false if it was already present
  79432. */
  79433. pushNoDuplicate(value: T): boolean;
  79434. /**
  79435. * Resets the active data to an empty array.
  79436. */
  79437. reset(): void;
  79438. /**
  79439. * Concats the active data with a given array.
  79440. * This ensures no dupplicate will be present in the result.
  79441. * @param array defines the data to concatenate with.
  79442. */
  79443. concatWithNoDuplicate(array: any): void;
  79444. }
  79445. }
  79446. declare module BABYLON {
  79447. /**
  79448. * @ignore
  79449. * This is a list of all the different input types that are available in the application.
  79450. * Fo instance: ArcRotateCameraGamepadInput...
  79451. */
  79452. export var CameraInputTypes: {};
  79453. /**
  79454. * This is the contract to implement in order to create a new input class.
  79455. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79456. */
  79457. export interface ICameraInput<TCamera extends Camera> {
  79458. /**
  79459. * Defines the camera the input is attached to.
  79460. */
  79461. camera: Nullable<TCamera>;
  79462. /**
  79463. * Gets the class name of the current intput.
  79464. * @returns the class name
  79465. */
  79466. getClassName(): string;
  79467. /**
  79468. * Get the friendly name associated with the input class.
  79469. * @returns the input friendly name
  79470. */
  79471. getSimpleName(): string;
  79472. /**
  79473. * Attach the input controls to a specific dom element to get the input from.
  79474. * @param element Defines the element the controls should be listened from
  79475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79476. */
  79477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79478. /**
  79479. * Detach the current controls from the specified dom element.
  79480. * @param element Defines the element to stop listening the inputs from
  79481. */
  79482. detachControl(element: Nullable<HTMLElement>): void;
  79483. /**
  79484. * Update the current camera state depending on the inputs that have been used this frame.
  79485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79486. */
  79487. checkInputs?: () => void;
  79488. }
  79489. /**
  79490. * Represents a map of input types to input instance or input index to input instance.
  79491. */
  79492. export interface CameraInputsMap<TCamera extends Camera> {
  79493. /**
  79494. * Accessor to the input by input type.
  79495. */
  79496. [name: string]: ICameraInput<TCamera>;
  79497. /**
  79498. * Accessor to the input by input index.
  79499. */
  79500. [idx: number]: ICameraInput<TCamera>;
  79501. }
  79502. /**
  79503. * This represents the input manager used within a camera.
  79504. * It helps dealing with all the different kind of input attached to a camera.
  79505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79506. */
  79507. export class CameraInputsManager<TCamera extends Camera> {
  79508. /**
  79509. * Defines the list of inputs attahed to the camera.
  79510. */
  79511. attached: CameraInputsMap<TCamera>;
  79512. /**
  79513. * Defines the dom element the camera is collecting inputs from.
  79514. * This is null if the controls have not been attached.
  79515. */
  79516. attachedElement: Nullable<HTMLElement>;
  79517. /**
  79518. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79519. */
  79520. noPreventDefault: boolean;
  79521. /**
  79522. * Defined the camera the input manager belongs to.
  79523. */
  79524. camera: TCamera;
  79525. /**
  79526. * Update the current camera state depending on the inputs that have been used this frame.
  79527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79528. */
  79529. checkInputs: () => void;
  79530. /**
  79531. * Instantiate a new Camera Input Manager.
  79532. * @param camera Defines the camera the input manager blongs to
  79533. */
  79534. constructor(camera: TCamera);
  79535. /**
  79536. * Add an input method to a camera
  79537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79538. * @param input camera input method
  79539. */
  79540. add(input: ICameraInput<TCamera>): void;
  79541. /**
  79542. * Remove a specific input method from a camera
  79543. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79544. * @param inputToRemove camera input method
  79545. */
  79546. remove(inputToRemove: ICameraInput<TCamera>): void;
  79547. /**
  79548. * Remove a specific input type from a camera
  79549. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79550. * @param inputType the type of the input to remove
  79551. */
  79552. removeByType(inputType: string): void;
  79553. private _addCheckInputs;
  79554. /**
  79555. * Attach the input controls to the currently attached dom element to listen the events from.
  79556. * @param input Defines the input to attach
  79557. */
  79558. attachInput(input: ICameraInput<TCamera>): void;
  79559. /**
  79560. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79561. * @param element Defines the dom element to collect the events from
  79562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79563. */
  79564. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79565. /**
  79566. * Detach the current manager inputs controls from a specific dom element.
  79567. * @param element Defines the dom element to collect the events from
  79568. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79569. */
  79570. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79571. /**
  79572. * Rebuild the dynamic inputCheck function from the current list of
  79573. * defined inputs in the manager.
  79574. */
  79575. rebuildInputCheck(): void;
  79576. /**
  79577. * Remove all attached input methods from a camera
  79578. */
  79579. clear(): void;
  79580. /**
  79581. * Serialize the current input manager attached to a camera.
  79582. * This ensures than once parsed,
  79583. * the input associated to the camera will be identical to the current ones
  79584. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79585. */
  79586. serialize(serializedCamera: any): void;
  79587. /**
  79588. * Parses an input manager serialized JSON to restore the previous list of inputs
  79589. * and states associated to a camera.
  79590. * @param parsedCamera Defines the JSON to parse
  79591. */
  79592. parse(parsedCamera: any): void;
  79593. }
  79594. }
  79595. declare module BABYLON {
  79596. /**
  79597. * Class used to store data that will be store in GPU memory
  79598. */
  79599. export class Buffer {
  79600. private _engine;
  79601. private _buffer;
  79602. /** @hidden */
  79603. _data: Nullable<DataArray>;
  79604. private _updatable;
  79605. private _instanced;
  79606. private _divisor;
  79607. /**
  79608. * Gets the byte stride.
  79609. */
  79610. readonly byteStride: number;
  79611. /**
  79612. * Constructor
  79613. * @param engine the engine
  79614. * @param data the data to use for this buffer
  79615. * @param updatable whether the data is updatable
  79616. * @param stride the stride (optional)
  79617. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79618. * @param instanced whether the buffer is instanced (optional)
  79619. * @param useBytes set to true if the stride in in bytes (optional)
  79620. * @param divisor sets an optional divisor for instances (1 by default)
  79621. */
  79622. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79623. /**
  79624. * Create a new VertexBuffer based on the current buffer
  79625. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79626. * @param offset defines offset in the buffer (0 by default)
  79627. * @param size defines the size in floats of attributes (position is 3 for instance)
  79628. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79629. * @param instanced defines if the vertex buffer contains indexed data
  79630. * @param useBytes defines if the offset and stride are in bytes *
  79631. * @param divisor sets an optional divisor for instances (1 by default)
  79632. * @returns the new vertex buffer
  79633. */
  79634. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79635. /**
  79636. * Gets a boolean indicating if the Buffer is updatable?
  79637. * @returns true if the buffer is updatable
  79638. */
  79639. isUpdatable(): boolean;
  79640. /**
  79641. * Gets current buffer's data
  79642. * @returns a DataArray or null
  79643. */
  79644. getData(): Nullable<DataArray>;
  79645. /**
  79646. * Gets underlying native buffer
  79647. * @returns underlying native buffer
  79648. */
  79649. getBuffer(): Nullable<DataBuffer>;
  79650. /**
  79651. * Gets the stride in float32 units (i.e. byte stride / 4).
  79652. * May not be an integer if the byte stride is not divisible by 4.
  79653. * @returns the stride in float32 units
  79654. * @deprecated Please use byteStride instead.
  79655. */
  79656. getStrideSize(): number;
  79657. /**
  79658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79659. * @param data defines the data to store
  79660. */
  79661. create(data?: Nullable<DataArray>): void;
  79662. /** @hidden */
  79663. _rebuild(): void;
  79664. /**
  79665. * Update current buffer data
  79666. * @param data defines the data to store
  79667. */
  79668. update(data: DataArray): void;
  79669. /**
  79670. * Updates the data directly.
  79671. * @param data the new data
  79672. * @param offset the new offset
  79673. * @param vertexCount the vertex count (optional)
  79674. * @param useBytes set to true if the offset is in bytes
  79675. */
  79676. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79677. /**
  79678. * Release all resources
  79679. */
  79680. dispose(): void;
  79681. }
  79682. /**
  79683. * Specialized buffer used to store vertex data
  79684. */
  79685. export class VertexBuffer {
  79686. /** @hidden */
  79687. _buffer: Buffer;
  79688. private _kind;
  79689. private _size;
  79690. private _ownsBuffer;
  79691. private _instanced;
  79692. private _instanceDivisor;
  79693. /**
  79694. * The byte type.
  79695. */
  79696. static readonly BYTE: number;
  79697. /**
  79698. * The unsigned byte type.
  79699. */
  79700. static readonly UNSIGNED_BYTE: number;
  79701. /**
  79702. * The short type.
  79703. */
  79704. static readonly SHORT: number;
  79705. /**
  79706. * The unsigned short type.
  79707. */
  79708. static readonly UNSIGNED_SHORT: number;
  79709. /**
  79710. * The integer type.
  79711. */
  79712. static readonly INT: number;
  79713. /**
  79714. * The unsigned integer type.
  79715. */
  79716. static readonly UNSIGNED_INT: number;
  79717. /**
  79718. * The float type.
  79719. */
  79720. static readonly FLOAT: number;
  79721. /**
  79722. * Gets or sets the instance divisor when in instanced mode
  79723. */
  79724. get instanceDivisor(): number;
  79725. set instanceDivisor(value: number);
  79726. /**
  79727. * Gets the byte stride.
  79728. */
  79729. readonly byteStride: number;
  79730. /**
  79731. * Gets the byte offset.
  79732. */
  79733. readonly byteOffset: number;
  79734. /**
  79735. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79736. */
  79737. readonly normalized: boolean;
  79738. /**
  79739. * Gets the data type of each component in the array.
  79740. */
  79741. readonly type: number;
  79742. /**
  79743. * Constructor
  79744. * @param engine the engine
  79745. * @param data the data to use for this vertex buffer
  79746. * @param kind the vertex buffer kind
  79747. * @param updatable whether the data is updatable
  79748. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79749. * @param stride the stride (optional)
  79750. * @param instanced whether the buffer is instanced (optional)
  79751. * @param offset the offset of the data (optional)
  79752. * @param size the number of components (optional)
  79753. * @param type the type of the component (optional)
  79754. * @param normalized whether the data contains normalized data (optional)
  79755. * @param useBytes set to true if stride and offset are in bytes (optional)
  79756. * @param divisor defines the instance divisor to use (1 by default)
  79757. */
  79758. 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, divisor?: number);
  79759. /** @hidden */
  79760. _rebuild(): void;
  79761. /**
  79762. * Returns the kind of the VertexBuffer (string)
  79763. * @returns a string
  79764. */
  79765. getKind(): string;
  79766. /**
  79767. * Gets a boolean indicating if the VertexBuffer is updatable?
  79768. * @returns true if the buffer is updatable
  79769. */
  79770. isUpdatable(): boolean;
  79771. /**
  79772. * Gets current buffer's data
  79773. * @returns a DataArray or null
  79774. */
  79775. getData(): Nullable<DataArray>;
  79776. /**
  79777. * Gets underlying native buffer
  79778. * @returns underlying native buffer
  79779. */
  79780. getBuffer(): Nullable<DataBuffer>;
  79781. /**
  79782. * Gets the stride in float32 units (i.e. byte stride / 4).
  79783. * May not be an integer if the byte stride is not divisible by 4.
  79784. * @returns the stride in float32 units
  79785. * @deprecated Please use byteStride instead.
  79786. */
  79787. getStrideSize(): number;
  79788. /**
  79789. * Returns the offset as a multiple of the type byte length.
  79790. * @returns the offset in bytes
  79791. * @deprecated Please use byteOffset instead.
  79792. */
  79793. getOffset(): number;
  79794. /**
  79795. * Returns the number of components per vertex attribute (integer)
  79796. * @returns the size in float
  79797. */
  79798. getSize(): number;
  79799. /**
  79800. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79801. * @returns true if this buffer is instanced
  79802. */
  79803. getIsInstanced(): boolean;
  79804. /**
  79805. * Returns the instancing divisor, zero for non-instanced (integer).
  79806. * @returns a number
  79807. */
  79808. getInstanceDivisor(): number;
  79809. /**
  79810. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79811. * @param data defines the data to store
  79812. */
  79813. create(data?: DataArray): void;
  79814. /**
  79815. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79816. * This function will create a new buffer if the current one is not updatable
  79817. * @param data defines the data to store
  79818. */
  79819. update(data: DataArray): void;
  79820. /**
  79821. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79822. * Returns the directly updated WebGLBuffer.
  79823. * @param data the new data
  79824. * @param offset the new offset
  79825. * @param useBytes set to true if the offset is in bytes
  79826. */
  79827. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79828. /**
  79829. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79830. */
  79831. dispose(): void;
  79832. /**
  79833. * Enumerates each value of this vertex buffer as numbers.
  79834. * @param count the number of values to enumerate
  79835. * @param callback the callback function called for each value
  79836. */
  79837. forEach(count: number, callback: (value: number, index: number) => void): void;
  79838. /**
  79839. * Positions
  79840. */
  79841. static readonly PositionKind: string;
  79842. /**
  79843. * Normals
  79844. */
  79845. static readonly NormalKind: string;
  79846. /**
  79847. * Tangents
  79848. */
  79849. static readonly TangentKind: string;
  79850. /**
  79851. * Texture coordinates
  79852. */
  79853. static readonly UVKind: string;
  79854. /**
  79855. * Texture coordinates 2
  79856. */
  79857. static readonly UV2Kind: string;
  79858. /**
  79859. * Texture coordinates 3
  79860. */
  79861. static readonly UV3Kind: string;
  79862. /**
  79863. * Texture coordinates 4
  79864. */
  79865. static readonly UV4Kind: string;
  79866. /**
  79867. * Texture coordinates 5
  79868. */
  79869. static readonly UV5Kind: string;
  79870. /**
  79871. * Texture coordinates 6
  79872. */
  79873. static readonly UV6Kind: string;
  79874. /**
  79875. * Colors
  79876. */
  79877. static readonly ColorKind: string;
  79878. /**
  79879. * Matrix indices (for bones)
  79880. */
  79881. static readonly MatricesIndicesKind: string;
  79882. /**
  79883. * Matrix weights (for bones)
  79884. */
  79885. static readonly MatricesWeightsKind: string;
  79886. /**
  79887. * Additional matrix indices (for bones)
  79888. */
  79889. static readonly MatricesIndicesExtraKind: string;
  79890. /**
  79891. * Additional matrix weights (for bones)
  79892. */
  79893. static readonly MatricesWeightsExtraKind: string;
  79894. /**
  79895. * Deduces the stride given a kind.
  79896. * @param kind The kind string to deduce
  79897. * @returns The deduced stride
  79898. */
  79899. static DeduceStride(kind: string): number;
  79900. /**
  79901. * Gets the byte length of the given type.
  79902. * @param type the type
  79903. * @returns the number of bytes
  79904. */
  79905. static GetTypeByteLength(type: number): number;
  79906. /**
  79907. * Enumerates each value of the given parameters as numbers.
  79908. * @param data the data to enumerate
  79909. * @param byteOffset the byte offset of the data
  79910. * @param byteStride the byte stride of the data
  79911. * @param componentCount the number of components per element
  79912. * @param componentType the type of the component
  79913. * @param count the number of values to enumerate
  79914. * @param normalized whether the data is normalized
  79915. * @param callback the callback function called for each value
  79916. */
  79917. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79918. private static _GetFloatValue;
  79919. }
  79920. }
  79921. declare module BABYLON {
  79922. /**
  79923. * @hidden
  79924. */
  79925. export class IntersectionInfo {
  79926. bu: Nullable<number>;
  79927. bv: Nullable<number>;
  79928. distance: number;
  79929. faceId: number;
  79930. subMeshId: number;
  79931. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /**
  79936. * Represens a plane by the equation ax + by + cz + d = 0
  79937. */
  79938. export class Plane {
  79939. private static _TmpMatrix;
  79940. /**
  79941. * Normal of the plane (a,b,c)
  79942. */
  79943. normal: Vector3;
  79944. /**
  79945. * d component of the plane
  79946. */
  79947. d: number;
  79948. /**
  79949. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79950. * @param a a component of the plane
  79951. * @param b b component of the plane
  79952. * @param c c component of the plane
  79953. * @param d d component of the plane
  79954. */
  79955. constructor(a: number, b: number, c: number, d: number);
  79956. /**
  79957. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79958. */
  79959. asArray(): number[];
  79960. /**
  79961. * @returns a new plane copied from the current Plane.
  79962. */
  79963. clone(): Plane;
  79964. /**
  79965. * @returns the string "Plane".
  79966. */
  79967. getClassName(): string;
  79968. /**
  79969. * @returns the Plane hash code.
  79970. */
  79971. getHashCode(): number;
  79972. /**
  79973. * Normalize the current Plane in place.
  79974. * @returns the updated Plane.
  79975. */
  79976. normalize(): Plane;
  79977. /**
  79978. * Applies a transformation the plane and returns the result
  79979. * @param transformation the transformation matrix to be applied to the plane
  79980. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79981. */
  79982. transform(transformation: DeepImmutable<Matrix>): Plane;
  79983. /**
  79984. * Calcualtte the dot product between the point and the plane normal
  79985. * @param point point to calculate the dot product with
  79986. * @returns the dot product (float) of the point coordinates and the plane normal.
  79987. */
  79988. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79989. /**
  79990. * Updates the current Plane from the plane defined by the three given points.
  79991. * @param point1 one of the points used to contruct the plane
  79992. * @param point2 one of the points used to contruct the plane
  79993. * @param point3 one of the points used to contruct the plane
  79994. * @returns the updated Plane.
  79995. */
  79996. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79997. /**
  79998. * Checks if the plane is facing a given direction
  79999. * @param direction the direction to check if the plane is facing
  80000. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80001. * @returns True is the vector "direction" is the same side than the plane normal.
  80002. */
  80003. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80004. /**
  80005. * Calculates the distance to a point
  80006. * @param point point to calculate distance to
  80007. * @returns the signed distance (float) from the given point to the Plane.
  80008. */
  80009. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80010. /**
  80011. * Creates a plane from an array
  80012. * @param array the array to create a plane from
  80013. * @returns a new Plane from the given array.
  80014. */
  80015. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80016. /**
  80017. * Creates a plane from three points
  80018. * @param point1 point used to create the plane
  80019. * @param point2 point used to create the plane
  80020. * @param point3 point used to create the plane
  80021. * @returns a new Plane defined by the three given points.
  80022. */
  80023. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80024. /**
  80025. * Creates a plane from an origin point and a normal
  80026. * @param origin origin of the plane to be constructed
  80027. * @param normal normal of the plane to be constructed
  80028. * @returns a new Plane the normal vector to this plane at the given origin point.
  80029. * Note : the vector "normal" is updated because normalized.
  80030. */
  80031. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80032. /**
  80033. * Calculates the distance from a plane and a point
  80034. * @param origin origin of the plane to be constructed
  80035. * @param normal normal of the plane to be constructed
  80036. * @param point point to calculate distance to
  80037. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80038. */
  80039. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80040. }
  80041. }
  80042. declare module BABYLON {
  80043. /**
  80044. * Class used to store bounding sphere information
  80045. */
  80046. export class BoundingSphere {
  80047. /**
  80048. * Gets the center of the bounding sphere in local space
  80049. */
  80050. readonly center: Vector3;
  80051. /**
  80052. * Radius of the bounding sphere in local space
  80053. */
  80054. radius: number;
  80055. /**
  80056. * Gets the center of the bounding sphere in world space
  80057. */
  80058. readonly centerWorld: Vector3;
  80059. /**
  80060. * Radius of the bounding sphere in world space
  80061. */
  80062. radiusWorld: number;
  80063. /**
  80064. * Gets the minimum vector in local space
  80065. */
  80066. readonly minimum: Vector3;
  80067. /**
  80068. * Gets the maximum vector in local space
  80069. */
  80070. readonly maximum: Vector3;
  80071. private _worldMatrix;
  80072. private static readonly TmpVector3;
  80073. /**
  80074. * Creates a new bounding sphere
  80075. * @param min defines the minimum vector (in local space)
  80076. * @param max defines the maximum vector (in local space)
  80077. * @param worldMatrix defines the new world matrix
  80078. */
  80079. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80080. /**
  80081. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80082. * @param min defines the new minimum vector (in local space)
  80083. * @param max defines the new maximum vector (in local space)
  80084. * @param worldMatrix defines the new world matrix
  80085. */
  80086. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80087. /**
  80088. * Scale the current bounding sphere by applying a scale factor
  80089. * @param factor defines the scale factor to apply
  80090. * @returns the current bounding box
  80091. */
  80092. scale(factor: number): BoundingSphere;
  80093. /**
  80094. * Gets the world matrix of the bounding box
  80095. * @returns a matrix
  80096. */
  80097. getWorldMatrix(): DeepImmutable<Matrix>;
  80098. /** @hidden */
  80099. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80100. /**
  80101. * Tests if the bounding sphere is intersecting the frustum planes
  80102. * @param frustumPlanes defines the frustum planes to test
  80103. * @returns true if there is an intersection
  80104. */
  80105. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80106. /**
  80107. * Tests if the bounding sphere center is in between the frustum planes.
  80108. * Used for optimistic fast inclusion.
  80109. * @param frustumPlanes defines the frustum planes to test
  80110. * @returns true if the sphere center is in between the frustum planes
  80111. */
  80112. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80113. /**
  80114. * Tests if a point is inside the bounding sphere
  80115. * @param point defines the point to test
  80116. * @returns true if the point is inside the bounding sphere
  80117. */
  80118. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80119. /**
  80120. * Checks if two sphere intersct
  80121. * @param sphere0 sphere 0
  80122. * @param sphere1 sphere 1
  80123. * @returns true if the speres intersect
  80124. */
  80125. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80126. }
  80127. }
  80128. declare module BABYLON {
  80129. /**
  80130. * Class used to store bounding box information
  80131. */
  80132. export class BoundingBox implements ICullable {
  80133. /**
  80134. * Gets the 8 vectors representing the bounding box in local space
  80135. */
  80136. readonly vectors: Vector3[];
  80137. /**
  80138. * Gets the center of the bounding box in local space
  80139. */
  80140. readonly center: Vector3;
  80141. /**
  80142. * Gets the center of the bounding box in world space
  80143. */
  80144. readonly centerWorld: Vector3;
  80145. /**
  80146. * Gets the extend size in local space
  80147. */
  80148. readonly extendSize: Vector3;
  80149. /**
  80150. * Gets the extend size in world space
  80151. */
  80152. readonly extendSizeWorld: Vector3;
  80153. /**
  80154. * Gets the OBB (object bounding box) directions
  80155. */
  80156. readonly directions: Vector3[];
  80157. /**
  80158. * Gets the 8 vectors representing the bounding box in world space
  80159. */
  80160. readonly vectorsWorld: Vector3[];
  80161. /**
  80162. * Gets the minimum vector in world space
  80163. */
  80164. readonly minimumWorld: Vector3;
  80165. /**
  80166. * Gets the maximum vector in world space
  80167. */
  80168. readonly maximumWorld: Vector3;
  80169. /**
  80170. * Gets the minimum vector in local space
  80171. */
  80172. readonly minimum: Vector3;
  80173. /**
  80174. * Gets the maximum vector in local space
  80175. */
  80176. readonly maximum: Vector3;
  80177. private _worldMatrix;
  80178. private static readonly TmpVector3;
  80179. /**
  80180. * @hidden
  80181. */
  80182. _tag: number;
  80183. /**
  80184. * Creates a new bounding box
  80185. * @param min defines the minimum vector (in local space)
  80186. * @param max defines the maximum vector (in local space)
  80187. * @param worldMatrix defines the new world matrix
  80188. */
  80189. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80190. /**
  80191. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80192. * @param min defines the new minimum vector (in local space)
  80193. * @param max defines the new maximum vector (in local space)
  80194. * @param worldMatrix defines the new world matrix
  80195. */
  80196. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80197. /**
  80198. * Scale the current bounding box by applying a scale factor
  80199. * @param factor defines the scale factor to apply
  80200. * @returns the current bounding box
  80201. */
  80202. scale(factor: number): BoundingBox;
  80203. /**
  80204. * Gets the world matrix of the bounding box
  80205. * @returns a matrix
  80206. */
  80207. getWorldMatrix(): DeepImmutable<Matrix>;
  80208. /** @hidden */
  80209. _update(world: DeepImmutable<Matrix>): void;
  80210. /**
  80211. * Tests if the bounding box is intersecting the frustum planes
  80212. * @param frustumPlanes defines the frustum planes to test
  80213. * @returns true if there is an intersection
  80214. */
  80215. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80216. /**
  80217. * Tests if the bounding box is entirely inside the frustum planes
  80218. * @param frustumPlanes defines the frustum planes to test
  80219. * @returns true if there is an inclusion
  80220. */
  80221. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80222. /**
  80223. * Tests if a point is inside the bounding box
  80224. * @param point defines the point to test
  80225. * @returns true if the point is inside the bounding box
  80226. */
  80227. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80228. /**
  80229. * Tests if the bounding box intersects with a bounding sphere
  80230. * @param sphere defines the sphere to test
  80231. * @returns true if there is an intersection
  80232. */
  80233. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80234. /**
  80235. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80236. * @param min defines the min vector to use
  80237. * @param max defines the max vector to use
  80238. * @returns true if there is an intersection
  80239. */
  80240. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80241. /**
  80242. * Tests if two bounding boxes are intersections
  80243. * @param box0 defines the first box to test
  80244. * @param box1 defines the second box to test
  80245. * @returns true if there is an intersection
  80246. */
  80247. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80248. /**
  80249. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80250. * @param minPoint defines the minimum vector of the bounding box
  80251. * @param maxPoint defines the maximum vector of the bounding box
  80252. * @param sphereCenter defines the sphere center
  80253. * @param sphereRadius defines the sphere radius
  80254. * @returns true if there is an intersection
  80255. */
  80256. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80257. /**
  80258. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80259. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80260. * @param frustumPlanes defines the frustum planes to test
  80261. * @return true if there is an inclusion
  80262. */
  80263. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80264. /**
  80265. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80266. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80267. * @param frustumPlanes defines the frustum planes to test
  80268. * @return true if there is an intersection
  80269. */
  80270. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80271. }
  80272. }
  80273. declare module BABYLON {
  80274. /** @hidden */
  80275. export class Collider {
  80276. /** Define if a collision was found */
  80277. collisionFound: boolean;
  80278. /**
  80279. * Define last intersection point in local space
  80280. */
  80281. intersectionPoint: Vector3;
  80282. /**
  80283. * Define last collided mesh
  80284. */
  80285. collidedMesh: Nullable<AbstractMesh>;
  80286. private _collisionPoint;
  80287. private _planeIntersectionPoint;
  80288. private _tempVector;
  80289. private _tempVector2;
  80290. private _tempVector3;
  80291. private _tempVector4;
  80292. private _edge;
  80293. private _baseToVertex;
  80294. private _destinationPoint;
  80295. private _slidePlaneNormal;
  80296. private _displacementVector;
  80297. /** @hidden */
  80298. _radius: Vector3;
  80299. /** @hidden */
  80300. _retry: number;
  80301. private _velocity;
  80302. private _basePoint;
  80303. private _epsilon;
  80304. /** @hidden */
  80305. _velocityWorldLength: number;
  80306. /** @hidden */
  80307. _basePointWorld: Vector3;
  80308. private _velocityWorld;
  80309. private _normalizedVelocity;
  80310. /** @hidden */
  80311. _initialVelocity: Vector3;
  80312. /** @hidden */
  80313. _initialPosition: Vector3;
  80314. private _nearestDistance;
  80315. private _collisionMask;
  80316. get collisionMask(): number;
  80317. set collisionMask(mask: number);
  80318. /**
  80319. * Gets the plane normal used to compute the sliding response (in local space)
  80320. */
  80321. get slidePlaneNormal(): Vector3;
  80322. /** @hidden */
  80323. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80324. /** @hidden */
  80325. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80326. /** @hidden */
  80327. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80328. /** @hidden */
  80329. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80330. /** @hidden */
  80331. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80332. /** @hidden */
  80333. _getResponse(pos: Vector3, vel: Vector3): void;
  80334. }
  80335. }
  80336. declare module BABYLON {
  80337. /**
  80338. * Interface for cullable objects
  80339. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80340. */
  80341. export interface ICullable {
  80342. /**
  80343. * Checks if the object or part of the object is in the frustum
  80344. * @param frustumPlanes Camera near/planes
  80345. * @returns true if the object is in frustum otherwise false
  80346. */
  80347. isInFrustum(frustumPlanes: Plane[]): boolean;
  80348. /**
  80349. * Checks if a cullable object (mesh...) is in the camera frustum
  80350. * Unlike isInFrustum this cheks the full bounding box
  80351. * @param frustumPlanes Camera near/planes
  80352. * @returns true if the object is in frustum otherwise false
  80353. */
  80354. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80355. }
  80356. /**
  80357. * Info for a bounding data of a mesh
  80358. */
  80359. export class BoundingInfo implements ICullable {
  80360. /**
  80361. * Bounding box for the mesh
  80362. */
  80363. readonly boundingBox: BoundingBox;
  80364. /**
  80365. * Bounding sphere for the mesh
  80366. */
  80367. readonly boundingSphere: BoundingSphere;
  80368. private _isLocked;
  80369. private static readonly TmpVector3;
  80370. /**
  80371. * Constructs bounding info
  80372. * @param minimum min vector of the bounding box/sphere
  80373. * @param maximum max vector of the bounding box/sphere
  80374. * @param worldMatrix defines the new world matrix
  80375. */
  80376. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80377. /**
  80378. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80379. * @param min defines the new minimum vector (in local space)
  80380. * @param max defines the new maximum vector (in local space)
  80381. * @param worldMatrix defines the new world matrix
  80382. */
  80383. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80384. /**
  80385. * min vector of the bounding box/sphere
  80386. */
  80387. get minimum(): Vector3;
  80388. /**
  80389. * max vector of the bounding box/sphere
  80390. */
  80391. get maximum(): Vector3;
  80392. /**
  80393. * If the info is locked and won't be updated to avoid perf overhead
  80394. */
  80395. get isLocked(): boolean;
  80396. set isLocked(value: boolean);
  80397. /**
  80398. * Updates the bounding sphere and box
  80399. * @param world world matrix to be used to update
  80400. */
  80401. update(world: DeepImmutable<Matrix>): void;
  80402. /**
  80403. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80404. * @param center New center of the bounding info
  80405. * @param extend New extend of the bounding info
  80406. * @returns the current bounding info
  80407. */
  80408. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80409. /**
  80410. * Scale the current bounding info by applying a scale factor
  80411. * @param factor defines the scale factor to apply
  80412. * @returns the current bounding info
  80413. */
  80414. scale(factor: number): BoundingInfo;
  80415. /**
  80416. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80417. * @param frustumPlanes defines the frustum to test
  80418. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80419. * @returns true if the bounding info is in the frustum planes
  80420. */
  80421. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80422. /**
  80423. * Gets the world distance between the min and max points of the bounding box
  80424. */
  80425. get diagonalLength(): number;
  80426. /**
  80427. * Checks if a cullable object (mesh...) is in the camera frustum
  80428. * Unlike isInFrustum this cheks the full bounding box
  80429. * @param frustumPlanes Camera near/planes
  80430. * @returns true if the object is in frustum otherwise false
  80431. */
  80432. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80433. /** @hidden */
  80434. _checkCollision(collider: Collider): boolean;
  80435. /**
  80436. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80437. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80438. * @param point the point to check intersection with
  80439. * @returns if the point intersects
  80440. */
  80441. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80442. /**
  80443. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80444. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80445. * @param boundingInfo the bounding info to check intersection with
  80446. * @param precise if the intersection should be done using OBB
  80447. * @returns if the bounding info intersects
  80448. */
  80449. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80450. }
  80451. }
  80452. declare module BABYLON {
  80453. /**
  80454. * Extracts minimum and maximum values from a list of indexed positions
  80455. * @param positions defines the positions to use
  80456. * @param indices defines the indices to the positions
  80457. * @param indexStart defines the start index
  80458. * @param indexCount defines the end index
  80459. * @param bias defines bias value to add to the result
  80460. * @return minimum and maximum values
  80461. */
  80462. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80463. minimum: Vector3;
  80464. maximum: Vector3;
  80465. };
  80466. /**
  80467. * Extracts minimum and maximum values from a list of positions
  80468. * @param positions defines the positions to use
  80469. * @param start defines the start index in the positions array
  80470. * @param count defines the number of positions to handle
  80471. * @param bias defines bias value to add to the result
  80472. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80473. * @return minimum and maximum values
  80474. */
  80475. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80476. minimum: Vector3;
  80477. maximum: Vector3;
  80478. };
  80479. }
  80480. declare module BABYLON {
  80481. /** @hidden */
  80482. export class WebGLDataBuffer extends DataBuffer {
  80483. private _buffer;
  80484. constructor(resource: WebGLBuffer);
  80485. get underlyingResource(): any;
  80486. }
  80487. }
  80488. declare module BABYLON {
  80489. /** @hidden */
  80490. export class WebGLPipelineContext implements IPipelineContext {
  80491. engine: ThinEngine;
  80492. program: Nullable<WebGLProgram>;
  80493. context?: WebGLRenderingContext;
  80494. vertexShader?: WebGLShader;
  80495. fragmentShader?: WebGLShader;
  80496. isParallelCompiled: boolean;
  80497. onCompiled?: () => void;
  80498. transformFeedback?: WebGLTransformFeedback | null;
  80499. vertexCompilationError: Nullable<string>;
  80500. fragmentCompilationError: Nullable<string>;
  80501. programLinkError: Nullable<string>;
  80502. programValidationError: Nullable<string>;
  80503. get isAsync(): boolean;
  80504. get isReady(): boolean;
  80505. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80506. }
  80507. }
  80508. declare module BABYLON {
  80509. interface ThinEngine {
  80510. /**
  80511. * Create an uniform buffer
  80512. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80513. * @param elements defines the content of the uniform buffer
  80514. * @returns the webGL uniform buffer
  80515. */
  80516. createUniformBuffer(elements: FloatArray): DataBuffer;
  80517. /**
  80518. * Create a dynamic uniform buffer
  80519. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80520. * @param elements defines the content of the uniform buffer
  80521. * @returns the webGL uniform buffer
  80522. */
  80523. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80524. /**
  80525. * Update an existing uniform buffer
  80526. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80527. * @param uniformBuffer defines the target uniform buffer
  80528. * @param elements defines the content to update
  80529. * @param offset defines the offset in the uniform buffer where update should start
  80530. * @param count defines the size of the data to update
  80531. */
  80532. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80533. /**
  80534. * Bind an uniform buffer to the current webGL context
  80535. * @param buffer defines the buffer to bind
  80536. */
  80537. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80538. /**
  80539. * Bind a buffer to the current webGL context at a given location
  80540. * @param buffer defines the buffer to bind
  80541. * @param location defines the index where to bind the buffer
  80542. */
  80543. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80544. /**
  80545. * Bind a specific block at a given index in a specific shader program
  80546. * @param pipelineContext defines the pipeline context to use
  80547. * @param blockName defines the block name
  80548. * @param index defines the index where to bind the block
  80549. */
  80550. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80551. }
  80552. }
  80553. declare module BABYLON {
  80554. /**
  80555. * Uniform buffer objects.
  80556. *
  80557. * Handles blocks of uniform on the GPU.
  80558. *
  80559. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80560. *
  80561. * For more information, please refer to :
  80562. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80563. */
  80564. export class UniformBuffer {
  80565. private _engine;
  80566. private _buffer;
  80567. private _data;
  80568. private _bufferData;
  80569. private _dynamic?;
  80570. private _uniformLocations;
  80571. private _uniformSizes;
  80572. private _uniformLocationPointer;
  80573. private _needSync;
  80574. private _noUBO;
  80575. private _currentEffect;
  80576. /** @hidden */
  80577. _alreadyBound: boolean;
  80578. private static _MAX_UNIFORM_SIZE;
  80579. private static _tempBuffer;
  80580. /**
  80581. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80582. * This is dynamic to allow compat with webgl 1 and 2.
  80583. * You will need to pass the name of the uniform as well as the value.
  80584. */
  80585. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80586. /**
  80587. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80588. * This is dynamic to allow compat with webgl 1 and 2.
  80589. * You will need to pass the name of the uniform as well as the value.
  80590. */
  80591. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80592. /**
  80593. * Lambda to Update a single float in a uniform buffer.
  80594. * This is dynamic to allow compat with webgl 1 and 2.
  80595. * You will need to pass the name of the uniform as well as the value.
  80596. */
  80597. updateFloat: (name: string, x: number) => void;
  80598. /**
  80599. * Lambda to Update a vec2 of float in a uniform buffer.
  80600. * This is dynamic to allow compat with webgl 1 and 2.
  80601. * You will need to pass the name of the uniform as well as the value.
  80602. */
  80603. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80604. /**
  80605. * Lambda to Update a vec3 of float in a uniform buffer.
  80606. * This is dynamic to allow compat with webgl 1 and 2.
  80607. * You will need to pass the name of the uniform as well as the value.
  80608. */
  80609. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80610. /**
  80611. * Lambda to Update a vec4 of float in a uniform buffer.
  80612. * This is dynamic to allow compat with webgl 1 and 2.
  80613. * You will need to pass the name of the uniform as well as the value.
  80614. */
  80615. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80616. /**
  80617. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80618. * This is dynamic to allow compat with webgl 1 and 2.
  80619. * You will need to pass the name of the uniform as well as the value.
  80620. */
  80621. updateMatrix: (name: string, mat: Matrix) => void;
  80622. /**
  80623. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80624. * This is dynamic to allow compat with webgl 1 and 2.
  80625. * You will need to pass the name of the uniform as well as the value.
  80626. */
  80627. updateVector3: (name: string, vector: Vector3) => void;
  80628. /**
  80629. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80630. * This is dynamic to allow compat with webgl 1 and 2.
  80631. * You will need to pass the name of the uniform as well as the value.
  80632. */
  80633. updateVector4: (name: string, vector: Vector4) => void;
  80634. /**
  80635. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80636. * This is dynamic to allow compat with webgl 1 and 2.
  80637. * You will need to pass the name of the uniform as well as the value.
  80638. */
  80639. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80640. /**
  80641. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80642. * This is dynamic to allow compat with webgl 1 and 2.
  80643. * You will need to pass the name of the uniform as well as the value.
  80644. */
  80645. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80646. /**
  80647. * Instantiates a new Uniform buffer objects.
  80648. *
  80649. * Handles blocks of uniform on the GPU.
  80650. *
  80651. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80652. *
  80653. * For more information, please refer to :
  80654. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80655. * @param engine Define the engine the buffer is associated with
  80656. * @param data Define the data contained in the buffer
  80657. * @param dynamic Define if the buffer is updatable
  80658. */
  80659. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80660. /**
  80661. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80662. * or just falling back on setUniformXXX calls.
  80663. */
  80664. get useUbo(): boolean;
  80665. /**
  80666. * Indicates if the WebGL underlying uniform buffer is in sync
  80667. * with the javascript cache data.
  80668. */
  80669. get isSync(): boolean;
  80670. /**
  80671. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80672. * Also, a dynamic UniformBuffer will disable cache verification and always
  80673. * update the underlying WebGL uniform buffer to the GPU.
  80674. * @returns if Dynamic, otherwise false
  80675. */
  80676. isDynamic(): boolean;
  80677. /**
  80678. * The data cache on JS side.
  80679. * @returns the underlying data as a float array
  80680. */
  80681. getData(): Float32Array;
  80682. /**
  80683. * The underlying WebGL Uniform buffer.
  80684. * @returns the webgl buffer
  80685. */
  80686. getBuffer(): Nullable<DataBuffer>;
  80687. /**
  80688. * std140 layout specifies how to align data within an UBO structure.
  80689. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80690. * for specs.
  80691. */
  80692. private _fillAlignment;
  80693. /**
  80694. * Adds an uniform in the buffer.
  80695. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80696. * for the layout to be correct !
  80697. * @param name Name of the uniform, as used in the uniform block in the shader.
  80698. * @param size Data size, or data directly.
  80699. */
  80700. addUniform(name: string, size: number | number[]): void;
  80701. /**
  80702. * Adds a Matrix 4x4 to the uniform buffer.
  80703. * @param name Name of the uniform, as used in the uniform block in the shader.
  80704. * @param mat A 4x4 matrix.
  80705. */
  80706. addMatrix(name: string, mat: Matrix): void;
  80707. /**
  80708. * Adds a vec2 to the uniform buffer.
  80709. * @param name Name of the uniform, as used in the uniform block in the shader.
  80710. * @param x Define the x component value of the vec2
  80711. * @param y Define the y component value of the vec2
  80712. */
  80713. addFloat2(name: string, x: number, y: number): void;
  80714. /**
  80715. * Adds a vec3 to the uniform buffer.
  80716. * @param name Name of the uniform, as used in the uniform block in the shader.
  80717. * @param x Define the x component value of the vec3
  80718. * @param y Define the y component value of the vec3
  80719. * @param z Define the z component value of the vec3
  80720. */
  80721. addFloat3(name: string, x: number, y: number, z: number): void;
  80722. /**
  80723. * Adds a vec3 to the uniform buffer.
  80724. * @param name Name of the uniform, as used in the uniform block in the shader.
  80725. * @param color Define the vec3 from a Color
  80726. */
  80727. addColor3(name: string, color: Color3): void;
  80728. /**
  80729. * Adds a vec4 to the uniform buffer.
  80730. * @param name Name of the uniform, as used in the uniform block in the shader.
  80731. * @param color Define the rgb components from a Color
  80732. * @param alpha Define the a component of the vec4
  80733. */
  80734. addColor4(name: string, color: Color3, alpha: number): void;
  80735. /**
  80736. * Adds a vec3 to the uniform buffer.
  80737. * @param name Name of the uniform, as used in the uniform block in the shader.
  80738. * @param vector Define the vec3 components from a Vector
  80739. */
  80740. addVector3(name: string, vector: Vector3): void;
  80741. /**
  80742. * Adds a Matrix 3x3 to the uniform buffer.
  80743. * @param name Name of the uniform, as used in the uniform block in the shader.
  80744. */
  80745. addMatrix3x3(name: string): void;
  80746. /**
  80747. * Adds a Matrix 2x2 to the uniform buffer.
  80748. * @param name Name of the uniform, as used in the uniform block in the shader.
  80749. */
  80750. addMatrix2x2(name: string): void;
  80751. /**
  80752. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80753. */
  80754. create(): void;
  80755. /** @hidden */
  80756. _rebuild(): void;
  80757. /**
  80758. * Updates the WebGL Uniform Buffer on the GPU.
  80759. * If the `dynamic` flag is set to true, no cache comparison is done.
  80760. * Otherwise, the buffer will be updated only if the cache differs.
  80761. */
  80762. update(): void;
  80763. /**
  80764. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80765. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80766. * @param data Define the flattened data
  80767. * @param size Define the size of the data.
  80768. */
  80769. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80770. private _valueCache;
  80771. private _cacheMatrix;
  80772. private _updateMatrix3x3ForUniform;
  80773. private _updateMatrix3x3ForEffect;
  80774. private _updateMatrix2x2ForEffect;
  80775. private _updateMatrix2x2ForUniform;
  80776. private _updateFloatForEffect;
  80777. private _updateFloatForUniform;
  80778. private _updateFloat2ForEffect;
  80779. private _updateFloat2ForUniform;
  80780. private _updateFloat3ForEffect;
  80781. private _updateFloat3ForUniform;
  80782. private _updateFloat4ForEffect;
  80783. private _updateFloat4ForUniform;
  80784. private _updateMatrixForEffect;
  80785. private _updateMatrixForUniform;
  80786. private _updateVector3ForEffect;
  80787. private _updateVector3ForUniform;
  80788. private _updateVector4ForEffect;
  80789. private _updateVector4ForUniform;
  80790. private _updateColor3ForEffect;
  80791. private _updateColor3ForUniform;
  80792. private _updateColor4ForEffect;
  80793. private _updateColor4ForUniform;
  80794. /**
  80795. * Sets a sampler uniform on the effect.
  80796. * @param name Define the name of the sampler.
  80797. * @param texture Define the texture to set in the sampler
  80798. */
  80799. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80800. /**
  80801. * Directly updates the value of the uniform in the cache AND on the GPU.
  80802. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80803. * @param data Define the flattened data
  80804. */
  80805. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80806. /**
  80807. * Binds this uniform buffer to an effect.
  80808. * @param effect Define the effect to bind the buffer to
  80809. * @param name Name of the uniform block in the shader.
  80810. */
  80811. bindToEffect(effect: Effect, name: string): void;
  80812. /**
  80813. * Disposes the uniform buffer.
  80814. */
  80815. dispose(): void;
  80816. }
  80817. }
  80818. declare module BABYLON {
  80819. /**
  80820. * Enum that determines the text-wrapping mode to use.
  80821. */
  80822. export enum InspectableType {
  80823. /**
  80824. * Checkbox for booleans
  80825. */
  80826. Checkbox = 0,
  80827. /**
  80828. * Sliders for numbers
  80829. */
  80830. Slider = 1,
  80831. /**
  80832. * Vector3
  80833. */
  80834. Vector3 = 2,
  80835. /**
  80836. * Quaternions
  80837. */
  80838. Quaternion = 3,
  80839. /**
  80840. * Color3
  80841. */
  80842. Color3 = 4,
  80843. /**
  80844. * String
  80845. */
  80846. String = 5
  80847. }
  80848. /**
  80849. * Interface used to define custom inspectable properties.
  80850. * This interface is used by the inspector to display custom property grids
  80851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80852. */
  80853. export interface IInspectable {
  80854. /**
  80855. * Gets the label to display
  80856. */
  80857. label: string;
  80858. /**
  80859. * Gets the name of the property to edit
  80860. */
  80861. propertyName: string;
  80862. /**
  80863. * Gets the type of the editor to use
  80864. */
  80865. type: InspectableType;
  80866. /**
  80867. * Gets the minimum value of the property when using in "slider" mode
  80868. */
  80869. min?: number;
  80870. /**
  80871. * Gets the maximum value of the property when using in "slider" mode
  80872. */
  80873. max?: number;
  80874. /**
  80875. * Gets the setp to use when using in "slider" mode
  80876. */
  80877. step?: number;
  80878. }
  80879. }
  80880. declare module BABYLON {
  80881. /**
  80882. * Class used to provide helper for timing
  80883. */
  80884. export class TimingTools {
  80885. /**
  80886. * Polyfill for setImmediate
  80887. * @param action defines the action to execute after the current execution block
  80888. */
  80889. static SetImmediate(action: () => void): void;
  80890. }
  80891. }
  80892. declare module BABYLON {
  80893. /**
  80894. * Class used to enable instatition of objects by class name
  80895. */
  80896. export class InstantiationTools {
  80897. /**
  80898. * Use this object to register external classes like custom textures or material
  80899. * to allow the laoders to instantiate them
  80900. */
  80901. static RegisteredExternalClasses: {
  80902. [key: string]: Object;
  80903. };
  80904. /**
  80905. * Tries to instantiate a new object from a given class name
  80906. * @param className defines the class name to instantiate
  80907. * @returns the new object or null if the system was not able to do the instantiation
  80908. */
  80909. static Instantiate(className: string): any;
  80910. }
  80911. }
  80912. declare module BABYLON {
  80913. /**
  80914. * Define options used to create a depth texture
  80915. */
  80916. export class DepthTextureCreationOptions {
  80917. /** Specifies whether or not a stencil should be allocated in the texture */
  80918. generateStencil?: boolean;
  80919. /** Specifies whether or not bilinear filtering is enable on the texture */
  80920. bilinearFiltering?: boolean;
  80921. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80922. comparisonFunction?: number;
  80923. /** Specifies if the created texture is a cube texture */
  80924. isCube?: boolean;
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. interface ThinEngine {
  80929. /**
  80930. * Creates a depth stencil cube texture.
  80931. * This is only available in WebGL 2.
  80932. * @param size The size of face edge in the cube texture.
  80933. * @param options The options defining the cube texture.
  80934. * @returns The cube texture
  80935. */
  80936. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80937. /**
  80938. * Creates a cube texture
  80939. * @param rootUrl defines the url where the files to load is located
  80940. * @param scene defines the current scene
  80941. * @param files defines the list of files to load (1 per face)
  80942. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80943. * @param onLoad defines an optional callback raised when the texture is loaded
  80944. * @param onError defines an optional callback raised if there is an issue to load the texture
  80945. * @param format defines the format of the data
  80946. * @param forcedExtension defines the extension to use to pick the right loader
  80947. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80948. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80949. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80950. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80951. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80952. * @returns the cube texture as an InternalTexture
  80953. */
  80954. 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;
  80955. /**
  80956. * Creates a cube texture
  80957. * @param rootUrl defines the url where the files to load is located
  80958. * @param scene defines the current scene
  80959. * @param files defines the list of files to load (1 per face)
  80960. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80961. * @param onLoad defines an optional callback raised when the texture is loaded
  80962. * @param onError defines an optional callback raised if there is an issue to load the texture
  80963. * @param format defines the format of the data
  80964. * @param forcedExtension defines the extension to use to pick the right loader
  80965. * @returns the cube texture as an InternalTexture
  80966. */
  80967. 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;
  80968. /**
  80969. * Creates a cube texture
  80970. * @param rootUrl defines the url where the files to load is located
  80971. * @param scene defines the current scene
  80972. * @param files defines the list of files to load (1 per face)
  80973. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80974. * @param onLoad defines an optional callback raised when the texture is loaded
  80975. * @param onError defines an optional callback raised if there is an issue to load the texture
  80976. * @param format defines the format of the data
  80977. * @param forcedExtension defines the extension to use to pick the right loader
  80978. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80979. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80980. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80981. * @returns the cube texture as an InternalTexture
  80982. */
  80983. 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;
  80984. /** @hidden */
  80985. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80986. /** @hidden */
  80987. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80988. /** @hidden */
  80989. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80990. /** @hidden */
  80991. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80992. /**
  80993. * @hidden
  80994. */
  80995. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80996. }
  80997. }
  80998. declare module BABYLON {
  80999. /**
  81000. * Class for creating a cube texture
  81001. */
  81002. export class CubeTexture extends BaseTexture {
  81003. private _delayedOnLoad;
  81004. /**
  81005. * Observable triggered once the texture has been loaded.
  81006. */
  81007. onLoadObservable: Observable<CubeTexture>;
  81008. /**
  81009. * The url of the texture
  81010. */
  81011. url: string;
  81012. /**
  81013. * Gets or sets the center of the bounding box associated with the cube texture.
  81014. * It must define where the camera used to render the texture was set
  81015. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81016. */
  81017. boundingBoxPosition: Vector3;
  81018. private _boundingBoxSize;
  81019. /**
  81020. * Gets or sets the size of the bounding box associated with the cube texture
  81021. * When defined, the cubemap will switch to local mode
  81022. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81023. * @example https://www.babylonjs-playground.com/#RNASML
  81024. */
  81025. set boundingBoxSize(value: Vector3);
  81026. /**
  81027. * Returns the bounding box size
  81028. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81029. */
  81030. get boundingBoxSize(): Vector3;
  81031. protected _rotationY: number;
  81032. /**
  81033. * Sets texture matrix rotation angle around Y axis in radians.
  81034. */
  81035. set rotationY(value: number);
  81036. /**
  81037. * Gets texture matrix rotation angle around Y axis radians.
  81038. */
  81039. get rotationY(): number;
  81040. /**
  81041. * Are mip maps generated for this texture or not.
  81042. */
  81043. get noMipmap(): boolean;
  81044. private _noMipmap;
  81045. private _files;
  81046. protected _forcedExtension: Nullable<string>;
  81047. private _extensions;
  81048. private _textureMatrix;
  81049. private _format;
  81050. private _createPolynomials;
  81051. /** @hidden */
  81052. _prefiltered: boolean;
  81053. /**
  81054. * Creates a cube texture from an array of image urls
  81055. * @param files defines an array of image urls
  81056. * @param scene defines the hosting scene
  81057. * @param noMipmap specifies if mip maps are not used
  81058. * @returns a cube texture
  81059. */
  81060. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81061. /**
  81062. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81063. * @param url defines the url of the prefiltered texture
  81064. * @param scene defines the scene the texture is attached to
  81065. * @param forcedExtension defines the extension of the file if different from the url
  81066. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81067. * @return the prefiltered texture
  81068. */
  81069. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81070. /**
  81071. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81072. * as prefiltered data.
  81073. * @param rootUrl defines the url of the texture or the root name of the six images
  81074. * @param scene defines the scene the texture is attached to
  81075. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81076. * @param noMipmap defines if mipmaps should be created or not
  81077. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81078. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81079. * @param onError defines a callback triggered in case of error during load
  81080. * @param format defines the internal format to use for the texture once loaded
  81081. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81082. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81083. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81084. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81085. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81086. * @return the cube texture
  81087. */
  81088. 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);
  81089. /**
  81090. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81091. */
  81092. get isPrefiltered(): boolean;
  81093. /**
  81094. * Get the current class name of the texture useful for serialization or dynamic coding.
  81095. * @returns "CubeTexture"
  81096. */
  81097. getClassName(): string;
  81098. /**
  81099. * Update the url (and optional buffer) of this texture if url was null during construction.
  81100. * @param url the url of the texture
  81101. * @param forcedExtension defines the extension to use
  81102. * @param onLoad callback called when the texture is loaded (defaults to null)
  81103. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81104. */
  81105. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81106. /**
  81107. * Delays loading of the cube texture
  81108. * @param forcedExtension defines the extension to use
  81109. */
  81110. delayLoad(forcedExtension?: string): void;
  81111. /**
  81112. * Returns the reflection texture matrix
  81113. * @returns the reflection texture matrix
  81114. */
  81115. getReflectionTextureMatrix(): Matrix;
  81116. /**
  81117. * Sets the reflection texture matrix
  81118. * @param value Reflection texture matrix
  81119. */
  81120. setReflectionTextureMatrix(value: Matrix): void;
  81121. /**
  81122. * Parses text to create a cube texture
  81123. * @param parsedTexture define the serialized text to read from
  81124. * @param scene defines the hosting scene
  81125. * @param rootUrl defines the root url of the cube texture
  81126. * @returns a cube texture
  81127. */
  81128. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81129. /**
  81130. * Makes a clone, or deep copy, of the cube texture
  81131. * @returns a new cube texture
  81132. */
  81133. clone(): CubeTexture;
  81134. }
  81135. }
  81136. declare module BABYLON {
  81137. /**
  81138. * Manages the defines for the Material
  81139. */
  81140. export class MaterialDefines {
  81141. /** @hidden */
  81142. protected _keys: string[];
  81143. private _isDirty;
  81144. /** @hidden */
  81145. _renderId: number;
  81146. /** @hidden */
  81147. _areLightsDirty: boolean;
  81148. /** @hidden */
  81149. _areLightsDisposed: boolean;
  81150. /** @hidden */
  81151. _areAttributesDirty: boolean;
  81152. /** @hidden */
  81153. _areTexturesDirty: boolean;
  81154. /** @hidden */
  81155. _areFresnelDirty: boolean;
  81156. /** @hidden */
  81157. _areMiscDirty: boolean;
  81158. /** @hidden */
  81159. _areImageProcessingDirty: boolean;
  81160. /** @hidden */
  81161. _normals: boolean;
  81162. /** @hidden */
  81163. _uvs: boolean;
  81164. /** @hidden */
  81165. _needNormals: boolean;
  81166. /** @hidden */
  81167. _needUVs: boolean;
  81168. [id: string]: any;
  81169. /**
  81170. * Specifies if the material needs to be re-calculated
  81171. */
  81172. get isDirty(): boolean;
  81173. /**
  81174. * Marks the material to indicate that it has been re-calculated
  81175. */
  81176. markAsProcessed(): void;
  81177. /**
  81178. * Marks the material to indicate that it needs to be re-calculated
  81179. */
  81180. markAsUnprocessed(): void;
  81181. /**
  81182. * Marks the material to indicate all of its defines need to be re-calculated
  81183. */
  81184. markAllAsDirty(): void;
  81185. /**
  81186. * Marks the material to indicate that image processing needs to be re-calculated
  81187. */
  81188. markAsImageProcessingDirty(): void;
  81189. /**
  81190. * Marks the material to indicate the lights need to be re-calculated
  81191. * @param disposed Defines whether the light is dirty due to dispose or not
  81192. */
  81193. markAsLightDirty(disposed?: boolean): void;
  81194. /**
  81195. * Marks the attribute state as changed
  81196. */
  81197. markAsAttributesDirty(): void;
  81198. /**
  81199. * Marks the texture state as changed
  81200. */
  81201. markAsTexturesDirty(): void;
  81202. /**
  81203. * Marks the fresnel state as changed
  81204. */
  81205. markAsFresnelDirty(): void;
  81206. /**
  81207. * Marks the misc state as changed
  81208. */
  81209. markAsMiscDirty(): void;
  81210. /**
  81211. * Rebuilds the material defines
  81212. */
  81213. rebuild(): void;
  81214. /**
  81215. * Specifies if two material defines are equal
  81216. * @param other - A material define instance to compare to
  81217. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81218. */
  81219. isEqual(other: MaterialDefines): boolean;
  81220. /**
  81221. * Clones this instance's defines to another instance
  81222. * @param other - material defines to clone values to
  81223. */
  81224. cloneTo(other: MaterialDefines): void;
  81225. /**
  81226. * Resets the material define values
  81227. */
  81228. reset(): void;
  81229. /**
  81230. * Converts the material define values to a string
  81231. * @returns - String of material define information
  81232. */
  81233. toString(): string;
  81234. }
  81235. }
  81236. declare module BABYLON {
  81237. /**
  81238. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81239. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81240. * 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;
  81241. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81242. */
  81243. export class ColorCurves {
  81244. private _dirty;
  81245. private _tempColor;
  81246. private _globalCurve;
  81247. private _highlightsCurve;
  81248. private _midtonesCurve;
  81249. private _shadowsCurve;
  81250. private _positiveCurve;
  81251. private _negativeCurve;
  81252. private _globalHue;
  81253. private _globalDensity;
  81254. private _globalSaturation;
  81255. private _globalExposure;
  81256. /**
  81257. * Gets the global Hue value.
  81258. * 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).
  81259. */
  81260. get globalHue(): number;
  81261. /**
  81262. * Sets the global Hue value.
  81263. * 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).
  81264. */
  81265. set globalHue(value: number);
  81266. /**
  81267. * Gets the global Density value.
  81268. * 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.
  81269. * Values less than zero provide a filter of opposite hue.
  81270. */
  81271. get globalDensity(): number;
  81272. /**
  81273. * Sets the global Density value.
  81274. * 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.
  81275. * Values less than zero provide a filter of opposite hue.
  81276. */
  81277. set globalDensity(value: number);
  81278. /**
  81279. * Gets the global Saturation value.
  81280. * 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.
  81281. */
  81282. get globalSaturation(): number;
  81283. /**
  81284. * Sets the global Saturation value.
  81285. * 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.
  81286. */
  81287. set globalSaturation(value: number);
  81288. /**
  81289. * Gets the global Exposure value.
  81290. * 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.
  81291. */
  81292. get globalExposure(): number;
  81293. /**
  81294. * Sets the global Exposure value.
  81295. * 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.
  81296. */
  81297. set globalExposure(value: number);
  81298. private _highlightsHue;
  81299. private _highlightsDensity;
  81300. private _highlightsSaturation;
  81301. private _highlightsExposure;
  81302. /**
  81303. * Gets the highlights Hue value.
  81304. * 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).
  81305. */
  81306. get highlightsHue(): number;
  81307. /**
  81308. * Sets the highlights Hue value.
  81309. * 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).
  81310. */
  81311. set highlightsHue(value: number);
  81312. /**
  81313. * Gets the highlights Density value.
  81314. * 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.
  81315. * Values less than zero provide a filter of opposite hue.
  81316. */
  81317. get highlightsDensity(): number;
  81318. /**
  81319. * Sets the highlights Density value.
  81320. * 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.
  81321. * Values less than zero provide a filter of opposite hue.
  81322. */
  81323. set highlightsDensity(value: number);
  81324. /**
  81325. * Gets the highlights Saturation value.
  81326. * 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.
  81327. */
  81328. get highlightsSaturation(): number;
  81329. /**
  81330. * Sets the highlights Saturation value.
  81331. * 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.
  81332. */
  81333. set highlightsSaturation(value: number);
  81334. /**
  81335. * Gets the highlights Exposure value.
  81336. * 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.
  81337. */
  81338. get highlightsExposure(): number;
  81339. /**
  81340. * Sets the highlights Exposure value.
  81341. * 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.
  81342. */
  81343. set highlightsExposure(value: number);
  81344. private _midtonesHue;
  81345. private _midtonesDensity;
  81346. private _midtonesSaturation;
  81347. private _midtonesExposure;
  81348. /**
  81349. * Gets the midtones Hue value.
  81350. * 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).
  81351. */
  81352. get midtonesHue(): number;
  81353. /**
  81354. * Sets the midtones Hue value.
  81355. * 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).
  81356. */
  81357. set midtonesHue(value: number);
  81358. /**
  81359. * Gets the midtones Density value.
  81360. * 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.
  81361. * Values less than zero provide a filter of opposite hue.
  81362. */
  81363. get midtonesDensity(): number;
  81364. /**
  81365. * Sets the midtones Density value.
  81366. * 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.
  81367. * Values less than zero provide a filter of opposite hue.
  81368. */
  81369. set midtonesDensity(value: number);
  81370. /**
  81371. * Gets the midtones Saturation value.
  81372. * 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.
  81373. */
  81374. get midtonesSaturation(): number;
  81375. /**
  81376. * Sets the midtones Saturation value.
  81377. * 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.
  81378. */
  81379. set midtonesSaturation(value: number);
  81380. /**
  81381. * Gets the midtones Exposure value.
  81382. * 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.
  81383. */
  81384. get midtonesExposure(): number;
  81385. /**
  81386. * Sets the midtones Exposure value.
  81387. * 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.
  81388. */
  81389. set midtonesExposure(value: number);
  81390. private _shadowsHue;
  81391. private _shadowsDensity;
  81392. private _shadowsSaturation;
  81393. private _shadowsExposure;
  81394. /**
  81395. * Gets the shadows Hue value.
  81396. * 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).
  81397. */
  81398. get shadowsHue(): number;
  81399. /**
  81400. * Sets the shadows Hue value.
  81401. * 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).
  81402. */
  81403. set shadowsHue(value: number);
  81404. /**
  81405. * Gets the shadows Density value.
  81406. * 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.
  81407. * Values less than zero provide a filter of opposite hue.
  81408. */
  81409. get shadowsDensity(): number;
  81410. /**
  81411. * Sets the shadows Density value.
  81412. * 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.
  81413. * Values less than zero provide a filter of opposite hue.
  81414. */
  81415. set shadowsDensity(value: number);
  81416. /**
  81417. * Gets the shadows Saturation value.
  81418. * 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.
  81419. */
  81420. get shadowsSaturation(): number;
  81421. /**
  81422. * Sets the shadows Saturation value.
  81423. * 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.
  81424. */
  81425. set shadowsSaturation(value: number);
  81426. /**
  81427. * Gets the shadows Exposure value.
  81428. * 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.
  81429. */
  81430. get shadowsExposure(): number;
  81431. /**
  81432. * Sets the shadows Exposure value.
  81433. * 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.
  81434. */
  81435. set shadowsExposure(value: number);
  81436. /**
  81437. * Returns the class name
  81438. * @returns The class name
  81439. */
  81440. getClassName(): string;
  81441. /**
  81442. * Binds the color curves to the shader.
  81443. * @param colorCurves The color curve to bind
  81444. * @param effect The effect to bind to
  81445. * @param positiveUniform The positive uniform shader parameter
  81446. * @param neutralUniform The neutral uniform shader parameter
  81447. * @param negativeUniform The negative uniform shader parameter
  81448. */
  81449. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81450. /**
  81451. * Prepare the list of uniforms associated with the ColorCurves effects.
  81452. * @param uniformsList The list of uniforms used in the effect
  81453. */
  81454. static PrepareUniforms(uniformsList: string[]): void;
  81455. /**
  81456. * Returns color grading data based on a hue, density, saturation and exposure value.
  81457. * @param filterHue The hue of the color filter.
  81458. * @param filterDensity The density of the color filter.
  81459. * @param saturation The saturation.
  81460. * @param exposure The exposure.
  81461. * @param result The result data container.
  81462. */
  81463. private getColorGradingDataToRef;
  81464. /**
  81465. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81466. * @param value The input slider value in range [-100,100].
  81467. * @returns Adjusted value.
  81468. */
  81469. private static applyColorGradingSliderNonlinear;
  81470. /**
  81471. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81472. * @param hue The hue (H) input.
  81473. * @param saturation The saturation (S) input.
  81474. * @param brightness The brightness (B) input.
  81475. * @result An RGBA color represented as Vector4.
  81476. */
  81477. private static fromHSBToRef;
  81478. /**
  81479. * Returns a value clamped between min and max
  81480. * @param value The value to clamp
  81481. * @param min The minimum of value
  81482. * @param max The maximum of value
  81483. * @returns The clamped value.
  81484. */
  81485. private static clamp;
  81486. /**
  81487. * Clones the current color curve instance.
  81488. * @return The cloned curves
  81489. */
  81490. clone(): ColorCurves;
  81491. /**
  81492. * Serializes the current color curve instance to a json representation.
  81493. * @return a JSON representation
  81494. */
  81495. serialize(): any;
  81496. /**
  81497. * Parses the color curve from a json representation.
  81498. * @param source the JSON source to parse
  81499. * @return The parsed curves
  81500. */
  81501. static Parse(source: any): ColorCurves;
  81502. }
  81503. }
  81504. declare module BABYLON {
  81505. /**
  81506. * Interface to follow in your material defines to integrate easily the
  81507. * Image proccessing functions.
  81508. * @hidden
  81509. */
  81510. export interface IImageProcessingConfigurationDefines {
  81511. IMAGEPROCESSING: boolean;
  81512. VIGNETTE: boolean;
  81513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81514. VIGNETTEBLENDMODEOPAQUE: boolean;
  81515. TONEMAPPING: boolean;
  81516. TONEMAPPING_ACES: boolean;
  81517. CONTRAST: boolean;
  81518. EXPOSURE: boolean;
  81519. COLORCURVES: boolean;
  81520. COLORGRADING: boolean;
  81521. COLORGRADING3D: boolean;
  81522. SAMPLER3DGREENDEPTH: boolean;
  81523. SAMPLER3DBGRMAP: boolean;
  81524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81525. }
  81526. /**
  81527. * @hidden
  81528. */
  81529. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81530. IMAGEPROCESSING: boolean;
  81531. VIGNETTE: boolean;
  81532. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81533. VIGNETTEBLENDMODEOPAQUE: boolean;
  81534. TONEMAPPING: boolean;
  81535. TONEMAPPING_ACES: boolean;
  81536. CONTRAST: boolean;
  81537. COLORCURVES: boolean;
  81538. COLORGRADING: boolean;
  81539. COLORGRADING3D: boolean;
  81540. SAMPLER3DGREENDEPTH: boolean;
  81541. SAMPLER3DBGRMAP: boolean;
  81542. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81543. EXPOSURE: boolean;
  81544. constructor();
  81545. }
  81546. /**
  81547. * This groups together the common properties used for image processing either in direct forward pass
  81548. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81549. * or not.
  81550. */
  81551. export class ImageProcessingConfiguration {
  81552. /**
  81553. * Default tone mapping applied in BabylonJS.
  81554. */
  81555. static readonly TONEMAPPING_STANDARD: number;
  81556. /**
  81557. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81558. * to other engines rendering to increase portability.
  81559. */
  81560. static readonly TONEMAPPING_ACES: number;
  81561. /**
  81562. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81563. */
  81564. colorCurves: Nullable<ColorCurves>;
  81565. private _colorCurvesEnabled;
  81566. /**
  81567. * Gets wether the color curves effect is enabled.
  81568. */
  81569. get colorCurvesEnabled(): boolean;
  81570. /**
  81571. * Sets wether the color curves effect is enabled.
  81572. */
  81573. set colorCurvesEnabled(value: boolean);
  81574. private _colorGradingTexture;
  81575. /**
  81576. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81577. */
  81578. get colorGradingTexture(): Nullable<BaseTexture>;
  81579. /**
  81580. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81581. */
  81582. set colorGradingTexture(value: Nullable<BaseTexture>);
  81583. private _colorGradingEnabled;
  81584. /**
  81585. * Gets wether the color grading effect is enabled.
  81586. */
  81587. get colorGradingEnabled(): boolean;
  81588. /**
  81589. * Sets wether the color grading effect is enabled.
  81590. */
  81591. set colorGradingEnabled(value: boolean);
  81592. private _colorGradingWithGreenDepth;
  81593. /**
  81594. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81595. */
  81596. get colorGradingWithGreenDepth(): boolean;
  81597. /**
  81598. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81599. */
  81600. set colorGradingWithGreenDepth(value: boolean);
  81601. private _colorGradingBGR;
  81602. /**
  81603. * Gets wether the color grading texture contains BGR values.
  81604. */
  81605. get colorGradingBGR(): boolean;
  81606. /**
  81607. * Sets wether the color grading texture contains BGR values.
  81608. */
  81609. set colorGradingBGR(value: boolean);
  81610. /** @hidden */
  81611. _exposure: number;
  81612. /**
  81613. * Gets the Exposure used in the effect.
  81614. */
  81615. get exposure(): number;
  81616. /**
  81617. * Sets the Exposure used in the effect.
  81618. */
  81619. set exposure(value: number);
  81620. private _toneMappingEnabled;
  81621. /**
  81622. * Gets wether the tone mapping effect is enabled.
  81623. */
  81624. get toneMappingEnabled(): boolean;
  81625. /**
  81626. * Sets wether the tone mapping effect is enabled.
  81627. */
  81628. set toneMappingEnabled(value: boolean);
  81629. private _toneMappingType;
  81630. /**
  81631. * Gets the type of tone mapping effect.
  81632. */
  81633. get toneMappingType(): number;
  81634. /**
  81635. * Sets the type of tone mapping effect used in BabylonJS.
  81636. */
  81637. set toneMappingType(value: number);
  81638. protected _contrast: number;
  81639. /**
  81640. * Gets the contrast used in the effect.
  81641. */
  81642. get contrast(): number;
  81643. /**
  81644. * Sets the contrast used in the effect.
  81645. */
  81646. set contrast(value: number);
  81647. /**
  81648. * Vignette stretch size.
  81649. */
  81650. vignetteStretch: number;
  81651. /**
  81652. * Vignette centre X Offset.
  81653. */
  81654. vignetteCentreX: number;
  81655. /**
  81656. * Vignette centre Y Offset.
  81657. */
  81658. vignetteCentreY: number;
  81659. /**
  81660. * Vignette weight or intensity of the vignette effect.
  81661. */
  81662. vignetteWeight: number;
  81663. /**
  81664. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81665. * if vignetteEnabled is set to true.
  81666. */
  81667. vignetteColor: Color4;
  81668. /**
  81669. * Camera field of view used by the Vignette effect.
  81670. */
  81671. vignetteCameraFov: number;
  81672. private _vignetteBlendMode;
  81673. /**
  81674. * Gets the vignette blend mode allowing different kind of effect.
  81675. */
  81676. get vignetteBlendMode(): number;
  81677. /**
  81678. * Sets the vignette blend mode allowing different kind of effect.
  81679. */
  81680. set vignetteBlendMode(value: number);
  81681. private _vignetteEnabled;
  81682. /**
  81683. * Gets wether the vignette effect is enabled.
  81684. */
  81685. get vignetteEnabled(): boolean;
  81686. /**
  81687. * Sets wether the vignette effect is enabled.
  81688. */
  81689. set vignetteEnabled(value: boolean);
  81690. private _applyByPostProcess;
  81691. /**
  81692. * Gets wether the image processing is applied through a post process or not.
  81693. */
  81694. get applyByPostProcess(): boolean;
  81695. /**
  81696. * Sets wether the image processing is applied through a post process or not.
  81697. */
  81698. set applyByPostProcess(value: boolean);
  81699. private _isEnabled;
  81700. /**
  81701. * Gets wether the image processing is enabled or not.
  81702. */
  81703. get isEnabled(): boolean;
  81704. /**
  81705. * Sets wether the image processing is enabled or not.
  81706. */
  81707. set isEnabled(value: boolean);
  81708. /**
  81709. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81710. */
  81711. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81712. /**
  81713. * Method called each time the image processing information changes requires to recompile the effect.
  81714. */
  81715. protected _updateParameters(): void;
  81716. /**
  81717. * Gets the current class name.
  81718. * @return "ImageProcessingConfiguration"
  81719. */
  81720. getClassName(): string;
  81721. /**
  81722. * Prepare the list of uniforms associated with the Image Processing effects.
  81723. * @param uniforms The list of uniforms used in the effect
  81724. * @param defines the list of defines currently in use
  81725. */
  81726. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81727. /**
  81728. * Prepare the list of samplers associated with the Image Processing effects.
  81729. * @param samplersList The list of uniforms used in the effect
  81730. * @param defines the list of defines currently in use
  81731. */
  81732. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81733. /**
  81734. * Prepare the list of defines associated to the shader.
  81735. * @param defines the list of defines to complete
  81736. * @param forPostProcess Define if we are currently in post process mode or not
  81737. */
  81738. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81739. /**
  81740. * Returns true if all the image processing information are ready.
  81741. * @returns True if ready, otherwise, false
  81742. */
  81743. isReady(): boolean;
  81744. /**
  81745. * Binds the image processing to the shader.
  81746. * @param effect The effect to bind to
  81747. * @param overrideAspectRatio Override the aspect ratio of the effect
  81748. */
  81749. bind(effect: Effect, overrideAspectRatio?: number): void;
  81750. /**
  81751. * Clones the current image processing instance.
  81752. * @return The cloned image processing
  81753. */
  81754. clone(): ImageProcessingConfiguration;
  81755. /**
  81756. * Serializes the current image processing instance to a json representation.
  81757. * @return a JSON representation
  81758. */
  81759. serialize(): any;
  81760. /**
  81761. * Parses the image processing from a json representation.
  81762. * @param source the JSON source to parse
  81763. * @return The parsed image processing
  81764. */
  81765. static Parse(source: any): ImageProcessingConfiguration;
  81766. private static _VIGNETTEMODE_MULTIPLY;
  81767. private static _VIGNETTEMODE_OPAQUE;
  81768. /**
  81769. * Used to apply the vignette as a mix with the pixel color.
  81770. */
  81771. static get VIGNETTEMODE_MULTIPLY(): number;
  81772. /**
  81773. * Used to apply the vignette as a replacement of the pixel color.
  81774. */
  81775. static get VIGNETTEMODE_OPAQUE(): number;
  81776. }
  81777. }
  81778. declare module BABYLON {
  81779. /** @hidden */
  81780. export var postprocessVertexShader: {
  81781. name: string;
  81782. shader: string;
  81783. };
  81784. }
  81785. declare module BABYLON {
  81786. interface ThinEngine {
  81787. /**
  81788. * Creates a new render target texture
  81789. * @param size defines the size of the texture
  81790. * @param options defines the options used to create the texture
  81791. * @returns a new render target texture stored in an InternalTexture
  81792. */
  81793. createRenderTargetTexture(size: number | {
  81794. width: number;
  81795. height: number;
  81796. layers?: number;
  81797. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81798. /**
  81799. * Creates a depth stencil texture.
  81800. * This is only available in WebGL 2 or with the depth texture extension available.
  81801. * @param size The size of face edge in the texture.
  81802. * @param options The options defining the texture.
  81803. * @returns The texture
  81804. */
  81805. createDepthStencilTexture(size: number | {
  81806. width: number;
  81807. height: number;
  81808. layers?: number;
  81809. }, options: DepthTextureCreationOptions): InternalTexture;
  81810. /** @hidden */
  81811. _createDepthStencilTexture(size: number | {
  81812. width: number;
  81813. height: number;
  81814. layers?: number;
  81815. }, options: DepthTextureCreationOptions): InternalTexture;
  81816. }
  81817. }
  81818. declare module BABYLON {
  81819. /** Defines supported spaces */
  81820. export enum Space {
  81821. /** Local (object) space */
  81822. LOCAL = 0,
  81823. /** World space */
  81824. WORLD = 1,
  81825. /** Bone space */
  81826. BONE = 2
  81827. }
  81828. /** Defines the 3 main axes */
  81829. export class Axis {
  81830. /** X axis */
  81831. static X: Vector3;
  81832. /** Y axis */
  81833. static Y: Vector3;
  81834. /** Z axis */
  81835. static Z: Vector3;
  81836. }
  81837. }
  81838. declare module BABYLON {
  81839. /**
  81840. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81841. * This is the base of the follow, arc rotate cameras and Free camera
  81842. * @see http://doc.babylonjs.com/features/cameras
  81843. */
  81844. export class TargetCamera extends Camera {
  81845. private static _RigCamTransformMatrix;
  81846. private static _TargetTransformMatrix;
  81847. private static _TargetFocalPoint;
  81848. /**
  81849. * Define the current direction the camera is moving to
  81850. */
  81851. cameraDirection: Vector3;
  81852. /**
  81853. * Define the current rotation the camera is rotating to
  81854. */
  81855. cameraRotation: Vector2;
  81856. /**
  81857. * When set, the up vector of the camera will be updated by the rotation of the camera
  81858. */
  81859. updateUpVectorFromRotation: boolean;
  81860. private _tmpQuaternion;
  81861. /**
  81862. * Define the current rotation of the camera
  81863. */
  81864. rotation: Vector3;
  81865. /**
  81866. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81867. */
  81868. rotationQuaternion: Quaternion;
  81869. /**
  81870. * Define the current speed of the camera
  81871. */
  81872. speed: number;
  81873. /**
  81874. * Add constraint to the camera to prevent it to move freely in all directions and
  81875. * around all axis.
  81876. */
  81877. noRotationConstraint: boolean;
  81878. /**
  81879. * Define the current target of the camera as an object or a position.
  81880. */
  81881. lockedTarget: any;
  81882. /** @hidden */
  81883. _currentTarget: Vector3;
  81884. /** @hidden */
  81885. _initialFocalDistance: number;
  81886. /** @hidden */
  81887. _viewMatrix: Matrix;
  81888. /** @hidden */
  81889. _camMatrix: Matrix;
  81890. /** @hidden */
  81891. _cameraTransformMatrix: Matrix;
  81892. /** @hidden */
  81893. _cameraRotationMatrix: Matrix;
  81894. /** @hidden */
  81895. _referencePoint: Vector3;
  81896. /** @hidden */
  81897. _transformedReferencePoint: Vector3;
  81898. protected _globalCurrentTarget: Vector3;
  81899. protected _globalCurrentUpVector: Vector3;
  81900. /** @hidden */
  81901. _reset: () => void;
  81902. private _defaultUp;
  81903. /**
  81904. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81905. * This is the base of the follow, arc rotate cameras and Free camera
  81906. * @see http://doc.babylonjs.com/features/cameras
  81907. * @param name Defines the name of the camera in the scene
  81908. * @param position Defines the start position of the camera in the scene
  81909. * @param scene Defines the scene the camera belongs to
  81910. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81911. */
  81912. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81913. /**
  81914. * Gets the position in front of the camera at a given distance.
  81915. * @param distance The distance from the camera we want the position to be
  81916. * @returns the position
  81917. */
  81918. getFrontPosition(distance: number): Vector3;
  81919. /** @hidden */
  81920. _getLockedTargetPosition(): Nullable<Vector3>;
  81921. private _storedPosition;
  81922. private _storedRotation;
  81923. private _storedRotationQuaternion;
  81924. /**
  81925. * Store current camera state of the camera (fov, position, rotation, etc..)
  81926. * @returns the camera
  81927. */
  81928. storeState(): Camera;
  81929. /**
  81930. * Restored camera state. You must call storeState() first
  81931. * @returns whether it was successful or not
  81932. * @hidden
  81933. */
  81934. _restoreStateValues(): boolean;
  81935. /** @hidden */
  81936. _initCache(): void;
  81937. /** @hidden */
  81938. _updateCache(ignoreParentClass?: boolean): void;
  81939. /** @hidden */
  81940. _isSynchronizedViewMatrix(): boolean;
  81941. /** @hidden */
  81942. _computeLocalCameraSpeed(): number;
  81943. /**
  81944. * Defines the target the camera should look at.
  81945. * @param target Defines the new target as a Vector or a mesh
  81946. */
  81947. setTarget(target: Vector3): void;
  81948. /**
  81949. * Return the current target position of the camera. This value is expressed in local space.
  81950. * @returns the target position
  81951. */
  81952. getTarget(): Vector3;
  81953. /** @hidden */
  81954. _decideIfNeedsToMove(): boolean;
  81955. /** @hidden */
  81956. _updatePosition(): void;
  81957. /** @hidden */
  81958. _checkInputs(): void;
  81959. protected _updateCameraRotationMatrix(): void;
  81960. /**
  81961. * 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)
  81962. * @returns the current camera
  81963. */
  81964. private _rotateUpVectorWithCameraRotationMatrix;
  81965. private _cachedRotationZ;
  81966. private _cachedQuaternionRotationZ;
  81967. /** @hidden */
  81968. _getViewMatrix(): Matrix;
  81969. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81970. /**
  81971. * @hidden
  81972. */
  81973. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81974. /**
  81975. * @hidden
  81976. */
  81977. _updateRigCameras(): void;
  81978. private _getRigCamPositionAndTarget;
  81979. /**
  81980. * Gets the current object class name.
  81981. * @return the class name
  81982. */
  81983. getClassName(): string;
  81984. }
  81985. }
  81986. declare module BABYLON {
  81987. /**
  81988. * Gather the list of keyboard event types as constants.
  81989. */
  81990. export class KeyboardEventTypes {
  81991. /**
  81992. * The keydown event is fired when a key becomes active (pressed).
  81993. */
  81994. static readonly KEYDOWN: number;
  81995. /**
  81996. * The keyup event is fired when a key has been released.
  81997. */
  81998. static readonly KEYUP: number;
  81999. }
  82000. /**
  82001. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82002. */
  82003. export class KeyboardInfo {
  82004. /**
  82005. * Defines the type of event (KeyboardEventTypes)
  82006. */
  82007. type: number;
  82008. /**
  82009. * Defines the related dom event
  82010. */
  82011. event: KeyboardEvent;
  82012. /**
  82013. * Instantiates a new keyboard info.
  82014. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82015. * @param type Defines the type of event (KeyboardEventTypes)
  82016. * @param event Defines the related dom event
  82017. */
  82018. constructor(
  82019. /**
  82020. * Defines the type of event (KeyboardEventTypes)
  82021. */
  82022. type: number,
  82023. /**
  82024. * Defines the related dom event
  82025. */
  82026. event: KeyboardEvent);
  82027. }
  82028. /**
  82029. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82030. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82031. */
  82032. export class KeyboardInfoPre extends KeyboardInfo {
  82033. /**
  82034. * Defines the type of event (KeyboardEventTypes)
  82035. */
  82036. type: number;
  82037. /**
  82038. * Defines the related dom event
  82039. */
  82040. event: KeyboardEvent;
  82041. /**
  82042. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82043. */
  82044. skipOnPointerObservable: boolean;
  82045. /**
  82046. * Instantiates a new keyboard pre info.
  82047. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82048. * @param type Defines the type of event (KeyboardEventTypes)
  82049. * @param event Defines the related dom event
  82050. */
  82051. constructor(
  82052. /**
  82053. * Defines the type of event (KeyboardEventTypes)
  82054. */
  82055. type: number,
  82056. /**
  82057. * Defines the related dom event
  82058. */
  82059. event: KeyboardEvent);
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. /**
  82064. * Manage the keyboard inputs to control the movement of a free camera.
  82065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82066. */
  82067. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82068. /**
  82069. * Defines the camera the input is attached to.
  82070. */
  82071. camera: FreeCamera;
  82072. /**
  82073. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82074. */
  82075. keysUp: number[];
  82076. /**
  82077. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82078. */
  82079. keysDown: number[];
  82080. /**
  82081. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82082. */
  82083. keysLeft: number[];
  82084. /**
  82085. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82086. */
  82087. keysRight: number[];
  82088. private _keys;
  82089. private _onCanvasBlurObserver;
  82090. private _onKeyboardObserver;
  82091. private _engine;
  82092. private _scene;
  82093. /**
  82094. * Attach the input controls to a specific dom element to get the input from.
  82095. * @param element Defines the element the controls should be listened from
  82096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82097. */
  82098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82099. /**
  82100. * Detach the current controls from the specified dom element.
  82101. * @param element Defines the element to stop listening the inputs from
  82102. */
  82103. detachControl(element: Nullable<HTMLElement>): void;
  82104. /**
  82105. * Update the current camera state depending on the inputs that have been used this frame.
  82106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82107. */
  82108. checkInputs(): void;
  82109. /**
  82110. * Gets the class name of the current intput.
  82111. * @returns the class name
  82112. */
  82113. getClassName(): string;
  82114. /** @hidden */
  82115. _onLostFocus(): void;
  82116. /**
  82117. * Get the friendly name associated with the input class.
  82118. * @returns the input friendly name
  82119. */
  82120. getSimpleName(): string;
  82121. }
  82122. }
  82123. declare module BABYLON {
  82124. /**
  82125. * Interface describing all the common properties and methods a shadow light needs to implement.
  82126. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82127. * as well as binding the different shadow properties to the effects.
  82128. */
  82129. export interface IShadowLight extends Light {
  82130. /**
  82131. * The light id in the scene (used in scene.findLighById for instance)
  82132. */
  82133. id: string;
  82134. /**
  82135. * The position the shdow will be casted from.
  82136. */
  82137. position: Vector3;
  82138. /**
  82139. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82140. */
  82141. direction: Vector3;
  82142. /**
  82143. * The transformed position. Position of the light in world space taking parenting in account.
  82144. */
  82145. transformedPosition: Vector3;
  82146. /**
  82147. * The transformed direction. Direction of the light in world space taking parenting in account.
  82148. */
  82149. transformedDirection: Vector3;
  82150. /**
  82151. * The friendly name of the light in the scene.
  82152. */
  82153. name: string;
  82154. /**
  82155. * Defines the shadow projection clipping minimum z value.
  82156. */
  82157. shadowMinZ: number;
  82158. /**
  82159. * Defines the shadow projection clipping maximum z value.
  82160. */
  82161. shadowMaxZ: number;
  82162. /**
  82163. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82164. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82165. */
  82166. computeTransformedInformation(): boolean;
  82167. /**
  82168. * Gets the scene the light belongs to.
  82169. * @returns The scene
  82170. */
  82171. getScene(): Scene;
  82172. /**
  82173. * Callback defining a custom Projection Matrix Builder.
  82174. * This can be used to override the default projection matrix computation.
  82175. */
  82176. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82177. /**
  82178. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82179. * @param matrix The materix to updated with the projection information
  82180. * @param viewMatrix The transform matrix of the light
  82181. * @param renderList The list of mesh to render in the map
  82182. * @returns The current light
  82183. */
  82184. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82185. /**
  82186. * Gets the current depth scale used in ESM.
  82187. * @returns The scale
  82188. */
  82189. getDepthScale(): number;
  82190. /**
  82191. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82192. * @returns true if a cube texture needs to be use
  82193. */
  82194. needCube(): boolean;
  82195. /**
  82196. * Detects if the projection matrix requires to be recomputed this frame.
  82197. * @returns true if it requires to be recomputed otherwise, false.
  82198. */
  82199. needProjectionMatrixCompute(): boolean;
  82200. /**
  82201. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82202. */
  82203. forceProjectionMatrixCompute(): void;
  82204. /**
  82205. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82206. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82207. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82208. */
  82209. getShadowDirection(faceIndex?: number): Vector3;
  82210. /**
  82211. * Gets the minZ used for shadow according to both the scene and the light.
  82212. * @param activeCamera The camera we are returning the min for
  82213. * @returns the depth min z
  82214. */
  82215. getDepthMinZ(activeCamera: Camera): number;
  82216. /**
  82217. * Gets the maxZ used for shadow according to both the scene and the light.
  82218. * @param activeCamera The camera we are returning the max for
  82219. * @returns the depth max z
  82220. */
  82221. getDepthMaxZ(activeCamera: Camera): number;
  82222. }
  82223. /**
  82224. * Base implementation IShadowLight
  82225. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82226. */
  82227. export abstract class ShadowLight extends Light implements IShadowLight {
  82228. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82229. protected _position: Vector3;
  82230. protected _setPosition(value: Vector3): void;
  82231. /**
  82232. * Sets the position the shadow will be casted from. Also use as the light position for both
  82233. * point and spot lights.
  82234. */
  82235. get position(): Vector3;
  82236. /**
  82237. * Sets the position the shadow will be casted from. Also use as the light position for both
  82238. * point and spot lights.
  82239. */
  82240. set position(value: Vector3);
  82241. protected _direction: Vector3;
  82242. protected _setDirection(value: Vector3): void;
  82243. /**
  82244. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82245. * Also use as the light direction on spot and directional lights.
  82246. */
  82247. get direction(): Vector3;
  82248. /**
  82249. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82250. * Also use as the light direction on spot and directional lights.
  82251. */
  82252. set direction(value: Vector3);
  82253. protected _shadowMinZ: number;
  82254. /**
  82255. * Gets the shadow projection clipping minimum z value.
  82256. */
  82257. get shadowMinZ(): number;
  82258. /**
  82259. * Sets the shadow projection clipping minimum z value.
  82260. */
  82261. set shadowMinZ(value: number);
  82262. protected _shadowMaxZ: number;
  82263. /**
  82264. * Sets the shadow projection clipping maximum z value.
  82265. */
  82266. get shadowMaxZ(): number;
  82267. /**
  82268. * Gets the shadow projection clipping maximum z value.
  82269. */
  82270. set shadowMaxZ(value: number);
  82271. /**
  82272. * Callback defining a custom Projection Matrix Builder.
  82273. * This can be used to override the default projection matrix computation.
  82274. */
  82275. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82276. /**
  82277. * The transformed position. Position of the light in world space taking parenting in account.
  82278. */
  82279. transformedPosition: Vector3;
  82280. /**
  82281. * The transformed direction. Direction of the light in world space taking parenting in account.
  82282. */
  82283. transformedDirection: Vector3;
  82284. private _needProjectionMatrixCompute;
  82285. /**
  82286. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82287. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82288. */
  82289. computeTransformedInformation(): boolean;
  82290. /**
  82291. * Return the depth scale used for the shadow map.
  82292. * @returns the depth scale.
  82293. */
  82294. getDepthScale(): number;
  82295. /**
  82296. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82297. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82298. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82299. */
  82300. getShadowDirection(faceIndex?: number): Vector3;
  82301. /**
  82302. * Returns the ShadowLight absolute position in the World.
  82303. * @returns the position vector in world space
  82304. */
  82305. getAbsolutePosition(): Vector3;
  82306. /**
  82307. * Sets the ShadowLight direction toward the passed target.
  82308. * @param target The point to target in local space
  82309. * @returns the updated ShadowLight direction
  82310. */
  82311. setDirectionToTarget(target: Vector3): Vector3;
  82312. /**
  82313. * Returns the light rotation in euler definition.
  82314. * @returns the x y z rotation in local space.
  82315. */
  82316. getRotation(): Vector3;
  82317. /**
  82318. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82319. * @returns true if a cube texture needs to be use
  82320. */
  82321. needCube(): boolean;
  82322. /**
  82323. * Detects if the projection matrix requires to be recomputed this frame.
  82324. * @returns true if it requires to be recomputed otherwise, false.
  82325. */
  82326. needProjectionMatrixCompute(): boolean;
  82327. /**
  82328. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82329. */
  82330. forceProjectionMatrixCompute(): void;
  82331. /** @hidden */
  82332. _initCache(): void;
  82333. /** @hidden */
  82334. _isSynchronized(): boolean;
  82335. /**
  82336. * Computes the world matrix of the node
  82337. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82338. * @returns the world matrix
  82339. */
  82340. computeWorldMatrix(force?: boolean): Matrix;
  82341. /**
  82342. * Gets the minZ used for shadow according to both the scene and the light.
  82343. * @param activeCamera The camera we are returning the min for
  82344. * @returns the depth min z
  82345. */
  82346. getDepthMinZ(activeCamera: Camera): number;
  82347. /**
  82348. * Gets the maxZ used for shadow according to both the scene and the light.
  82349. * @param activeCamera The camera we are returning the max for
  82350. * @returns the depth max z
  82351. */
  82352. getDepthMaxZ(activeCamera: Camera): number;
  82353. /**
  82354. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82355. * @param matrix The materix to updated with the projection information
  82356. * @param viewMatrix The transform matrix of the light
  82357. * @param renderList The list of mesh to render in the map
  82358. * @returns The current light
  82359. */
  82360. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82361. }
  82362. }
  82363. declare module BABYLON {
  82364. /**
  82365. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82366. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82367. */
  82368. export class EffectFallbacks implements IEffectFallbacks {
  82369. private _defines;
  82370. private _currentRank;
  82371. private _maxRank;
  82372. private _mesh;
  82373. /**
  82374. * Removes the fallback from the bound mesh.
  82375. */
  82376. unBindMesh(): void;
  82377. /**
  82378. * Adds a fallback on the specified property.
  82379. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82380. * @param define The name of the define in the shader
  82381. */
  82382. addFallback(rank: number, define: string): void;
  82383. /**
  82384. * Sets the mesh to use CPU skinning when needing to fallback.
  82385. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82386. * @param mesh The mesh to use the fallbacks.
  82387. */
  82388. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82389. /**
  82390. * Checks to see if more fallbacks are still availible.
  82391. */
  82392. get hasMoreFallbacks(): boolean;
  82393. /**
  82394. * Removes the defines that should be removed when falling back.
  82395. * @param currentDefines defines the current define statements for the shader.
  82396. * @param effect defines the current effect we try to compile
  82397. * @returns The resulting defines with defines of the current rank removed.
  82398. */
  82399. reduce(currentDefines: string, effect: Effect): string;
  82400. }
  82401. }
  82402. declare module BABYLON {
  82403. /**
  82404. * "Static Class" containing the most commonly used helper while dealing with material for
  82405. * rendering purpose.
  82406. *
  82407. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82408. *
  82409. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82410. */
  82411. export class MaterialHelper {
  82412. /**
  82413. * Bind the current view position to an effect.
  82414. * @param effect The effect to be bound
  82415. * @param scene The scene the eyes position is used from
  82416. */
  82417. static BindEyePosition(effect: Effect, scene: Scene): void;
  82418. /**
  82419. * Helps preparing the defines values about the UVs in used in the effect.
  82420. * UVs are shared as much as we can accross channels in the shaders.
  82421. * @param texture The texture we are preparing the UVs for
  82422. * @param defines The defines to update
  82423. * @param key The channel key "diffuse", "specular"... used in the shader
  82424. */
  82425. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82426. /**
  82427. * Binds a texture matrix value to its corrsponding uniform
  82428. * @param texture The texture to bind the matrix for
  82429. * @param uniformBuffer The uniform buffer receivin the data
  82430. * @param key The channel key "diffuse", "specular"... used in the shader
  82431. */
  82432. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82433. /**
  82434. * Gets the current status of the fog (should it be enabled?)
  82435. * @param mesh defines the mesh to evaluate for fog support
  82436. * @param scene defines the hosting scene
  82437. * @returns true if fog must be enabled
  82438. */
  82439. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82440. /**
  82441. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82442. * @param mesh defines the current mesh
  82443. * @param scene defines the current scene
  82444. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82445. * @param pointsCloud defines if point cloud rendering has to be turned on
  82446. * @param fogEnabled defines if fog has to be turned on
  82447. * @param alphaTest defines if alpha testing has to be turned on
  82448. * @param defines defines the current list of defines
  82449. */
  82450. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82451. /**
  82452. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82453. * @param scene defines the current scene
  82454. * @param engine defines the current engine
  82455. * @param defines specifies the list of active defines
  82456. * @param useInstances defines if instances have to be turned on
  82457. * @param useClipPlane defines if clip plane have to be turned on
  82458. */
  82459. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82460. /**
  82461. * Prepares the defines for bones
  82462. * @param mesh The mesh containing the geometry data we will draw
  82463. * @param defines The defines to update
  82464. */
  82465. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82466. /**
  82467. * Prepares the defines for morph targets
  82468. * @param mesh The mesh containing the geometry data we will draw
  82469. * @param defines The defines to update
  82470. */
  82471. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82472. /**
  82473. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82474. * @param mesh The mesh containing the geometry data we will draw
  82475. * @param defines The defines to update
  82476. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82477. * @param useBones Precise whether bones should be used or not (override mesh info)
  82478. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82479. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82480. * @returns false if defines are considered not dirty and have not been checked
  82481. */
  82482. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82483. /**
  82484. * Prepares the defines related to multiview
  82485. * @param scene The scene we are intending to draw
  82486. * @param defines The defines to update
  82487. */
  82488. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82489. /**
  82490. * Prepares the defines related to the light information passed in parameter
  82491. * @param scene The scene we are intending to draw
  82492. * @param mesh The mesh the effect is compiling for
  82493. * @param light The light the effect is compiling for
  82494. * @param lightIndex The index of the light
  82495. * @param defines The defines to update
  82496. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82497. * @param state Defines the current state regarding what is needed (normals, etc...)
  82498. */
  82499. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82500. needNormals: boolean;
  82501. needRebuild: boolean;
  82502. shadowEnabled: boolean;
  82503. specularEnabled: boolean;
  82504. lightmapMode: boolean;
  82505. }): void;
  82506. /**
  82507. * Prepares the defines related to the light information passed in parameter
  82508. * @param scene The scene we are intending to draw
  82509. * @param mesh The mesh the effect is compiling for
  82510. * @param defines The defines to update
  82511. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82512. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82513. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82514. * @returns true if normals will be required for the rest of the effect
  82515. */
  82516. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82517. /**
  82518. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82519. * @param lightIndex defines the light index
  82520. * @param uniformsList The uniform list
  82521. * @param samplersList The sampler list
  82522. * @param projectedLightTexture defines if projected texture must be used
  82523. * @param uniformBuffersList defines an optional list of uniform buffers
  82524. */
  82525. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82526. /**
  82527. * Prepares the uniforms and samplers list to be used in the effect
  82528. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82529. * @param samplersList The sampler list
  82530. * @param defines The defines helping in the list generation
  82531. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82532. */
  82533. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82534. /**
  82535. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82536. * @param defines The defines to update while falling back
  82537. * @param fallbacks The authorized effect fallbacks
  82538. * @param maxSimultaneousLights The maximum number of lights allowed
  82539. * @param rank the current rank of the Effect
  82540. * @returns The newly affected rank
  82541. */
  82542. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82543. private static _TmpMorphInfluencers;
  82544. /**
  82545. * Prepares the list of attributes required for morph targets according to the effect defines.
  82546. * @param attribs The current list of supported attribs
  82547. * @param mesh The mesh to prepare the morph targets attributes for
  82548. * @param influencers The number of influencers
  82549. */
  82550. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82551. /**
  82552. * Prepares the list of attributes required for morph targets according to the effect defines.
  82553. * @param attribs The current list of supported attribs
  82554. * @param mesh The mesh to prepare the morph targets attributes for
  82555. * @param defines The current Defines of the effect
  82556. */
  82557. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82558. /**
  82559. * Prepares the list of attributes required for bones according to the effect defines.
  82560. * @param attribs The current list of supported attribs
  82561. * @param mesh The mesh to prepare the bones attributes for
  82562. * @param defines The current Defines of the effect
  82563. * @param fallbacks The current efffect fallback strategy
  82564. */
  82565. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82566. /**
  82567. * Check and prepare the list of attributes required for instances according to the effect defines.
  82568. * @param attribs The current list of supported attribs
  82569. * @param defines The current MaterialDefines of the effect
  82570. */
  82571. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82572. /**
  82573. * Add the list of attributes required for instances to the attribs array.
  82574. * @param attribs The current list of supported attribs
  82575. */
  82576. static PushAttributesForInstances(attribs: string[]): void;
  82577. /**
  82578. * Binds the light information to the effect.
  82579. * @param light The light containing the generator
  82580. * @param effect The effect we are binding the data to
  82581. * @param lightIndex The light index in the effect used to render
  82582. */
  82583. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82584. /**
  82585. * Binds the lights information from the scene to the effect for the given mesh.
  82586. * @param light Light to bind
  82587. * @param lightIndex Light index
  82588. * @param scene The scene where the light belongs to
  82589. * @param effect The effect we are binding the data to
  82590. * @param useSpecular Defines if specular is supported
  82591. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82592. */
  82593. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82594. /**
  82595. * Binds the lights information from the scene to the effect for the given mesh.
  82596. * @param scene The scene the lights belongs to
  82597. * @param mesh The mesh we are binding the information to render
  82598. * @param effect The effect we are binding the data to
  82599. * @param defines The generated defines for the effect
  82600. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82601. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82602. */
  82603. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82604. private static _tempFogColor;
  82605. /**
  82606. * Binds the fog information from the scene to the effect for the given mesh.
  82607. * @param scene The scene the lights belongs to
  82608. * @param mesh The mesh we are binding the information to render
  82609. * @param effect The effect we are binding the data to
  82610. * @param linearSpace Defines if the fog effect is applied in linear space
  82611. */
  82612. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82613. /**
  82614. * Binds the bones information from the mesh to the effect.
  82615. * @param mesh The mesh we are binding the information to render
  82616. * @param effect The effect we are binding the data to
  82617. */
  82618. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82619. /**
  82620. * Binds the morph targets information from the mesh to the effect.
  82621. * @param abstractMesh The mesh we are binding the information to render
  82622. * @param effect The effect we are binding the data to
  82623. */
  82624. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82625. /**
  82626. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82627. * @param defines The generated defines used in the effect
  82628. * @param effect The effect we are binding the data to
  82629. * @param scene The scene we are willing to render with logarithmic scale for
  82630. */
  82631. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82632. /**
  82633. * Binds the clip plane information from the scene to the effect.
  82634. * @param scene The scene the clip plane information are extracted from
  82635. * @param effect The effect we are binding the data to
  82636. */
  82637. static BindClipPlane(effect: Effect, scene: Scene): void;
  82638. }
  82639. }
  82640. declare module BABYLON {
  82641. /** @hidden */
  82642. export var packingFunctions: {
  82643. name: string;
  82644. shader: string;
  82645. };
  82646. }
  82647. declare module BABYLON {
  82648. /** @hidden */
  82649. export var clipPlaneFragmentDeclaration: {
  82650. name: string;
  82651. shader: string;
  82652. };
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var clipPlaneFragment: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. /** @hidden */
  82663. export var shadowMapPixelShader: {
  82664. name: string;
  82665. shader: string;
  82666. };
  82667. }
  82668. declare module BABYLON {
  82669. /** @hidden */
  82670. export var bonesDeclaration: {
  82671. name: string;
  82672. shader: string;
  82673. };
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export var morphTargetsVertexGlobalDeclaration: {
  82678. name: string;
  82679. shader: string;
  82680. };
  82681. }
  82682. declare module BABYLON {
  82683. /** @hidden */
  82684. export var morphTargetsVertexDeclaration: {
  82685. name: string;
  82686. shader: string;
  82687. };
  82688. }
  82689. declare module BABYLON {
  82690. /** @hidden */
  82691. export var instancesDeclaration: {
  82692. name: string;
  82693. shader: string;
  82694. };
  82695. }
  82696. declare module BABYLON {
  82697. /** @hidden */
  82698. export var helperFunctions: {
  82699. name: string;
  82700. shader: string;
  82701. };
  82702. }
  82703. declare module BABYLON {
  82704. /** @hidden */
  82705. export var clipPlaneVertexDeclaration: {
  82706. name: string;
  82707. shader: string;
  82708. };
  82709. }
  82710. declare module BABYLON {
  82711. /** @hidden */
  82712. export var morphTargetsVertex: {
  82713. name: string;
  82714. shader: string;
  82715. };
  82716. }
  82717. declare module BABYLON {
  82718. /** @hidden */
  82719. export var instancesVertex: {
  82720. name: string;
  82721. shader: string;
  82722. };
  82723. }
  82724. declare module BABYLON {
  82725. /** @hidden */
  82726. export var bonesVertex: {
  82727. name: string;
  82728. shader: string;
  82729. };
  82730. }
  82731. declare module BABYLON {
  82732. /** @hidden */
  82733. export var clipPlaneVertex: {
  82734. name: string;
  82735. shader: string;
  82736. };
  82737. }
  82738. declare module BABYLON {
  82739. /** @hidden */
  82740. export var shadowMapVertexShader: {
  82741. name: string;
  82742. shader: string;
  82743. };
  82744. }
  82745. declare module BABYLON {
  82746. /** @hidden */
  82747. export var depthBoxBlurPixelShader: {
  82748. name: string;
  82749. shader: string;
  82750. };
  82751. }
  82752. declare module BABYLON {
  82753. /**
  82754. * Class representing a ray with position and direction
  82755. */
  82756. export class Ray {
  82757. /** origin point */
  82758. origin: Vector3;
  82759. /** direction */
  82760. direction: Vector3;
  82761. /** length of the ray */
  82762. length: number;
  82763. private static readonly TmpVector3;
  82764. private _tmpRay;
  82765. /**
  82766. * Creates a new ray
  82767. * @param origin origin point
  82768. * @param direction direction
  82769. * @param length length of the ray
  82770. */
  82771. constructor(
  82772. /** origin point */
  82773. origin: Vector3,
  82774. /** direction */
  82775. direction: Vector3,
  82776. /** length of the ray */
  82777. length?: number);
  82778. /**
  82779. * Checks if the ray intersects a box
  82780. * @param minimum bound of the box
  82781. * @param maximum bound of the box
  82782. * @param intersectionTreshold extra extend to be added to the box in all direction
  82783. * @returns if the box was hit
  82784. */
  82785. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82786. /**
  82787. * Checks if the ray intersects a box
  82788. * @param box the bounding box to check
  82789. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82790. * @returns if the box was hit
  82791. */
  82792. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82793. /**
  82794. * If the ray hits a sphere
  82795. * @param sphere the bounding sphere to check
  82796. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82797. * @returns true if it hits the sphere
  82798. */
  82799. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82800. /**
  82801. * If the ray hits a triange
  82802. * @param vertex0 triangle vertex
  82803. * @param vertex1 triangle vertex
  82804. * @param vertex2 triangle vertex
  82805. * @returns intersection information if hit
  82806. */
  82807. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82808. /**
  82809. * Checks if ray intersects a plane
  82810. * @param plane the plane to check
  82811. * @returns the distance away it was hit
  82812. */
  82813. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82814. /**
  82815. * Calculate the intercept of a ray on a given axis
  82816. * @param axis to check 'x' | 'y' | 'z'
  82817. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82818. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82819. */
  82820. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82821. /**
  82822. * Checks if ray intersects a mesh
  82823. * @param mesh the mesh to check
  82824. * @param fastCheck if only the bounding box should checked
  82825. * @returns picking info of the intersecton
  82826. */
  82827. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82828. /**
  82829. * Checks if ray intersects a mesh
  82830. * @param meshes the meshes to check
  82831. * @param fastCheck if only the bounding box should checked
  82832. * @param results array to store result in
  82833. * @returns Array of picking infos
  82834. */
  82835. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82836. private _comparePickingInfo;
  82837. private static smallnum;
  82838. private static rayl;
  82839. /**
  82840. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82841. * @param sega the first point of the segment to test the intersection against
  82842. * @param segb the second point of the segment to test the intersection against
  82843. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82844. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82845. */
  82846. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82847. /**
  82848. * Update the ray from viewport position
  82849. * @param x position
  82850. * @param y y position
  82851. * @param viewportWidth viewport width
  82852. * @param viewportHeight viewport height
  82853. * @param world world matrix
  82854. * @param view view matrix
  82855. * @param projection projection matrix
  82856. * @returns this ray updated
  82857. */
  82858. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82859. /**
  82860. * Creates a ray with origin and direction of 0,0,0
  82861. * @returns the new ray
  82862. */
  82863. static Zero(): Ray;
  82864. /**
  82865. * Creates a new ray from screen space and viewport
  82866. * @param x position
  82867. * @param y y position
  82868. * @param viewportWidth viewport width
  82869. * @param viewportHeight viewport height
  82870. * @param world world matrix
  82871. * @param view view matrix
  82872. * @param projection projection matrix
  82873. * @returns new ray
  82874. */
  82875. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82876. /**
  82877. * 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
  82878. * transformed to the given world matrix.
  82879. * @param origin The origin point
  82880. * @param end The end point
  82881. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82882. * @returns the new ray
  82883. */
  82884. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82885. /**
  82886. * Transforms a ray by a matrix
  82887. * @param ray ray to transform
  82888. * @param matrix matrix to apply
  82889. * @returns the resulting new ray
  82890. */
  82891. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82892. /**
  82893. * Transforms a ray by a matrix
  82894. * @param ray ray to transform
  82895. * @param matrix matrix to apply
  82896. * @param result ray to store result in
  82897. */
  82898. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82899. /**
  82900. * Unproject a ray from screen space to object space
  82901. * @param sourceX defines the screen space x coordinate to use
  82902. * @param sourceY defines the screen space y coordinate to use
  82903. * @param viewportWidth defines the current width of the viewport
  82904. * @param viewportHeight defines the current height of the viewport
  82905. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82906. * @param view defines the view matrix to use
  82907. * @param projection defines the projection matrix to use
  82908. */
  82909. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82910. }
  82911. /**
  82912. * Type used to define predicate used to select faces when a mesh intersection is detected
  82913. */
  82914. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82915. interface Scene {
  82916. /** @hidden */
  82917. _tempPickingRay: Nullable<Ray>;
  82918. /** @hidden */
  82919. _cachedRayForTransform: Ray;
  82920. /** @hidden */
  82921. _pickWithRayInverseMatrix: Matrix;
  82922. /** @hidden */
  82923. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82924. /** @hidden */
  82925. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82926. }
  82927. }
  82928. declare module BABYLON {
  82929. /**
  82930. * Groups all the scene component constants in one place to ease maintenance.
  82931. * @hidden
  82932. */
  82933. export class SceneComponentConstants {
  82934. static readonly NAME_EFFECTLAYER: string;
  82935. static readonly NAME_LAYER: string;
  82936. static readonly NAME_LENSFLARESYSTEM: string;
  82937. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82938. static readonly NAME_PARTICLESYSTEM: string;
  82939. static readonly NAME_GAMEPAD: string;
  82940. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82941. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82942. static readonly NAME_DEPTHRENDERER: string;
  82943. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82944. static readonly NAME_SPRITE: string;
  82945. static readonly NAME_OUTLINERENDERER: string;
  82946. static readonly NAME_PROCEDURALTEXTURE: string;
  82947. static readonly NAME_SHADOWGENERATOR: string;
  82948. static readonly NAME_OCTREE: string;
  82949. static readonly NAME_PHYSICSENGINE: string;
  82950. static readonly NAME_AUDIO: string;
  82951. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82952. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82953. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82954. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82955. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82956. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82957. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82958. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82959. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82960. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82961. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82962. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82963. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82964. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82965. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82966. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82967. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82968. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82969. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82970. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82971. static readonly STEP_AFTERRENDER_AUDIO: number;
  82972. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82973. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82974. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82975. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82976. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82977. static readonly STEP_POINTERMOVE_SPRITE: number;
  82978. static readonly STEP_POINTERDOWN_SPRITE: number;
  82979. static readonly STEP_POINTERUP_SPRITE: number;
  82980. }
  82981. /**
  82982. * This represents a scene component.
  82983. *
  82984. * This is used to decouple the dependency the scene is having on the different workloads like
  82985. * layers, post processes...
  82986. */
  82987. export interface ISceneComponent {
  82988. /**
  82989. * The name of the component. Each component must have a unique name.
  82990. */
  82991. name: string;
  82992. /**
  82993. * The scene the component belongs to.
  82994. */
  82995. scene: Scene;
  82996. /**
  82997. * Register the component to one instance of a scene.
  82998. */
  82999. register(): void;
  83000. /**
  83001. * Rebuilds the elements related to this component in case of
  83002. * context lost for instance.
  83003. */
  83004. rebuild(): void;
  83005. /**
  83006. * Disposes the component and the associated ressources.
  83007. */
  83008. dispose(): void;
  83009. }
  83010. /**
  83011. * This represents a SERIALIZABLE scene component.
  83012. *
  83013. * This extends Scene Component to add Serialization methods on top.
  83014. */
  83015. export interface ISceneSerializableComponent extends ISceneComponent {
  83016. /**
  83017. * Adds all the elements from the container to the scene
  83018. * @param container the container holding the elements
  83019. */
  83020. addFromContainer(container: AbstractScene): void;
  83021. /**
  83022. * Removes all the elements in the container from the scene
  83023. * @param container contains the elements to remove
  83024. * @param dispose if the removed element should be disposed (default: false)
  83025. */
  83026. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83027. /**
  83028. * Serializes the component data to the specified json object
  83029. * @param serializationObject The object to serialize to
  83030. */
  83031. serialize(serializationObject: any): void;
  83032. }
  83033. /**
  83034. * Strong typing of a Mesh related stage step action
  83035. */
  83036. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83037. /**
  83038. * Strong typing of a Evaluate Sub Mesh related stage step action
  83039. */
  83040. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83041. /**
  83042. * Strong typing of a Active Mesh related stage step action
  83043. */
  83044. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83045. /**
  83046. * Strong typing of a Camera related stage step action
  83047. */
  83048. export type CameraStageAction = (camera: Camera) => void;
  83049. /**
  83050. * Strong typing of a Camera Frame buffer related stage step action
  83051. */
  83052. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83053. /**
  83054. * Strong typing of a Render Target related stage step action
  83055. */
  83056. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83057. /**
  83058. * Strong typing of a RenderingGroup related stage step action
  83059. */
  83060. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83061. /**
  83062. * Strong typing of a Mesh Render related stage step action
  83063. */
  83064. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83065. /**
  83066. * Strong typing of a simple stage step action
  83067. */
  83068. export type SimpleStageAction = () => void;
  83069. /**
  83070. * Strong typing of a render target action.
  83071. */
  83072. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83073. /**
  83074. * Strong typing of a pointer move action.
  83075. */
  83076. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83077. /**
  83078. * Strong typing of a pointer up/down action.
  83079. */
  83080. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83081. /**
  83082. * Representation of a stage in the scene (Basically a list of ordered steps)
  83083. * @hidden
  83084. */
  83085. export class Stage<T extends Function> extends Array<{
  83086. index: number;
  83087. component: ISceneComponent;
  83088. action: T;
  83089. }> {
  83090. /**
  83091. * Hide ctor from the rest of the world.
  83092. * @param items The items to add.
  83093. */
  83094. private constructor();
  83095. /**
  83096. * Creates a new Stage.
  83097. * @returns A new instance of a Stage
  83098. */
  83099. static Create<T extends Function>(): Stage<T>;
  83100. /**
  83101. * Registers a step in an ordered way in the targeted stage.
  83102. * @param index Defines the position to register the step in
  83103. * @param component Defines the component attached to the step
  83104. * @param action Defines the action to launch during the step
  83105. */
  83106. registerStep(index: number, component: ISceneComponent, action: T): void;
  83107. /**
  83108. * Clears all the steps from the stage.
  83109. */
  83110. clear(): void;
  83111. }
  83112. }
  83113. declare module BABYLON {
  83114. interface Scene {
  83115. /** @hidden */
  83116. _pointerOverSprite: Nullable<Sprite>;
  83117. /** @hidden */
  83118. _pickedDownSprite: Nullable<Sprite>;
  83119. /** @hidden */
  83120. _tempSpritePickingRay: Nullable<Ray>;
  83121. /**
  83122. * All of the sprite managers added to this scene
  83123. * @see http://doc.babylonjs.com/babylon101/sprites
  83124. */
  83125. spriteManagers: Array<ISpriteManager>;
  83126. /**
  83127. * An event triggered when sprites rendering is about to start
  83128. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83129. */
  83130. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83131. /**
  83132. * An event triggered when sprites rendering is done
  83133. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83134. */
  83135. onAfterSpritesRenderingObservable: Observable<Scene>;
  83136. /** @hidden */
  83137. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83138. /** Launch a ray to try to pick a sprite in the scene
  83139. * @param x position on screen
  83140. * @param y position on screen
  83141. * @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
  83142. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83143. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83144. * @returns a PickingInfo
  83145. */
  83146. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83147. /** Use the given ray to pick a sprite in the scene
  83148. * @param ray The ray (in world space) to use to pick meshes
  83149. * @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
  83150. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83151. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83152. * @returns a PickingInfo
  83153. */
  83154. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83155. /** @hidden */
  83156. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83157. /** Launch a ray to try to pick sprites in the scene
  83158. * @param x position on screen
  83159. * @param y position on screen
  83160. * @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
  83161. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83162. * @returns a PickingInfo array
  83163. */
  83164. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83165. /** Use the given ray to pick sprites in the scene
  83166. * @param ray The ray (in world space) to use to pick meshes
  83167. * @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
  83168. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83169. * @returns a PickingInfo array
  83170. */
  83171. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83172. /**
  83173. * Force the sprite under the pointer
  83174. * @param sprite defines the sprite to use
  83175. */
  83176. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83177. /**
  83178. * Gets the sprite under the pointer
  83179. * @returns a Sprite or null if no sprite is under the pointer
  83180. */
  83181. getPointerOverSprite(): Nullable<Sprite>;
  83182. }
  83183. /**
  83184. * Defines the sprite scene component responsible to manage sprites
  83185. * in a given scene.
  83186. */
  83187. export class SpriteSceneComponent implements ISceneComponent {
  83188. /**
  83189. * The component name helpfull to identify the component in the list of scene components.
  83190. */
  83191. readonly name: string;
  83192. /**
  83193. * The scene the component belongs to.
  83194. */
  83195. scene: Scene;
  83196. /** @hidden */
  83197. private _spritePredicate;
  83198. /**
  83199. * Creates a new instance of the component for the given scene
  83200. * @param scene Defines the scene to register the component in
  83201. */
  83202. constructor(scene: Scene);
  83203. /**
  83204. * Registers the component in a given scene
  83205. */
  83206. register(): void;
  83207. /**
  83208. * Rebuilds the elements related to this component in case of
  83209. * context lost for instance.
  83210. */
  83211. rebuild(): void;
  83212. /**
  83213. * Disposes the component and the associated ressources.
  83214. */
  83215. dispose(): void;
  83216. private _pickSpriteButKeepRay;
  83217. private _pointerMove;
  83218. private _pointerDown;
  83219. private _pointerUp;
  83220. }
  83221. }
  83222. declare module BABYLON {
  83223. /** @hidden */
  83224. export var fogFragmentDeclaration: {
  83225. name: string;
  83226. shader: string;
  83227. };
  83228. }
  83229. declare module BABYLON {
  83230. /** @hidden */
  83231. export var fogFragment: {
  83232. name: string;
  83233. shader: string;
  83234. };
  83235. }
  83236. declare module BABYLON {
  83237. /** @hidden */
  83238. export var spritesPixelShader: {
  83239. name: string;
  83240. shader: string;
  83241. };
  83242. }
  83243. declare module BABYLON {
  83244. /** @hidden */
  83245. export var fogVertexDeclaration: {
  83246. name: string;
  83247. shader: string;
  83248. };
  83249. }
  83250. declare module BABYLON {
  83251. /** @hidden */
  83252. export var spritesVertexShader: {
  83253. name: string;
  83254. shader: string;
  83255. };
  83256. }
  83257. declare module BABYLON {
  83258. /**
  83259. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83260. */
  83261. export interface ISpriteManager extends IDisposable {
  83262. /**
  83263. * Restricts the camera to viewing objects with the same layerMask.
  83264. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83265. */
  83266. layerMask: number;
  83267. /**
  83268. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83269. */
  83270. isPickable: boolean;
  83271. /**
  83272. * Specifies the rendering group id for this mesh (0 by default)
  83273. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83274. */
  83275. renderingGroupId: number;
  83276. /**
  83277. * Defines the list of sprites managed by the manager.
  83278. */
  83279. sprites: Array<Sprite>;
  83280. /**
  83281. * Tests the intersection of a sprite with a specific ray.
  83282. * @param ray The ray we are sending to test the collision
  83283. * @param camera The camera space we are sending rays in
  83284. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83285. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83286. * @returns picking info or null.
  83287. */
  83288. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83289. /**
  83290. * Intersects the sprites with a ray
  83291. * @param ray defines the ray to intersect with
  83292. * @param camera defines the current active camera
  83293. * @param predicate defines a predicate used to select candidate sprites
  83294. * @returns null if no hit or a PickingInfo array
  83295. */
  83296. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83297. /**
  83298. * Renders the list of sprites on screen.
  83299. */
  83300. render(): void;
  83301. }
  83302. /**
  83303. * Class used to manage multiple sprites on the same spritesheet
  83304. * @see http://doc.babylonjs.com/babylon101/sprites
  83305. */
  83306. export class SpriteManager implements ISpriteManager {
  83307. /** defines the manager's name */
  83308. name: string;
  83309. /** Gets the list of sprites */
  83310. sprites: Sprite[];
  83311. /** Gets or sets the rendering group id (0 by default) */
  83312. renderingGroupId: number;
  83313. /** Gets or sets camera layer mask */
  83314. layerMask: number;
  83315. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83316. fogEnabled: boolean;
  83317. /** Gets or sets a boolean indicating if the sprites are pickable */
  83318. isPickable: boolean;
  83319. /** Defines the default width of a cell in the spritesheet */
  83320. cellWidth: number;
  83321. /** Defines the default height of a cell in the spritesheet */
  83322. cellHeight: number;
  83323. /** Associative array from JSON sprite data file */
  83324. private _cellData;
  83325. /** Array of sprite names from JSON sprite data file */
  83326. private _spriteMap;
  83327. /** True when packed cell data from JSON file is ready*/
  83328. private _packedAndReady;
  83329. /**
  83330. * An event triggered when the manager is disposed.
  83331. */
  83332. onDisposeObservable: Observable<SpriteManager>;
  83333. private _onDisposeObserver;
  83334. /**
  83335. * Callback called when the manager is disposed
  83336. */
  83337. set onDispose(callback: () => void);
  83338. private _capacity;
  83339. private _fromPacked;
  83340. private _spriteTexture;
  83341. private _epsilon;
  83342. private _scene;
  83343. private _vertexData;
  83344. private _buffer;
  83345. private _vertexBuffers;
  83346. private _indexBuffer;
  83347. private _effectBase;
  83348. private _effectFog;
  83349. /**
  83350. * Gets or sets the spritesheet texture
  83351. */
  83352. get texture(): Texture;
  83353. set texture(value: Texture);
  83354. /**
  83355. * Creates a new sprite manager
  83356. * @param name defines the manager's name
  83357. * @param imgUrl defines the sprite sheet url
  83358. * @param capacity defines the maximum allowed number of sprites
  83359. * @param cellSize defines the size of a sprite cell
  83360. * @param scene defines the hosting scene
  83361. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83362. * @param samplingMode defines the smapling mode to use with spritesheet
  83363. * @param fromPacked set to false; do not alter
  83364. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83365. */
  83366. constructor(
  83367. /** defines the manager's name */
  83368. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83369. private _makePacked;
  83370. private _appendSpriteVertex;
  83371. /**
  83372. * Intersects the sprites with a ray
  83373. * @param ray defines the ray to intersect with
  83374. * @param camera defines the current active camera
  83375. * @param predicate defines a predicate used to select candidate sprites
  83376. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83377. * @returns null if no hit or a PickingInfo
  83378. */
  83379. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83380. /**
  83381. * Intersects the sprites with a ray
  83382. * @param ray defines the ray to intersect with
  83383. * @param camera defines the current active camera
  83384. * @param predicate defines a predicate used to select candidate sprites
  83385. * @returns null if no hit or a PickingInfo array
  83386. */
  83387. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83388. /**
  83389. * Render all child sprites
  83390. */
  83391. render(): void;
  83392. /**
  83393. * Release associated resources
  83394. */
  83395. dispose(): void;
  83396. }
  83397. }
  83398. declare module BABYLON {
  83399. /** Interface used by value gradients (color, factor, ...) */
  83400. export interface IValueGradient {
  83401. /**
  83402. * Gets or sets the gradient value (between 0 and 1)
  83403. */
  83404. gradient: number;
  83405. }
  83406. /** Class used to store color4 gradient */
  83407. export class ColorGradient implements IValueGradient {
  83408. /**
  83409. * Gets or sets the gradient value (between 0 and 1)
  83410. */
  83411. gradient: number;
  83412. /**
  83413. * Gets or sets first associated color
  83414. */
  83415. color1: Color4;
  83416. /**
  83417. * Gets or sets second associated color
  83418. */
  83419. color2?: Color4;
  83420. /**
  83421. * Will get a color picked randomly between color1 and color2.
  83422. * If color2 is undefined then color1 will be used
  83423. * @param result defines the target Color4 to store the result in
  83424. */
  83425. getColorToRef(result: Color4): void;
  83426. }
  83427. /** Class used to store color 3 gradient */
  83428. export class Color3Gradient implements IValueGradient {
  83429. /**
  83430. * Gets or sets the gradient value (between 0 and 1)
  83431. */
  83432. gradient: number;
  83433. /**
  83434. * Gets or sets the associated color
  83435. */
  83436. color: Color3;
  83437. }
  83438. /** Class used to store factor gradient */
  83439. export class FactorGradient implements IValueGradient {
  83440. /**
  83441. * Gets or sets the gradient value (between 0 and 1)
  83442. */
  83443. gradient: number;
  83444. /**
  83445. * Gets or sets first associated factor
  83446. */
  83447. factor1: number;
  83448. /**
  83449. * Gets or sets second associated factor
  83450. */
  83451. factor2?: number;
  83452. /**
  83453. * Will get a number picked randomly between factor1 and factor2.
  83454. * If factor2 is undefined then factor1 will be used
  83455. * @returns the picked number
  83456. */
  83457. getFactor(): number;
  83458. }
  83459. /**
  83460. * Helper used to simplify some generic gradient tasks
  83461. */
  83462. export class GradientHelper {
  83463. /**
  83464. * Gets the current gradient from an array of IValueGradient
  83465. * @param ratio defines the current ratio to get
  83466. * @param gradients defines the array of IValueGradient
  83467. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83468. */
  83469. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83470. }
  83471. }
  83472. declare module BABYLON {
  83473. /**
  83474. * Interface for the size containing width and height
  83475. */
  83476. export interface ISize {
  83477. /**
  83478. * Width
  83479. */
  83480. width: number;
  83481. /**
  83482. * Heighht
  83483. */
  83484. height: number;
  83485. }
  83486. /**
  83487. * Size containing widht and height
  83488. */
  83489. export class Size implements ISize {
  83490. /**
  83491. * Width
  83492. */
  83493. width: number;
  83494. /**
  83495. * Height
  83496. */
  83497. height: number;
  83498. /**
  83499. * Creates a Size object from the given width and height (floats).
  83500. * @param width width of the new size
  83501. * @param height height of the new size
  83502. */
  83503. constructor(width: number, height: number);
  83504. /**
  83505. * Returns a string with the Size width and height
  83506. * @returns a string with the Size width and height
  83507. */
  83508. toString(): string;
  83509. /**
  83510. * "Size"
  83511. * @returns the string "Size"
  83512. */
  83513. getClassName(): string;
  83514. /**
  83515. * Returns the Size hash code.
  83516. * @returns a hash code for a unique width and height
  83517. */
  83518. getHashCode(): number;
  83519. /**
  83520. * Updates the current size from the given one.
  83521. * @param src the given size
  83522. */
  83523. copyFrom(src: Size): void;
  83524. /**
  83525. * Updates in place the current Size from the given floats.
  83526. * @param width width of the new size
  83527. * @param height height of the new size
  83528. * @returns the updated Size.
  83529. */
  83530. copyFromFloats(width: number, height: number): Size;
  83531. /**
  83532. * Updates in place the current Size from the given floats.
  83533. * @param width width to set
  83534. * @param height height to set
  83535. * @returns the updated Size.
  83536. */
  83537. set(width: number, height: number): Size;
  83538. /**
  83539. * Multiplies the width and height by numbers
  83540. * @param w factor to multiple the width by
  83541. * @param h factor to multiple the height by
  83542. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83543. */
  83544. multiplyByFloats(w: number, h: number): Size;
  83545. /**
  83546. * Clones the size
  83547. * @returns a new Size copied from the given one.
  83548. */
  83549. clone(): Size;
  83550. /**
  83551. * True if the current Size and the given one width and height are strictly equal.
  83552. * @param other the other size to compare against
  83553. * @returns True if the current Size and the given one width and height are strictly equal.
  83554. */
  83555. equals(other: Size): boolean;
  83556. /**
  83557. * The surface of the Size : width * height (float).
  83558. */
  83559. get surface(): number;
  83560. /**
  83561. * Create a new size of zero
  83562. * @returns a new Size set to (0.0, 0.0)
  83563. */
  83564. static Zero(): Size;
  83565. /**
  83566. * Sums the width and height of two sizes
  83567. * @param otherSize size to add to this size
  83568. * @returns a new Size set as the addition result of the current Size and the given one.
  83569. */
  83570. add(otherSize: Size): Size;
  83571. /**
  83572. * Subtracts the width and height of two
  83573. * @param otherSize size to subtract to this size
  83574. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83575. */
  83576. subtract(otherSize: Size): Size;
  83577. /**
  83578. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83579. * @param start starting size to lerp between
  83580. * @param end end size to lerp between
  83581. * @param amount amount to lerp between the start and end values
  83582. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83583. */
  83584. static Lerp(start: Size, end: Size, amount: number): Size;
  83585. }
  83586. }
  83587. declare module BABYLON {
  83588. interface ThinEngine {
  83589. /**
  83590. * Creates a dynamic texture
  83591. * @param width defines the width of the texture
  83592. * @param height defines the height of the texture
  83593. * @param generateMipMaps defines if the engine should generate the mip levels
  83594. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83595. * @returns the dynamic texture inside an InternalTexture
  83596. */
  83597. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83598. /**
  83599. * Update the content of a dynamic texture
  83600. * @param texture defines the texture to update
  83601. * @param canvas defines the canvas containing the source
  83602. * @param invertY defines if data must be stored with Y axis inverted
  83603. * @param premulAlpha defines if alpha is stored as premultiplied
  83604. * @param format defines the format of the data
  83605. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83606. */
  83607. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83608. }
  83609. }
  83610. declare module BABYLON {
  83611. /**
  83612. * Helper class used to generate a canvas to manipulate images
  83613. */
  83614. export class CanvasGenerator {
  83615. /**
  83616. * Create a new canvas (or offscreen canvas depending on the context)
  83617. * @param width defines the expected width
  83618. * @param height defines the expected height
  83619. * @return a new canvas or offscreen canvas
  83620. */
  83621. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83622. }
  83623. }
  83624. declare module BABYLON {
  83625. /**
  83626. * A class extending Texture allowing drawing on a texture
  83627. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83628. */
  83629. export class DynamicTexture extends Texture {
  83630. private _generateMipMaps;
  83631. private _canvas;
  83632. private _context;
  83633. private _engine;
  83634. /**
  83635. * Creates a DynamicTexture
  83636. * @param name defines the name of the texture
  83637. * @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
  83638. * @param scene defines the scene where you want the texture
  83639. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83640. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83641. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83642. */
  83643. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83644. /**
  83645. * Get the current class name of the texture useful for serialization or dynamic coding.
  83646. * @returns "DynamicTexture"
  83647. */
  83648. getClassName(): string;
  83649. /**
  83650. * Gets the current state of canRescale
  83651. */
  83652. get canRescale(): boolean;
  83653. private _recreate;
  83654. /**
  83655. * Scales the texture
  83656. * @param ratio the scale factor to apply to both width and height
  83657. */
  83658. scale(ratio: number): void;
  83659. /**
  83660. * Resizes the texture
  83661. * @param width the new width
  83662. * @param height the new height
  83663. */
  83664. scaleTo(width: number, height: number): void;
  83665. /**
  83666. * Gets the context of the canvas used by the texture
  83667. * @returns the canvas context of the dynamic texture
  83668. */
  83669. getContext(): CanvasRenderingContext2D;
  83670. /**
  83671. * Clears the texture
  83672. */
  83673. clear(): void;
  83674. /**
  83675. * Updates the texture
  83676. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83677. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83678. */
  83679. update(invertY?: boolean, premulAlpha?: boolean): void;
  83680. /**
  83681. * Draws text onto the texture
  83682. * @param text defines the text to be drawn
  83683. * @param x defines the placement of the text from the left
  83684. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83685. * @param font defines the font to be used with font-style, font-size, font-name
  83686. * @param color defines the color used for the text
  83687. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83688. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83689. * @param update defines whether texture is immediately update (default is true)
  83690. */
  83691. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83692. /**
  83693. * Clones the texture
  83694. * @returns the clone of the texture.
  83695. */
  83696. clone(): DynamicTexture;
  83697. /**
  83698. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83699. * @returns a serialized dynamic texture object
  83700. */
  83701. serialize(): any;
  83702. /** @hidden */
  83703. _rebuild(): void;
  83704. }
  83705. }
  83706. declare module BABYLON {
  83707. interface Engine {
  83708. /**
  83709. * Creates a raw texture
  83710. * @param data defines the data to store in the texture
  83711. * @param width defines the width of the texture
  83712. * @param height defines the height of the texture
  83713. * @param format defines the format of the data
  83714. * @param generateMipMaps defines if the engine should generate the mip levels
  83715. * @param invertY defines if data must be stored with Y axis inverted
  83716. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83717. * @param compression defines the compression used (null by default)
  83718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83719. * @returns the raw texture inside an InternalTexture
  83720. */
  83721. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83722. /**
  83723. * Update a raw texture
  83724. * @param texture defines the texture to update
  83725. * @param data defines the data to store in the texture
  83726. * @param format defines the format of the data
  83727. * @param invertY defines if data must be stored with Y axis inverted
  83728. */
  83729. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83730. /**
  83731. * Update a raw texture
  83732. * @param texture defines the texture to update
  83733. * @param data defines the data to store in the texture
  83734. * @param format defines the format of the data
  83735. * @param invertY defines if data must be stored with Y axis inverted
  83736. * @param compression defines the compression used (null by default)
  83737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83738. */
  83739. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83740. /**
  83741. * Creates a new raw cube texture
  83742. * @param data defines the array of data to use to create each face
  83743. * @param size defines the size of the textures
  83744. * @param format defines the format of the data
  83745. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83746. * @param generateMipMaps defines if the engine should generate the mip levels
  83747. * @param invertY defines if data must be stored with Y axis inverted
  83748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83749. * @param compression defines the compression used (null by default)
  83750. * @returns the cube texture as an InternalTexture
  83751. */
  83752. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83753. /**
  83754. * Update a raw cube texture
  83755. * @param texture defines the texture to udpdate
  83756. * @param data defines the data to store
  83757. * @param format defines the data format
  83758. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83759. * @param invertY defines if data must be stored with Y axis inverted
  83760. */
  83761. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83762. /**
  83763. * Update a raw cube texture
  83764. * @param texture defines the texture to udpdate
  83765. * @param data defines the data to store
  83766. * @param format defines the data format
  83767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83768. * @param invertY defines if data must be stored with Y axis inverted
  83769. * @param compression defines the compression used (null by default)
  83770. */
  83771. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83772. /**
  83773. * Update a raw cube texture
  83774. * @param texture defines the texture to udpdate
  83775. * @param data defines the data to store
  83776. * @param format defines the data format
  83777. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83778. * @param invertY defines if data must be stored with Y axis inverted
  83779. * @param compression defines the compression used (null by default)
  83780. * @param level defines which level of the texture to update
  83781. */
  83782. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83783. /**
  83784. * Creates a new raw cube texture from a specified url
  83785. * @param url defines the url where the data is located
  83786. * @param scene defines the current scene
  83787. * @param size defines the size of the textures
  83788. * @param format defines the format of the data
  83789. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83790. * @param noMipmap defines if the engine should avoid generating the mip levels
  83791. * @param callback defines a callback used to extract texture data from loaded data
  83792. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83793. * @param onLoad defines a callback called when texture is loaded
  83794. * @param onError defines a callback called if there is an error
  83795. * @returns the cube texture as an InternalTexture
  83796. */
  83797. 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;
  83798. /**
  83799. * Creates a new raw cube texture from a specified url
  83800. * @param url defines the url where the data is located
  83801. * @param scene defines the current scene
  83802. * @param size defines the size of the textures
  83803. * @param format defines the format of the data
  83804. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83805. * @param noMipmap defines if the engine should avoid generating the mip levels
  83806. * @param callback defines a callback used to extract texture data from loaded data
  83807. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83808. * @param onLoad defines a callback called when texture is loaded
  83809. * @param onError defines a callback called if there is an error
  83810. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83811. * @param invertY defines if data must be stored with Y axis inverted
  83812. * @returns the cube texture as an InternalTexture
  83813. */
  83814. 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;
  83815. /**
  83816. * Creates a new raw 3D texture
  83817. * @param data defines the data used to create the texture
  83818. * @param width defines the width of the texture
  83819. * @param height defines the height of the texture
  83820. * @param depth defines the depth of the texture
  83821. * @param format defines the format of the texture
  83822. * @param generateMipMaps defines if the engine must generate mip levels
  83823. * @param invertY defines if data must be stored with Y axis inverted
  83824. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83825. * @param compression defines the compressed used (can be null)
  83826. * @param textureType defines the compressed used (can be null)
  83827. * @returns a new raw 3D texture (stored in an InternalTexture)
  83828. */
  83829. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83830. /**
  83831. * Update a raw 3D texture
  83832. * @param texture defines the texture to update
  83833. * @param data defines the data to store
  83834. * @param format defines the data format
  83835. * @param invertY defines if data must be stored with Y axis inverted
  83836. */
  83837. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83838. /**
  83839. * Update a raw 3D texture
  83840. * @param texture defines the texture to update
  83841. * @param data defines the data to store
  83842. * @param format defines the data format
  83843. * @param invertY defines if data must be stored with Y axis inverted
  83844. * @param compression defines the used compression (can be null)
  83845. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83846. */
  83847. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83848. /**
  83849. * Creates a new raw 2D array texture
  83850. * @param data defines the data used to create the texture
  83851. * @param width defines the width of the texture
  83852. * @param height defines the height of the texture
  83853. * @param depth defines the number of layers of the texture
  83854. * @param format defines the format of the texture
  83855. * @param generateMipMaps defines if the engine must generate mip levels
  83856. * @param invertY defines if data must be stored with Y axis inverted
  83857. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83858. * @param compression defines the compressed used (can be null)
  83859. * @param textureType defines the compressed used (can be null)
  83860. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83861. */
  83862. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83863. /**
  83864. * Update a raw 2D array texture
  83865. * @param texture defines the texture to update
  83866. * @param data defines the data to store
  83867. * @param format defines the data format
  83868. * @param invertY defines if data must be stored with Y axis inverted
  83869. */
  83870. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83871. /**
  83872. * Update a raw 2D array texture
  83873. * @param texture defines the texture to update
  83874. * @param data defines the data to store
  83875. * @param format defines the data format
  83876. * @param invertY defines if data must be stored with Y axis inverted
  83877. * @param compression defines the used compression (can be null)
  83878. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83879. */
  83880. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83881. }
  83882. }
  83883. declare module BABYLON {
  83884. /**
  83885. * Raw texture can help creating a texture directly from an array of data.
  83886. * This can be super useful if you either get the data from an uncompressed source or
  83887. * if you wish to create your texture pixel by pixel.
  83888. */
  83889. export class RawTexture extends Texture {
  83890. /**
  83891. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83892. */
  83893. format: number;
  83894. private _engine;
  83895. /**
  83896. * Instantiates a new RawTexture.
  83897. * Raw texture can help creating a texture directly from an array of data.
  83898. * This can be super useful if you either get the data from an uncompressed source or
  83899. * if you wish to create your texture pixel by pixel.
  83900. * @param data define the array of data to use to create the texture
  83901. * @param width define the width of the texture
  83902. * @param height define the height of the texture
  83903. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83904. * @param scene define the scene the texture belongs to
  83905. * @param generateMipMaps define whether mip maps should be generated or not
  83906. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83907. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83908. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83909. */
  83910. constructor(data: ArrayBufferView, width: number, height: number,
  83911. /**
  83912. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83913. */
  83914. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83915. /**
  83916. * Updates the texture underlying data.
  83917. * @param data Define the new data of the texture
  83918. */
  83919. update(data: ArrayBufferView): void;
  83920. /**
  83921. * Creates a luminance texture from some data.
  83922. * @param data Define the texture data
  83923. * @param width Define the width of the texture
  83924. * @param height Define the height of the texture
  83925. * @param scene Define the scene the texture belongs to
  83926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83929. * @returns the luminance texture
  83930. */
  83931. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83932. /**
  83933. * Creates a luminance alpha texture from some data.
  83934. * @param data Define the texture data
  83935. * @param width Define the width of the texture
  83936. * @param height Define the height of the texture
  83937. * @param scene Define the scene the texture belongs to
  83938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83941. * @returns the luminance alpha texture
  83942. */
  83943. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83944. /**
  83945. * Creates an alpha texture from some data.
  83946. * @param data Define the texture data
  83947. * @param width Define the width of the texture
  83948. * @param height Define the height of the texture
  83949. * @param scene Define the scene the texture belongs to
  83950. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83953. * @returns the alpha texture
  83954. */
  83955. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83956. /**
  83957. * Creates a RGB texture from some data.
  83958. * @param data Define the texture data
  83959. * @param width Define the width of the texture
  83960. * @param height Define the height of the texture
  83961. * @param scene Define the scene the texture belongs to
  83962. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83963. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83964. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83965. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83966. * @returns the RGB alpha texture
  83967. */
  83968. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83969. /**
  83970. * Creates a RGBA texture from some data.
  83971. * @param data Define the texture data
  83972. * @param width Define the width of the texture
  83973. * @param height Define the height of the texture
  83974. * @param scene Define the scene the texture belongs to
  83975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83979. * @returns the RGBA texture
  83980. */
  83981. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83982. /**
  83983. * Creates a R texture from some data.
  83984. * @param data Define the texture data
  83985. * @param width Define the width of the texture
  83986. * @param height Define the height of the texture
  83987. * @param scene Define the scene the texture belongs to
  83988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83992. * @returns the R texture
  83993. */
  83994. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83995. }
  83996. }
  83997. declare module BABYLON {
  83998. interface AbstractScene {
  83999. /**
  84000. * The list of procedural textures added to the scene
  84001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84002. */
  84003. proceduralTextures: Array<ProceduralTexture>;
  84004. }
  84005. /**
  84006. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84007. * in a given scene.
  84008. */
  84009. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84010. /**
  84011. * The component name helpfull to identify the component in the list of scene components.
  84012. */
  84013. readonly name: string;
  84014. /**
  84015. * The scene the component belongs to.
  84016. */
  84017. scene: Scene;
  84018. /**
  84019. * Creates a new instance of the component for the given scene
  84020. * @param scene Defines the scene to register the component in
  84021. */
  84022. constructor(scene: Scene);
  84023. /**
  84024. * Registers the component in a given scene
  84025. */
  84026. register(): void;
  84027. /**
  84028. * Rebuilds the elements related to this component in case of
  84029. * context lost for instance.
  84030. */
  84031. rebuild(): void;
  84032. /**
  84033. * Disposes the component and the associated ressources.
  84034. */
  84035. dispose(): void;
  84036. private _beforeClear;
  84037. }
  84038. }
  84039. declare module BABYLON {
  84040. interface ThinEngine {
  84041. /**
  84042. * Creates a new render target cube texture
  84043. * @param size defines the size of the texture
  84044. * @param options defines the options used to create the texture
  84045. * @returns a new render target cube texture stored in an InternalTexture
  84046. */
  84047. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84048. }
  84049. }
  84050. declare module BABYLON {
  84051. /** @hidden */
  84052. export var proceduralVertexShader: {
  84053. name: string;
  84054. shader: string;
  84055. };
  84056. }
  84057. declare module BABYLON {
  84058. /**
  84059. * 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.
  84060. * This is the base class of any Procedural texture and contains most of the shareable code.
  84061. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84062. */
  84063. export class ProceduralTexture extends Texture {
  84064. isCube: boolean;
  84065. /**
  84066. * Define if the texture is enabled or not (disabled texture will not render)
  84067. */
  84068. isEnabled: boolean;
  84069. /**
  84070. * Define if the texture must be cleared before rendering (default is true)
  84071. */
  84072. autoClear: boolean;
  84073. /**
  84074. * Callback called when the texture is generated
  84075. */
  84076. onGenerated: () => void;
  84077. /**
  84078. * Event raised when the texture is generated
  84079. */
  84080. onGeneratedObservable: Observable<ProceduralTexture>;
  84081. /** @hidden */
  84082. _generateMipMaps: boolean;
  84083. /** @hidden **/
  84084. _effect: Effect;
  84085. /** @hidden */
  84086. _textures: {
  84087. [key: string]: Texture;
  84088. };
  84089. private _size;
  84090. private _currentRefreshId;
  84091. private _frameId;
  84092. private _refreshRate;
  84093. private _vertexBuffers;
  84094. private _indexBuffer;
  84095. private _uniforms;
  84096. private _samplers;
  84097. private _fragment;
  84098. private _floats;
  84099. private _ints;
  84100. private _floatsArrays;
  84101. private _colors3;
  84102. private _colors4;
  84103. private _vectors2;
  84104. private _vectors3;
  84105. private _matrices;
  84106. private _fallbackTexture;
  84107. private _fallbackTextureUsed;
  84108. private _engine;
  84109. private _cachedDefines;
  84110. private _contentUpdateId;
  84111. private _contentData;
  84112. /**
  84113. * Instantiates a new procedural texture.
  84114. * 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.
  84115. * This is the base class of any Procedural texture and contains most of the shareable code.
  84116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84117. * @param name Define the name of the texture
  84118. * @param size Define the size of the texture to create
  84119. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84120. * @param scene Define the scene the texture belongs to
  84121. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84122. * @param generateMipMaps Define if the texture should creates mip maps or not
  84123. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84124. */
  84125. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84126. /**
  84127. * The effect that is created when initializing the post process.
  84128. * @returns The created effect corresponding the the postprocess.
  84129. */
  84130. getEffect(): Effect;
  84131. /**
  84132. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84133. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84134. */
  84135. getContent(): Nullable<ArrayBufferView>;
  84136. private _createIndexBuffer;
  84137. /** @hidden */
  84138. _rebuild(): void;
  84139. /**
  84140. * Resets the texture in order to recreate its associated resources.
  84141. * This can be called in case of context loss
  84142. */
  84143. reset(): void;
  84144. protected _getDefines(): string;
  84145. /**
  84146. * Is the texture ready to be used ? (rendered at least once)
  84147. * @returns true if ready, otherwise, false.
  84148. */
  84149. isReady(): boolean;
  84150. /**
  84151. * Resets the refresh counter of the texture and start bak from scratch.
  84152. * Could be useful to regenerate the texture if it is setup to render only once.
  84153. */
  84154. resetRefreshCounter(): void;
  84155. /**
  84156. * Set the fragment shader to use in order to render the texture.
  84157. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84158. */
  84159. setFragment(fragment: any): void;
  84160. /**
  84161. * Define the refresh rate of the texture or the rendering frequency.
  84162. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84163. */
  84164. get refreshRate(): number;
  84165. set refreshRate(value: number);
  84166. /** @hidden */
  84167. _shouldRender(): boolean;
  84168. /**
  84169. * Get the size the texture is rendering at.
  84170. * @returns the size (texture is always squared)
  84171. */
  84172. getRenderSize(): number;
  84173. /**
  84174. * Resize the texture to new value.
  84175. * @param size Define the new size the texture should have
  84176. * @param generateMipMaps Define whether the new texture should create mip maps
  84177. */
  84178. resize(size: number, generateMipMaps: boolean): void;
  84179. private _checkUniform;
  84180. /**
  84181. * Set a texture in the shader program used to render.
  84182. * @param name Define the name of the uniform samplers as defined in the shader
  84183. * @param texture Define the texture to bind to this sampler
  84184. * @return the texture itself allowing "fluent" like uniform updates
  84185. */
  84186. setTexture(name: string, texture: Texture): ProceduralTexture;
  84187. /**
  84188. * Set a float in the shader.
  84189. * @param name Define the name of the uniform as defined in the shader
  84190. * @param value Define the value to give to the uniform
  84191. * @return the texture itself allowing "fluent" like uniform updates
  84192. */
  84193. setFloat(name: string, value: number): ProceduralTexture;
  84194. /**
  84195. * Set a int in the shader.
  84196. * @param name Define the name of the uniform as defined in the shader
  84197. * @param value Define the value to give to the uniform
  84198. * @return the texture itself allowing "fluent" like uniform updates
  84199. */
  84200. setInt(name: string, value: number): ProceduralTexture;
  84201. /**
  84202. * Set an array of floats in the shader.
  84203. * @param name Define the name of the uniform as defined in the shader
  84204. * @param value Define the value to give to the uniform
  84205. * @return the texture itself allowing "fluent" like uniform updates
  84206. */
  84207. setFloats(name: string, value: number[]): ProceduralTexture;
  84208. /**
  84209. * Set a vec3 in the shader from a Color3.
  84210. * @param name Define the name of the uniform as defined in the shader
  84211. * @param value Define the value to give to the uniform
  84212. * @return the texture itself allowing "fluent" like uniform updates
  84213. */
  84214. setColor3(name: string, value: Color3): ProceduralTexture;
  84215. /**
  84216. * Set a vec4 in the shader from a Color4.
  84217. * @param name Define the name of the uniform as defined in the shader
  84218. * @param value Define the value to give to the uniform
  84219. * @return the texture itself allowing "fluent" like uniform updates
  84220. */
  84221. setColor4(name: string, value: Color4): ProceduralTexture;
  84222. /**
  84223. * Set a vec2 in the shader from a Vector2.
  84224. * @param name Define the name of the uniform as defined in the shader
  84225. * @param value Define the value to give to the uniform
  84226. * @return the texture itself allowing "fluent" like uniform updates
  84227. */
  84228. setVector2(name: string, value: Vector2): ProceduralTexture;
  84229. /**
  84230. * Set a vec3 in the shader from a Vector3.
  84231. * @param name Define the name of the uniform as defined in the shader
  84232. * @param value Define the value to give to the uniform
  84233. * @return the texture itself allowing "fluent" like uniform updates
  84234. */
  84235. setVector3(name: string, value: Vector3): ProceduralTexture;
  84236. /**
  84237. * Set a mat4 in the shader from a MAtrix.
  84238. * @param name Define the name of the uniform as defined in the shader
  84239. * @param value Define the value to give to the uniform
  84240. * @return the texture itself allowing "fluent" like uniform updates
  84241. */
  84242. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84243. /**
  84244. * Render the texture to its associated render target.
  84245. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84246. */
  84247. render(useCameraPostProcess?: boolean): void;
  84248. /**
  84249. * Clone the texture.
  84250. * @returns the cloned texture
  84251. */
  84252. clone(): ProceduralTexture;
  84253. /**
  84254. * Dispose the texture and release its asoociated resources.
  84255. */
  84256. dispose(): void;
  84257. }
  84258. }
  84259. declare module BABYLON {
  84260. /**
  84261. * This represents the base class for particle system in Babylon.
  84262. * 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.
  84263. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84264. * @example https://doc.babylonjs.com/babylon101/particles
  84265. */
  84266. export class BaseParticleSystem {
  84267. /**
  84268. * Source color is added to the destination color without alpha affecting the result
  84269. */
  84270. static BLENDMODE_ONEONE: number;
  84271. /**
  84272. * Blend current color and particle color using particle’s alpha
  84273. */
  84274. static BLENDMODE_STANDARD: number;
  84275. /**
  84276. * Add current color and particle color multiplied by particle’s alpha
  84277. */
  84278. static BLENDMODE_ADD: number;
  84279. /**
  84280. * Multiply current color with particle color
  84281. */
  84282. static BLENDMODE_MULTIPLY: number;
  84283. /**
  84284. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84285. */
  84286. static BLENDMODE_MULTIPLYADD: number;
  84287. /**
  84288. * List of animations used by the particle system.
  84289. */
  84290. animations: Animation[];
  84291. /**
  84292. * The id of the Particle system.
  84293. */
  84294. id: string;
  84295. /**
  84296. * The friendly name of the Particle system.
  84297. */
  84298. name: string;
  84299. /**
  84300. * The rendering group used by the Particle system to chose when to render.
  84301. */
  84302. renderingGroupId: number;
  84303. /**
  84304. * The emitter represents the Mesh or position we are attaching the particle system to.
  84305. */
  84306. emitter: Nullable<AbstractMesh | Vector3>;
  84307. /**
  84308. * The maximum number of particles to emit per frame
  84309. */
  84310. emitRate: number;
  84311. /**
  84312. * If you want to launch only a few particles at once, that can be done, as well.
  84313. */
  84314. manualEmitCount: number;
  84315. /**
  84316. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84317. */
  84318. updateSpeed: number;
  84319. /**
  84320. * The amount of time the particle system is running (depends of the overall update speed).
  84321. */
  84322. targetStopDuration: number;
  84323. /**
  84324. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84325. */
  84326. disposeOnStop: boolean;
  84327. /**
  84328. * Minimum power of emitting particles.
  84329. */
  84330. minEmitPower: number;
  84331. /**
  84332. * Maximum power of emitting particles.
  84333. */
  84334. maxEmitPower: number;
  84335. /**
  84336. * Minimum life time of emitting particles.
  84337. */
  84338. minLifeTime: number;
  84339. /**
  84340. * Maximum life time of emitting particles.
  84341. */
  84342. maxLifeTime: number;
  84343. /**
  84344. * Minimum Size of emitting particles.
  84345. */
  84346. minSize: number;
  84347. /**
  84348. * Maximum Size of emitting particles.
  84349. */
  84350. maxSize: number;
  84351. /**
  84352. * Minimum scale of emitting particles on X axis.
  84353. */
  84354. minScaleX: number;
  84355. /**
  84356. * Maximum scale of emitting particles on X axis.
  84357. */
  84358. maxScaleX: number;
  84359. /**
  84360. * Minimum scale of emitting particles on Y axis.
  84361. */
  84362. minScaleY: number;
  84363. /**
  84364. * Maximum scale of emitting particles on Y axis.
  84365. */
  84366. maxScaleY: number;
  84367. /**
  84368. * Gets or sets the minimal initial rotation in radians.
  84369. */
  84370. minInitialRotation: number;
  84371. /**
  84372. * Gets or sets the maximal initial rotation in radians.
  84373. */
  84374. maxInitialRotation: number;
  84375. /**
  84376. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84377. */
  84378. minAngularSpeed: number;
  84379. /**
  84380. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84381. */
  84382. maxAngularSpeed: number;
  84383. /**
  84384. * The texture used to render each particle. (this can be a spritesheet)
  84385. */
  84386. particleTexture: Nullable<Texture>;
  84387. /**
  84388. * The layer mask we are rendering the particles through.
  84389. */
  84390. layerMask: number;
  84391. /**
  84392. * This can help using your own shader to render the particle system.
  84393. * The according effect will be created
  84394. */
  84395. customShader: any;
  84396. /**
  84397. * By default particle system starts as soon as they are created. This prevents the
  84398. * automatic start to happen and let you decide when to start emitting particles.
  84399. */
  84400. preventAutoStart: boolean;
  84401. private _noiseTexture;
  84402. /**
  84403. * Gets or sets a texture used to add random noise to particle positions
  84404. */
  84405. get noiseTexture(): Nullable<ProceduralTexture>;
  84406. set noiseTexture(value: Nullable<ProceduralTexture>);
  84407. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84408. noiseStrength: Vector3;
  84409. /**
  84410. * Callback triggered when the particle animation is ending.
  84411. */
  84412. onAnimationEnd: Nullable<() => void>;
  84413. /**
  84414. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84415. */
  84416. blendMode: number;
  84417. /**
  84418. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84419. * to override the particles.
  84420. */
  84421. forceDepthWrite: boolean;
  84422. /** 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 */
  84423. preWarmCycles: number;
  84424. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84425. preWarmStepOffset: number;
  84426. /**
  84427. * 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)
  84428. */
  84429. spriteCellChangeSpeed: number;
  84430. /**
  84431. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84432. */
  84433. startSpriteCellID: number;
  84434. /**
  84435. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84436. */
  84437. endSpriteCellID: number;
  84438. /**
  84439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84440. */
  84441. spriteCellWidth: number;
  84442. /**
  84443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84444. */
  84445. spriteCellHeight: number;
  84446. /**
  84447. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84448. */
  84449. spriteRandomStartCell: boolean;
  84450. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84451. translationPivot: Vector2;
  84452. /** @hidden */
  84453. protected _isAnimationSheetEnabled: boolean;
  84454. /**
  84455. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84456. */
  84457. beginAnimationOnStart: boolean;
  84458. /**
  84459. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84460. */
  84461. beginAnimationFrom: number;
  84462. /**
  84463. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84464. */
  84465. beginAnimationTo: number;
  84466. /**
  84467. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84468. */
  84469. beginAnimationLoop: boolean;
  84470. /**
  84471. * Gets or sets a world offset applied to all particles
  84472. */
  84473. worldOffset: Vector3;
  84474. /**
  84475. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84476. */
  84477. get isAnimationSheetEnabled(): boolean;
  84478. set isAnimationSheetEnabled(value: boolean);
  84479. /**
  84480. * Get hosting scene
  84481. * @returns the scene
  84482. */
  84483. getScene(): Scene;
  84484. /**
  84485. * You can use gravity if you want to give an orientation to your particles.
  84486. */
  84487. gravity: Vector3;
  84488. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84489. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84490. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84491. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84492. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84493. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84494. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84495. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84496. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84497. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84498. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84499. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84500. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84501. /**
  84502. * Defines the delay in milliseconds before starting the system (0 by default)
  84503. */
  84504. startDelay: number;
  84505. /**
  84506. * Gets the current list of drag gradients.
  84507. * You must use addDragGradient and removeDragGradient to udpate this list
  84508. * @returns the list of drag gradients
  84509. */
  84510. getDragGradients(): Nullable<Array<FactorGradient>>;
  84511. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84512. limitVelocityDamping: number;
  84513. /**
  84514. * Gets the current list of limit velocity gradients.
  84515. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84516. * @returns the list of limit velocity gradients
  84517. */
  84518. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84519. /**
  84520. * Gets the current list of color gradients.
  84521. * You must use addColorGradient and removeColorGradient to udpate this list
  84522. * @returns the list of color gradients
  84523. */
  84524. getColorGradients(): Nullable<Array<ColorGradient>>;
  84525. /**
  84526. * Gets the current list of size gradients.
  84527. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84528. * @returns the list of size gradients
  84529. */
  84530. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84531. /**
  84532. * Gets the current list of color remap gradients.
  84533. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84534. * @returns the list of color remap gradients
  84535. */
  84536. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84537. /**
  84538. * Gets the current list of alpha remap gradients.
  84539. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84540. * @returns the list of alpha remap gradients
  84541. */
  84542. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84543. /**
  84544. * Gets the current list of life time gradients.
  84545. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84546. * @returns the list of life time gradients
  84547. */
  84548. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84549. /**
  84550. * Gets the current list of angular speed gradients.
  84551. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84552. * @returns the list of angular speed gradients
  84553. */
  84554. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84555. /**
  84556. * Gets the current list of velocity gradients.
  84557. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84558. * @returns the list of velocity gradients
  84559. */
  84560. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84561. /**
  84562. * Gets the current list of start size gradients.
  84563. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84564. * @returns the list of start size gradients
  84565. */
  84566. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84567. /**
  84568. * Gets the current list of emit rate gradients.
  84569. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84570. * @returns the list of emit rate gradients
  84571. */
  84572. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84573. /**
  84574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84576. */
  84577. get direction1(): Vector3;
  84578. set direction1(value: Vector3);
  84579. /**
  84580. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84582. */
  84583. get direction2(): Vector3;
  84584. set direction2(value: Vector3);
  84585. /**
  84586. * 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.
  84587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84588. */
  84589. get minEmitBox(): Vector3;
  84590. set minEmitBox(value: Vector3);
  84591. /**
  84592. * 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.
  84593. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84594. */
  84595. get maxEmitBox(): Vector3;
  84596. set maxEmitBox(value: Vector3);
  84597. /**
  84598. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84599. */
  84600. color1: Color4;
  84601. /**
  84602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84603. */
  84604. color2: Color4;
  84605. /**
  84606. * Color the particle will have at the end of its lifetime
  84607. */
  84608. colorDead: Color4;
  84609. /**
  84610. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84611. */
  84612. textureMask: Color4;
  84613. /**
  84614. * The particle emitter type defines the emitter used by the particle system.
  84615. * It can be for example box, sphere, or cone...
  84616. */
  84617. particleEmitterType: IParticleEmitterType;
  84618. /** @hidden */
  84619. _isSubEmitter: boolean;
  84620. /**
  84621. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84622. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84623. */
  84624. billboardMode: number;
  84625. protected _isBillboardBased: boolean;
  84626. /**
  84627. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84628. */
  84629. get isBillboardBased(): boolean;
  84630. set isBillboardBased(value: boolean);
  84631. /**
  84632. * The scene the particle system belongs to.
  84633. */
  84634. protected _scene: Scene;
  84635. /**
  84636. * Local cache of defines for image processing.
  84637. */
  84638. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84639. /**
  84640. * Default configuration related to image processing available in the standard Material.
  84641. */
  84642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84643. /**
  84644. * Gets the image processing configuration used either in this material.
  84645. */
  84646. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84647. /**
  84648. * Sets the Default image processing configuration used either in the this material.
  84649. *
  84650. * If sets to null, the scene one is in use.
  84651. */
  84652. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84653. /**
  84654. * Attaches a new image processing configuration to the Standard Material.
  84655. * @param configuration
  84656. */
  84657. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84658. /** @hidden */
  84659. protected _reset(): void;
  84660. /** @hidden */
  84661. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84662. /**
  84663. * Instantiates a particle system.
  84664. * 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.
  84665. * @param name The name of the particle system
  84666. */
  84667. constructor(name: string);
  84668. /**
  84669. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84672. * @returns the emitter
  84673. */
  84674. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84675. /**
  84676. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84677. * @param radius The radius of the hemisphere to emit from
  84678. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84679. * @returns the emitter
  84680. */
  84681. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84682. /**
  84683. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84684. * @param radius The radius of the sphere to emit from
  84685. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84686. * @returns the emitter
  84687. */
  84688. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84689. /**
  84690. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84691. * @param radius The radius of the sphere to emit from
  84692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84694. * @returns the emitter
  84695. */
  84696. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84697. /**
  84698. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84699. * @param radius The radius of the emission cylinder
  84700. * @param height The height of the emission cylinder
  84701. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84702. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84703. * @returns the emitter
  84704. */
  84705. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84706. /**
  84707. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84708. * @param radius The radius of the cylinder to emit from
  84709. * @param height The height of the emission cylinder
  84710. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84713. * @returns the emitter
  84714. */
  84715. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84716. /**
  84717. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84718. * @param radius The radius of the cone to emit from
  84719. * @param angle The base angle of the cone
  84720. * @returns the emitter
  84721. */
  84722. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84723. /**
  84724. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84725. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84726. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84727. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84728. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84729. * @returns the emitter
  84730. */
  84731. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84732. }
  84733. }
  84734. declare module BABYLON {
  84735. /**
  84736. * Type of sub emitter
  84737. */
  84738. export enum SubEmitterType {
  84739. /**
  84740. * Attached to the particle over it's lifetime
  84741. */
  84742. ATTACHED = 0,
  84743. /**
  84744. * Created when the particle dies
  84745. */
  84746. END = 1
  84747. }
  84748. /**
  84749. * Sub emitter class used to emit particles from an existing particle
  84750. */
  84751. export class SubEmitter {
  84752. /**
  84753. * the particle system to be used by the sub emitter
  84754. */
  84755. particleSystem: ParticleSystem;
  84756. /**
  84757. * Type of the submitter (Default: END)
  84758. */
  84759. type: SubEmitterType;
  84760. /**
  84761. * 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)
  84762. * Note: This only is supported when using an emitter of type Mesh
  84763. */
  84764. inheritDirection: boolean;
  84765. /**
  84766. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84767. */
  84768. inheritedVelocityAmount: number;
  84769. /**
  84770. * Creates a sub emitter
  84771. * @param particleSystem the particle system to be used by the sub emitter
  84772. */
  84773. constructor(
  84774. /**
  84775. * the particle system to be used by the sub emitter
  84776. */
  84777. particleSystem: ParticleSystem);
  84778. /**
  84779. * Clones the sub emitter
  84780. * @returns the cloned sub emitter
  84781. */
  84782. clone(): SubEmitter;
  84783. /**
  84784. * Serialize current object to a JSON object
  84785. * @returns the serialized object
  84786. */
  84787. serialize(): any;
  84788. /** @hidden */
  84789. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84790. /**
  84791. * Creates a new SubEmitter from a serialized JSON version
  84792. * @param serializationObject defines the JSON object to read from
  84793. * @param scene defines the hosting scene
  84794. * @param rootUrl defines the rootUrl for data loading
  84795. * @returns a new SubEmitter
  84796. */
  84797. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84798. /** Release associated resources */
  84799. dispose(): void;
  84800. }
  84801. }
  84802. declare module BABYLON {
  84803. /** @hidden */
  84804. export var imageProcessingDeclaration: {
  84805. name: string;
  84806. shader: string;
  84807. };
  84808. }
  84809. declare module BABYLON {
  84810. /** @hidden */
  84811. export var imageProcessingFunctions: {
  84812. name: string;
  84813. shader: string;
  84814. };
  84815. }
  84816. declare module BABYLON {
  84817. /** @hidden */
  84818. export var particlesPixelShader: {
  84819. name: string;
  84820. shader: string;
  84821. };
  84822. }
  84823. declare module BABYLON {
  84824. /** @hidden */
  84825. export var particlesVertexShader: {
  84826. name: string;
  84827. shader: string;
  84828. };
  84829. }
  84830. declare module BABYLON {
  84831. /**
  84832. * This represents a particle system in Babylon.
  84833. * 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.
  84834. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84835. * @example https://doc.babylonjs.com/babylon101/particles
  84836. */
  84837. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84838. /**
  84839. * Billboard mode will only apply to Y axis
  84840. */
  84841. static readonly BILLBOARDMODE_Y: number;
  84842. /**
  84843. * Billboard mode will apply to all axes
  84844. */
  84845. static readonly BILLBOARDMODE_ALL: number;
  84846. /**
  84847. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84848. */
  84849. static readonly BILLBOARDMODE_STRETCHED: number;
  84850. /**
  84851. * This function can be defined to provide custom update for active particles.
  84852. * This function will be called instead of regular update (age, position, color, etc.).
  84853. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84854. */
  84855. updateFunction: (particles: Particle[]) => void;
  84856. private _emitterWorldMatrix;
  84857. /**
  84858. * This function can be defined to specify initial direction for every new particle.
  84859. * It by default use the emitterType defined function
  84860. */
  84861. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84862. /**
  84863. * This function can be defined to specify initial position for every new particle.
  84864. * It by default use the emitterType defined function
  84865. */
  84866. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84867. /**
  84868. * @hidden
  84869. */
  84870. _inheritedVelocityOffset: Vector3;
  84871. /**
  84872. * An event triggered when the system is disposed
  84873. */
  84874. onDisposeObservable: Observable<ParticleSystem>;
  84875. private _onDisposeObserver;
  84876. /**
  84877. * Sets a callback that will be triggered when the system is disposed
  84878. */
  84879. set onDispose(callback: () => void);
  84880. private _particles;
  84881. private _epsilon;
  84882. private _capacity;
  84883. private _stockParticles;
  84884. private _newPartsExcess;
  84885. private _vertexData;
  84886. private _vertexBuffer;
  84887. private _vertexBuffers;
  84888. private _spriteBuffer;
  84889. private _indexBuffer;
  84890. private _effect;
  84891. private _customEffect;
  84892. private _cachedDefines;
  84893. private _scaledColorStep;
  84894. private _colorDiff;
  84895. private _scaledDirection;
  84896. private _scaledGravity;
  84897. private _currentRenderId;
  84898. private _alive;
  84899. private _useInstancing;
  84900. private _started;
  84901. private _stopped;
  84902. private _actualFrame;
  84903. private _scaledUpdateSpeed;
  84904. private _vertexBufferSize;
  84905. /** @hidden */
  84906. _currentEmitRateGradient: Nullable<FactorGradient>;
  84907. /** @hidden */
  84908. _currentEmitRate1: number;
  84909. /** @hidden */
  84910. _currentEmitRate2: number;
  84911. /** @hidden */
  84912. _currentStartSizeGradient: Nullable<FactorGradient>;
  84913. /** @hidden */
  84914. _currentStartSize1: number;
  84915. /** @hidden */
  84916. _currentStartSize2: number;
  84917. private readonly _rawTextureWidth;
  84918. private _rampGradientsTexture;
  84919. private _useRampGradients;
  84920. /** Gets or sets a boolean indicating that ramp gradients must be used
  84921. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84922. */
  84923. get useRampGradients(): boolean;
  84924. set useRampGradients(value: boolean);
  84925. /**
  84926. * 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.
  84927. * 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: [])
  84928. */
  84929. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84930. private _subEmitters;
  84931. /**
  84932. * @hidden
  84933. * If the particle systems emitter should be disposed when the particle system is disposed
  84934. */
  84935. _disposeEmitterOnDispose: boolean;
  84936. /**
  84937. * The current active Sub-systems, this property is used by the root particle system only.
  84938. */
  84939. activeSubSystems: Array<ParticleSystem>;
  84940. private _rootParticleSystem;
  84941. /**
  84942. * Gets the current list of active particles
  84943. */
  84944. get particles(): Particle[];
  84945. /**
  84946. * Returns the string "ParticleSystem"
  84947. * @returns a string containing the class name
  84948. */
  84949. getClassName(): string;
  84950. /**
  84951. * Instantiates a particle system.
  84952. * 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.
  84953. * @param name The name of the particle system
  84954. * @param capacity The max number of particles alive at the same time
  84955. * @param scene The scene the particle system belongs to
  84956. * @param customEffect a custom effect used to change the way particles are rendered by default
  84957. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84958. * @param epsilon Offset used to render the particles
  84959. */
  84960. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84961. private _addFactorGradient;
  84962. private _removeFactorGradient;
  84963. /**
  84964. * Adds a new life time gradient
  84965. * @param gradient defines the gradient to use (between 0 and 1)
  84966. * @param factor defines the life time factor to affect to the specified gradient
  84967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84968. * @returns the current particle system
  84969. */
  84970. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84971. /**
  84972. * Remove a specific life time gradient
  84973. * @param gradient defines the gradient to remove
  84974. * @returns the current particle system
  84975. */
  84976. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84977. /**
  84978. * Adds a new size gradient
  84979. * @param gradient defines the gradient to use (between 0 and 1)
  84980. * @param factor defines the size factor to affect to the specified gradient
  84981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84982. * @returns the current particle system
  84983. */
  84984. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84985. /**
  84986. * Remove a specific size gradient
  84987. * @param gradient defines the gradient to remove
  84988. * @returns the current particle system
  84989. */
  84990. removeSizeGradient(gradient: number): IParticleSystem;
  84991. /**
  84992. * Adds a new color remap gradient
  84993. * @param gradient defines the gradient to use (between 0 and 1)
  84994. * @param min defines the color remap minimal range
  84995. * @param max defines the color remap maximal range
  84996. * @returns the current particle system
  84997. */
  84998. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84999. /**
  85000. * Remove a specific color remap gradient
  85001. * @param gradient defines the gradient to remove
  85002. * @returns the current particle system
  85003. */
  85004. removeColorRemapGradient(gradient: number): IParticleSystem;
  85005. /**
  85006. * Adds a new alpha remap gradient
  85007. * @param gradient defines the gradient to use (between 0 and 1)
  85008. * @param min defines the alpha remap minimal range
  85009. * @param max defines the alpha remap maximal range
  85010. * @returns the current particle system
  85011. */
  85012. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85013. /**
  85014. * Remove a specific alpha remap gradient
  85015. * @param gradient defines the gradient to remove
  85016. * @returns the current particle system
  85017. */
  85018. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85019. /**
  85020. * Adds a new angular speed gradient
  85021. * @param gradient defines the gradient to use (between 0 and 1)
  85022. * @param factor defines the angular speed to affect to the specified gradient
  85023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85024. * @returns the current particle system
  85025. */
  85026. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85027. /**
  85028. * Remove a specific angular speed gradient
  85029. * @param gradient defines the gradient to remove
  85030. * @returns the current particle system
  85031. */
  85032. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85033. /**
  85034. * Adds a new velocity gradient
  85035. * @param gradient defines the gradient to use (between 0 and 1)
  85036. * @param factor defines the velocity to affect to the specified gradient
  85037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85038. * @returns the current particle system
  85039. */
  85040. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85041. /**
  85042. * Remove a specific velocity gradient
  85043. * @param gradient defines the gradient to remove
  85044. * @returns the current particle system
  85045. */
  85046. removeVelocityGradient(gradient: number): IParticleSystem;
  85047. /**
  85048. * Adds a new limit velocity gradient
  85049. * @param gradient defines the gradient to use (between 0 and 1)
  85050. * @param factor defines the limit velocity value to affect to the specified gradient
  85051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85052. * @returns the current particle system
  85053. */
  85054. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85055. /**
  85056. * Remove a specific limit velocity gradient
  85057. * @param gradient defines the gradient to remove
  85058. * @returns the current particle system
  85059. */
  85060. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85061. /**
  85062. * Adds a new drag gradient
  85063. * @param gradient defines the gradient to use (between 0 and 1)
  85064. * @param factor defines the drag value to affect to the specified gradient
  85065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85066. * @returns the current particle system
  85067. */
  85068. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85069. /**
  85070. * Remove a specific drag gradient
  85071. * @param gradient defines the gradient to remove
  85072. * @returns the current particle system
  85073. */
  85074. removeDragGradient(gradient: number): IParticleSystem;
  85075. /**
  85076. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85077. * @param gradient defines the gradient to use (between 0 and 1)
  85078. * @param factor defines the emit rate value to affect to the specified gradient
  85079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85080. * @returns the current particle system
  85081. */
  85082. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85083. /**
  85084. * Remove a specific emit rate gradient
  85085. * @param gradient defines the gradient to remove
  85086. * @returns the current particle system
  85087. */
  85088. removeEmitRateGradient(gradient: number): IParticleSystem;
  85089. /**
  85090. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85091. * @param gradient defines the gradient to use (between 0 and 1)
  85092. * @param factor defines the start size value to affect to the specified gradient
  85093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85094. * @returns the current particle system
  85095. */
  85096. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85097. /**
  85098. * Remove a specific start size gradient
  85099. * @param gradient defines the gradient to remove
  85100. * @returns the current particle system
  85101. */
  85102. removeStartSizeGradient(gradient: number): IParticleSystem;
  85103. private _createRampGradientTexture;
  85104. /**
  85105. * Gets the current list of ramp gradients.
  85106. * You must use addRampGradient and removeRampGradient to udpate this list
  85107. * @returns the list of ramp gradients
  85108. */
  85109. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85110. /**
  85111. * Adds a new ramp gradient used to remap particle colors
  85112. * @param gradient defines the gradient to use (between 0 and 1)
  85113. * @param color defines the color to affect to the specified gradient
  85114. * @returns the current particle system
  85115. */
  85116. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85117. /**
  85118. * Remove a specific ramp gradient
  85119. * @param gradient defines the gradient to remove
  85120. * @returns the current particle system
  85121. */
  85122. removeRampGradient(gradient: number): ParticleSystem;
  85123. /**
  85124. * Adds a new color gradient
  85125. * @param gradient defines the gradient to use (between 0 and 1)
  85126. * @param color1 defines the color to affect to the specified gradient
  85127. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85128. * @returns this particle system
  85129. */
  85130. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85131. /**
  85132. * Remove a specific color gradient
  85133. * @param gradient defines the gradient to remove
  85134. * @returns this particle system
  85135. */
  85136. removeColorGradient(gradient: number): IParticleSystem;
  85137. private _fetchR;
  85138. protected _reset(): void;
  85139. private _resetEffect;
  85140. private _createVertexBuffers;
  85141. private _createIndexBuffer;
  85142. /**
  85143. * Gets the maximum number of particles active at the same time.
  85144. * @returns The max number of active particles.
  85145. */
  85146. getCapacity(): number;
  85147. /**
  85148. * Gets whether there are still active particles in the system.
  85149. * @returns True if it is alive, otherwise false.
  85150. */
  85151. isAlive(): boolean;
  85152. /**
  85153. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85154. * @returns True if it has been started, otherwise false.
  85155. */
  85156. isStarted(): boolean;
  85157. private _prepareSubEmitterInternalArray;
  85158. /**
  85159. * Starts the particle system and begins to emit
  85160. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85161. */
  85162. start(delay?: number): void;
  85163. /**
  85164. * Stops the particle system.
  85165. * @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.
  85166. */
  85167. stop(stopSubEmitters?: boolean): void;
  85168. /**
  85169. * Remove all active particles
  85170. */
  85171. reset(): void;
  85172. /**
  85173. * @hidden (for internal use only)
  85174. */
  85175. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85176. /**
  85177. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85178. * Its lifetime will start back at 0.
  85179. */
  85180. recycleParticle: (particle: Particle) => void;
  85181. private _stopSubEmitters;
  85182. private _createParticle;
  85183. private _removeFromRoot;
  85184. private _emitFromParticle;
  85185. private _update;
  85186. /** @hidden */
  85187. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85188. /** @hidden */
  85189. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85190. /** @hidden */
  85191. private _getEffect;
  85192. /**
  85193. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85194. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85195. */
  85196. animate(preWarmOnly?: boolean): void;
  85197. private _appendParticleVertices;
  85198. /**
  85199. * Rebuilds the particle system.
  85200. */
  85201. rebuild(): void;
  85202. /**
  85203. * Is this system ready to be used/rendered
  85204. * @return true if the system is ready
  85205. */
  85206. isReady(): boolean;
  85207. private _render;
  85208. /**
  85209. * Renders the particle system in its current state.
  85210. * @returns the current number of particles
  85211. */
  85212. render(): number;
  85213. /**
  85214. * Disposes the particle system and free the associated resources
  85215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85216. */
  85217. dispose(disposeTexture?: boolean): void;
  85218. /**
  85219. * Clones the particle system.
  85220. * @param name The name of the cloned object
  85221. * @param newEmitter The new emitter to use
  85222. * @returns the cloned particle system
  85223. */
  85224. clone(name: string, newEmitter: any): ParticleSystem;
  85225. /**
  85226. * Serializes the particle system to a JSON object.
  85227. * @returns the JSON object
  85228. */
  85229. serialize(): any;
  85230. /** @hidden */
  85231. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85232. /** @hidden */
  85233. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85234. /**
  85235. * Parses a JSON object to create a particle system.
  85236. * @param parsedParticleSystem The JSON object to parse
  85237. * @param scene The scene to create the particle system in
  85238. * @param rootUrl The root url to use to load external dependencies like texture
  85239. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85240. * @returns the Parsed particle system
  85241. */
  85242. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85243. }
  85244. }
  85245. declare module BABYLON {
  85246. /**
  85247. * A particle represents one of the element emitted by a particle system.
  85248. * This is mainly define by its coordinates, direction, velocity and age.
  85249. */
  85250. export class Particle {
  85251. /**
  85252. * The particle system the particle belongs to.
  85253. */
  85254. particleSystem: ParticleSystem;
  85255. private static _Count;
  85256. /**
  85257. * Unique ID of the particle
  85258. */
  85259. id: number;
  85260. /**
  85261. * The world position of the particle in the scene.
  85262. */
  85263. position: Vector3;
  85264. /**
  85265. * The world direction of the particle in the scene.
  85266. */
  85267. direction: Vector3;
  85268. /**
  85269. * The color of the particle.
  85270. */
  85271. color: Color4;
  85272. /**
  85273. * The color change of the particle per step.
  85274. */
  85275. colorStep: Color4;
  85276. /**
  85277. * Defines how long will the life of the particle be.
  85278. */
  85279. lifeTime: number;
  85280. /**
  85281. * The current age of the particle.
  85282. */
  85283. age: number;
  85284. /**
  85285. * The current size of the particle.
  85286. */
  85287. size: number;
  85288. /**
  85289. * The current scale of the particle.
  85290. */
  85291. scale: Vector2;
  85292. /**
  85293. * The current angle of the particle.
  85294. */
  85295. angle: number;
  85296. /**
  85297. * Defines how fast is the angle changing.
  85298. */
  85299. angularSpeed: number;
  85300. /**
  85301. * Defines the cell index used by the particle to be rendered from a sprite.
  85302. */
  85303. cellIndex: number;
  85304. /**
  85305. * The information required to support color remapping
  85306. */
  85307. remapData: Vector4;
  85308. /** @hidden */
  85309. _randomCellOffset?: number;
  85310. /** @hidden */
  85311. _initialDirection: Nullable<Vector3>;
  85312. /** @hidden */
  85313. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85314. /** @hidden */
  85315. _initialStartSpriteCellID: number;
  85316. /** @hidden */
  85317. _initialEndSpriteCellID: number;
  85318. /** @hidden */
  85319. _currentColorGradient: Nullable<ColorGradient>;
  85320. /** @hidden */
  85321. _currentColor1: Color4;
  85322. /** @hidden */
  85323. _currentColor2: Color4;
  85324. /** @hidden */
  85325. _currentSizeGradient: Nullable<FactorGradient>;
  85326. /** @hidden */
  85327. _currentSize1: number;
  85328. /** @hidden */
  85329. _currentSize2: number;
  85330. /** @hidden */
  85331. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85332. /** @hidden */
  85333. _currentAngularSpeed1: number;
  85334. /** @hidden */
  85335. _currentAngularSpeed2: number;
  85336. /** @hidden */
  85337. _currentVelocityGradient: Nullable<FactorGradient>;
  85338. /** @hidden */
  85339. _currentVelocity1: number;
  85340. /** @hidden */
  85341. _currentVelocity2: number;
  85342. /** @hidden */
  85343. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85344. /** @hidden */
  85345. _currentLimitVelocity1: number;
  85346. /** @hidden */
  85347. _currentLimitVelocity2: number;
  85348. /** @hidden */
  85349. _currentDragGradient: Nullable<FactorGradient>;
  85350. /** @hidden */
  85351. _currentDrag1: number;
  85352. /** @hidden */
  85353. _currentDrag2: number;
  85354. /** @hidden */
  85355. _randomNoiseCoordinates1: Vector3;
  85356. /** @hidden */
  85357. _randomNoiseCoordinates2: Vector3;
  85358. /**
  85359. * Creates a new instance Particle
  85360. * @param particleSystem the particle system the particle belongs to
  85361. */
  85362. constructor(
  85363. /**
  85364. * The particle system the particle belongs to.
  85365. */
  85366. particleSystem: ParticleSystem);
  85367. private updateCellInfoFromSystem;
  85368. /**
  85369. * Defines how the sprite cell index is updated for the particle
  85370. */
  85371. updateCellIndex(): void;
  85372. /** @hidden */
  85373. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85374. /** @hidden */
  85375. _inheritParticleInfoToSubEmitters(): void;
  85376. /** @hidden */
  85377. _reset(): void;
  85378. /**
  85379. * Copy the properties of particle to another one.
  85380. * @param other the particle to copy the information to.
  85381. */
  85382. copyTo(other: Particle): void;
  85383. }
  85384. }
  85385. declare module BABYLON {
  85386. /**
  85387. * Particle emitter represents a volume emitting particles.
  85388. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85389. */
  85390. export interface IParticleEmitterType {
  85391. /**
  85392. * Called by the particle System when the direction is computed for the created particle.
  85393. * @param worldMatrix is the world matrix of the particle system
  85394. * @param directionToUpdate is the direction vector to update with the result
  85395. * @param particle is the particle we are computed the direction for
  85396. */
  85397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85398. /**
  85399. * Called by the particle System when the position is computed for the created particle.
  85400. * @param worldMatrix is the world matrix of the particle system
  85401. * @param positionToUpdate is the position vector to update with the result
  85402. * @param particle is the particle we are computed the position for
  85403. */
  85404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85405. /**
  85406. * Clones the current emitter and returns a copy of it
  85407. * @returns the new emitter
  85408. */
  85409. clone(): IParticleEmitterType;
  85410. /**
  85411. * Called by the GPUParticleSystem to setup the update shader
  85412. * @param effect defines the update shader
  85413. */
  85414. applyToShader(effect: Effect): void;
  85415. /**
  85416. * Returns a string to use to update the GPU particles update shader
  85417. * @returns the effect defines string
  85418. */
  85419. getEffectDefines(): string;
  85420. /**
  85421. * Returns a string representing the class name
  85422. * @returns a string containing the class name
  85423. */
  85424. getClassName(): string;
  85425. /**
  85426. * Serializes the particle system to a JSON object.
  85427. * @returns the JSON object
  85428. */
  85429. serialize(): any;
  85430. /**
  85431. * Parse properties from a JSON object
  85432. * @param serializationObject defines the JSON object
  85433. * @param scene defines the hosting scene
  85434. */
  85435. parse(serializationObject: any, scene: Scene): void;
  85436. }
  85437. }
  85438. declare module BABYLON {
  85439. /**
  85440. * Particle emitter emitting particles from the inside of a box.
  85441. * It emits the particles randomly between 2 given directions.
  85442. */
  85443. export class BoxParticleEmitter implements IParticleEmitterType {
  85444. /**
  85445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85446. */
  85447. direction1: Vector3;
  85448. /**
  85449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85450. */
  85451. direction2: Vector3;
  85452. /**
  85453. * 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.
  85454. */
  85455. minEmitBox: Vector3;
  85456. /**
  85457. * 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.
  85458. */
  85459. maxEmitBox: Vector3;
  85460. /**
  85461. * Creates a new instance BoxParticleEmitter
  85462. */
  85463. constructor();
  85464. /**
  85465. * Called by the particle System when the direction is computed for the created particle.
  85466. * @param worldMatrix is the world matrix of the particle system
  85467. * @param directionToUpdate is the direction vector to update with the result
  85468. * @param particle is the particle we are computed the direction for
  85469. */
  85470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85471. /**
  85472. * Called by the particle System when the position is computed for the created particle.
  85473. * @param worldMatrix is the world matrix of the particle system
  85474. * @param positionToUpdate is the position vector to update with the result
  85475. * @param particle is the particle we are computed the position for
  85476. */
  85477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85478. /**
  85479. * Clones the current emitter and returns a copy of it
  85480. * @returns the new emitter
  85481. */
  85482. clone(): BoxParticleEmitter;
  85483. /**
  85484. * Called by the GPUParticleSystem to setup the update shader
  85485. * @param effect defines the update shader
  85486. */
  85487. applyToShader(effect: Effect): void;
  85488. /**
  85489. * Returns a string to use to update the GPU particles update shader
  85490. * @returns a string containng the defines string
  85491. */
  85492. getEffectDefines(): string;
  85493. /**
  85494. * Returns the string "BoxParticleEmitter"
  85495. * @returns a string containing the class name
  85496. */
  85497. getClassName(): string;
  85498. /**
  85499. * Serializes the particle system to a JSON object.
  85500. * @returns the JSON object
  85501. */
  85502. serialize(): any;
  85503. /**
  85504. * Parse properties from a JSON object
  85505. * @param serializationObject defines the JSON object
  85506. */
  85507. parse(serializationObject: any): void;
  85508. }
  85509. }
  85510. declare module BABYLON {
  85511. /**
  85512. * Particle emitter emitting particles from the inside of a cone.
  85513. * It emits the particles alongside the cone volume from the base to the particle.
  85514. * The emission direction might be randomized.
  85515. */
  85516. export class ConeParticleEmitter implements IParticleEmitterType {
  85517. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85518. directionRandomizer: number;
  85519. private _radius;
  85520. private _angle;
  85521. private _height;
  85522. /**
  85523. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85524. */
  85525. radiusRange: number;
  85526. /**
  85527. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85528. */
  85529. heightRange: number;
  85530. /**
  85531. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85532. */
  85533. emitFromSpawnPointOnly: boolean;
  85534. /**
  85535. * Gets or sets the radius of the emission cone
  85536. */
  85537. get radius(): number;
  85538. set radius(value: number);
  85539. /**
  85540. * Gets or sets the angle of the emission cone
  85541. */
  85542. get angle(): number;
  85543. set angle(value: number);
  85544. private _buildHeight;
  85545. /**
  85546. * Creates a new instance ConeParticleEmitter
  85547. * @param radius the radius of the emission cone (1 by default)
  85548. * @param angle the cone base angle (PI by default)
  85549. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85550. */
  85551. constructor(radius?: number, angle?: number,
  85552. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85553. directionRandomizer?: number);
  85554. /**
  85555. * Called by the particle System when the direction is computed for the created particle.
  85556. * @param worldMatrix is the world matrix of the particle system
  85557. * @param directionToUpdate is the direction vector to update with the result
  85558. * @param particle is the particle we are computed the direction for
  85559. */
  85560. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85561. /**
  85562. * Called by the particle System when the position is computed for the created particle.
  85563. * @param worldMatrix is the world matrix of the particle system
  85564. * @param positionToUpdate is the position vector to update with the result
  85565. * @param particle is the particle we are computed the position for
  85566. */
  85567. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85568. /**
  85569. * Clones the current emitter and returns a copy of it
  85570. * @returns the new emitter
  85571. */
  85572. clone(): ConeParticleEmitter;
  85573. /**
  85574. * Called by the GPUParticleSystem to setup the update shader
  85575. * @param effect defines the update shader
  85576. */
  85577. applyToShader(effect: Effect): void;
  85578. /**
  85579. * Returns a string to use to update the GPU particles update shader
  85580. * @returns a string containng the defines string
  85581. */
  85582. getEffectDefines(): string;
  85583. /**
  85584. * Returns the string "ConeParticleEmitter"
  85585. * @returns a string containing the class name
  85586. */
  85587. getClassName(): string;
  85588. /**
  85589. * Serializes the particle system to a JSON object.
  85590. * @returns the JSON object
  85591. */
  85592. serialize(): any;
  85593. /**
  85594. * Parse properties from a JSON object
  85595. * @param serializationObject defines the JSON object
  85596. */
  85597. parse(serializationObject: any): void;
  85598. }
  85599. }
  85600. declare module BABYLON {
  85601. /**
  85602. * Particle emitter emitting particles from the inside of a cylinder.
  85603. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85604. */
  85605. export class CylinderParticleEmitter implements IParticleEmitterType {
  85606. /**
  85607. * The radius of the emission cylinder.
  85608. */
  85609. radius: number;
  85610. /**
  85611. * The height of the emission cylinder.
  85612. */
  85613. height: number;
  85614. /**
  85615. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85616. */
  85617. radiusRange: number;
  85618. /**
  85619. * How much to randomize the particle direction [0-1].
  85620. */
  85621. directionRandomizer: number;
  85622. /**
  85623. * Creates a new instance CylinderParticleEmitter
  85624. * @param radius the radius of the emission cylinder (1 by default)
  85625. * @param height the height of the emission cylinder (1 by default)
  85626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85627. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85628. */
  85629. constructor(
  85630. /**
  85631. * The radius of the emission cylinder.
  85632. */
  85633. radius?: number,
  85634. /**
  85635. * The height of the emission cylinder.
  85636. */
  85637. height?: number,
  85638. /**
  85639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85640. */
  85641. radiusRange?: number,
  85642. /**
  85643. * How much to randomize the particle direction [0-1].
  85644. */
  85645. directionRandomizer?: number);
  85646. /**
  85647. * Called by the particle System when the direction is computed for the created particle.
  85648. * @param worldMatrix is the world matrix of the particle system
  85649. * @param directionToUpdate is the direction vector to update with the result
  85650. * @param particle is the particle we are computed the direction for
  85651. */
  85652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85653. /**
  85654. * Called by the particle System when the position is computed for the created particle.
  85655. * @param worldMatrix is the world matrix of the particle system
  85656. * @param positionToUpdate is the position vector to update with the result
  85657. * @param particle is the particle we are computed the position for
  85658. */
  85659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85660. /**
  85661. * Clones the current emitter and returns a copy of it
  85662. * @returns the new emitter
  85663. */
  85664. clone(): CylinderParticleEmitter;
  85665. /**
  85666. * Called by the GPUParticleSystem to setup the update shader
  85667. * @param effect defines the update shader
  85668. */
  85669. applyToShader(effect: Effect): void;
  85670. /**
  85671. * Returns a string to use to update the GPU particles update shader
  85672. * @returns a string containng the defines string
  85673. */
  85674. getEffectDefines(): string;
  85675. /**
  85676. * Returns the string "CylinderParticleEmitter"
  85677. * @returns a string containing the class name
  85678. */
  85679. getClassName(): string;
  85680. /**
  85681. * Serializes the particle system to a JSON object.
  85682. * @returns the JSON object
  85683. */
  85684. serialize(): any;
  85685. /**
  85686. * Parse properties from a JSON object
  85687. * @param serializationObject defines the JSON object
  85688. */
  85689. parse(serializationObject: any): void;
  85690. }
  85691. /**
  85692. * Particle emitter emitting particles from the inside of a cylinder.
  85693. * It emits the particles randomly between two vectors.
  85694. */
  85695. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85696. /**
  85697. * The min limit of the emission direction.
  85698. */
  85699. direction1: Vector3;
  85700. /**
  85701. * The max limit of the emission direction.
  85702. */
  85703. direction2: Vector3;
  85704. /**
  85705. * Creates a new instance CylinderDirectedParticleEmitter
  85706. * @param radius the radius of the emission cylinder (1 by default)
  85707. * @param height the height of the emission cylinder (1 by default)
  85708. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85709. * @param direction1 the min limit of the emission direction (up vector by default)
  85710. * @param direction2 the max limit of the emission direction (up vector by default)
  85711. */
  85712. constructor(radius?: number, height?: number, radiusRange?: number,
  85713. /**
  85714. * The min limit of the emission direction.
  85715. */
  85716. direction1?: Vector3,
  85717. /**
  85718. * The max limit of the emission direction.
  85719. */
  85720. direction2?: Vector3);
  85721. /**
  85722. * Called by the particle System when the direction is computed for the created particle.
  85723. * @param worldMatrix is the world matrix of the particle system
  85724. * @param directionToUpdate is the direction vector to update with the result
  85725. * @param particle is the particle we are computed the direction for
  85726. */
  85727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85728. /**
  85729. * Clones the current emitter and returns a copy of it
  85730. * @returns the new emitter
  85731. */
  85732. clone(): CylinderDirectedParticleEmitter;
  85733. /**
  85734. * Called by the GPUParticleSystem to setup the update shader
  85735. * @param effect defines the update shader
  85736. */
  85737. applyToShader(effect: Effect): void;
  85738. /**
  85739. * Returns a string to use to update the GPU particles update shader
  85740. * @returns a string containng the defines string
  85741. */
  85742. getEffectDefines(): string;
  85743. /**
  85744. * Returns the string "CylinderDirectedParticleEmitter"
  85745. * @returns a string containing the class name
  85746. */
  85747. getClassName(): string;
  85748. /**
  85749. * Serializes the particle system to a JSON object.
  85750. * @returns the JSON object
  85751. */
  85752. serialize(): any;
  85753. /**
  85754. * Parse properties from a JSON object
  85755. * @param serializationObject defines the JSON object
  85756. */
  85757. parse(serializationObject: any): void;
  85758. }
  85759. }
  85760. declare module BABYLON {
  85761. /**
  85762. * Particle emitter emitting particles from the inside of a hemisphere.
  85763. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85764. */
  85765. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85766. /**
  85767. * The radius of the emission hemisphere.
  85768. */
  85769. radius: number;
  85770. /**
  85771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85772. */
  85773. radiusRange: number;
  85774. /**
  85775. * How much to randomize the particle direction [0-1].
  85776. */
  85777. directionRandomizer: number;
  85778. /**
  85779. * Creates a new instance HemisphericParticleEmitter
  85780. * @param radius the radius of the emission hemisphere (1 by default)
  85781. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85782. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85783. */
  85784. constructor(
  85785. /**
  85786. * The radius of the emission hemisphere.
  85787. */
  85788. radius?: number,
  85789. /**
  85790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85791. */
  85792. radiusRange?: number,
  85793. /**
  85794. * How much to randomize the particle direction [0-1].
  85795. */
  85796. directionRandomizer?: number);
  85797. /**
  85798. * Called by the particle System when the direction is computed for the created particle.
  85799. * @param worldMatrix is the world matrix of the particle system
  85800. * @param directionToUpdate is the direction vector to update with the result
  85801. * @param particle is the particle we are computed the direction for
  85802. */
  85803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85804. /**
  85805. * Called by the particle System when the position is computed for the created particle.
  85806. * @param worldMatrix is the world matrix of the particle system
  85807. * @param positionToUpdate is the position vector to update with the result
  85808. * @param particle is the particle we are computed the position for
  85809. */
  85810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85811. /**
  85812. * Clones the current emitter and returns a copy of it
  85813. * @returns the new emitter
  85814. */
  85815. clone(): HemisphericParticleEmitter;
  85816. /**
  85817. * Called by the GPUParticleSystem to setup the update shader
  85818. * @param effect defines the update shader
  85819. */
  85820. applyToShader(effect: Effect): void;
  85821. /**
  85822. * Returns a string to use to update the GPU particles update shader
  85823. * @returns a string containng the defines string
  85824. */
  85825. getEffectDefines(): string;
  85826. /**
  85827. * Returns the string "HemisphericParticleEmitter"
  85828. * @returns a string containing the class name
  85829. */
  85830. getClassName(): string;
  85831. /**
  85832. * Serializes the particle system to a JSON object.
  85833. * @returns the JSON object
  85834. */
  85835. serialize(): any;
  85836. /**
  85837. * Parse properties from a JSON object
  85838. * @param serializationObject defines the JSON object
  85839. */
  85840. parse(serializationObject: any): void;
  85841. }
  85842. }
  85843. declare module BABYLON {
  85844. /**
  85845. * Particle emitter emitting particles from a point.
  85846. * It emits the particles randomly between 2 given directions.
  85847. */
  85848. export class PointParticleEmitter implements IParticleEmitterType {
  85849. /**
  85850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85851. */
  85852. direction1: Vector3;
  85853. /**
  85854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85855. */
  85856. direction2: Vector3;
  85857. /**
  85858. * Creates a new instance PointParticleEmitter
  85859. */
  85860. constructor();
  85861. /**
  85862. * Called by the particle System when the direction is computed for the created particle.
  85863. * @param worldMatrix is the world matrix of the particle system
  85864. * @param directionToUpdate is the direction vector to update with the result
  85865. * @param particle is the particle we are computed the direction for
  85866. */
  85867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85868. /**
  85869. * Called by the particle System when the position is computed for the created particle.
  85870. * @param worldMatrix is the world matrix of the particle system
  85871. * @param positionToUpdate is the position vector to update with the result
  85872. * @param particle is the particle we are computed the position for
  85873. */
  85874. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85875. /**
  85876. * Clones the current emitter and returns a copy of it
  85877. * @returns the new emitter
  85878. */
  85879. clone(): PointParticleEmitter;
  85880. /**
  85881. * Called by the GPUParticleSystem to setup the update shader
  85882. * @param effect defines the update shader
  85883. */
  85884. applyToShader(effect: Effect): void;
  85885. /**
  85886. * Returns a string to use to update the GPU particles update shader
  85887. * @returns a string containng the defines string
  85888. */
  85889. getEffectDefines(): string;
  85890. /**
  85891. * Returns the string "PointParticleEmitter"
  85892. * @returns a string containing the class name
  85893. */
  85894. getClassName(): string;
  85895. /**
  85896. * Serializes the particle system to a JSON object.
  85897. * @returns the JSON object
  85898. */
  85899. serialize(): any;
  85900. /**
  85901. * Parse properties from a JSON object
  85902. * @param serializationObject defines the JSON object
  85903. */
  85904. parse(serializationObject: any): void;
  85905. }
  85906. }
  85907. declare module BABYLON {
  85908. /**
  85909. * Particle emitter emitting particles from the inside of a sphere.
  85910. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85911. */
  85912. export class SphereParticleEmitter implements IParticleEmitterType {
  85913. /**
  85914. * The radius of the emission sphere.
  85915. */
  85916. radius: number;
  85917. /**
  85918. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85919. */
  85920. radiusRange: number;
  85921. /**
  85922. * How much to randomize the particle direction [0-1].
  85923. */
  85924. directionRandomizer: number;
  85925. /**
  85926. * Creates a new instance SphereParticleEmitter
  85927. * @param radius the radius of the emission sphere (1 by default)
  85928. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85929. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85930. */
  85931. constructor(
  85932. /**
  85933. * The radius of the emission sphere.
  85934. */
  85935. radius?: number,
  85936. /**
  85937. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85938. */
  85939. radiusRange?: number,
  85940. /**
  85941. * How much to randomize the particle direction [0-1].
  85942. */
  85943. directionRandomizer?: number);
  85944. /**
  85945. * Called by the particle System when the direction is computed for the created particle.
  85946. * @param worldMatrix is the world matrix of the particle system
  85947. * @param directionToUpdate is the direction vector to update with the result
  85948. * @param particle is the particle we are computed the direction for
  85949. */
  85950. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85951. /**
  85952. * Called by the particle System when the position is computed for the created particle.
  85953. * @param worldMatrix is the world matrix of the particle system
  85954. * @param positionToUpdate is the position vector to update with the result
  85955. * @param particle is the particle we are computed the position for
  85956. */
  85957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85958. /**
  85959. * Clones the current emitter and returns a copy of it
  85960. * @returns the new emitter
  85961. */
  85962. clone(): SphereParticleEmitter;
  85963. /**
  85964. * Called by the GPUParticleSystem to setup the update shader
  85965. * @param effect defines the update shader
  85966. */
  85967. applyToShader(effect: Effect): void;
  85968. /**
  85969. * Returns a string to use to update the GPU particles update shader
  85970. * @returns a string containng the defines string
  85971. */
  85972. getEffectDefines(): string;
  85973. /**
  85974. * Returns the string "SphereParticleEmitter"
  85975. * @returns a string containing the class name
  85976. */
  85977. getClassName(): string;
  85978. /**
  85979. * Serializes the particle system to a JSON object.
  85980. * @returns the JSON object
  85981. */
  85982. serialize(): any;
  85983. /**
  85984. * Parse properties from a JSON object
  85985. * @param serializationObject defines the JSON object
  85986. */
  85987. parse(serializationObject: any): void;
  85988. }
  85989. /**
  85990. * Particle emitter emitting particles from the inside of a sphere.
  85991. * It emits the particles randomly between two vectors.
  85992. */
  85993. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85994. /**
  85995. * The min limit of the emission direction.
  85996. */
  85997. direction1: Vector3;
  85998. /**
  85999. * The max limit of the emission direction.
  86000. */
  86001. direction2: Vector3;
  86002. /**
  86003. * Creates a new instance SphereDirectedParticleEmitter
  86004. * @param radius the radius of the emission sphere (1 by default)
  86005. * @param direction1 the min limit of the emission direction (up vector by default)
  86006. * @param direction2 the max limit of the emission direction (up vector by default)
  86007. */
  86008. constructor(radius?: number,
  86009. /**
  86010. * The min limit of the emission direction.
  86011. */
  86012. direction1?: Vector3,
  86013. /**
  86014. * The max limit of the emission direction.
  86015. */
  86016. direction2?: Vector3);
  86017. /**
  86018. * Called by the particle System when the direction is computed for the created particle.
  86019. * @param worldMatrix is the world matrix of the particle system
  86020. * @param directionToUpdate is the direction vector to update with the result
  86021. * @param particle is the particle we are computed the direction for
  86022. */
  86023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86024. /**
  86025. * Clones the current emitter and returns a copy of it
  86026. * @returns the new emitter
  86027. */
  86028. clone(): SphereDirectedParticleEmitter;
  86029. /**
  86030. * Called by the GPUParticleSystem to setup the update shader
  86031. * @param effect defines the update shader
  86032. */
  86033. applyToShader(effect: Effect): void;
  86034. /**
  86035. * Returns a string to use to update the GPU particles update shader
  86036. * @returns a string containng the defines string
  86037. */
  86038. getEffectDefines(): string;
  86039. /**
  86040. * Returns the string "SphereDirectedParticleEmitter"
  86041. * @returns a string containing the class name
  86042. */
  86043. getClassName(): string;
  86044. /**
  86045. * Serializes the particle system to a JSON object.
  86046. * @returns the JSON object
  86047. */
  86048. serialize(): any;
  86049. /**
  86050. * Parse properties from a JSON object
  86051. * @param serializationObject defines the JSON object
  86052. */
  86053. parse(serializationObject: any): void;
  86054. }
  86055. }
  86056. declare module BABYLON {
  86057. /**
  86058. * Particle emitter emitting particles from a custom list of positions.
  86059. */
  86060. export class CustomParticleEmitter implements IParticleEmitterType {
  86061. /**
  86062. * Gets or sets the position generator that will create the inital position of each particle.
  86063. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86064. */
  86065. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86066. /**
  86067. * Gets or sets the destination generator that will create the final destination of each particle.
  86068. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86069. */
  86070. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86071. /**
  86072. * Creates a new instance CustomParticleEmitter
  86073. */
  86074. constructor();
  86075. /**
  86076. * Called by the particle System when the direction is computed for the created particle.
  86077. * @param worldMatrix is the world matrix of the particle system
  86078. * @param directionToUpdate is the direction vector to update with the result
  86079. * @param particle is the particle we are computed the direction for
  86080. */
  86081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86082. /**
  86083. * Called by the particle System when the position is computed for the created particle.
  86084. * @param worldMatrix is the world matrix of the particle system
  86085. * @param positionToUpdate is the position vector to update with the result
  86086. * @param particle is the particle we are computed the position for
  86087. */
  86088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86089. /**
  86090. * Clones the current emitter and returns a copy of it
  86091. * @returns the new emitter
  86092. */
  86093. clone(): CustomParticleEmitter;
  86094. /**
  86095. * Called by the GPUParticleSystem to setup the update shader
  86096. * @param effect defines the update shader
  86097. */
  86098. applyToShader(effect: Effect): void;
  86099. /**
  86100. * Returns a string to use to update the GPU particles update shader
  86101. * @returns a string containng the defines string
  86102. */
  86103. getEffectDefines(): string;
  86104. /**
  86105. * Returns the string "PointParticleEmitter"
  86106. * @returns a string containing the class name
  86107. */
  86108. getClassName(): string;
  86109. /**
  86110. * Serializes the particle system to a JSON object.
  86111. * @returns the JSON object
  86112. */
  86113. serialize(): any;
  86114. /**
  86115. * Parse properties from a JSON object
  86116. * @param serializationObject defines the JSON object
  86117. */
  86118. parse(serializationObject: any): void;
  86119. }
  86120. }
  86121. declare module BABYLON {
  86122. /**
  86123. * Particle emitter emitting particles from the inside of a box.
  86124. * It emits the particles randomly between 2 given directions.
  86125. */
  86126. export class MeshParticleEmitter implements IParticleEmitterType {
  86127. /** Defines the mesh to use as source */
  86128. mesh?: AbstractMesh | undefined;
  86129. private _indices;
  86130. private _positions;
  86131. private _normals;
  86132. private _storedNormal;
  86133. /**
  86134. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86135. */
  86136. direction1: Vector3;
  86137. /**
  86138. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86139. */
  86140. direction2: Vector3;
  86141. /**
  86142. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86143. */
  86144. useMeshNormalsForDirection: boolean;
  86145. /**
  86146. * Creates a new instance MeshParticleEmitter
  86147. * @param mesh defines the mesh to use as source
  86148. */
  86149. constructor(
  86150. /** Defines the mesh to use as source */
  86151. mesh?: AbstractMesh | undefined);
  86152. /**
  86153. * Called by the particle System when the direction is computed for the created particle.
  86154. * @param worldMatrix is the world matrix of the particle system
  86155. * @param directionToUpdate is the direction vector to update with the result
  86156. * @param particle is the particle we are computed the direction for
  86157. */
  86158. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86159. /**
  86160. * Called by the particle System when the position is computed for the created particle.
  86161. * @param worldMatrix is the world matrix of the particle system
  86162. * @param positionToUpdate is the position vector to update with the result
  86163. * @param particle is the particle we are computed the position for
  86164. */
  86165. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86166. /**
  86167. * Clones the current emitter and returns a copy of it
  86168. * @returns the new emitter
  86169. */
  86170. clone(): MeshParticleEmitter;
  86171. /**
  86172. * Called by the GPUParticleSystem to setup the update shader
  86173. * @param effect defines the update shader
  86174. */
  86175. applyToShader(effect: Effect): void;
  86176. /**
  86177. * Returns a string to use to update the GPU particles update shader
  86178. * @returns a string containng the defines string
  86179. */
  86180. getEffectDefines(): string;
  86181. /**
  86182. * Returns the string "BoxParticleEmitter"
  86183. * @returns a string containing the class name
  86184. */
  86185. getClassName(): string;
  86186. /**
  86187. * Serializes the particle system to a JSON object.
  86188. * @returns the JSON object
  86189. */
  86190. serialize(): any;
  86191. /**
  86192. * Parse properties from a JSON object
  86193. * @param serializationObject defines the JSON object
  86194. * @param scene defines the hosting scene
  86195. */
  86196. parse(serializationObject: any, scene: Scene): void;
  86197. }
  86198. }
  86199. declare module BABYLON {
  86200. /**
  86201. * Interface representing a particle system in Babylon.js.
  86202. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86203. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86204. */
  86205. export interface IParticleSystem {
  86206. /**
  86207. * List of animations used by the particle system.
  86208. */
  86209. animations: Animation[];
  86210. /**
  86211. * The id of the Particle system.
  86212. */
  86213. id: string;
  86214. /**
  86215. * The name of the Particle system.
  86216. */
  86217. name: string;
  86218. /**
  86219. * The emitter represents the Mesh or position we are attaching the particle system to.
  86220. */
  86221. emitter: Nullable<AbstractMesh | Vector3>;
  86222. /**
  86223. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86224. */
  86225. isBillboardBased: boolean;
  86226. /**
  86227. * The rendering group used by the Particle system to chose when to render.
  86228. */
  86229. renderingGroupId: number;
  86230. /**
  86231. * The layer mask we are rendering the particles through.
  86232. */
  86233. layerMask: number;
  86234. /**
  86235. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86236. */
  86237. updateSpeed: number;
  86238. /**
  86239. * The amount of time the particle system is running (depends of the overall update speed).
  86240. */
  86241. targetStopDuration: number;
  86242. /**
  86243. * The texture used to render each particle. (this can be a spritesheet)
  86244. */
  86245. particleTexture: Nullable<Texture>;
  86246. /**
  86247. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86248. */
  86249. blendMode: number;
  86250. /**
  86251. * Minimum life time of emitting particles.
  86252. */
  86253. minLifeTime: number;
  86254. /**
  86255. * Maximum life time of emitting particles.
  86256. */
  86257. maxLifeTime: number;
  86258. /**
  86259. * Minimum Size of emitting particles.
  86260. */
  86261. minSize: number;
  86262. /**
  86263. * Maximum Size of emitting particles.
  86264. */
  86265. maxSize: number;
  86266. /**
  86267. * Minimum scale of emitting particles on X axis.
  86268. */
  86269. minScaleX: number;
  86270. /**
  86271. * Maximum scale of emitting particles on X axis.
  86272. */
  86273. maxScaleX: number;
  86274. /**
  86275. * Minimum scale of emitting particles on Y axis.
  86276. */
  86277. minScaleY: number;
  86278. /**
  86279. * Maximum scale of emitting particles on Y axis.
  86280. */
  86281. maxScaleY: number;
  86282. /**
  86283. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86284. */
  86285. color1: Color4;
  86286. /**
  86287. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86288. */
  86289. color2: Color4;
  86290. /**
  86291. * Color the particle will have at the end of its lifetime.
  86292. */
  86293. colorDead: Color4;
  86294. /**
  86295. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86296. */
  86297. emitRate: number;
  86298. /**
  86299. * You can use gravity if you want to give an orientation to your particles.
  86300. */
  86301. gravity: Vector3;
  86302. /**
  86303. * Minimum power of emitting particles.
  86304. */
  86305. minEmitPower: number;
  86306. /**
  86307. * Maximum power of emitting particles.
  86308. */
  86309. maxEmitPower: number;
  86310. /**
  86311. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86312. */
  86313. minAngularSpeed: number;
  86314. /**
  86315. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86316. */
  86317. maxAngularSpeed: number;
  86318. /**
  86319. * Gets or sets the minimal initial rotation in radians.
  86320. */
  86321. minInitialRotation: number;
  86322. /**
  86323. * Gets or sets the maximal initial rotation in radians.
  86324. */
  86325. maxInitialRotation: number;
  86326. /**
  86327. * The particle emitter type defines the emitter used by the particle system.
  86328. * It can be for example box, sphere, or cone...
  86329. */
  86330. particleEmitterType: Nullable<IParticleEmitterType>;
  86331. /**
  86332. * Defines the delay in milliseconds before starting the system (0 by default)
  86333. */
  86334. startDelay: number;
  86335. /**
  86336. * 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
  86337. */
  86338. preWarmCycles: number;
  86339. /**
  86340. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86341. */
  86342. preWarmStepOffset: number;
  86343. /**
  86344. * 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)
  86345. */
  86346. spriteCellChangeSpeed: number;
  86347. /**
  86348. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86349. */
  86350. startSpriteCellID: number;
  86351. /**
  86352. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86353. */
  86354. endSpriteCellID: number;
  86355. /**
  86356. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86357. */
  86358. spriteCellWidth: number;
  86359. /**
  86360. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86361. */
  86362. spriteCellHeight: number;
  86363. /**
  86364. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86365. */
  86366. spriteRandomStartCell: boolean;
  86367. /**
  86368. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86369. */
  86370. isAnimationSheetEnabled: boolean;
  86371. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86372. translationPivot: Vector2;
  86373. /**
  86374. * Gets or sets a texture used to add random noise to particle positions
  86375. */
  86376. noiseTexture: Nullable<BaseTexture>;
  86377. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86378. noiseStrength: Vector3;
  86379. /**
  86380. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86381. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86382. */
  86383. billboardMode: number;
  86384. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86385. limitVelocityDamping: number;
  86386. /**
  86387. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86388. */
  86389. beginAnimationOnStart: boolean;
  86390. /**
  86391. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86392. */
  86393. beginAnimationFrom: number;
  86394. /**
  86395. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86396. */
  86397. beginAnimationTo: number;
  86398. /**
  86399. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86400. */
  86401. beginAnimationLoop: boolean;
  86402. /**
  86403. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86404. */
  86405. disposeOnStop: boolean;
  86406. /**
  86407. * Gets the maximum number of particles active at the same time.
  86408. * @returns The max number of active particles.
  86409. */
  86410. getCapacity(): number;
  86411. /**
  86412. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86413. * @returns True if it has been started, otherwise false.
  86414. */
  86415. isStarted(): boolean;
  86416. /**
  86417. * Animates the particle system for this frame.
  86418. */
  86419. animate(): void;
  86420. /**
  86421. * Renders the particle system in its current state.
  86422. * @returns the current number of particles
  86423. */
  86424. render(): number;
  86425. /**
  86426. * Dispose the particle system and frees its associated resources.
  86427. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86428. */
  86429. dispose(disposeTexture?: boolean): void;
  86430. /**
  86431. * Clones the particle system.
  86432. * @param name The name of the cloned object
  86433. * @param newEmitter The new emitter to use
  86434. * @returns the cloned particle system
  86435. */
  86436. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86437. /**
  86438. * Serializes the particle system to a JSON object.
  86439. * @returns the JSON object
  86440. */
  86441. serialize(): any;
  86442. /**
  86443. * Rebuild the particle system
  86444. */
  86445. rebuild(): void;
  86446. /**
  86447. * Starts the particle system and begins to emit
  86448. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86449. */
  86450. start(delay?: number): void;
  86451. /**
  86452. * Stops the particle system.
  86453. */
  86454. stop(): void;
  86455. /**
  86456. * Remove all active particles
  86457. */
  86458. reset(): void;
  86459. /**
  86460. * Is this system ready to be used/rendered
  86461. * @return true if the system is ready
  86462. */
  86463. isReady(): boolean;
  86464. /**
  86465. * Adds a new color gradient
  86466. * @param gradient defines the gradient to use (between 0 and 1)
  86467. * @param color1 defines the color to affect to the specified gradient
  86468. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86469. * @returns the current particle system
  86470. */
  86471. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86472. /**
  86473. * Remove a specific color gradient
  86474. * @param gradient defines the gradient to remove
  86475. * @returns the current particle system
  86476. */
  86477. removeColorGradient(gradient: number): IParticleSystem;
  86478. /**
  86479. * Adds a new size gradient
  86480. * @param gradient defines the gradient to use (between 0 and 1)
  86481. * @param factor defines the size factor to affect to the specified gradient
  86482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86483. * @returns the current particle system
  86484. */
  86485. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86486. /**
  86487. * Remove a specific size gradient
  86488. * @param gradient defines the gradient to remove
  86489. * @returns the current particle system
  86490. */
  86491. removeSizeGradient(gradient: number): IParticleSystem;
  86492. /**
  86493. * Gets the current list of color gradients.
  86494. * You must use addColorGradient and removeColorGradient to udpate this list
  86495. * @returns the list of color gradients
  86496. */
  86497. getColorGradients(): Nullable<Array<ColorGradient>>;
  86498. /**
  86499. * Gets the current list of size gradients.
  86500. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86501. * @returns the list of size gradients
  86502. */
  86503. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86504. /**
  86505. * Gets the current list of angular speed gradients.
  86506. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86507. * @returns the list of angular speed gradients
  86508. */
  86509. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86510. /**
  86511. * Adds a new angular speed gradient
  86512. * @param gradient defines the gradient to use (between 0 and 1)
  86513. * @param factor defines the angular speed to affect to the specified gradient
  86514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86515. * @returns the current particle system
  86516. */
  86517. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86518. /**
  86519. * Remove a specific angular speed gradient
  86520. * @param gradient defines the gradient to remove
  86521. * @returns the current particle system
  86522. */
  86523. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86524. /**
  86525. * Gets the current list of velocity gradients.
  86526. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86527. * @returns the list of velocity gradients
  86528. */
  86529. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86530. /**
  86531. * Adds a new velocity gradient
  86532. * @param gradient defines the gradient to use (between 0 and 1)
  86533. * @param factor defines the velocity to affect to the specified gradient
  86534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86535. * @returns the current particle system
  86536. */
  86537. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86538. /**
  86539. * Remove a specific velocity gradient
  86540. * @param gradient defines the gradient to remove
  86541. * @returns the current particle system
  86542. */
  86543. removeVelocityGradient(gradient: number): IParticleSystem;
  86544. /**
  86545. * Gets the current list of limit velocity gradients.
  86546. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86547. * @returns the list of limit velocity gradients
  86548. */
  86549. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86550. /**
  86551. * Adds a new limit velocity gradient
  86552. * @param gradient defines the gradient to use (between 0 and 1)
  86553. * @param factor defines the limit velocity to affect to the specified gradient
  86554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86555. * @returns the current particle system
  86556. */
  86557. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86558. /**
  86559. * Remove a specific limit velocity gradient
  86560. * @param gradient defines the gradient to remove
  86561. * @returns the current particle system
  86562. */
  86563. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86564. /**
  86565. * Adds a new drag gradient
  86566. * @param gradient defines the gradient to use (between 0 and 1)
  86567. * @param factor defines the drag to affect to the specified gradient
  86568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86569. * @returns the current particle system
  86570. */
  86571. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86572. /**
  86573. * Remove a specific drag gradient
  86574. * @param gradient defines the gradient to remove
  86575. * @returns the current particle system
  86576. */
  86577. removeDragGradient(gradient: number): IParticleSystem;
  86578. /**
  86579. * Gets the current list of drag gradients.
  86580. * You must use addDragGradient and removeDragGradient to udpate this list
  86581. * @returns the list of drag gradients
  86582. */
  86583. getDragGradients(): Nullable<Array<FactorGradient>>;
  86584. /**
  86585. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86586. * @param gradient defines the gradient to use (between 0 and 1)
  86587. * @param factor defines the emit rate to affect to the specified gradient
  86588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86589. * @returns the current particle system
  86590. */
  86591. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86592. /**
  86593. * Remove a specific emit rate gradient
  86594. * @param gradient defines the gradient to remove
  86595. * @returns the current particle system
  86596. */
  86597. removeEmitRateGradient(gradient: number): IParticleSystem;
  86598. /**
  86599. * Gets the current list of emit rate gradients.
  86600. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86601. * @returns the list of emit rate gradients
  86602. */
  86603. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86604. /**
  86605. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86606. * @param gradient defines the gradient to use (between 0 and 1)
  86607. * @param factor defines the start size to affect to the specified gradient
  86608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86609. * @returns the current particle system
  86610. */
  86611. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86612. /**
  86613. * Remove a specific start size gradient
  86614. * @param gradient defines the gradient to remove
  86615. * @returns the current particle system
  86616. */
  86617. removeStartSizeGradient(gradient: number): IParticleSystem;
  86618. /**
  86619. * Gets the current list of start size gradients.
  86620. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86621. * @returns the list of start size gradients
  86622. */
  86623. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86624. /**
  86625. * Adds a new life time gradient
  86626. * @param gradient defines the gradient to use (between 0 and 1)
  86627. * @param factor defines the life time factor to affect to the specified gradient
  86628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86629. * @returns the current particle system
  86630. */
  86631. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86632. /**
  86633. * Remove a specific life time gradient
  86634. * @param gradient defines the gradient to remove
  86635. * @returns the current particle system
  86636. */
  86637. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86638. /**
  86639. * Gets the current list of life time gradients.
  86640. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86641. * @returns the list of life time gradients
  86642. */
  86643. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86644. /**
  86645. * Gets the current list of color gradients.
  86646. * You must use addColorGradient and removeColorGradient to udpate this list
  86647. * @returns the list of color gradients
  86648. */
  86649. getColorGradients(): Nullable<Array<ColorGradient>>;
  86650. /**
  86651. * Adds a new ramp gradient used to remap particle colors
  86652. * @param gradient defines the gradient to use (between 0 and 1)
  86653. * @param color defines the color to affect to the specified gradient
  86654. * @returns the current particle system
  86655. */
  86656. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86657. /**
  86658. * Gets the current list of ramp gradients.
  86659. * You must use addRampGradient and removeRampGradient to udpate this list
  86660. * @returns the list of ramp gradients
  86661. */
  86662. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86663. /** Gets or sets a boolean indicating that ramp gradients must be used
  86664. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86665. */
  86666. useRampGradients: boolean;
  86667. /**
  86668. * Adds a new color remap gradient
  86669. * @param gradient defines the gradient to use (between 0 and 1)
  86670. * @param min defines the color remap minimal range
  86671. * @param max defines the color remap maximal range
  86672. * @returns the current particle system
  86673. */
  86674. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86675. /**
  86676. * Gets the current list of color remap gradients.
  86677. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86678. * @returns the list of color remap gradients
  86679. */
  86680. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86681. /**
  86682. * Adds a new alpha remap gradient
  86683. * @param gradient defines the gradient to use (between 0 and 1)
  86684. * @param min defines the alpha remap minimal range
  86685. * @param max defines the alpha remap maximal range
  86686. * @returns the current particle system
  86687. */
  86688. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86689. /**
  86690. * Gets the current list of alpha remap gradients.
  86691. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86692. * @returns the list of alpha remap gradients
  86693. */
  86694. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86695. /**
  86696. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86699. * @returns the emitter
  86700. */
  86701. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86702. /**
  86703. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86704. * @param radius The radius of the hemisphere to emit from
  86705. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86706. * @returns the emitter
  86707. */
  86708. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86709. /**
  86710. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86711. * @param radius The radius of the sphere to emit from
  86712. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86713. * @returns the emitter
  86714. */
  86715. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86716. /**
  86717. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86718. * @param radius The radius of the sphere to emit from
  86719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86721. * @returns the emitter
  86722. */
  86723. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86724. /**
  86725. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86726. * @param radius The radius of the emission cylinder
  86727. * @param height The height of the emission cylinder
  86728. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86729. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86730. * @returns the emitter
  86731. */
  86732. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86733. /**
  86734. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86735. * @param radius The radius of the cylinder to emit from
  86736. * @param height The height of the emission cylinder
  86737. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86740. * @returns the emitter
  86741. */
  86742. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86743. /**
  86744. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86745. * @param radius The radius of the cone to emit from
  86746. * @param angle The base angle of the cone
  86747. * @returns the emitter
  86748. */
  86749. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86750. /**
  86751. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86752. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86753. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86754. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86755. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86756. * @returns the emitter
  86757. */
  86758. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86759. /**
  86760. * Get hosting scene
  86761. * @returns the scene
  86762. */
  86763. getScene(): Scene;
  86764. }
  86765. }
  86766. declare module BABYLON {
  86767. /**
  86768. * 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.
  86769. * @see https://doc.babylonjs.com/how_to/transformnode
  86770. */
  86771. export class TransformNode extends Node {
  86772. /**
  86773. * Object will not rotate to face the camera
  86774. */
  86775. static BILLBOARDMODE_NONE: number;
  86776. /**
  86777. * Object will rotate to face the camera but only on the x axis
  86778. */
  86779. static BILLBOARDMODE_X: number;
  86780. /**
  86781. * Object will rotate to face the camera but only on the y axis
  86782. */
  86783. static BILLBOARDMODE_Y: number;
  86784. /**
  86785. * Object will rotate to face the camera but only on the z axis
  86786. */
  86787. static BILLBOARDMODE_Z: number;
  86788. /**
  86789. * Object will rotate to face the camera
  86790. */
  86791. static BILLBOARDMODE_ALL: number;
  86792. /**
  86793. * Object will rotate to face the camera's position instead of orientation
  86794. */
  86795. static BILLBOARDMODE_USE_POSITION: number;
  86796. private _forward;
  86797. private _forwardInverted;
  86798. private _up;
  86799. private _right;
  86800. private _rightInverted;
  86801. private _position;
  86802. private _rotation;
  86803. private _rotationQuaternion;
  86804. protected _scaling: Vector3;
  86805. protected _isDirty: boolean;
  86806. private _transformToBoneReferal;
  86807. private _isAbsoluteSynced;
  86808. private _billboardMode;
  86809. /**
  86810. * Gets or sets the billboard mode. Default is 0.
  86811. *
  86812. * | Value | Type | Description |
  86813. * | --- | --- | --- |
  86814. * | 0 | BILLBOARDMODE_NONE | |
  86815. * | 1 | BILLBOARDMODE_X | |
  86816. * | 2 | BILLBOARDMODE_Y | |
  86817. * | 4 | BILLBOARDMODE_Z | |
  86818. * | 7 | BILLBOARDMODE_ALL | |
  86819. *
  86820. */
  86821. get billboardMode(): number;
  86822. set billboardMode(value: number);
  86823. private _preserveParentRotationForBillboard;
  86824. /**
  86825. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86826. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86827. */
  86828. get preserveParentRotationForBillboard(): boolean;
  86829. set preserveParentRotationForBillboard(value: boolean);
  86830. /**
  86831. * 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
  86832. */
  86833. scalingDeterminant: number;
  86834. private _infiniteDistance;
  86835. /**
  86836. * Gets or sets the distance of the object to max, often used by skybox
  86837. */
  86838. get infiniteDistance(): boolean;
  86839. set infiniteDistance(value: boolean);
  86840. /**
  86841. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86842. * By default the system will update normals to compensate
  86843. */
  86844. ignoreNonUniformScaling: boolean;
  86845. /**
  86846. * 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
  86847. */
  86848. reIntegrateRotationIntoRotationQuaternion: boolean;
  86849. /** @hidden */
  86850. _poseMatrix: Nullable<Matrix>;
  86851. /** @hidden */
  86852. _localMatrix: Matrix;
  86853. private _usePivotMatrix;
  86854. private _absolutePosition;
  86855. private _absoluteScaling;
  86856. private _absoluteRotationQuaternion;
  86857. private _pivotMatrix;
  86858. private _pivotMatrixInverse;
  86859. protected _postMultiplyPivotMatrix: boolean;
  86860. protected _isWorldMatrixFrozen: boolean;
  86861. /** @hidden */
  86862. _indexInSceneTransformNodesArray: number;
  86863. /**
  86864. * An event triggered after the world matrix is updated
  86865. */
  86866. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86867. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86868. /**
  86869. * Gets a string identifying the name of the class
  86870. * @returns "TransformNode" string
  86871. */
  86872. getClassName(): string;
  86873. /**
  86874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86875. */
  86876. get position(): Vector3;
  86877. set position(newPosition: Vector3);
  86878. /**
  86879. * 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)).
  86880. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86881. */
  86882. get rotation(): Vector3;
  86883. set rotation(newRotation: Vector3);
  86884. /**
  86885. * 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)).
  86886. */
  86887. get scaling(): Vector3;
  86888. set scaling(newScaling: Vector3);
  86889. /**
  86890. * 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).
  86891. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86892. */
  86893. get rotationQuaternion(): Nullable<Quaternion>;
  86894. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86895. /**
  86896. * The forward direction of that transform in world space.
  86897. */
  86898. get forward(): Vector3;
  86899. /**
  86900. * The up direction of that transform in world space.
  86901. */
  86902. get up(): Vector3;
  86903. /**
  86904. * The right direction of that transform in world space.
  86905. */
  86906. get right(): Vector3;
  86907. /**
  86908. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86909. * @param matrix the matrix to copy the pose from
  86910. * @returns this TransformNode.
  86911. */
  86912. updatePoseMatrix(matrix: Matrix): TransformNode;
  86913. /**
  86914. * Returns the mesh Pose matrix.
  86915. * @returns the pose matrix
  86916. */
  86917. getPoseMatrix(): Matrix;
  86918. /** @hidden */
  86919. _isSynchronized(): boolean;
  86920. /** @hidden */
  86921. _initCache(): void;
  86922. /**
  86923. * Flag the transform node as dirty (Forcing it to update everything)
  86924. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86925. * @returns this transform node
  86926. */
  86927. markAsDirty(property: string): TransformNode;
  86928. /**
  86929. * Returns the current mesh absolute position.
  86930. * Returns a Vector3.
  86931. */
  86932. get absolutePosition(): Vector3;
  86933. /**
  86934. * Returns the current mesh absolute scaling.
  86935. * Returns a Vector3.
  86936. */
  86937. get absoluteScaling(): Vector3;
  86938. /**
  86939. * Returns the current mesh absolute rotation.
  86940. * Returns a Quaternion.
  86941. */
  86942. get absoluteRotationQuaternion(): Quaternion;
  86943. /**
  86944. * Sets a new matrix to apply before all other transformation
  86945. * @param matrix defines the transform matrix
  86946. * @returns the current TransformNode
  86947. */
  86948. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86949. /**
  86950. * Sets a new pivot matrix to the current node
  86951. * @param matrix defines the new pivot matrix to use
  86952. * @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
  86953. * @returns the current TransformNode
  86954. */
  86955. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86956. /**
  86957. * Returns the mesh pivot matrix.
  86958. * Default : Identity.
  86959. * @returns the matrix
  86960. */
  86961. getPivotMatrix(): Matrix;
  86962. /**
  86963. * Instantiate (when possible) or clone that node with its hierarchy
  86964. * @param newParent defines the new parent to use for the instance (or clone)
  86965. * @param options defines options to configure how copy is done
  86966. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86967. * @returns an instance (or a clone) of the current node with its hiearchy
  86968. */
  86969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86970. doNotInstantiate: boolean;
  86971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86972. /**
  86973. * Prevents the World matrix to be computed any longer
  86974. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86975. * @returns the TransformNode.
  86976. */
  86977. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86978. /**
  86979. * Allows back the World matrix computation.
  86980. * @returns the TransformNode.
  86981. */
  86982. unfreezeWorldMatrix(): this;
  86983. /**
  86984. * True if the World matrix has been frozen.
  86985. */
  86986. get isWorldMatrixFrozen(): boolean;
  86987. /**
  86988. * Retuns the mesh absolute position in the World.
  86989. * @returns a Vector3.
  86990. */
  86991. getAbsolutePosition(): Vector3;
  86992. /**
  86993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86994. * @param absolutePosition the absolute position to set
  86995. * @returns the TransformNode.
  86996. */
  86997. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86998. /**
  86999. * Sets the mesh position in its local space.
  87000. * @param vector3 the position to set in localspace
  87001. * @returns the TransformNode.
  87002. */
  87003. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87004. /**
  87005. * Returns the mesh position in the local space from the current World matrix values.
  87006. * @returns a new Vector3.
  87007. */
  87008. getPositionExpressedInLocalSpace(): Vector3;
  87009. /**
  87010. * Translates the mesh along the passed Vector3 in its local space.
  87011. * @param vector3 the distance to translate in localspace
  87012. * @returns the TransformNode.
  87013. */
  87014. locallyTranslate(vector3: Vector3): TransformNode;
  87015. private static _lookAtVectorCache;
  87016. /**
  87017. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87018. * @param targetPoint the position (must be in same space as current mesh) to look at
  87019. * @param yawCor optional yaw (y-axis) correction in radians
  87020. * @param pitchCor optional pitch (x-axis) correction in radians
  87021. * @param rollCor optional roll (z-axis) correction in radians
  87022. * @param space the choosen space of the target
  87023. * @returns the TransformNode.
  87024. */
  87025. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87026. /**
  87027. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87028. * This Vector3 is expressed in the World space.
  87029. * @param localAxis axis to rotate
  87030. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87031. */
  87032. getDirection(localAxis: Vector3): Vector3;
  87033. /**
  87034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87035. * localAxis is expressed in the mesh local space.
  87036. * result is computed in the Wordl space from the mesh World matrix.
  87037. * @param localAxis axis to rotate
  87038. * @param result the resulting transformnode
  87039. * @returns this TransformNode.
  87040. */
  87041. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87042. /**
  87043. * Sets this transform node rotation to the given local axis.
  87044. * @param localAxis the axis in local space
  87045. * @param yawCor optional yaw (y-axis) correction in radians
  87046. * @param pitchCor optional pitch (x-axis) correction in radians
  87047. * @param rollCor optional roll (z-axis) correction in radians
  87048. * @returns this TransformNode
  87049. */
  87050. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87051. /**
  87052. * Sets a new pivot point to the current node
  87053. * @param point defines the new pivot point to use
  87054. * @param space defines if the point is in world or local space (local by default)
  87055. * @returns the current TransformNode
  87056. */
  87057. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87058. /**
  87059. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87060. * @returns the pivot point
  87061. */
  87062. getPivotPoint(): Vector3;
  87063. /**
  87064. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87065. * @param result the vector3 to store the result
  87066. * @returns this TransformNode.
  87067. */
  87068. getPivotPointToRef(result: Vector3): TransformNode;
  87069. /**
  87070. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87071. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87072. */
  87073. getAbsolutePivotPoint(): Vector3;
  87074. /**
  87075. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87076. * @param result vector3 to store the result
  87077. * @returns this TransformNode.
  87078. */
  87079. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87080. /**
  87081. * Defines the passed node as the parent of the current node.
  87082. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87083. * @see https://doc.babylonjs.com/how_to/parenting
  87084. * @param node the node ot set as the parent
  87085. * @returns this TransformNode.
  87086. */
  87087. setParent(node: Nullable<Node>): TransformNode;
  87088. private _nonUniformScaling;
  87089. /**
  87090. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87091. */
  87092. get nonUniformScaling(): boolean;
  87093. /** @hidden */
  87094. _updateNonUniformScalingState(value: boolean): boolean;
  87095. /**
  87096. * Attach the current TransformNode to another TransformNode associated with a bone
  87097. * @param bone Bone affecting the TransformNode
  87098. * @param affectedTransformNode TransformNode associated with the bone
  87099. * @returns this object
  87100. */
  87101. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87102. /**
  87103. * Detach the transform node if its associated with a bone
  87104. * @returns this object
  87105. */
  87106. detachFromBone(): TransformNode;
  87107. private static _rotationAxisCache;
  87108. /**
  87109. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87110. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87112. * The passed axis is also normalized.
  87113. * @param axis the axis to rotate around
  87114. * @param amount the amount to rotate in radians
  87115. * @param space Space to rotate in (Default: local)
  87116. * @returns the TransformNode.
  87117. */
  87118. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87119. /**
  87120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87121. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87122. * The passed axis is also normalized. .
  87123. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87124. * @param point the point to rotate around
  87125. * @param axis the axis to rotate around
  87126. * @param amount the amount to rotate in radians
  87127. * @returns the TransformNode
  87128. */
  87129. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87130. /**
  87131. * Translates the mesh along the axis vector for the passed distance in the given space.
  87132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87133. * @param axis the axis to translate in
  87134. * @param distance the distance to translate
  87135. * @param space Space to rotate in (Default: local)
  87136. * @returns the TransformNode.
  87137. */
  87138. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87139. /**
  87140. * Adds a rotation step to the mesh current rotation.
  87141. * x, y, z are Euler angles expressed in radians.
  87142. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87143. * This means this rotation is made in the mesh local space only.
  87144. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87145. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87146. * ```javascript
  87147. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87148. * ```
  87149. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87150. * 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.
  87151. * @param x Rotation to add
  87152. * @param y Rotation to add
  87153. * @param z Rotation to add
  87154. * @returns the TransformNode.
  87155. */
  87156. addRotation(x: number, y: number, z: number): TransformNode;
  87157. /**
  87158. * @hidden
  87159. */
  87160. protected _getEffectiveParent(): Nullable<Node>;
  87161. /**
  87162. * Computes the world matrix of the node
  87163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87164. * @returns the world matrix
  87165. */
  87166. computeWorldMatrix(force?: boolean): Matrix;
  87167. /**
  87168. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87169. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87170. */
  87171. resetLocalMatrix(independentOfChildren?: boolean): void;
  87172. protected _afterComputeWorldMatrix(): void;
  87173. /**
  87174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87175. * @param func callback function to add
  87176. *
  87177. * @returns the TransformNode.
  87178. */
  87179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87180. /**
  87181. * Removes a registered callback function.
  87182. * @param func callback function to remove
  87183. * @returns the TransformNode.
  87184. */
  87185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87186. /**
  87187. * Gets the position of the current mesh in camera space
  87188. * @param camera defines the camera to use
  87189. * @returns a position
  87190. */
  87191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87192. /**
  87193. * Returns the distance from the mesh to the active camera
  87194. * @param camera defines the camera to use
  87195. * @returns the distance
  87196. */
  87197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87198. /**
  87199. * Clone the current transform node
  87200. * @param name Name of the new clone
  87201. * @param newParent New parent for the clone
  87202. * @param doNotCloneChildren Do not clone children hierarchy
  87203. * @returns the new transform node
  87204. */
  87205. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87206. /**
  87207. * Serializes the objects information.
  87208. * @param currentSerializationObject defines the object to serialize in
  87209. * @returns the serialized object
  87210. */
  87211. serialize(currentSerializationObject?: any): any;
  87212. /**
  87213. * Returns a new TransformNode object parsed from the source provided.
  87214. * @param parsedTransformNode is the source.
  87215. * @param scene the scne the object belongs to
  87216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87217. * @returns a new TransformNode object parsed from the source provided.
  87218. */
  87219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87220. /**
  87221. * Get all child-transformNodes of this node
  87222. * @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
  87223. * @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
  87224. * @returns an array of TransformNode
  87225. */
  87226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87227. /**
  87228. * Releases resources associated with this transform node.
  87229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87231. */
  87232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87233. /**
  87234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87238. * @returns the current mesh
  87239. */
  87240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87241. private _syncAbsoluteScalingAndRotation;
  87242. }
  87243. }
  87244. declare module BABYLON {
  87245. /**
  87246. * Class used to override all child animations of a given target
  87247. */
  87248. export class AnimationPropertiesOverride {
  87249. /**
  87250. * Gets or sets a value indicating if animation blending must be used
  87251. */
  87252. enableBlending: boolean;
  87253. /**
  87254. * Gets or sets the blending speed to use when enableBlending is true
  87255. */
  87256. blendingSpeed: number;
  87257. /**
  87258. * Gets or sets the default loop mode to use
  87259. */
  87260. loopMode: number;
  87261. }
  87262. }
  87263. declare module BABYLON {
  87264. /**
  87265. * Class used to store bone information
  87266. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87267. */
  87268. export class Bone extends Node {
  87269. /**
  87270. * defines the bone name
  87271. */
  87272. name: string;
  87273. private static _tmpVecs;
  87274. private static _tmpQuat;
  87275. private static _tmpMats;
  87276. /**
  87277. * Gets the list of child bones
  87278. */
  87279. children: Bone[];
  87280. /** Gets the animations associated with this bone */
  87281. animations: Animation[];
  87282. /**
  87283. * Gets or sets bone length
  87284. */
  87285. length: number;
  87286. /**
  87287. * @hidden Internal only
  87288. * Set this value to map this bone to a different index in the transform matrices
  87289. * Set this value to -1 to exclude the bone from the transform matrices
  87290. */
  87291. _index: Nullable<number>;
  87292. private _skeleton;
  87293. private _localMatrix;
  87294. private _restPose;
  87295. private _baseMatrix;
  87296. private _absoluteTransform;
  87297. private _invertedAbsoluteTransform;
  87298. private _parent;
  87299. private _scalingDeterminant;
  87300. private _worldTransform;
  87301. private _localScaling;
  87302. private _localRotation;
  87303. private _localPosition;
  87304. private _needToDecompose;
  87305. private _needToCompose;
  87306. /** @hidden */
  87307. _linkedTransformNode: Nullable<TransformNode>;
  87308. /** @hidden */
  87309. _waitingTransformNodeId: Nullable<string>;
  87310. /** @hidden */
  87311. get _matrix(): Matrix;
  87312. /** @hidden */
  87313. set _matrix(value: Matrix);
  87314. /**
  87315. * Create a new bone
  87316. * @param name defines the bone name
  87317. * @param skeleton defines the parent skeleton
  87318. * @param parentBone defines the parent (can be null if the bone is the root)
  87319. * @param localMatrix defines the local matrix
  87320. * @param restPose defines the rest pose matrix
  87321. * @param baseMatrix defines the base matrix
  87322. * @param index defines index of the bone in the hiearchy
  87323. */
  87324. constructor(
  87325. /**
  87326. * defines the bone name
  87327. */
  87328. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87329. /**
  87330. * Gets the current object class name.
  87331. * @return the class name
  87332. */
  87333. getClassName(): string;
  87334. /**
  87335. * Gets the parent skeleton
  87336. * @returns a skeleton
  87337. */
  87338. getSkeleton(): Skeleton;
  87339. /**
  87340. * Gets parent bone
  87341. * @returns a bone or null if the bone is the root of the bone hierarchy
  87342. */
  87343. getParent(): Nullable<Bone>;
  87344. /**
  87345. * Returns an array containing the root bones
  87346. * @returns an array containing the root bones
  87347. */
  87348. getChildren(): Array<Bone>;
  87349. /**
  87350. * Gets the node index in matrix array generated for rendering
  87351. * @returns the node index
  87352. */
  87353. getIndex(): number;
  87354. /**
  87355. * Sets the parent bone
  87356. * @param parent defines the parent (can be null if the bone is the root)
  87357. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87358. */
  87359. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87360. /**
  87361. * Gets the local matrix
  87362. * @returns a matrix
  87363. */
  87364. getLocalMatrix(): Matrix;
  87365. /**
  87366. * Gets the base matrix (initial matrix which remains unchanged)
  87367. * @returns a matrix
  87368. */
  87369. getBaseMatrix(): Matrix;
  87370. /**
  87371. * Gets the rest pose matrix
  87372. * @returns a matrix
  87373. */
  87374. getRestPose(): Matrix;
  87375. /**
  87376. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87377. */
  87378. getWorldMatrix(): Matrix;
  87379. /**
  87380. * Sets the local matrix to rest pose matrix
  87381. */
  87382. returnToRest(): void;
  87383. /**
  87384. * Gets the inverse of the absolute transform matrix.
  87385. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87386. * @returns a matrix
  87387. */
  87388. getInvertedAbsoluteTransform(): Matrix;
  87389. /**
  87390. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87391. * @returns a matrix
  87392. */
  87393. getAbsoluteTransform(): Matrix;
  87394. /**
  87395. * Links with the given transform node.
  87396. * The local matrix of this bone is copied from the transform node every frame.
  87397. * @param transformNode defines the transform node to link to
  87398. */
  87399. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87400. /**
  87401. * Gets the node used to drive the bone's transformation
  87402. * @returns a transform node or null
  87403. */
  87404. getTransformNode(): Nullable<TransformNode>;
  87405. /** Gets or sets current position (in local space) */
  87406. get position(): Vector3;
  87407. set position(newPosition: Vector3);
  87408. /** Gets or sets current rotation (in local space) */
  87409. get rotation(): Vector3;
  87410. set rotation(newRotation: Vector3);
  87411. /** Gets or sets current rotation quaternion (in local space) */
  87412. get rotationQuaternion(): Quaternion;
  87413. set rotationQuaternion(newRotation: Quaternion);
  87414. /** Gets or sets current scaling (in local space) */
  87415. get scaling(): Vector3;
  87416. set scaling(newScaling: Vector3);
  87417. /**
  87418. * Gets the animation properties override
  87419. */
  87420. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87421. private _decompose;
  87422. private _compose;
  87423. /**
  87424. * Update the base and local matrices
  87425. * @param matrix defines the new base or local matrix
  87426. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87427. * @param updateLocalMatrix defines if the local matrix should be updated
  87428. */
  87429. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87430. /** @hidden */
  87431. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87432. /**
  87433. * Flag the bone as dirty (Forcing it to update everything)
  87434. */
  87435. markAsDirty(): void;
  87436. /** @hidden */
  87437. _markAsDirtyAndCompose(): void;
  87438. private _markAsDirtyAndDecompose;
  87439. /**
  87440. * Translate the bone in local or world space
  87441. * @param vec The amount to translate the bone
  87442. * @param space The space that the translation is in
  87443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87444. */
  87445. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87446. /**
  87447. * Set the postion of the bone in local or world space
  87448. * @param position The position to set the bone
  87449. * @param space The space that the position is in
  87450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87451. */
  87452. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87453. /**
  87454. * Set the absolute position of the bone (world space)
  87455. * @param position The position to set the bone
  87456. * @param mesh The mesh that this bone is attached to
  87457. */
  87458. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87459. /**
  87460. * Scale the bone on the x, y and z axes (in local space)
  87461. * @param x The amount to scale the bone on the x axis
  87462. * @param y The amount to scale the bone on the y axis
  87463. * @param z The amount to scale the bone on the z axis
  87464. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87465. */
  87466. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87467. /**
  87468. * Set the bone scaling in local space
  87469. * @param scale defines the scaling vector
  87470. */
  87471. setScale(scale: Vector3): void;
  87472. /**
  87473. * Gets the current scaling in local space
  87474. * @returns the current scaling vector
  87475. */
  87476. getScale(): Vector3;
  87477. /**
  87478. * Gets the current scaling in local space and stores it in a target vector
  87479. * @param result defines the target vector
  87480. */
  87481. getScaleToRef(result: Vector3): void;
  87482. /**
  87483. * Set the yaw, pitch, and roll of the bone in local or world space
  87484. * @param yaw The rotation of the bone on the y axis
  87485. * @param pitch The rotation of the bone on the x axis
  87486. * @param roll The rotation of the bone on the z axis
  87487. * @param space The space that the axes of rotation are in
  87488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87489. */
  87490. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87491. /**
  87492. * Add a rotation to the bone on an axis in local or world space
  87493. * @param axis The axis to rotate the bone on
  87494. * @param amount The amount to rotate the bone
  87495. * @param space The space that the axis is in
  87496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87497. */
  87498. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87499. /**
  87500. * Set the rotation of the bone to a particular axis angle in local or world space
  87501. * @param axis The axis to rotate the bone on
  87502. * @param angle The angle that the bone should be rotated to
  87503. * @param space The space that the axis is in
  87504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87505. */
  87506. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87507. /**
  87508. * Set the euler rotation of the bone in local of world space
  87509. * @param rotation The euler rotation that the bone should be set to
  87510. * @param space The space that the rotation is in
  87511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87512. */
  87513. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87514. /**
  87515. * Set the quaternion rotation of the bone in local of world space
  87516. * @param quat The quaternion rotation that the bone should be set to
  87517. * @param space The space that the rotation is in
  87518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87519. */
  87520. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87521. /**
  87522. * Set the rotation matrix of the bone in local of world space
  87523. * @param rotMat The rotation matrix that the bone should be set to
  87524. * @param space The space that the rotation is in
  87525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87526. */
  87527. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87528. private _rotateWithMatrix;
  87529. private _getNegativeRotationToRef;
  87530. /**
  87531. * Get the position of the bone in local or world space
  87532. * @param space The space that the returned position is in
  87533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87534. * @returns The position of the bone
  87535. */
  87536. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87537. /**
  87538. * Copy the position of the bone to a vector3 in local or world space
  87539. * @param space The space that the returned position is in
  87540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87541. * @param result The vector3 to copy the position to
  87542. */
  87543. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87544. /**
  87545. * Get the absolute position of the bone (world space)
  87546. * @param mesh The mesh that this bone is attached to
  87547. * @returns The absolute position of the bone
  87548. */
  87549. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87550. /**
  87551. * Copy the absolute position of the bone (world space) to the result param
  87552. * @param mesh The mesh that this bone is attached to
  87553. * @param result The vector3 to copy the absolute position to
  87554. */
  87555. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87556. /**
  87557. * Compute the absolute transforms of this bone and its children
  87558. */
  87559. computeAbsoluteTransforms(): void;
  87560. /**
  87561. * Get the world direction from an axis that is in the local space of the bone
  87562. * @param localAxis The local direction that is used to compute the world direction
  87563. * @param mesh The mesh that this bone is attached to
  87564. * @returns The world direction
  87565. */
  87566. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87567. /**
  87568. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87569. * @param localAxis The local direction that is used to compute the world direction
  87570. * @param mesh The mesh that this bone is attached to
  87571. * @param result The vector3 that the world direction will be copied to
  87572. */
  87573. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87574. /**
  87575. * Get the euler rotation of the bone in local or world space
  87576. * @param space The space that the rotation should be in
  87577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87578. * @returns The euler rotation
  87579. */
  87580. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87581. /**
  87582. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87583. * @param space The space that the rotation should be in
  87584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87585. * @param result The vector3 that the rotation should be copied to
  87586. */
  87587. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87588. /**
  87589. * Get the quaternion rotation of the bone in either local or world space
  87590. * @param space The space that the rotation should be in
  87591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87592. * @returns The quaternion rotation
  87593. */
  87594. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87595. /**
  87596. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87597. * @param space The space that the rotation should be in
  87598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87599. * @param result The quaternion that the rotation should be copied to
  87600. */
  87601. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87602. /**
  87603. * Get the rotation matrix of the bone in local or world space
  87604. * @param space The space that the rotation should be in
  87605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87606. * @returns The rotation matrix
  87607. */
  87608. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87609. /**
  87610. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87611. * @param space The space that the rotation should be in
  87612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87613. * @param result The quaternion that the rotation should be copied to
  87614. */
  87615. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87616. /**
  87617. * Get the world position of a point that is in the local space of the bone
  87618. * @param position The local position
  87619. * @param mesh The mesh that this bone is attached to
  87620. * @returns The world position
  87621. */
  87622. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87623. /**
  87624. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87625. * @param position The local position
  87626. * @param mesh The mesh that this bone is attached to
  87627. * @param result The vector3 that the world position should be copied to
  87628. */
  87629. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87630. /**
  87631. * Get the local position of a point that is in world space
  87632. * @param position The world position
  87633. * @param mesh The mesh that this bone is attached to
  87634. * @returns The local position
  87635. */
  87636. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87637. /**
  87638. * Get the local position of a point that is in world space and copy it to the result param
  87639. * @param position The world position
  87640. * @param mesh The mesh that this bone is attached to
  87641. * @param result The vector3 that the local position should be copied to
  87642. */
  87643. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87644. }
  87645. }
  87646. declare module BABYLON {
  87647. /**
  87648. * Defines a runtime animation
  87649. */
  87650. export class RuntimeAnimation {
  87651. private _events;
  87652. /**
  87653. * The current frame of the runtime animation
  87654. */
  87655. private _currentFrame;
  87656. /**
  87657. * The animation used by the runtime animation
  87658. */
  87659. private _animation;
  87660. /**
  87661. * The target of the runtime animation
  87662. */
  87663. private _target;
  87664. /**
  87665. * The initiating animatable
  87666. */
  87667. private _host;
  87668. /**
  87669. * The original value of the runtime animation
  87670. */
  87671. private _originalValue;
  87672. /**
  87673. * The original blend value of the runtime animation
  87674. */
  87675. private _originalBlendValue;
  87676. /**
  87677. * The offsets cache of the runtime animation
  87678. */
  87679. private _offsetsCache;
  87680. /**
  87681. * The high limits cache of the runtime animation
  87682. */
  87683. private _highLimitsCache;
  87684. /**
  87685. * Specifies if the runtime animation has been stopped
  87686. */
  87687. private _stopped;
  87688. /**
  87689. * The blending factor of the runtime animation
  87690. */
  87691. private _blendingFactor;
  87692. /**
  87693. * The BabylonJS scene
  87694. */
  87695. private _scene;
  87696. /**
  87697. * The current value of the runtime animation
  87698. */
  87699. private _currentValue;
  87700. /** @hidden */
  87701. _animationState: _IAnimationState;
  87702. /**
  87703. * The active target of the runtime animation
  87704. */
  87705. private _activeTargets;
  87706. private _currentActiveTarget;
  87707. private _directTarget;
  87708. /**
  87709. * The target path of the runtime animation
  87710. */
  87711. private _targetPath;
  87712. /**
  87713. * The weight of the runtime animation
  87714. */
  87715. private _weight;
  87716. /**
  87717. * The ratio offset of the runtime animation
  87718. */
  87719. private _ratioOffset;
  87720. /**
  87721. * The previous delay of the runtime animation
  87722. */
  87723. private _previousDelay;
  87724. /**
  87725. * The previous ratio of the runtime animation
  87726. */
  87727. private _previousRatio;
  87728. private _enableBlending;
  87729. private _keys;
  87730. private _minFrame;
  87731. private _maxFrame;
  87732. private _minValue;
  87733. private _maxValue;
  87734. private _targetIsArray;
  87735. /**
  87736. * Gets the current frame of the runtime animation
  87737. */
  87738. get currentFrame(): number;
  87739. /**
  87740. * Gets the weight of the runtime animation
  87741. */
  87742. get weight(): number;
  87743. /**
  87744. * Gets the current value of the runtime animation
  87745. */
  87746. get currentValue(): any;
  87747. /**
  87748. * Gets the target path of the runtime animation
  87749. */
  87750. get targetPath(): string;
  87751. /**
  87752. * Gets the actual target of the runtime animation
  87753. */
  87754. get target(): any;
  87755. /** @hidden */
  87756. _onLoop: () => void;
  87757. /**
  87758. * Create a new RuntimeAnimation object
  87759. * @param target defines the target of the animation
  87760. * @param animation defines the source animation object
  87761. * @param scene defines the hosting scene
  87762. * @param host defines the initiating Animatable
  87763. */
  87764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87765. private _preparePath;
  87766. /**
  87767. * Gets the animation from the runtime animation
  87768. */
  87769. get animation(): Animation;
  87770. /**
  87771. * Resets the runtime animation to the beginning
  87772. * @param restoreOriginal defines whether to restore the target property to the original value
  87773. */
  87774. reset(restoreOriginal?: boolean): void;
  87775. /**
  87776. * Specifies if the runtime animation is stopped
  87777. * @returns Boolean specifying if the runtime animation is stopped
  87778. */
  87779. isStopped(): boolean;
  87780. /**
  87781. * Disposes of the runtime animation
  87782. */
  87783. dispose(): void;
  87784. /**
  87785. * Apply the interpolated value to the target
  87786. * @param currentValue defines the value computed by the animation
  87787. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87788. */
  87789. setValue(currentValue: any, weight: number): void;
  87790. private _getOriginalValues;
  87791. private _setValue;
  87792. /**
  87793. * Gets the loop pmode of the runtime animation
  87794. * @returns Loop Mode
  87795. */
  87796. private _getCorrectLoopMode;
  87797. /**
  87798. * Move the current animation to a given frame
  87799. * @param frame defines the frame to move to
  87800. */
  87801. goToFrame(frame: number): void;
  87802. /**
  87803. * @hidden Internal use only
  87804. */
  87805. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87806. /**
  87807. * Execute the current animation
  87808. * @param delay defines the delay to add to the current frame
  87809. * @param from defines the lower bound of the animation range
  87810. * @param to defines the upper bound of the animation range
  87811. * @param loop defines if the current animation must loop
  87812. * @param speedRatio defines the current speed ratio
  87813. * @param weight defines the weight of the animation (default is -1 so no weight)
  87814. * @param onLoop optional callback called when animation loops
  87815. * @returns a boolean indicating if the animation is running
  87816. */
  87817. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87818. }
  87819. }
  87820. declare module BABYLON {
  87821. /**
  87822. * Class used to store an actual running animation
  87823. */
  87824. export class Animatable {
  87825. /** defines the target object */
  87826. target: any;
  87827. /** defines the starting frame number (default is 0) */
  87828. fromFrame: number;
  87829. /** defines the ending frame number (default is 100) */
  87830. toFrame: number;
  87831. /** defines if the animation must loop (default is false) */
  87832. loopAnimation: boolean;
  87833. /** defines a callback to call when animation ends if it is not looping */
  87834. onAnimationEnd?: (() => void) | null | undefined;
  87835. /** defines a callback to call when animation loops */
  87836. onAnimationLoop?: (() => void) | null | undefined;
  87837. private _localDelayOffset;
  87838. private _pausedDelay;
  87839. private _runtimeAnimations;
  87840. private _paused;
  87841. private _scene;
  87842. private _speedRatio;
  87843. private _weight;
  87844. private _syncRoot;
  87845. /**
  87846. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87847. * This will only apply for non looping animation (default is true)
  87848. */
  87849. disposeOnEnd: boolean;
  87850. /**
  87851. * Gets a boolean indicating if the animation has started
  87852. */
  87853. animationStarted: boolean;
  87854. /**
  87855. * Observer raised when the animation ends
  87856. */
  87857. onAnimationEndObservable: Observable<Animatable>;
  87858. /**
  87859. * Observer raised when the animation loops
  87860. */
  87861. onAnimationLoopObservable: Observable<Animatable>;
  87862. /**
  87863. * Gets the root Animatable used to synchronize and normalize animations
  87864. */
  87865. get syncRoot(): Nullable<Animatable>;
  87866. /**
  87867. * Gets the current frame of the first RuntimeAnimation
  87868. * Used to synchronize Animatables
  87869. */
  87870. get masterFrame(): number;
  87871. /**
  87872. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87873. */
  87874. get weight(): number;
  87875. set weight(value: number);
  87876. /**
  87877. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87878. */
  87879. get speedRatio(): number;
  87880. set speedRatio(value: number);
  87881. /**
  87882. * Creates a new Animatable
  87883. * @param scene defines the hosting scene
  87884. * @param target defines the target object
  87885. * @param fromFrame defines the starting frame number (default is 0)
  87886. * @param toFrame defines the ending frame number (default is 100)
  87887. * @param loopAnimation defines if the animation must loop (default is false)
  87888. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87889. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87890. * @param animations defines a group of animation to add to the new Animatable
  87891. * @param onAnimationLoop defines a callback to call when animation loops
  87892. */
  87893. constructor(scene: Scene,
  87894. /** defines the target object */
  87895. target: any,
  87896. /** defines the starting frame number (default is 0) */
  87897. fromFrame?: number,
  87898. /** defines the ending frame number (default is 100) */
  87899. toFrame?: number,
  87900. /** defines if the animation must loop (default is false) */
  87901. loopAnimation?: boolean, speedRatio?: number,
  87902. /** defines a callback to call when animation ends if it is not looping */
  87903. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87904. /** defines a callback to call when animation loops */
  87905. onAnimationLoop?: (() => void) | null | undefined);
  87906. /**
  87907. * Synchronize and normalize current Animatable with a source Animatable
  87908. * This is useful when using animation weights and when animations are not of the same length
  87909. * @param root defines the root Animatable to synchronize with
  87910. * @returns the current Animatable
  87911. */
  87912. syncWith(root: Animatable): Animatable;
  87913. /**
  87914. * Gets the list of runtime animations
  87915. * @returns an array of RuntimeAnimation
  87916. */
  87917. getAnimations(): RuntimeAnimation[];
  87918. /**
  87919. * Adds more animations to the current animatable
  87920. * @param target defines the target of the animations
  87921. * @param animations defines the new animations to add
  87922. */
  87923. appendAnimations(target: any, animations: Animation[]): void;
  87924. /**
  87925. * Gets the source animation for a specific property
  87926. * @param property defines the propertyu to look for
  87927. * @returns null or the source animation for the given property
  87928. */
  87929. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87930. /**
  87931. * Gets the runtime animation for a specific property
  87932. * @param property defines the propertyu to look for
  87933. * @returns null or the runtime animation for the given property
  87934. */
  87935. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87936. /**
  87937. * Resets the animatable to its original state
  87938. */
  87939. reset(): void;
  87940. /**
  87941. * Allows the animatable to blend with current running animations
  87942. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87943. * @param blendingSpeed defines the blending speed to use
  87944. */
  87945. enableBlending(blendingSpeed: number): void;
  87946. /**
  87947. * Disable animation blending
  87948. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87949. */
  87950. disableBlending(): void;
  87951. /**
  87952. * Jump directly to a given frame
  87953. * @param frame defines the frame to jump to
  87954. */
  87955. goToFrame(frame: number): void;
  87956. /**
  87957. * Pause the animation
  87958. */
  87959. pause(): void;
  87960. /**
  87961. * Restart the animation
  87962. */
  87963. restart(): void;
  87964. private _raiseOnAnimationEnd;
  87965. /**
  87966. * Stop and delete the current animation
  87967. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87968. * @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)
  87969. */
  87970. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87971. /**
  87972. * Wait asynchronously for the animation to end
  87973. * @returns a promise which will be fullfilled when the animation ends
  87974. */
  87975. waitAsync(): Promise<Animatable>;
  87976. /** @hidden */
  87977. _animate(delay: number): boolean;
  87978. }
  87979. interface Scene {
  87980. /** @hidden */
  87981. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87982. /** @hidden */
  87983. _processLateAnimationBindingsForMatrices(holder: {
  87984. totalWeight: number;
  87985. animations: RuntimeAnimation[];
  87986. originalValue: Matrix;
  87987. }): any;
  87988. /** @hidden */
  87989. _processLateAnimationBindingsForQuaternions(holder: {
  87990. totalWeight: number;
  87991. animations: RuntimeAnimation[];
  87992. originalValue: Quaternion;
  87993. }, refQuaternion: Quaternion): Quaternion;
  87994. /** @hidden */
  87995. _processLateAnimationBindings(): void;
  87996. /**
  87997. * Will start the animation sequence of a given target
  87998. * @param target defines the target
  87999. * @param from defines from which frame should animation start
  88000. * @param to defines until which frame should animation run.
  88001. * @param weight defines the weight to apply to the animation (1.0 by default)
  88002. * @param loop defines if the animation loops
  88003. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88004. * @param onAnimationEnd defines the function to be executed when the animation ends
  88005. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88006. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88007. * @param onAnimationLoop defines the callback to call when an animation loops
  88008. * @returns the animatable object created for this animation
  88009. */
  88010. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88011. /**
  88012. * Will start the animation sequence of a given target
  88013. * @param target defines the target
  88014. * @param from defines from which frame should animation start
  88015. * @param to defines until which frame should animation run.
  88016. * @param loop defines if the animation loops
  88017. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88018. * @param onAnimationEnd defines the function to be executed when the animation ends
  88019. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88020. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88021. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88022. * @param onAnimationLoop defines the callback to call when an animation loops
  88023. * @returns the animatable object created for this animation
  88024. */
  88025. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88026. /**
  88027. * Will start the animation sequence of a given target and its hierarchy
  88028. * @param target defines the target
  88029. * @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.
  88030. * @param from defines from which frame should animation start
  88031. * @param to defines until which frame should animation run.
  88032. * @param loop defines if the animation loops
  88033. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88034. * @param onAnimationEnd defines the function to be executed when the animation ends
  88035. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88036. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88037. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88038. * @param onAnimationLoop defines the callback to call when an animation loops
  88039. * @returns the list of created animatables
  88040. */
  88041. 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[];
  88042. /**
  88043. * Begin a new animation on a given node
  88044. * @param target defines the target where the animation will take place
  88045. * @param animations defines the list of animations to start
  88046. * @param from defines the initial value
  88047. * @param to defines the final value
  88048. * @param loop defines if you want animation to loop (off by default)
  88049. * @param speedRatio defines the speed ratio to apply to all animations
  88050. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88051. * @param onAnimationLoop defines the callback to call when an animation loops
  88052. * @returns the list of created animatables
  88053. */
  88054. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88055. /**
  88056. * Begin a new animation on a given node and its hierarchy
  88057. * @param target defines the root node where the animation will take place
  88058. * @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.
  88059. * @param animations defines the list of animations to start
  88060. * @param from defines the initial value
  88061. * @param to defines the final value
  88062. * @param loop defines if you want animation to loop (off by default)
  88063. * @param speedRatio defines the speed ratio to apply to all animations
  88064. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88065. * @param onAnimationLoop defines the callback to call when an animation loops
  88066. * @returns the list of animatables created for all nodes
  88067. */
  88068. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88069. /**
  88070. * Gets the animatable associated with a specific target
  88071. * @param target defines the target of the animatable
  88072. * @returns the required animatable if found
  88073. */
  88074. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88075. /**
  88076. * Gets all animatables associated with a given target
  88077. * @param target defines the target to look animatables for
  88078. * @returns an array of Animatables
  88079. */
  88080. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88081. /**
  88082. * Stops and removes all animations that have been applied to the scene
  88083. */
  88084. stopAllAnimations(): void;
  88085. /**
  88086. * Gets the current delta time used by animation engine
  88087. */
  88088. deltaTime: number;
  88089. }
  88090. interface Bone {
  88091. /**
  88092. * Copy an animation range from another bone
  88093. * @param source defines the source bone
  88094. * @param rangeName defines the range name to copy
  88095. * @param frameOffset defines the frame offset
  88096. * @param rescaleAsRequired defines if rescaling must be applied if required
  88097. * @param skelDimensionsRatio defines the scaling ratio
  88098. * @returns true if operation was successful
  88099. */
  88100. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88101. }
  88102. }
  88103. declare module BABYLON {
  88104. /**
  88105. * Class used to handle skinning animations
  88106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88107. */
  88108. export class Skeleton implements IAnimatable {
  88109. /** defines the skeleton name */
  88110. name: string;
  88111. /** defines the skeleton Id */
  88112. id: string;
  88113. /**
  88114. * Defines the list of child bones
  88115. */
  88116. bones: Bone[];
  88117. /**
  88118. * Defines an estimate of the dimension of the skeleton at rest
  88119. */
  88120. dimensionsAtRest: Vector3;
  88121. /**
  88122. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88123. */
  88124. needInitialSkinMatrix: boolean;
  88125. /**
  88126. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88127. */
  88128. overrideMesh: Nullable<AbstractMesh>;
  88129. /**
  88130. * Gets the list of animations attached to this skeleton
  88131. */
  88132. animations: Array<Animation>;
  88133. private _scene;
  88134. private _isDirty;
  88135. private _transformMatrices;
  88136. private _transformMatrixTexture;
  88137. private _meshesWithPoseMatrix;
  88138. private _animatables;
  88139. private _identity;
  88140. private _synchronizedWithMesh;
  88141. private _ranges;
  88142. private _lastAbsoluteTransformsUpdateId;
  88143. private _canUseTextureForBones;
  88144. private _uniqueId;
  88145. /** @hidden */
  88146. _numBonesWithLinkedTransformNode: number;
  88147. /** @hidden */
  88148. _hasWaitingData: Nullable<boolean>;
  88149. /**
  88150. * Specifies if the skeleton should be serialized
  88151. */
  88152. doNotSerialize: boolean;
  88153. private _useTextureToStoreBoneMatrices;
  88154. /**
  88155. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88156. * Please note that this option is not available if the hardware does not support it
  88157. */
  88158. get useTextureToStoreBoneMatrices(): boolean;
  88159. set useTextureToStoreBoneMatrices(value: boolean);
  88160. private _animationPropertiesOverride;
  88161. /**
  88162. * Gets or sets the animation properties override
  88163. */
  88164. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88165. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88166. /**
  88167. * List of inspectable custom properties (used by the Inspector)
  88168. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88169. */
  88170. inspectableCustomProperties: IInspectable[];
  88171. /**
  88172. * An observable triggered before computing the skeleton's matrices
  88173. */
  88174. onBeforeComputeObservable: Observable<Skeleton>;
  88175. /**
  88176. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88177. */
  88178. get isUsingTextureForMatrices(): boolean;
  88179. /**
  88180. * Gets the unique ID of this skeleton
  88181. */
  88182. get uniqueId(): number;
  88183. /**
  88184. * Creates a new skeleton
  88185. * @param name defines the skeleton name
  88186. * @param id defines the skeleton Id
  88187. * @param scene defines the hosting scene
  88188. */
  88189. constructor(
  88190. /** defines the skeleton name */
  88191. name: string,
  88192. /** defines the skeleton Id */
  88193. id: string, scene: Scene);
  88194. /**
  88195. * Gets the current object class name.
  88196. * @return the class name
  88197. */
  88198. getClassName(): string;
  88199. /**
  88200. * Returns an array containing the root bones
  88201. * @returns an array containing the root bones
  88202. */
  88203. getChildren(): Array<Bone>;
  88204. /**
  88205. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88206. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88207. * @returns a Float32Array containing matrices data
  88208. */
  88209. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88210. /**
  88211. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88212. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88213. * @returns a raw texture containing the data
  88214. */
  88215. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88216. /**
  88217. * Gets the current hosting scene
  88218. * @returns a scene object
  88219. */
  88220. getScene(): Scene;
  88221. /**
  88222. * Gets a string representing the current skeleton data
  88223. * @param fullDetails defines a boolean indicating if we want a verbose version
  88224. * @returns a string representing the current skeleton data
  88225. */
  88226. toString(fullDetails?: boolean): string;
  88227. /**
  88228. * Get bone's index searching by name
  88229. * @param name defines bone's name to search for
  88230. * @return the indice of the bone. Returns -1 if not found
  88231. */
  88232. getBoneIndexByName(name: string): number;
  88233. /**
  88234. * Creater a new animation range
  88235. * @param name defines the name of the range
  88236. * @param from defines the start key
  88237. * @param to defines the end key
  88238. */
  88239. createAnimationRange(name: string, from: number, to: number): void;
  88240. /**
  88241. * Delete a specific animation range
  88242. * @param name defines the name of the range
  88243. * @param deleteFrames defines if frames must be removed as well
  88244. */
  88245. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88246. /**
  88247. * Gets a specific animation range
  88248. * @param name defines the name of the range to look for
  88249. * @returns the requested animation range or null if not found
  88250. */
  88251. getAnimationRange(name: string): Nullable<AnimationRange>;
  88252. /**
  88253. * Gets the list of all animation ranges defined on this skeleton
  88254. * @returns an array
  88255. */
  88256. getAnimationRanges(): Nullable<AnimationRange>[];
  88257. /**
  88258. * Copy animation range from a source skeleton.
  88259. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88260. * @param source defines the source skeleton
  88261. * @param name defines the name of the range to copy
  88262. * @param rescaleAsRequired defines if rescaling must be applied if required
  88263. * @returns true if operation was successful
  88264. */
  88265. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88266. /**
  88267. * Forces the skeleton to go to rest pose
  88268. */
  88269. returnToRest(): void;
  88270. private _getHighestAnimationFrame;
  88271. /**
  88272. * Begin a specific animation range
  88273. * @param name defines the name of the range to start
  88274. * @param loop defines if looping must be turned on (false by default)
  88275. * @param speedRatio defines the speed ratio to apply (1 by default)
  88276. * @param onAnimationEnd defines a callback which will be called when animation will end
  88277. * @returns a new animatable
  88278. */
  88279. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88280. /** @hidden */
  88281. _markAsDirty(): void;
  88282. /** @hidden */
  88283. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88284. /** @hidden */
  88285. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88286. private _computeTransformMatrices;
  88287. /**
  88288. * Build all resources required to render a skeleton
  88289. */
  88290. prepare(): void;
  88291. /**
  88292. * Gets the list of animatables currently running for this skeleton
  88293. * @returns an array of animatables
  88294. */
  88295. getAnimatables(): IAnimatable[];
  88296. /**
  88297. * Clone the current skeleton
  88298. * @param name defines the name of the new skeleton
  88299. * @param id defines the id of the new skeleton
  88300. * @returns the new skeleton
  88301. */
  88302. clone(name: string, id?: string): Skeleton;
  88303. /**
  88304. * Enable animation blending for this skeleton
  88305. * @param blendingSpeed defines the blending speed to apply
  88306. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88307. */
  88308. enableBlending(blendingSpeed?: number): void;
  88309. /**
  88310. * Releases all resources associated with the current skeleton
  88311. */
  88312. dispose(): void;
  88313. /**
  88314. * Serialize the skeleton in a JSON object
  88315. * @returns a JSON object
  88316. */
  88317. serialize(): any;
  88318. /**
  88319. * Creates a new skeleton from serialized data
  88320. * @param parsedSkeleton defines the serialized data
  88321. * @param scene defines the hosting scene
  88322. * @returns a new skeleton
  88323. */
  88324. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88325. /**
  88326. * Compute all node absolute transforms
  88327. * @param forceUpdate defines if computation must be done even if cache is up to date
  88328. */
  88329. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88330. /**
  88331. * Gets the root pose matrix
  88332. * @returns a matrix
  88333. */
  88334. getPoseMatrix(): Nullable<Matrix>;
  88335. /**
  88336. * Sorts bones per internal index
  88337. */
  88338. sortBones(): void;
  88339. private _sortBones;
  88340. }
  88341. }
  88342. declare module BABYLON {
  88343. /**
  88344. * Creates an instance based on a source mesh.
  88345. */
  88346. export class InstancedMesh extends AbstractMesh {
  88347. private _sourceMesh;
  88348. private _currentLOD;
  88349. /** @hidden */
  88350. _indexInSourceMeshInstanceArray: number;
  88351. constructor(name: string, source: Mesh);
  88352. /**
  88353. * Returns the string "InstancedMesh".
  88354. */
  88355. getClassName(): string;
  88356. /** Gets the list of lights affecting that mesh */
  88357. get lightSources(): Light[];
  88358. _resyncLightSources(): void;
  88359. _resyncLightSource(light: Light): void;
  88360. _removeLightSource(light: Light, dispose: boolean): void;
  88361. /**
  88362. * If the source mesh receives shadows
  88363. */
  88364. get receiveShadows(): boolean;
  88365. /**
  88366. * The material of the source mesh
  88367. */
  88368. get material(): Nullable<Material>;
  88369. /**
  88370. * Visibility of the source mesh
  88371. */
  88372. get visibility(): number;
  88373. /**
  88374. * Skeleton of the source mesh
  88375. */
  88376. get skeleton(): Nullable<Skeleton>;
  88377. /**
  88378. * Rendering ground id of the source mesh
  88379. */
  88380. get renderingGroupId(): number;
  88381. set renderingGroupId(value: number);
  88382. /**
  88383. * Returns the total number of vertices (integer).
  88384. */
  88385. getTotalVertices(): number;
  88386. /**
  88387. * Returns a positive integer : the total number of indices in this mesh geometry.
  88388. * @returns the numner of indices or zero if the mesh has no geometry.
  88389. */
  88390. getTotalIndices(): number;
  88391. /**
  88392. * The source mesh of the instance
  88393. */
  88394. get sourceMesh(): Mesh;
  88395. /**
  88396. * Is this node ready to be used/rendered
  88397. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88398. * @return {boolean} is it ready
  88399. */
  88400. isReady(completeCheck?: boolean): boolean;
  88401. /**
  88402. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88403. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88404. * @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.
  88405. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88406. */
  88407. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88408. /**
  88409. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88410. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88411. * The `data` are either a numeric array either a Float32Array.
  88412. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88413. * 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).
  88414. * Note that a new underlying VertexBuffer object is created each call.
  88415. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88416. *
  88417. * Possible `kind` values :
  88418. * - VertexBuffer.PositionKind
  88419. * - VertexBuffer.UVKind
  88420. * - VertexBuffer.UV2Kind
  88421. * - VertexBuffer.UV3Kind
  88422. * - VertexBuffer.UV4Kind
  88423. * - VertexBuffer.UV5Kind
  88424. * - VertexBuffer.UV6Kind
  88425. * - VertexBuffer.ColorKind
  88426. * - VertexBuffer.MatricesIndicesKind
  88427. * - VertexBuffer.MatricesIndicesExtraKind
  88428. * - VertexBuffer.MatricesWeightsKind
  88429. * - VertexBuffer.MatricesWeightsExtraKind
  88430. *
  88431. * Returns the Mesh.
  88432. */
  88433. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88434. /**
  88435. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88436. * If the mesh has no geometry, it is simply returned as it is.
  88437. * The `data` are either a numeric array either a Float32Array.
  88438. * No new underlying VertexBuffer object is created.
  88439. * 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.
  88440. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88441. *
  88442. * Possible `kind` values :
  88443. * - VertexBuffer.PositionKind
  88444. * - VertexBuffer.UVKind
  88445. * - VertexBuffer.UV2Kind
  88446. * - VertexBuffer.UV3Kind
  88447. * - VertexBuffer.UV4Kind
  88448. * - VertexBuffer.UV5Kind
  88449. * - VertexBuffer.UV6Kind
  88450. * - VertexBuffer.ColorKind
  88451. * - VertexBuffer.MatricesIndicesKind
  88452. * - VertexBuffer.MatricesIndicesExtraKind
  88453. * - VertexBuffer.MatricesWeightsKind
  88454. * - VertexBuffer.MatricesWeightsExtraKind
  88455. *
  88456. * Returns the Mesh.
  88457. */
  88458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88459. /**
  88460. * Sets the mesh indices.
  88461. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88462. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88463. * This method creates a new index buffer each call.
  88464. * Returns the Mesh.
  88465. */
  88466. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88467. /**
  88468. * Boolean : True if the mesh owns the requested kind of data.
  88469. */
  88470. isVerticesDataPresent(kind: string): boolean;
  88471. /**
  88472. * Returns an array of indices (IndicesArray).
  88473. */
  88474. getIndices(): Nullable<IndicesArray>;
  88475. get _positions(): Nullable<Vector3[]>;
  88476. /**
  88477. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88478. * This means the mesh underlying bounding box and sphere are recomputed.
  88479. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88480. * @returns the current mesh
  88481. */
  88482. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88483. /** @hidden */
  88484. _preActivate(): InstancedMesh;
  88485. /** @hidden */
  88486. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88487. /** @hidden */
  88488. _postActivate(): void;
  88489. getWorldMatrix(): Matrix;
  88490. get isAnInstance(): boolean;
  88491. /**
  88492. * Returns the current associated LOD AbstractMesh.
  88493. */
  88494. getLOD(camera: Camera): AbstractMesh;
  88495. /** @hidden */
  88496. _syncSubMeshes(): InstancedMesh;
  88497. /** @hidden */
  88498. _generatePointsArray(): boolean;
  88499. /**
  88500. * Creates a new InstancedMesh from the current mesh.
  88501. * - name (string) : the cloned mesh name
  88502. * - newParent (optional Node) : the optional Node to parent the clone to.
  88503. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88504. *
  88505. * Returns the clone.
  88506. */
  88507. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88508. /**
  88509. * Disposes the InstancedMesh.
  88510. * Returns nothing.
  88511. */
  88512. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88513. }
  88514. interface Mesh {
  88515. /**
  88516. * Register a custom buffer that will be instanced
  88517. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88518. * @param kind defines the buffer kind
  88519. * @param stride defines the stride in floats
  88520. */
  88521. registerInstancedBuffer(kind: string, stride: number): void;
  88522. /** @hidden */
  88523. _userInstancedBuffersStorage: {
  88524. data: {
  88525. [key: string]: Float32Array;
  88526. };
  88527. sizes: {
  88528. [key: string]: number;
  88529. };
  88530. vertexBuffers: {
  88531. [key: string]: Nullable<VertexBuffer>;
  88532. };
  88533. strides: {
  88534. [key: string]: number;
  88535. };
  88536. };
  88537. }
  88538. interface AbstractMesh {
  88539. /**
  88540. * Object used to store instanced buffers defined by user
  88541. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88542. */
  88543. instancedBuffers: {
  88544. [key: string]: any;
  88545. };
  88546. }
  88547. }
  88548. declare module BABYLON {
  88549. /**
  88550. * Defines the options associated with the creation of a shader material.
  88551. */
  88552. export interface IShaderMaterialOptions {
  88553. /**
  88554. * Does the material work in alpha blend mode
  88555. */
  88556. needAlphaBlending: boolean;
  88557. /**
  88558. * Does the material work in alpha test mode
  88559. */
  88560. needAlphaTesting: boolean;
  88561. /**
  88562. * The list of attribute names used in the shader
  88563. */
  88564. attributes: string[];
  88565. /**
  88566. * The list of unifrom names used in the shader
  88567. */
  88568. uniforms: string[];
  88569. /**
  88570. * The list of UBO names used in the shader
  88571. */
  88572. uniformBuffers: string[];
  88573. /**
  88574. * The list of sampler names used in the shader
  88575. */
  88576. samplers: string[];
  88577. /**
  88578. * The list of defines used in the shader
  88579. */
  88580. defines: string[];
  88581. }
  88582. /**
  88583. * 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.
  88584. *
  88585. * This returned material effects how the mesh will look based on the code in the shaders.
  88586. *
  88587. * @see http://doc.babylonjs.com/how_to/shader_material
  88588. */
  88589. export class ShaderMaterial extends Material {
  88590. private _shaderPath;
  88591. private _options;
  88592. private _textures;
  88593. private _textureArrays;
  88594. private _floats;
  88595. private _ints;
  88596. private _floatsArrays;
  88597. private _colors3;
  88598. private _colors3Arrays;
  88599. private _colors4;
  88600. private _colors4Arrays;
  88601. private _vectors2;
  88602. private _vectors3;
  88603. private _vectors4;
  88604. private _matrices;
  88605. private _matrixArrays;
  88606. private _matrices3x3;
  88607. private _matrices2x2;
  88608. private _vectors2Arrays;
  88609. private _vectors3Arrays;
  88610. private _vectors4Arrays;
  88611. private _cachedWorldViewMatrix;
  88612. private _cachedWorldViewProjectionMatrix;
  88613. private _renderId;
  88614. private _multiview;
  88615. /**
  88616. * Instantiate a new shader material.
  88617. * 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.
  88618. * This returned material effects how the mesh will look based on the code in the shaders.
  88619. * @see http://doc.babylonjs.com/how_to/shader_material
  88620. * @param name Define the name of the material in the scene
  88621. * @param scene Define the scene the material belongs to
  88622. * @param shaderPath Defines the route to the shader code in one of three ways:
  88623. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88624. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88625. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88626. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88627. * @param options Define the options used to create the shader
  88628. */
  88629. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88630. /**
  88631. * Gets the shader path used to define the shader code
  88632. * It can be modified to trigger a new compilation
  88633. */
  88634. get shaderPath(): any;
  88635. /**
  88636. * Sets the shader path used to define the shader code
  88637. * It can be modified to trigger a new compilation
  88638. */
  88639. set shaderPath(shaderPath: any);
  88640. /**
  88641. * Gets the options used to compile the shader.
  88642. * They can be modified to trigger a new compilation
  88643. */
  88644. get options(): IShaderMaterialOptions;
  88645. /**
  88646. * Gets the current class name of the material e.g. "ShaderMaterial"
  88647. * Mainly use in serialization.
  88648. * @returns the class name
  88649. */
  88650. getClassName(): string;
  88651. /**
  88652. * Specifies if the material will require alpha blending
  88653. * @returns a boolean specifying if alpha blending is needed
  88654. */
  88655. needAlphaBlending(): boolean;
  88656. /**
  88657. * Specifies if this material should be rendered in alpha test mode
  88658. * @returns a boolean specifying if an alpha test is needed.
  88659. */
  88660. needAlphaTesting(): boolean;
  88661. private _checkUniform;
  88662. /**
  88663. * Set a texture in the shader.
  88664. * @param name Define the name of the uniform samplers as defined in the shader
  88665. * @param texture Define the texture to bind to this sampler
  88666. * @return the material itself allowing "fluent" like uniform updates
  88667. */
  88668. setTexture(name: string, texture: Texture): ShaderMaterial;
  88669. /**
  88670. * Set a texture array in the shader.
  88671. * @param name Define the name of the uniform sampler array as defined in the shader
  88672. * @param textures Define the list of textures to bind to this sampler
  88673. * @return the material itself allowing "fluent" like uniform updates
  88674. */
  88675. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88676. /**
  88677. * Set a float in the shader.
  88678. * @param name Define the name of the uniform as defined in the shader
  88679. * @param value Define the value to give to the uniform
  88680. * @return the material itself allowing "fluent" like uniform updates
  88681. */
  88682. setFloat(name: string, value: number): ShaderMaterial;
  88683. /**
  88684. * Set a int in the shader.
  88685. * @param name Define the name of the uniform as defined in the shader
  88686. * @param value Define the value to give to the uniform
  88687. * @return the material itself allowing "fluent" like uniform updates
  88688. */
  88689. setInt(name: string, value: number): ShaderMaterial;
  88690. /**
  88691. * Set an array of floats in the shader.
  88692. * @param name Define the name of the uniform as defined in the shader
  88693. * @param value Define the value to give to the uniform
  88694. * @return the material itself allowing "fluent" like uniform updates
  88695. */
  88696. setFloats(name: string, value: number[]): ShaderMaterial;
  88697. /**
  88698. * Set a vec3 in the shader from a Color3.
  88699. * @param name Define the name of the uniform as defined in the shader
  88700. * @param value Define the value to give to the uniform
  88701. * @return the material itself allowing "fluent" like uniform updates
  88702. */
  88703. setColor3(name: string, value: Color3): ShaderMaterial;
  88704. /**
  88705. * Set a vec3 array in the shader from a Color3 array.
  88706. * @param name Define the name of the uniform as defined in the shader
  88707. * @param value Define the value to give to the uniform
  88708. * @return the material itself allowing "fluent" like uniform updates
  88709. */
  88710. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88711. /**
  88712. * Set a vec4 in the shader from a Color4.
  88713. * @param name Define the name of the uniform as defined in the shader
  88714. * @param value Define the value to give to the uniform
  88715. * @return the material itself allowing "fluent" like uniform updates
  88716. */
  88717. setColor4(name: string, value: Color4): ShaderMaterial;
  88718. /**
  88719. * Set a vec4 array in the shader from a Color4 array.
  88720. * @param name Define the name of the uniform as defined in the shader
  88721. * @param value Define the value to give to the uniform
  88722. * @return the material itself allowing "fluent" like uniform updates
  88723. */
  88724. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88725. /**
  88726. * Set a vec2 in the shader from a Vector2.
  88727. * @param name Define the name of the uniform as defined in the shader
  88728. * @param value Define the value to give to the uniform
  88729. * @return the material itself allowing "fluent" like uniform updates
  88730. */
  88731. setVector2(name: string, value: Vector2): ShaderMaterial;
  88732. /**
  88733. * Set a vec3 in the shader from a Vector3.
  88734. * @param name Define the name of the uniform as defined in the shader
  88735. * @param value Define the value to give to the uniform
  88736. * @return the material itself allowing "fluent" like uniform updates
  88737. */
  88738. setVector3(name: string, value: Vector3): ShaderMaterial;
  88739. /**
  88740. * Set a vec4 in the shader from a Vector4.
  88741. * @param name Define the name of the uniform as defined in the shader
  88742. * @param value Define the value to give to the uniform
  88743. * @return the material itself allowing "fluent" like uniform updates
  88744. */
  88745. setVector4(name: string, value: Vector4): ShaderMaterial;
  88746. /**
  88747. * Set a mat4 in the shader from a Matrix.
  88748. * @param name Define the name of the uniform as defined in the shader
  88749. * @param value Define the value to give to the uniform
  88750. * @return the material itself allowing "fluent" like uniform updates
  88751. */
  88752. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88753. /**
  88754. * Set a float32Array in the shader from a matrix array.
  88755. * @param name Define the name of the uniform as defined in the shader
  88756. * @param value Define the value to give to the uniform
  88757. * @return the material itself allowing "fluent" like uniform updates
  88758. */
  88759. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88760. /**
  88761. * Set a mat3 in the shader from a Float32Array.
  88762. * @param name Define the name of the uniform as defined in the shader
  88763. * @param value Define the value to give to the uniform
  88764. * @return the material itself allowing "fluent" like uniform updates
  88765. */
  88766. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88767. /**
  88768. * Set a mat2 in the shader from a Float32Array.
  88769. * @param name Define the name of the uniform as defined in the shader
  88770. * @param value Define the value to give to the uniform
  88771. * @return the material itself allowing "fluent" like uniform updates
  88772. */
  88773. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88774. /**
  88775. * Set a vec2 array in the shader from a number array.
  88776. * @param name Define the name of the uniform as defined in the shader
  88777. * @param value Define the value to give to the uniform
  88778. * @return the material itself allowing "fluent" like uniform updates
  88779. */
  88780. setArray2(name: string, value: number[]): ShaderMaterial;
  88781. /**
  88782. * Set a vec3 array in the shader from a number array.
  88783. * @param name Define the name of the uniform as defined in the shader
  88784. * @param value Define the value to give to the uniform
  88785. * @return the material itself allowing "fluent" like uniform updates
  88786. */
  88787. setArray3(name: string, value: number[]): ShaderMaterial;
  88788. /**
  88789. * Set a vec4 array in the shader from a number array.
  88790. * @param name Define the name of the uniform as defined in the shader
  88791. * @param value Define the value to give to the uniform
  88792. * @return the material itself allowing "fluent" like uniform updates
  88793. */
  88794. setArray4(name: string, value: number[]): ShaderMaterial;
  88795. private _checkCache;
  88796. /**
  88797. * Specifies that the submesh is ready to be used
  88798. * @param mesh defines the mesh to check
  88799. * @param subMesh defines which submesh to check
  88800. * @param useInstances specifies that instances should be used
  88801. * @returns a boolean indicating that the submesh is ready or not
  88802. */
  88803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88804. /**
  88805. * Checks if the material is ready to render the requested mesh
  88806. * @param mesh Define the mesh to render
  88807. * @param useInstances Define whether or not the material is used with instances
  88808. * @returns true if ready, otherwise false
  88809. */
  88810. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88811. /**
  88812. * Binds the world matrix to the material
  88813. * @param world defines the world transformation matrix
  88814. */
  88815. bindOnlyWorldMatrix(world: Matrix): void;
  88816. /**
  88817. * Binds the material to the mesh
  88818. * @param world defines the world transformation matrix
  88819. * @param mesh defines the mesh to bind the material to
  88820. */
  88821. bind(world: Matrix, mesh?: Mesh): void;
  88822. /**
  88823. * Gets the active textures from the material
  88824. * @returns an array of textures
  88825. */
  88826. getActiveTextures(): BaseTexture[];
  88827. /**
  88828. * Specifies if the material uses a texture
  88829. * @param texture defines the texture to check against the material
  88830. * @returns a boolean specifying if the material uses the texture
  88831. */
  88832. hasTexture(texture: BaseTexture): boolean;
  88833. /**
  88834. * Makes a duplicate of the material, and gives it a new name
  88835. * @param name defines the new name for the duplicated material
  88836. * @returns the cloned material
  88837. */
  88838. clone(name: string): ShaderMaterial;
  88839. /**
  88840. * Disposes the material
  88841. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88842. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88843. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88844. */
  88845. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88846. /**
  88847. * Serializes this material in a JSON representation
  88848. * @returns the serialized material object
  88849. */
  88850. serialize(): any;
  88851. /**
  88852. * Creates a shader material from parsed shader material data
  88853. * @param source defines the JSON represnetation of the material
  88854. * @param scene defines the hosting scene
  88855. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88856. * @returns a new material
  88857. */
  88858. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88859. }
  88860. }
  88861. declare module BABYLON {
  88862. /** @hidden */
  88863. export var colorPixelShader: {
  88864. name: string;
  88865. shader: string;
  88866. };
  88867. }
  88868. declare module BABYLON {
  88869. /** @hidden */
  88870. export var colorVertexShader: {
  88871. name: string;
  88872. shader: string;
  88873. };
  88874. }
  88875. declare module BABYLON {
  88876. /**
  88877. * Line mesh
  88878. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88879. */
  88880. export class LinesMesh extends Mesh {
  88881. /**
  88882. * If vertex color should be applied to the mesh
  88883. */
  88884. readonly useVertexColor?: boolean | undefined;
  88885. /**
  88886. * If vertex alpha should be applied to the mesh
  88887. */
  88888. readonly useVertexAlpha?: boolean | undefined;
  88889. /**
  88890. * Color of the line (Default: White)
  88891. */
  88892. color: Color3;
  88893. /**
  88894. * Alpha of the line (Default: 1)
  88895. */
  88896. alpha: number;
  88897. /**
  88898. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88899. * This margin is expressed in world space coordinates, so its value may vary.
  88900. * Default value is 0.1
  88901. */
  88902. intersectionThreshold: number;
  88903. private _colorShader;
  88904. private color4;
  88905. /**
  88906. * Creates a new LinesMesh
  88907. * @param name defines the name
  88908. * @param scene defines the hosting scene
  88909. * @param parent defines the parent mesh if any
  88910. * @param source defines the optional source LinesMesh used to clone data from
  88911. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88912. * When false, achieved by calling a clone(), also passing False.
  88913. * This will make creation of children, recursive.
  88914. * @param useVertexColor defines if this LinesMesh supports vertex color
  88915. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88916. */
  88917. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88918. /**
  88919. * If vertex color should be applied to the mesh
  88920. */
  88921. useVertexColor?: boolean | undefined,
  88922. /**
  88923. * If vertex alpha should be applied to the mesh
  88924. */
  88925. useVertexAlpha?: boolean | undefined);
  88926. private _addClipPlaneDefine;
  88927. private _removeClipPlaneDefine;
  88928. isReady(): boolean;
  88929. /**
  88930. * Returns the string "LineMesh"
  88931. */
  88932. getClassName(): string;
  88933. /**
  88934. * @hidden
  88935. */
  88936. get material(): Material;
  88937. /**
  88938. * @hidden
  88939. */
  88940. set material(value: Material);
  88941. /**
  88942. * @hidden
  88943. */
  88944. get checkCollisions(): boolean;
  88945. /** @hidden */
  88946. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88947. /** @hidden */
  88948. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88949. /**
  88950. * Disposes of the line mesh
  88951. * @param doNotRecurse If children should be disposed
  88952. */
  88953. dispose(doNotRecurse?: boolean): void;
  88954. /**
  88955. * Returns a new LineMesh object cloned from the current one.
  88956. */
  88957. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88958. /**
  88959. * Creates a new InstancedLinesMesh object from the mesh model.
  88960. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88961. * @param name defines the name of the new instance
  88962. * @returns a new InstancedLinesMesh
  88963. */
  88964. createInstance(name: string): InstancedLinesMesh;
  88965. }
  88966. /**
  88967. * Creates an instance based on a source LinesMesh
  88968. */
  88969. export class InstancedLinesMesh extends InstancedMesh {
  88970. /**
  88971. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88972. * This margin is expressed in world space coordinates, so its value may vary.
  88973. * Initilized with the intersectionThreshold value of the source LinesMesh
  88974. */
  88975. intersectionThreshold: number;
  88976. constructor(name: string, source: LinesMesh);
  88977. /**
  88978. * Returns the string "InstancedLinesMesh".
  88979. */
  88980. getClassName(): string;
  88981. }
  88982. }
  88983. declare module BABYLON {
  88984. /** @hidden */
  88985. export var linePixelShader: {
  88986. name: string;
  88987. shader: string;
  88988. };
  88989. }
  88990. declare module BABYLON {
  88991. /** @hidden */
  88992. export var lineVertexShader: {
  88993. name: string;
  88994. shader: string;
  88995. };
  88996. }
  88997. declare module BABYLON {
  88998. interface AbstractMesh {
  88999. /**
  89000. * Gets the edgesRenderer associated with the mesh
  89001. */
  89002. edgesRenderer: Nullable<EdgesRenderer>;
  89003. }
  89004. interface LinesMesh {
  89005. /**
  89006. * Enables the edge rendering mode on the mesh.
  89007. * This mode makes the mesh edges visible
  89008. * @param epsilon defines the maximal distance between two angles to detect a face
  89009. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89010. * @returns the currentAbstractMesh
  89011. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89012. */
  89013. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89014. }
  89015. interface InstancedLinesMesh {
  89016. /**
  89017. * Enables the edge rendering mode on the mesh.
  89018. * This mode makes the mesh edges visible
  89019. * @param epsilon defines the maximal distance between two angles to detect a face
  89020. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89021. * @returns the current InstancedLinesMesh
  89022. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89023. */
  89024. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89025. }
  89026. /**
  89027. * Defines the minimum contract an Edges renderer should follow.
  89028. */
  89029. export interface IEdgesRenderer extends IDisposable {
  89030. /**
  89031. * Gets or sets a boolean indicating if the edgesRenderer is active
  89032. */
  89033. isEnabled: boolean;
  89034. /**
  89035. * Renders the edges of the attached mesh,
  89036. */
  89037. render(): void;
  89038. /**
  89039. * Checks wether or not the edges renderer is ready to render.
  89040. * @return true if ready, otherwise false.
  89041. */
  89042. isReady(): boolean;
  89043. }
  89044. /**
  89045. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89046. */
  89047. export class EdgesRenderer implements IEdgesRenderer {
  89048. /**
  89049. * Define the size of the edges with an orthographic camera
  89050. */
  89051. edgesWidthScalerForOrthographic: number;
  89052. /**
  89053. * Define the size of the edges with a perspective camera
  89054. */
  89055. edgesWidthScalerForPerspective: number;
  89056. protected _source: AbstractMesh;
  89057. protected _linesPositions: number[];
  89058. protected _linesNormals: number[];
  89059. protected _linesIndices: number[];
  89060. protected _epsilon: number;
  89061. protected _indicesCount: number;
  89062. protected _lineShader: ShaderMaterial;
  89063. protected _ib: DataBuffer;
  89064. protected _buffers: {
  89065. [key: string]: Nullable<VertexBuffer>;
  89066. };
  89067. protected _checkVerticesInsteadOfIndices: boolean;
  89068. private _meshRebuildObserver;
  89069. private _meshDisposeObserver;
  89070. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89071. isEnabled: boolean;
  89072. /**
  89073. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89074. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89075. * @param source Mesh used to create edges
  89076. * @param epsilon sum of angles in adjacency to check for edge
  89077. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89078. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89079. */
  89080. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89081. protected _prepareRessources(): void;
  89082. /** @hidden */
  89083. _rebuild(): void;
  89084. /**
  89085. * Releases the required resources for the edges renderer
  89086. */
  89087. dispose(): void;
  89088. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89089. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89090. /**
  89091. * Checks if the pair of p0 and p1 is en edge
  89092. * @param faceIndex
  89093. * @param edge
  89094. * @param faceNormals
  89095. * @param p0
  89096. * @param p1
  89097. * @private
  89098. */
  89099. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89100. /**
  89101. * push line into the position, normal and index buffer
  89102. * @protected
  89103. */
  89104. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89105. /**
  89106. * Generates lines edges from adjacencjes
  89107. * @private
  89108. */
  89109. _generateEdgesLines(): void;
  89110. /**
  89111. * Checks wether or not the edges renderer is ready to render.
  89112. * @return true if ready, otherwise false.
  89113. */
  89114. isReady(): boolean;
  89115. /**
  89116. * Renders the edges of the attached mesh,
  89117. */
  89118. render(): void;
  89119. }
  89120. /**
  89121. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89122. */
  89123. export class LineEdgesRenderer extends EdgesRenderer {
  89124. /**
  89125. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89126. * @param source LineMesh used to generate edges
  89127. * @param epsilon not important (specified angle for edge detection)
  89128. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89129. */
  89130. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89131. /**
  89132. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89133. */
  89134. _generateEdgesLines(): void;
  89135. }
  89136. }
  89137. declare module BABYLON {
  89138. /**
  89139. * This represents the object necessary to create a rendering group.
  89140. * This is exclusively used and created by the rendering manager.
  89141. * To modify the behavior, you use the available helpers in your scene or meshes.
  89142. * @hidden
  89143. */
  89144. export class RenderingGroup {
  89145. index: number;
  89146. private static _zeroVector;
  89147. private _scene;
  89148. private _opaqueSubMeshes;
  89149. private _transparentSubMeshes;
  89150. private _alphaTestSubMeshes;
  89151. private _depthOnlySubMeshes;
  89152. private _particleSystems;
  89153. private _spriteManagers;
  89154. private _opaqueSortCompareFn;
  89155. private _alphaTestSortCompareFn;
  89156. private _transparentSortCompareFn;
  89157. private _renderOpaque;
  89158. private _renderAlphaTest;
  89159. private _renderTransparent;
  89160. /** @hidden */
  89161. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89162. onBeforeTransparentRendering: () => void;
  89163. /**
  89164. * Set the opaque sort comparison function.
  89165. * If null the sub meshes will be render in the order they were created
  89166. */
  89167. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89168. /**
  89169. * Set the alpha test sort comparison function.
  89170. * If null the sub meshes will be render in the order they were created
  89171. */
  89172. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89173. /**
  89174. * Set the transparent sort comparison function.
  89175. * If null the sub meshes will be render in the order they were created
  89176. */
  89177. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89178. /**
  89179. * Creates a new rendering group.
  89180. * @param index The rendering group index
  89181. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89182. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89183. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89184. */
  89185. 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>);
  89186. /**
  89187. * Render all the sub meshes contained in the group.
  89188. * @param customRenderFunction Used to override the default render behaviour of the group.
  89189. * @returns true if rendered some submeshes.
  89190. */
  89191. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89192. /**
  89193. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89194. * @param subMeshes The submeshes to render
  89195. */
  89196. private renderOpaqueSorted;
  89197. /**
  89198. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89199. * @param subMeshes The submeshes to render
  89200. */
  89201. private renderAlphaTestSorted;
  89202. /**
  89203. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89204. * @param subMeshes The submeshes to render
  89205. */
  89206. private renderTransparentSorted;
  89207. /**
  89208. * Renders the submeshes in a specified order.
  89209. * @param subMeshes The submeshes to sort before render
  89210. * @param sortCompareFn The comparison function use to sort
  89211. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89212. * @param transparent Specifies to activate blending if true
  89213. */
  89214. private static renderSorted;
  89215. /**
  89216. * Renders the submeshes in the order they were dispatched (no sort applied).
  89217. * @param subMeshes The submeshes to render
  89218. */
  89219. private static renderUnsorted;
  89220. /**
  89221. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89222. * are rendered back to front if in the same alpha index.
  89223. *
  89224. * @param a The first submesh
  89225. * @param b The second submesh
  89226. * @returns The result of the comparison
  89227. */
  89228. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89229. /**
  89230. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89231. * are rendered back to front.
  89232. *
  89233. * @param a The first submesh
  89234. * @param b The second submesh
  89235. * @returns The result of the comparison
  89236. */
  89237. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89238. /**
  89239. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89240. * are rendered front to back (prevent overdraw).
  89241. *
  89242. * @param a The first submesh
  89243. * @param b The second submesh
  89244. * @returns The result of the comparison
  89245. */
  89246. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89247. /**
  89248. * Resets the different lists of submeshes to prepare a new frame.
  89249. */
  89250. prepare(): void;
  89251. dispose(): void;
  89252. /**
  89253. * Inserts the submesh in its correct queue depending on its material.
  89254. * @param subMesh The submesh to dispatch
  89255. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89256. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89257. */
  89258. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89259. dispatchSprites(spriteManager: ISpriteManager): void;
  89260. dispatchParticles(particleSystem: IParticleSystem): void;
  89261. private _renderParticles;
  89262. private _renderSprites;
  89263. }
  89264. }
  89265. declare module BABYLON {
  89266. /**
  89267. * Interface describing the different options available in the rendering manager
  89268. * regarding Auto Clear between groups.
  89269. */
  89270. export interface IRenderingManagerAutoClearSetup {
  89271. /**
  89272. * Defines whether or not autoclear is enable.
  89273. */
  89274. autoClear: boolean;
  89275. /**
  89276. * Defines whether or not to autoclear the depth buffer.
  89277. */
  89278. depth: boolean;
  89279. /**
  89280. * Defines whether or not to autoclear the stencil buffer.
  89281. */
  89282. stencil: boolean;
  89283. }
  89284. /**
  89285. * This class is used by the onRenderingGroupObservable
  89286. */
  89287. export class RenderingGroupInfo {
  89288. /**
  89289. * The Scene that being rendered
  89290. */
  89291. scene: Scene;
  89292. /**
  89293. * The camera currently used for the rendering pass
  89294. */
  89295. camera: Nullable<Camera>;
  89296. /**
  89297. * The ID of the renderingGroup being processed
  89298. */
  89299. renderingGroupId: number;
  89300. }
  89301. /**
  89302. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89303. * It is enable to manage the different groups as well as the different necessary sort functions.
  89304. * This should not be used directly aside of the few static configurations
  89305. */
  89306. export class RenderingManager {
  89307. /**
  89308. * The max id used for rendering groups (not included)
  89309. */
  89310. static MAX_RENDERINGGROUPS: number;
  89311. /**
  89312. * The min id used for rendering groups (included)
  89313. */
  89314. static MIN_RENDERINGGROUPS: number;
  89315. /**
  89316. * Used to globally prevent autoclearing scenes.
  89317. */
  89318. static AUTOCLEAR: boolean;
  89319. /**
  89320. * @hidden
  89321. */
  89322. _useSceneAutoClearSetup: boolean;
  89323. private _scene;
  89324. private _renderingGroups;
  89325. private _depthStencilBufferAlreadyCleaned;
  89326. private _autoClearDepthStencil;
  89327. private _customOpaqueSortCompareFn;
  89328. private _customAlphaTestSortCompareFn;
  89329. private _customTransparentSortCompareFn;
  89330. private _renderingGroupInfo;
  89331. /**
  89332. * Instantiates a new rendering group for a particular scene
  89333. * @param scene Defines the scene the groups belongs to
  89334. */
  89335. constructor(scene: Scene);
  89336. private _clearDepthStencilBuffer;
  89337. /**
  89338. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89339. * @hidden
  89340. */
  89341. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89342. /**
  89343. * Resets the different information of the group to prepare a new frame
  89344. * @hidden
  89345. */
  89346. reset(): void;
  89347. /**
  89348. * Dispose and release the group and its associated resources.
  89349. * @hidden
  89350. */
  89351. dispose(): void;
  89352. /**
  89353. * Clear the info related to rendering groups preventing retention points during dispose.
  89354. */
  89355. freeRenderingGroups(): void;
  89356. private _prepareRenderingGroup;
  89357. /**
  89358. * Add a sprite manager to the rendering manager in order to render it this frame.
  89359. * @param spriteManager Define the sprite manager to render
  89360. */
  89361. dispatchSprites(spriteManager: ISpriteManager): void;
  89362. /**
  89363. * Add a particle system to the rendering manager in order to render it this frame.
  89364. * @param particleSystem Define the particle system to render
  89365. */
  89366. dispatchParticles(particleSystem: IParticleSystem): void;
  89367. /**
  89368. * Add a submesh to the manager in order to render it this frame
  89369. * @param subMesh The submesh to dispatch
  89370. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89371. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89372. */
  89373. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89374. /**
  89375. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89376. * This allowed control for front to back rendering or reversly depending of the special needs.
  89377. *
  89378. * @param renderingGroupId The rendering group id corresponding to its index
  89379. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89380. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89381. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89382. */
  89383. 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;
  89384. /**
  89385. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89386. *
  89387. * @param renderingGroupId The rendering group id corresponding to its index
  89388. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89389. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89390. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89391. */
  89392. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89393. /**
  89394. * Gets the current auto clear configuration for one rendering group of the rendering
  89395. * manager.
  89396. * @param index the rendering group index to get the information for
  89397. * @returns The auto clear setup for the requested rendering group
  89398. */
  89399. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89400. }
  89401. }
  89402. declare module BABYLON {
  89403. /**
  89404. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89405. */
  89406. export interface ICustomShaderOptions {
  89407. /**
  89408. * Gets or sets the custom shader name to use
  89409. */
  89410. shaderName: string;
  89411. /**
  89412. * The list of attribute names used in the shader
  89413. */
  89414. attributes?: string[];
  89415. /**
  89416. * The list of unifrom names used in the shader
  89417. */
  89418. uniforms?: string[];
  89419. /**
  89420. * The list of sampler names used in the shader
  89421. */
  89422. samplers?: string[];
  89423. /**
  89424. * The list of defines used in the shader
  89425. */
  89426. defines?: string[];
  89427. }
  89428. /**
  89429. * Interface to implement to create a shadow generator compatible with BJS.
  89430. */
  89431. export interface IShadowGenerator {
  89432. /**
  89433. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89434. * @returns The render target texture if present otherwise, null
  89435. */
  89436. getShadowMap(): Nullable<RenderTargetTexture>;
  89437. /**
  89438. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89439. * @param subMesh The submesh we want to render in the shadow map
  89440. * @param useInstances Defines wether will draw in the map using instances
  89441. * @returns true if ready otherwise, false
  89442. */
  89443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89444. /**
  89445. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89446. * @param defines Defines of the material we want to update
  89447. * @param lightIndex Index of the light in the enabled light list of the material
  89448. */
  89449. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89450. /**
  89451. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89452. * defined in the generator but impacting the effect).
  89453. * It implies the unifroms available on the materials are the standard BJS ones.
  89454. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89455. * @param effect The effect we are binfing the information for
  89456. */
  89457. bindShadowLight(lightIndex: string, effect: Effect): void;
  89458. /**
  89459. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89460. * (eq to shadow prjection matrix * light transform matrix)
  89461. * @returns The transform matrix used to create the shadow map
  89462. */
  89463. getTransformMatrix(): Matrix;
  89464. /**
  89465. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89466. * Cube and 2D textures for instance.
  89467. */
  89468. recreateShadowMap(): void;
  89469. /**
  89470. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89471. * @param onCompiled Callback triggered at the and of the effects compilation
  89472. * @param options Sets of optional options forcing the compilation with different modes
  89473. */
  89474. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89475. useInstances: boolean;
  89476. }>): void;
  89477. /**
  89478. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89479. * @param options Sets of optional options forcing the compilation with different modes
  89480. * @returns A promise that resolves when the compilation completes
  89481. */
  89482. forceCompilationAsync(options?: Partial<{
  89483. useInstances: boolean;
  89484. }>): Promise<void>;
  89485. /**
  89486. * Serializes the shadow generator setup to a json object.
  89487. * @returns The serialized JSON object
  89488. */
  89489. serialize(): any;
  89490. /**
  89491. * Disposes the Shadow map and related Textures and effects.
  89492. */
  89493. dispose(): void;
  89494. }
  89495. /**
  89496. * Default implementation IShadowGenerator.
  89497. * This is the main object responsible of generating shadows in the framework.
  89498. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89499. */
  89500. export class ShadowGenerator implements IShadowGenerator {
  89501. /**
  89502. * Name of the shadow generator class
  89503. */
  89504. static CLASSNAME: string;
  89505. /**
  89506. * Shadow generator mode None: no filtering applied.
  89507. */
  89508. static readonly FILTER_NONE: number;
  89509. /**
  89510. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89512. */
  89513. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89514. /**
  89515. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89516. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89517. */
  89518. static readonly FILTER_POISSONSAMPLING: number;
  89519. /**
  89520. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89522. */
  89523. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89524. /**
  89525. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89526. * edge artifacts on steep falloff.
  89527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89528. */
  89529. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89530. /**
  89531. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89532. * edge artifacts on steep falloff.
  89533. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89534. */
  89535. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89536. /**
  89537. * Shadow generator mode PCF: Percentage Closer Filtering
  89538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89539. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89540. */
  89541. static readonly FILTER_PCF: number;
  89542. /**
  89543. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89544. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89545. * Contact Hardening
  89546. */
  89547. static readonly FILTER_PCSS: number;
  89548. /**
  89549. * Reserved for PCF and PCSS
  89550. * Highest Quality.
  89551. *
  89552. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89553. *
  89554. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89555. */
  89556. static readonly QUALITY_HIGH: number;
  89557. /**
  89558. * Reserved for PCF and PCSS
  89559. * Good tradeoff for quality/perf cross devices
  89560. *
  89561. * Execute PCF on a 3*3 kernel.
  89562. *
  89563. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89564. */
  89565. static readonly QUALITY_MEDIUM: number;
  89566. /**
  89567. * Reserved for PCF and PCSS
  89568. * The lowest quality but the fastest.
  89569. *
  89570. * Execute PCF on a 1*1 kernel.
  89571. *
  89572. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89573. */
  89574. static readonly QUALITY_LOW: number;
  89575. /** Gets or sets the custom shader name to use */
  89576. customShaderOptions: ICustomShaderOptions;
  89577. /**
  89578. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89579. */
  89580. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89581. /**
  89582. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89583. */
  89584. onAfterShadowMapRenderObservable: Observable<Effect>;
  89585. /**
  89586. * Observable triggered before a mesh is rendered in the shadow map.
  89587. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89588. */
  89589. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89590. /**
  89591. * Observable triggered after a mesh is rendered in the shadow map.
  89592. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89593. */
  89594. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89595. protected _bias: number;
  89596. /**
  89597. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89598. */
  89599. get bias(): number;
  89600. /**
  89601. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89602. */
  89603. set bias(bias: number);
  89604. protected _normalBias: number;
  89605. /**
  89606. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89607. */
  89608. get normalBias(): number;
  89609. /**
  89610. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89611. */
  89612. set normalBias(normalBias: number);
  89613. protected _blurBoxOffset: number;
  89614. /**
  89615. * Gets the blur box offset: offset applied during the blur pass.
  89616. * Only useful if useKernelBlur = false
  89617. */
  89618. get blurBoxOffset(): number;
  89619. /**
  89620. * Sets the blur box offset: offset applied during the blur pass.
  89621. * Only useful if useKernelBlur = false
  89622. */
  89623. set blurBoxOffset(value: number);
  89624. protected _blurScale: number;
  89625. /**
  89626. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89627. * 2 means half of the size.
  89628. */
  89629. get blurScale(): number;
  89630. /**
  89631. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89632. * 2 means half of the size.
  89633. */
  89634. set blurScale(value: number);
  89635. protected _blurKernel: number;
  89636. /**
  89637. * Gets the blur kernel: kernel size of the blur pass.
  89638. * Only useful if useKernelBlur = true
  89639. */
  89640. get blurKernel(): number;
  89641. /**
  89642. * Sets the blur kernel: kernel size of the blur pass.
  89643. * Only useful if useKernelBlur = true
  89644. */
  89645. set blurKernel(value: number);
  89646. protected _useKernelBlur: boolean;
  89647. /**
  89648. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89649. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89650. */
  89651. get useKernelBlur(): boolean;
  89652. /**
  89653. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89654. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89655. */
  89656. set useKernelBlur(value: boolean);
  89657. protected _depthScale: number;
  89658. /**
  89659. * Gets the depth scale used in ESM mode.
  89660. */
  89661. get depthScale(): number;
  89662. /**
  89663. * Sets the depth scale used in ESM mode.
  89664. * This can override the scale stored on the light.
  89665. */
  89666. set depthScale(value: number);
  89667. protected _validateFilter(filter: number): number;
  89668. protected _filter: number;
  89669. /**
  89670. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89671. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89672. */
  89673. get filter(): number;
  89674. /**
  89675. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89676. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89677. */
  89678. set filter(value: number);
  89679. /**
  89680. * Gets if the current filter is set to Poisson Sampling.
  89681. */
  89682. get usePoissonSampling(): boolean;
  89683. /**
  89684. * Sets the current filter to Poisson Sampling.
  89685. */
  89686. set usePoissonSampling(value: boolean);
  89687. /**
  89688. * Gets if the current filter is set to ESM.
  89689. */
  89690. get useExponentialShadowMap(): boolean;
  89691. /**
  89692. * Sets the current filter is to ESM.
  89693. */
  89694. set useExponentialShadowMap(value: boolean);
  89695. /**
  89696. * Gets if the current filter is set to filtered ESM.
  89697. */
  89698. get useBlurExponentialShadowMap(): boolean;
  89699. /**
  89700. * Gets if the current filter is set to filtered ESM.
  89701. */
  89702. set useBlurExponentialShadowMap(value: boolean);
  89703. /**
  89704. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89705. * exponential to prevent steep falloff artifacts).
  89706. */
  89707. get useCloseExponentialShadowMap(): boolean;
  89708. /**
  89709. * Sets the current filter to "close ESM" (using the inverse of the
  89710. * exponential to prevent steep falloff artifacts).
  89711. */
  89712. set useCloseExponentialShadowMap(value: boolean);
  89713. /**
  89714. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89715. * exponential to prevent steep falloff artifacts).
  89716. */
  89717. get useBlurCloseExponentialShadowMap(): boolean;
  89718. /**
  89719. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89720. * exponential to prevent steep falloff artifacts).
  89721. */
  89722. set useBlurCloseExponentialShadowMap(value: boolean);
  89723. /**
  89724. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89725. */
  89726. get usePercentageCloserFiltering(): boolean;
  89727. /**
  89728. * Sets the current filter to "PCF" (percentage closer filtering).
  89729. */
  89730. set usePercentageCloserFiltering(value: boolean);
  89731. protected _filteringQuality: number;
  89732. /**
  89733. * Gets the PCF or PCSS Quality.
  89734. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89735. */
  89736. get filteringQuality(): number;
  89737. /**
  89738. * Sets the PCF or PCSS Quality.
  89739. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89740. */
  89741. set filteringQuality(filteringQuality: number);
  89742. /**
  89743. * Gets if the current filter is set to "PCSS" (contact hardening).
  89744. */
  89745. get useContactHardeningShadow(): boolean;
  89746. /**
  89747. * Sets the current filter to "PCSS" (contact hardening).
  89748. */
  89749. set useContactHardeningShadow(value: boolean);
  89750. protected _contactHardeningLightSizeUVRatio: number;
  89751. /**
  89752. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89753. * Using a ratio helps keeping shape stability independently of the map size.
  89754. *
  89755. * It does not account for the light projection as it was having too much
  89756. * instability during the light setup or during light position changes.
  89757. *
  89758. * Only valid if useContactHardeningShadow is true.
  89759. */
  89760. get contactHardeningLightSizeUVRatio(): number;
  89761. /**
  89762. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89763. * Using a ratio helps keeping shape stability independently of the map size.
  89764. *
  89765. * It does not account for the light projection as it was having too much
  89766. * instability during the light setup or during light position changes.
  89767. *
  89768. * Only valid if useContactHardeningShadow is true.
  89769. */
  89770. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89771. protected _darkness: number;
  89772. /** Gets or sets the actual darkness of a shadow */
  89773. get darkness(): number;
  89774. set darkness(value: number);
  89775. /**
  89776. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89777. * 0 means strongest and 1 would means no shadow.
  89778. * @returns the darkness.
  89779. */
  89780. getDarkness(): number;
  89781. /**
  89782. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89783. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89784. * @returns the shadow generator allowing fluent coding.
  89785. */
  89786. setDarkness(darkness: number): ShadowGenerator;
  89787. protected _transparencyShadow: boolean;
  89788. /** Gets or sets the ability to have transparent shadow */
  89789. get transparencyShadow(): boolean;
  89790. set transparencyShadow(value: boolean);
  89791. /**
  89792. * Sets the ability to have transparent shadow (boolean).
  89793. * @param transparent True if transparent else False
  89794. * @returns the shadow generator allowing fluent coding
  89795. */
  89796. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89797. protected _shadowMap: Nullable<RenderTargetTexture>;
  89798. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89799. /**
  89800. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89801. * @returns The render target texture if present otherwise, null
  89802. */
  89803. getShadowMap(): Nullable<RenderTargetTexture>;
  89804. /**
  89805. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89806. * @returns The render target texture if the shadow map is present otherwise, null
  89807. */
  89808. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89809. /**
  89810. * Gets the class name of that object
  89811. * @returns "ShadowGenerator"
  89812. */
  89813. getClassName(): string;
  89814. /**
  89815. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89816. * @param mesh Mesh to add
  89817. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89818. * @returns the Shadow Generator itself
  89819. */
  89820. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89821. /**
  89822. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89823. * @param mesh Mesh to remove
  89824. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89825. * @returns the Shadow Generator itself
  89826. */
  89827. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89828. /**
  89829. * Controls the extent to which the shadows fade out at the edge of the frustum
  89830. */
  89831. frustumEdgeFalloff: number;
  89832. protected _light: IShadowLight;
  89833. /**
  89834. * Returns the associated light object.
  89835. * @returns the light generating the shadow
  89836. */
  89837. getLight(): IShadowLight;
  89838. /**
  89839. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89840. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89841. * It might on the other hand introduce peter panning.
  89842. */
  89843. forceBackFacesOnly: boolean;
  89844. protected _scene: Scene;
  89845. protected _lightDirection: Vector3;
  89846. protected _effect: Effect;
  89847. protected _viewMatrix: Matrix;
  89848. protected _projectionMatrix: Matrix;
  89849. protected _transformMatrix: Matrix;
  89850. protected _cachedPosition: Vector3;
  89851. protected _cachedDirection: Vector3;
  89852. protected _cachedDefines: string;
  89853. protected _currentRenderID: number;
  89854. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89855. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89856. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89857. protected _blurPostProcesses: PostProcess[];
  89858. protected _mapSize: number;
  89859. protected _currentFaceIndex: number;
  89860. protected _currentFaceIndexCache: number;
  89861. protected _textureType: number;
  89862. protected _defaultTextureMatrix: Matrix;
  89863. protected _storedUniqueId: Nullable<number>;
  89864. /** @hidden */
  89865. static _SceneComponentInitialization: (scene: Scene) => void;
  89866. /**
  89867. * Creates a ShadowGenerator object.
  89868. * A ShadowGenerator is the required tool to use the shadows.
  89869. * Each light casting shadows needs to use its own ShadowGenerator.
  89870. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89871. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89872. * @param light The light object generating the shadows.
  89873. * @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.
  89874. */
  89875. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89876. protected _initializeGenerator(): void;
  89877. protected _createTargetRenderTexture(): void;
  89878. protected _initializeShadowMap(): void;
  89879. protected _initializeBlurRTTAndPostProcesses(): void;
  89880. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89881. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89882. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89883. protected _applyFilterValues(): void;
  89884. /**
  89885. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89886. * @param onCompiled Callback triggered at the and of the effects compilation
  89887. * @param options Sets of optional options forcing the compilation with different modes
  89888. */
  89889. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89890. useInstances: boolean;
  89891. }>): void;
  89892. /**
  89893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89894. * @param options Sets of optional options forcing the compilation with different modes
  89895. * @returns A promise that resolves when the compilation completes
  89896. */
  89897. forceCompilationAsync(options?: Partial<{
  89898. useInstances: boolean;
  89899. }>): Promise<void>;
  89900. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89901. /**
  89902. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89903. * @param subMesh The submesh we want to render in the shadow map
  89904. * @param useInstances Defines wether will draw in the map using instances
  89905. * @returns true if ready otherwise, false
  89906. */
  89907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89908. /**
  89909. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89910. * @param defines Defines of the material we want to update
  89911. * @param lightIndex Index of the light in the enabled light list of the material
  89912. */
  89913. prepareDefines(defines: any, lightIndex: number): void;
  89914. /**
  89915. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89916. * defined in the generator but impacting the effect).
  89917. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89918. * @param effect The effect we are binfing the information for
  89919. */
  89920. bindShadowLight(lightIndex: string, effect: Effect): void;
  89921. /**
  89922. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89923. * (eq to shadow prjection matrix * light transform matrix)
  89924. * @returns The transform matrix used to create the shadow map
  89925. */
  89926. getTransformMatrix(): Matrix;
  89927. /**
  89928. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89929. * Cube and 2D textures for instance.
  89930. */
  89931. recreateShadowMap(): void;
  89932. protected _disposeBlurPostProcesses(): void;
  89933. protected _disposeRTTandPostProcesses(): void;
  89934. /**
  89935. * Disposes the ShadowGenerator.
  89936. * Returns nothing.
  89937. */
  89938. dispose(): void;
  89939. /**
  89940. * Serializes the shadow generator setup to a json object.
  89941. * @returns The serialized JSON object
  89942. */
  89943. serialize(): any;
  89944. /**
  89945. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89946. * @param parsedShadowGenerator The JSON object to parse
  89947. * @param scene The scene to create the shadow map for
  89948. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89949. * @returns The parsed shadow generator
  89950. */
  89951. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89952. }
  89953. }
  89954. declare module BABYLON {
  89955. /**
  89956. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89957. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89958. * 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.
  89959. */
  89960. export abstract class Light extends Node {
  89961. /**
  89962. * Falloff Default: light is falling off following the material specification:
  89963. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89964. */
  89965. static readonly FALLOFF_DEFAULT: number;
  89966. /**
  89967. * Falloff Physical: light is falling off following the inverse squared distance law.
  89968. */
  89969. static readonly FALLOFF_PHYSICAL: number;
  89970. /**
  89971. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89972. * to enhance interoperability with other engines.
  89973. */
  89974. static readonly FALLOFF_GLTF: number;
  89975. /**
  89976. * Falloff Standard: light is falling off like in the standard material
  89977. * to enhance interoperability with other materials.
  89978. */
  89979. static readonly FALLOFF_STANDARD: number;
  89980. /**
  89981. * If every light affecting the material is in this lightmapMode,
  89982. * material.lightmapTexture adds or multiplies
  89983. * (depends on material.useLightmapAsShadowmap)
  89984. * after every other light calculations.
  89985. */
  89986. static readonly LIGHTMAP_DEFAULT: number;
  89987. /**
  89988. * material.lightmapTexture as only diffuse lighting from this light
  89989. * adds only specular lighting from this light
  89990. * adds dynamic shadows
  89991. */
  89992. static readonly LIGHTMAP_SPECULAR: number;
  89993. /**
  89994. * material.lightmapTexture as only lighting
  89995. * no light calculation from this light
  89996. * only adds dynamic shadows from this light
  89997. */
  89998. static readonly LIGHTMAP_SHADOWSONLY: number;
  89999. /**
  90000. * Each light type uses the default quantity according to its type:
  90001. * point/spot lights use luminous intensity
  90002. * directional lights use illuminance
  90003. */
  90004. static readonly INTENSITYMODE_AUTOMATIC: number;
  90005. /**
  90006. * lumen (lm)
  90007. */
  90008. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90009. /**
  90010. * candela (lm/sr)
  90011. */
  90012. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90013. /**
  90014. * lux (lm/m^2)
  90015. */
  90016. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90017. /**
  90018. * nit (cd/m^2)
  90019. */
  90020. static readonly INTENSITYMODE_LUMINANCE: number;
  90021. /**
  90022. * Light type const id of the point light.
  90023. */
  90024. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90025. /**
  90026. * Light type const id of the directional light.
  90027. */
  90028. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90029. /**
  90030. * Light type const id of the spot light.
  90031. */
  90032. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90033. /**
  90034. * Light type const id of the hemispheric light.
  90035. */
  90036. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90037. /**
  90038. * Diffuse gives the basic color to an object.
  90039. */
  90040. diffuse: Color3;
  90041. /**
  90042. * Specular produces a highlight color on an object.
  90043. * Note: This is note affecting PBR materials.
  90044. */
  90045. specular: Color3;
  90046. /**
  90047. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90048. * falling off base on range or angle.
  90049. * This can be set to any values in Light.FALLOFF_x.
  90050. *
  90051. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90052. * other types of materials.
  90053. */
  90054. falloffType: number;
  90055. /**
  90056. * Strength of the light.
  90057. * Note: By default it is define in the framework own unit.
  90058. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90059. */
  90060. intensity: number;
  90061. private _range;
  90062. protected _inverseSquaredRange: number;
  90063. /**
  90064. * Defines how far from the source the light is impacting in scene units.
  90065. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90066. */
  90067. get range(): number;
  90068. /**
  90069. * Defines how far from the source the light is impacting in scene units.
  90070. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90071. */
  90072. set range(value: number);
  90073. /**
  90074. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90075. * of light.
  90076. */
  90077. private _photometricScale;
  90078. private _intensityMode;
  90079. /**
  90080. * Gets the photometric scale used to interpret the intensity.
  90081. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90082. */
  90083. get intensityMode(): number;
  90084. /**
  90085. * Sets the photometric scale used to interpret the intensity.
  90086. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90087. */
  90088. set intensityMode(value: number);
  90089. private _radius;
  90090. /**
  90091. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90092. */
  90093. get radius(): number;
  90094. /**
  90095. * sets the light radius used by PBR Materials to simulate soft area lights.
  90096. */
  90097. set radius(value: number);
  90098. private _renderPriority;
  90099. /**
  90100. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90101. * exceeding the number allowed of the materials.
  90102. */
  90103. renderPriority: number;
  90104. private _shadowEnabled;
  90105. /**
  90106. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90107. * the current shadow generator.
  90108. */
  90109. get shadowEnabled(): boolean;
  90110. /**
  90111. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90112. * the current shadow generator.
  90113. */
  90114. set shadowEnabled(value: boolean);
  90115. private _includedOnlyMeshes;
  90116. /**
  90117. * Gets the only meshes impacted by this light.
  90118. */
  90119. get includedOnlyMeshes(): AbstractMesh[];
  90120. /**
  90121. * Sets the only meshes impacted by this light.
  90122. */
  90123. set includedOnlyMeshes(value: AbstractMesh[]);
  90124. private _excludedMeshes;
  90125. /**
  90126. * Gets the meshes not impacted by this light.
  90127. */
  90128. get excludedMeshes(): AbstractMesh[];
  90129. /**
  90130. * Sets the meshes not impacted by this light.
  90131. */
  90132. set excludedMeshes(value: AbstractMesh[]);
  90133. private _excludeWithLayerMask;
  90134. /**
  90135. * Gets the layer id use to find what meshes are not impacted by the light.
  90136. * Inactive if 0
  90137. */
  90138. get excludeWithLayerMask(): number;
  90139. /**
  90140. * Sets the layer id use to find what meshes are not impacted by the light.
  90141. * Inactive if 0
  90142. */
  90143. set excludeWithLayerMask(value: number);
  90144. private _includeOnlyWithLayerMask;
  90145. /**
  90146. * Gets the layer id use to find what meshes are impacted by the light.
  90147. * Inactive if 0
  90148. */
  90149. get includeOnlyWithLayerMask(): number;
  90150. /**
  90151. * Sets the layer id use to find what meshes are impacted by the light.
  90152. * Inactive if 0
  90153. */
  90154. set includeOnlyWithLayerMask(value: number);
  90155. private _lightmapMode;
  90156. /**
  90157. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90158. */
  90159. get lightmapMode(): number;
  90160. /**
  90161. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90162. */
  90163. set lightmapMode(value: number);
  90164. /**
  90165. * Shadow generator associted to the light.
  90166. * @hidden Internal use only.
  90167. */
  90168. _shadowGenerator: Nullable<IShadowGenerator>;
  90169. /**
  90170. * @hidden Internal use only.
  90171. */
  90172. _excludedMeshesIds: string[];
  90173. /**
  90174. * @hidden Internal use only.
  90175. */
  90176. _includedOnlyMeshesIds: string[];
  90177. /**
  90178. * The current light unifom buffer.
  90179. * @hidden Internal use only.
  90180. */
  90181. _uniformBuffer: UniformBuffer;
  90182. /** @hidden */
  90183. _renderId: number;
  90184. /**
  90185. * Creates a Light object in the scene.
  90186. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90187. * @param name The firendly name of the light
  90188. * @param scene The scene the light belongs too
  90189. */
  90190. constructor(name: string, scene: Scene);
  90191. protected abstract _buildUniformLayout(): void;
  90192. /**
  90193. * Sets the passed Effect "effect" with the Light information.
  90194. * @param effect The effect to update
  90195. * @param lightIndex The index of the light in the effect to update
  90196. * @returns The light
  90197. */
  90198. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90199. /**
  90200. * Sets the passed Effect "effect" with the Light textures.
  90201. * @param effect The effect to update
  90202. * @param lightIndex The index of the light in the effect to update
  90203. * @returns The light
  90204. */
  90205. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90206. /**
  90207. * Binds the lights information from the scene to the effect for the given mesh.
  90208. * @param lightIndex Light index
  90209. * @param scene The scene where the light belongs to
  90210. * @param effect The effect we are binding the data to
  90211. * @param useSpecular Defines if specular is supported
  90212. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90213. */
  90214. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90215. /**
  90216. * Sets the passed Effect "effect" with the Light information.
  90217. * @param effect The effect to update
  90218. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90219. * @returns The light
  90220. */
  90221. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90222. /**
  90223. * Returns the string "Light".
  90224. * @returns the class name
  90225. */
  90226. getClassName(): string;
  90227. /** @hidden */
  90228. readonly _isLight: boolean;
  90229. /**
  90230. * Converts the light information to a readable string for debug purpose.
  90231. * @param fullDetails Supports for multiple levels of logging within scene loading
  90232. * @returns the human readable light info
  90233. */
  90234. toString(fullDetails?: boolean): string;
  90235. /** @hidden */
  90236. protected _syncParentEnabledState(): void;
  90237. /**
  90238. * Set the enabled state of this node.
  90239. * @param value - the new enabled state
  90240. */
  90241. setEnabled(value: boolean): void;
  90242. /**
  90243. * Returns the Light associated shadow generator if any.
  90244. * @return the associated shadow generator.
  90245. */
  90246. getShadowGenerator(): Nullable<IShadowGenerator>;
  90247. /**
  90248. * Returns a Vector3, the absolute light position in the World.
  90249. * @returns the world space position of the light
  90250. */
  90251. getAbsolutePosition(): Vector3;
  90252. /**
  90253. * Specifies if the light will affect the passed mesh.
  90254. * @param mesh The mesh to test against the light
  90255. * @return true the mesh is affected otherwise, false.
  90256. */
  90257. canAffectMesh(mesh: AbstractMesh): boolean;
  90258. /**
  90259. * Sort function to order lights for rendering.
  90260. * @param a First Light object to compare to second.
  90261. * @param b Second Light object to compare first.
  90262. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90263. */
  90264. static CompareLightsPriority(a: Light, b: Light): number;
  90265. /**
  90266. * Releases resources associated with this node.
  90267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90269. */
  90270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90271. /**
  90272. * Returns the light type ID (integer).
  90273. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90274. */
  90275. getTypeID(): number;
  90276. /**
  90277. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90278. * @returns the scaled intensity in intensity mode unit
  90279. */
  90280. getScaledIntensity(): number;
  90281. /**
  90282. * Returns a new Light object, named "name", from the current one.
  90283. * @param name The name of the cloned light
  90284. * @returns the new created light
  90285. */
  90286. clone(name: string): Nullable<Light>;
  90287. /**
  90288. * Serializes the current light into a Serialization object.
  90289. * @returns the serialized object.
  90290. */
  90291. serialize(): any;
  90292. /**
  90293. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90294. * This new light is named "name" and added to the passed scene.
  90295. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90296. * @param name The friendly name of the light
  90297. * @param scene The scene the new light will belong to
  90298. * @returns the constructor function
  90299. */
  90300. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90301. /**
  90302. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90303. * @param parsedLight The JSON representation of the light
  90304. * @param scene The scene to create the parsed light in
  90305. * @returns the created light after parsing
  90306. */
  90307. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90308. private _hookArrayForExcluded;
  90309. private _hookArrayForIncludedOnly;
  90310. private _resyncMeshes;
  90311. /**
  90312. * Forces the meshes to update their light related information in their rendering used effects
  90313. * @hidden Internal Use Only
  90314. */
  90315. _markMeshesAsLightDirty(): void;
  90316. /**
  90317. * Recomputes the cached photometric scale if needed.
  90318. */
  90319. private _computePhotometricScale;
  90320. /**
  90321. * Returns the Photometric Scale according to the light type and intensity mode.
  90322. */
  90323. private _getPhotometricScale;
  90324. /**
  90325. * Reorder the light in the scene according to their defined priority.
  90326. * @hidden Internal Use Only
  90327. */
  90328. _reorderLightsInScene(): void;
  90329. /**
  90330. * Prepares the list of defines specific to the light type.
  90331. * @param defines the list of defines
  90332. * @param lightIndex defines the index of the light for the effect
  90333. */
  90334. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90335. }
  90336. }
  90337. declare module BABYLON {
  90338. /**
  90339. * Interface used to define Action
  90340. */
  90341. export interface IAction {
  90342. /**
  90343. * Trigger for the action
  90344. */
  90345. trigger: number;
  90346. /** Options of the trigger */
  90347. triggerOptions: any;
  90348. /**
  90349. * Gets the trigger parameters
  90350. * @returns the trigger parameters
  90351. */
  90352. getTriggerParameter(): any;
  90353. /**
  90354. * Internal only - executes current action event
  90355. * @hidden
  90356. */
  90357. _executeCurrent(evt?: ActionEvent): void;
  90358. /**
  90359. * Serialize placeholder for child classes
  90360. * @param parent of child
  90361. * @returns the serialized object
  90362. */
  90363. serialize(parent: any): any;
  90364. /**
  90365. * Internal only
  90366. * @hidden
  90367. */
  90368. _prepare(): void;
  90369. /**
  90370. * Internal only - manager for action
  90371. * @hidden
  90372. */
  90373. _actionManager: AbstractActionManager;
  90374. /**
  90375. * Adds action to chain of actions, may be a DoNothingAction
  90376. * @param action defines the next action to execute
  90377. * @returns The action passed in
  90378. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90379. */
  90380. then(action: IAction): IAction;
  90381. }
  90382. /**
  90383. * The action to be carried out following a trigger
  90384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90385. */
  90386. export class Action implements IAction {
  90387. /** the trigger, with or without parameters, for the action */
  90388. triggerOptions: any;
  90389. /**
  90390. * Trigger for the action
  90391. */
  90392. trigger: number;
  90393. /**
  90394. * Internal only - manager for action
  90395. * @hidden
  90396. */
  90397. _actionManager: ActionManager;
  90398. private _nextActiveAction;
  90399. private _child;
  90400. private _condition?;
  90401. private _triggerParameter;
  90402. /**
  90403. * An event triggered prior to action being executed.
  90404. */
  90405. onBeforeExecuteObservable: Observable<Action>;
  90406. /**
  90407. * Creates a new Action
  90408. * @param triggerOptions the trigger, with or without parameters, for the action
  90409. * @param condition an optional determinant of action
  90410. */
  90411. constructor(
  90412. /** the trigger, with or without parameters, for the action */
  90413. triggerOptions: any, condition?: Condition);
  90414. /**
  90415. * Internal only
  90416. * @hidden
  90417. */
  90418. _prepare(): void;
  90419. /**
  90420. * Gets the trigger parameters
  90421. * @returns the trigger parameters
  90422. */
  90423. getTriggerParameter(): any;
  90424. /**
  90425. * Internal only - executes current action event
  90426. * @hidden
  90427. */
  90428. _executeCurrent(evt?: ActionEvent): void;
  90429. /**
  90430. * Execute placeholder for child classes
  90431. * @param evt optional action event
  90432. */
  90433. execute(evt?: ActionEvent): void;
  90434. /**
  90435. * Skips to next active action
  90436. */
  90437. skipToNextActiveAction(): void;
  90438. /**
  90439. * Adds action to chain of actions, may be a DoNothingAction
  90440. * @param action defines the next action to execute
  90441. * @returns The action passed in
  90442. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90443. */
  90444. then(action: Action): Action;
  90445. /**
  90446. * Internal only
  90447. * @hidden
  90448. */
  90449. _getProperty(propertyPath: string): string;
  90450. /**
  90451. * Internal only
  90452. * @hidden
  90453. */
  90454. _getEffectiveTarget(target: any, propertyPath: string): any;
  90455. /**
  90456. * Serialize placeholder for child classes
  90457. * @param parent of child
  90458. * @returns the serialized object
  90459. */
  90460. serialize(parent: any): any;
  90461. /**
  90462. * Internal only called by serialize
  90463. * @hidden
  90464. */
  90465. protected _serialize(serializedAction: any, parent?: any): any;
  90466. /**
  90467. * Internal only
  90468. * @hidden
  90469. */
  90470. static _SerializeValueAsString: (value: any) => string;
  90471. /**
  90472. * Internal only
  90473. * @hidden
  90474. */
  90475. static _GetTargetProperty: (target: Node | Scene) => {
  90476. name: string;
  90477. targetType: string;
  90478. value: string;
  90479. };
  90480. }
  90481. }
  90482. declare module BABYLON {
  90483. /**
  90484. * A Condition applied to an Action
  90485. */
  90486. export class Condition {
  90487. /**
  90488. * Internal only - manager for action
  90489. * @hidden
  90490. */
  90491. _actionManager: ActionManager;
  90492. /**
  90493. * Internal only
  90494. * @hidden
  90495. */
  90496. _evaluationId: number;
  90497. /**
  90498. * Internal only
  90499. * @hidden
  90500. */
  90501. _currentResult: boolean;
  90502. /**
  90503. * Creates a new Condition
  90504. * @param actionManager the manager of the action the condition is applied to
  90505. */
  90506. constructor(actionManager: ActionManager);
  90507. /**
  90508. * Check if the current condition is valid
  90509. * @returns a boolean
  90510. */
  90511. isValid(): boolean;
  90512. /**
  90513. * Internal only
  90514. * @hidden
  90515. */
  90516. _getProperty(propertyPath: string): string;
  90517. /**
  90518. * Internal only
  90519. * @hidden
  90520. */
  90521. _getEffectiveTarget(target: any, propertyPath: string): any;
  90522. /**
  90523. * Serialize placeholder for child classes
  90524. * @returns the serialized object
  90525. */
  90526. serialize(): any;
  90527. /**
  90528. * Internal only
  90529. * @hidden
  90530. */
  90531. protected _serialize(serializedCondition: any): any;
  90532. }
  90533. /**
  90534. * Defines specific conditional operators as extensions of Condition
  90535. */
  90536. export class ValueCondition extends Condition {
  90537. /** path to specify the property of the target the conditional operator uses */
  90538. propertyPath: string;
  90539. /** the value compared by the conditional operator against the current value of the property */
  90540. value: any;
  90541. /** the conditional operator, default ValueCondition.IsEqual */
  90542. operator: number;
  90543. /**
  90544. * Internal only
  90545. * @hidden
  90546. */
  90547. private static _IsEqual;
  90548. /**
  90549. * Internal only
  90550. * @hidden
  90551. */
  90552. private static _IsDifferent;
  90553. /**
  90554. * Internal only
  90555. * @hidden
  90556. */
  90557. private static _IsGreater;
  90558. /**
  90559. * Internal only
  90560. * @hidden
  90561. */
  90562. private static _IsLesser;
  90563. /**
  90564. * returns the number for IsEqual
  90565. */
  90566. static get IsEqual(): number;
  90567. /**
  90568. * Returns the number for IsDifferent
  90569. */
  90570. static get IsDifferent(): number;
  90571. /**
  90572. * Returns the number for IsGreater
  90573. */
  90574. static get IsGreater(): number;
  90575. /**
  90576. * Returns the number for IsLesser
  90577. */
  90578. static get IsLesser(): number;
  90579. /**
  90580. * Internal only The action manager for the condition
  90581. * @hidden
  90582. */
  90583. _actionManager: ActionManager;
  90584. /**
  90585. * Internal only
  90586. * @hidden
  90587. */
  90588. private _target;
  90589. /**
  90590. * Internal only
  90591. * @hidden
  90592. */
  90593. private _effectiveTarget;
  90594. /**
  90595. * Internal only
  90596. * @hidden
  90597. */
  90598. private _property;
  90599. /**
  90600. * Creates a new ValueCondition
  90601. * @param actionManager manager for the action the condition applies to
  90602. * @param target for the action
  90603. * @param propertyPath path to specify the property of the target the conditional operator uses
  90604. * @param value the value compared by the conditional operator against the current value of the property
  90605. * @param operator the conditional operator, default ValueCondition.IsEqual
  90606. */
  90607. constructor(actionManager: ActionManager, target: any,
  90608. /** path to specify the property of the target the conditional operator uses */
  90609. propertyPath: string,
  90610. /** the value compared by the conditional operator against the current value of the property */
  90611. value: any,
  90612. /** the conditional operator, default ValueCondition.IsEqual */
  90613. operator?: number);
  90614. /**
  90615. * Compares the given value with the property value for the specified conditional operator
  90616. * @returns the result of the comparison
  90617. */
  90618. isValid(): boolean;
  90619. /**
  90620. * Serialize the ValueCondition into a JSON compatible object
  90621. * @returns serialization object
  90622. */
  90623. serialize(): any;
  90624. /**
  90625. * Gets the name of the conditional operator for the ValueCondition
  90626. * @param operator the conditional operator
  90627. * @returns the name
  90628. */
  90629. static GetOperatorName(operator: number): string;
  90630. }
  90631. /**
  90632. * Defines a predicate condition as an extension of Condition
  90633. */
  90634. export class PredicateCondition extends Condition {
  90635. /** defines the predicate function used to validate the condition */
  90636. predicate: () => boolean;
  90637. /**
  90638. * Internal only - manager for action
  90639. * @hidden
  90640. */
  90641. _actionManager: ActionManager;
  90642. /**
  90643. * Creates a new PredicateCondition
  90644. * @param actionManager manager for the action the condition applies to
  90645. * @param predicate defines the predicate function used to validate the condition
  90646. */
  90647. constructor(actionManager: ActionManager,
  90648. /** defines the predicate function used to validate the condition */
  90649. predicate: () => boolean);
  90650. /**
  90651. * @returns the validity of the predicate condition
  90652. */
  90653. isValid(): boolean;
  90654. }
  90655. /**
  90656. * Defines a state condition as an extension of Condition
  90657. */
  90658. export class StateCondition extends Condition {
  90659. /** Value to compare with target state */
  90660. value: string;
  90661. /**
  90662. * Internal only - manager for action
  90663. * @hidden
  90664. */
  90665. _actionManager: ActionManager;
  90666. /**
  90667. * Internal only
  90668. * @hidden
  90669. */
  90670. private _target;
  90671. /**
  90672. * Creates a new StateCondition
  90673. * @param actionManager manager for the action the condition applies to
  90674. * @param target of the condition
  90675. * @param value to compare with target state
  90676. */
  90677. constructor(actionManager: ActionManager, target: any,
  90678. /** Value to compare with target state */
  90679. value: string);
  90680. /**
  90681. * Gets a boolean indicating if the current condition is met
  90682. * @returns the validity of the state
  90683. */
  90684. isValid(): boolean;
  90685. /**
  90686. * Serialize the StateCondition into a JSON compatible object
  90687. * @returns serialization object
  90688. */
  90689. serialize(): any;
  90690. }
  90691. }
  90692. declare module BABYLON {
  90693. /**
  90694. * This defines an action responsible to toggle a boolean once triggered.
  90695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90696. */
  90697. export class SwitchBooleanAction extends Action {
  90698. /**
  90699. * The path to the boolean property in the target object
  90700. */
  90701. propertyPath: string;
  90702. private _target;
  90703. private _effectiveTarget;
  90704. private _property;
  90705. /**
  90706. * Instantiate the action
  90707. * @param triggerOptions defines the trigger options
  90708. * @param target defines the object containing the boolean
  90709. * @param propertyPath defines the path to the boolean property in the target object
  90710. * @param condition defines the trigger related conditions
  90711. */
  90712. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90713. /** @hidden */
  90714. _prepare(): void;
  90715. /**
  90716. * Execute the action toggle the boolean value.
  90717. */
  90718. execute(): void;
  90719. /**
  90720. * Serializes the actions and its related information.
  90721. * @param parent defines the object to serialize in
  90722. * @returns the serialized object
  90723. */
  90724. serialize(parent: any): any;
  90725. }
  90726. /**
  90727. * This defines an action responsible to set a the state field of the target
  90728. * to a desired value once triggered.
  90729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90730. */
  90731. export class SetStateAction extends Action {
  90732. /**
  90733. * The value to store in the state field.
  90734. */
  90735. value: string;
  90736. private _target;
  90737. /**
  90738. * Instantiate the action
  90739. * @param triggerOptions defines the trigger options
  90740. * @param target defines the object containing the state property
  90741. * @param value defines the value to store in the state field
  90742. * @param condition defines the trigger related conditions
  90743. */
  90744. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90745. /**
  90746. * Execute the action and store the value on the target state property.
  90747. */
  90748. execute(): void;
  90749. /**
  90750. * Serializes the actions and its related information.
  90751. * @param parent defines the object to serialize in
  90752. * @returns the serialized object
  90753. */
  90754. serialize(parent: any): any;
  90755. }
  90756. /**
  90757. * This defines an action responsible to set a property of the target
  90758. * to a desired value once triggered.
  90759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90760. */
  90761. export class SetValueAction extends Action {
  90762. /**
  90763. * The path of the property to set in the target.
  90764. */
  90765. propertyPath: string;
  90766. /**
  90767. * The value to set in the property
  90768. */
  90769. value: any;
  90770. private _target;
  90771. private _effectiveTarget;
  90772. private _property;
  90773. /**
  90774. * Instantiate the action
  90775. * @param triggerOptions defines the trigger options
  90776. * @param target defines the object containing the property
  90777. * @param propertyPath defines the path of the property to set in the target
  90778. * @param value defines the value to set in the property
  90779. * @param condition defines the trigger related conditions
  90780. */
  90781. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90782. /** @hidden */
  90783. _prepare(): void;
  90784. /**
  90785. * Execute the action and set the targetted property to the desired value.
  90786. */
  90787. execute(): void;
  90788. /**
  90789. * Serializes the actions and its related information.
  90790. * @param parent defines the object to serialize in
  90791. * @returns the serialized object
  90792. */
  90793. serialize(parent: any): any;
  90794. }
  90795. /**
  90796. * This defines an action responsible to increment the target value
  90797. * to a desired value once triggered.
  90798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90799. */
  90800. export class IncrementValueAction extends Action {
  90801. /**
  90802. * The path of the property to increment in the target.
  90803. */
  90804. propertyPath: string;
  90805. /**
  90806. * The value we should increment the property by.
  90807. */
  90808. value: any;
  90809. private _target;
  90810. private _effectiveTarget;
  90811. private _property;
  90812. /**
  90813. * Instantiate the action
  90814. * @param triggerOptions defines the trigger options
  90815. * @param target defines the object containing the property
  90816. * @param propertyPath defines the path of the property to increment in the target
  90817. * @param value defines the value value we should increment the property by
  90818. * @param condition defines the trigger related conditions
  90819. */
  90820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90821. /** @hidden */
  90822. _prepare(): void;
  90823. /**
  90824. * Execute the action and increment the target of the value amount.
  90825. */
  90826. execute(): void;
  90827. /**
  90828. * Serializes the actions and its related information.
  90829. * @param parent defines the object to serialize in
  90830. * @returns the serialized object
  90831. */
  90832. serialize(parent: any): any;
  90833. }
  90834. /**
  90835. * This defines an action responsible to start an animation once triggered.
  90836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90837. */
  90838. export class PlayAnimationAction extends Action {
  90839. /**
  90840. * Where the animation should start (animation frame)
  90841. */
  90842. from: number;
  90843. /**
  90844. * Where the animation should stop (animation frame)
  90845. */
  90846. to: number;
  90847. /**
  90848. * Define if the animation should loop or stop after the first play.
  90849. */
  90850. loop?: boolean;
  90851. private _target;
  90852. /**
  90853. * Instantiate the action
  90854. * @param triggerOptions defines the trigger options
  90855. * @param target defines the target animation or animation name
  90856. * @param from defines from where the animation should start (animation frame)
  90857. * @param end defines where the animation should stop (animation frame)
  90858. * @param loop defines if the animation should loop or stop after the first play
  90859. * @param condition defines the trigger related conditions
  90860. */
  90861. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90862. /** @hidden */
  90863. _prepare(): void;
  90864. /**
  90865. * Execute the action and play the animation.
  90866. */
  90867. execute(): void;
  90868. /**
  90869. * Serializes the actions and its related information.
  90870. * @param parent defines the object to serialize in
  90871. * @returns the serialized object
  90872. */
  90873. serialize(parent: any): any;
  90874. }
  90875. /**
  90876. * This defines an action responsible to stop an animation once triggered.
  90877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90878. */
  90879. export class StopAnimationAction extends Action {
  90880. private _target;
  90881. /**
  90882. * Instantiate the action
  90883. * @param triggerOptions defines the trigger options
  90884. * @param target defines the target animation or animation name
  90885. * @param condition defines the trigger related conditions
  90886. */
  90887. constructor(triggerOptions: any, target: any, condition?: Condition);
  90888. /** @hidden */
  90889. _prepare(): void;
  90890. /**
  90891. * Execute the action and stop the animation.
  90892. */
  90893. execute(): void;
  90894. /**
  90895. * Serializes the actions and its related information.
  90896. * @param parent defines the object to serialize in
  90897. * @returns the serialized object
  90898. */
  90899. serialize(parent: any): any;
  90900. }
  90901. /**
  90902. * This defines an action responsible that does nothing once triggered.
  90903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90904. */
  90905. export class DoNothingAction extends Action {
  90906. /**
  90907. * Instantiate the action
  90908. * @param triggerOptions defines the trigger options
  90909. * @param condition defines the trigger related conditions
  90910. */
  90911. constructor(triggerOptions?: any, condition?: Condition);
  90912. /**
  90913. * Execute the action and do nothing.
  90914. */
  90915. execute(): void;
  90916. /**
  90917. * Serializes the actions and its related information.
  90918. * @param parent defines the object to serialize in
  90919. * @returns the serialized object
  90920. */
  90921. serialize(parent: any): any;
  90922. }
  90923. /**
  90924. * This defines an action responsible to trigger several actions once triggered.
  90925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90926. */
  90927. export class CombineAction extends Action {
  90928. /**
  90929. * The list of aggregated animations to run.
  90930. */
  90931. children: Action[];
  90932. /**
  90933. * Instantiate the action
  90934. * @param triggerOptions defines the trigger options
  90935. * @param children defines the list of aggregated animations to run
  90936. * @param condition defines the trigger related conditions
  90937. */
  90938. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90939. /** @hidden */
  90940. _prepare(): void;
  90941. /**
  90942. * Execute the action and executes all the aggregated actions.
  90943. */
  90944. execute(evt: ActionEvent): void;
  90945. /**
  90946. * Serializes the actions and its related information.
  90947. * @param parent defines the object to serialize in
  90948. * @returns the serialized object
  90949. */
  90950. serialize(parent: any): any;
  90951. }
  90952. /**
  90953. * This defines an action responsible to run code (external event) once triggered.
  90954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90955. */
  90956. export class ExecuteCodeAction extends Action {
  90957. /**
  90958. * The callback function to run.
  90959. */
  90960. func: (evt: ActionEvent) => void;
  90961. /**
  90962. * Instantiate the action
  90963. * @param triggerOptions defines the trigger options
  90964. * @param func defines the callback function to run
  90965. * @param condition defines the trigger related conditions
  90966. */
  90967. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90968. /**
  90969. * Execute the action and run the attached code.
  90970. */
  90971. execute(evt: ActionEvent): void;
  90972. }
  90973. /**
  90974. * This defines an action responsible to set the parent property of the target once triggered.
  90975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90976. */
  90977. export class SetParentAction extends Action {
  90978. private _parent;
  90979. private _target;
  90980. /**
  90981. * Instantiate the action
  90982. * @param triggerOptions defines the trigger options
  90983. * @param target defines the target containing the parent property
  90984. * @param parent defines from where the animation should start (animation frame)
  90985. * @param condition defines the trigger related conditions
  90986. */
  90987. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90988. /** @hidden */
  90989. _prepare(): void;
  90990. /**
  90991. * Execute the action and set the parent property.
  90992. */
  90993. execute(): void;
  90994. /**
  90995. * Serializes the actions and its related information.
  90996. * @param parent defines the object to serialize in
  90997. * @returns the serialized object
  90998. */
  90999. serialize(parent: any): any;
  91000. }
  91001. }
  91002. declare module BABYLON {
  91003. /**
  91004. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91005. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91007. */
  91008. export class ActionManager extends AbstractActionManager {
  91009. /**
  91010. * Nothing
  91011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91012. */
  91013. static readonly NothingTrigger: number;
  91014. /**
  91015. * On pick
  91016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91017. */
  91018. static readonly OnPickTrigger: number;
  91019. /**
  91020. * On left pick
  91021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91022. */
  91023. static readonly OnLeftPickTrigger: number;
  91024. /**
  91025. * On right pick
  91026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91027. */
  91028. static readonly OnRightPickTrigger: number;
  91029. /**
  91030. * On center pick
  91031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91032. */
  91033. static readonly OnCenterPickTrigger: number;
  91034. /**
  91035. * On pick down
  91036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91037. */
  91038. static readonly OnPickDownTrigger: number;
  91039. /**
  91040. * On double pick
  91041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91042. */
  91043. static readonly OnDoublePickTrigger: number;
  91044. /**
  91045. * On pick up
  91046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91047. */
  91048. static readonly OnPickUpTrigger: number;
  91049. /**
  91050. * On pick out.
  91051. * This trigger will only be raised if you also declared a OnPickDown
  91052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91053. */
  91054. static readonly OnPickOutTrigger: number;
  91055. /**
  91056. * On long press
  91057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91058. */
  91059. static readonly OnLongPressTrigger: number;
  91060. /**
  91061. * On pointer over
  91062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91063. */
  91064. static readonly OnPointerOverTrigger: number;
  91065. /**
  91066. * On pointer out
  91067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91068. */
  91069. static readonly OnPointerOutTrigger: number;
  91070. /**
  91071. * On every frame
  91072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91073. */
  91074. static readonly OnEveryFrameTrigger: number;
  91075. /**
  91076. * On intersection enter
  91077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91078. */
  91079. static readonly OnIntersectionEnterTrigger: number;
  91080. /**
  91081. * On intersection exit
  91082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91083. */
  91084. static readonly OnIntersectionExitTrigger: number;
  91085. /**
  91086. * On key down
  91087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91088. */
  91089. static readonly OnKeyDownTrigger: number;
  91090. /**
  91091. * On key up
  91092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91093. */
  91094. static readonly OnKeyUpTrigger: number;
  91095. private _scene;
  91096. /**
  91097. * Creates a new action manager
  91098. * @param scene defines the hosting scene
  91099. */
  91100. constructor(scene: Scene);
  91101. /**
  91102. * Releases all associated resources
  91103. */
  91104. dispose(): void;
  91105. /**
  91106. * Gets hosting scene
  91107. * @returns the hosting scene
  91108. */
  91109. getScene(): Scene;
  91110. /**
  91111. * Does this action manager handles actions of any of the given triggers
  91112. * @param triggers defines the triggers to be tested
  91113. * @return a boolean indicating whether one (or more) of the triggers is handled
  91114. */
  91115. hasSpecificTriggers(triggers: number[]): boolean;
  91116. /**
  91117. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91118. * speed.
  91119. * @param triggerA defines the trigger to be tested
  91120. * @param triggerB defines the trigger to be tested
  91121. * @return a boolean indicating whether one (or more) of the triggers is handled
  91122. */
  91123. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91124. /**
  91125. * Does this action manager handles actions of a given trigger
  91126. * @param trigger defines the trigger to be tested
  91127. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91128. * @return whether the trigger is handled
  91129. */
  91130. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91131. /**
  91132. * Does this action manager has pointer triggers
  91133. */
  91134. get hasPointerTriggers(): boolean;
  91135. /**
  91136. * Does this action manager has pick triggers
  91137. */
  91138. get hasPickTriggers(): boolean;
  91139. /**
  91140. * Registers an action to this action manager
  91141. * @param action defines the action to be registered
  91142. * @return the action amended (prepared) after registration
  91143. */
  91144. registerAction(action: IAction): Nullable<IAction>;
  91145. /**
  91146. * Unregisters an action to this action manager
  91147. * @param action defines the action to be unregistered
  91148. * @return a boolean indicating whether the action has been unregistered
  91149. */
  91150. unregisterAction(action: IAction): Boolean;
  91151. /**
  91152. * Process a specific trigger
  91153. * @param trigger defines the trigger to process
  91154. * @param evt defines the event details to be processed
  91155. */
  91156. processTrigger(trigger: number, evt?: IActionEvent): void;
  91157. /** @hidden */
  91158. _getEffectiveTarget(target: any, propertyPath: string): any;
  91159. /** @hidden */
  91160. _getProperty(propertyPath: string): string;
  91161. /**
  91162. * Serialize this manager to a JSON object
  91163. * @param name defines the property name to store this manager
  91164. * @returns a JSON representation of this manager
  91165. */
  91166. serialize(name: string): any;
  91167. /**
  91168. * Creates a new ActionManager from a JSON data
  91169. * @param parsedActions defines the JSON data to read from
  91170. * @param object defines the hosting mesh
  91171. * @param scene defines the hosting scene
  91172. */
  91173. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91174. /**
  91175. * Get a trigger name by index
  91176. * @param trigger defines the trigger index
  91177. * @returns a trigger name
  91178. */
  91179. static GetTriggerName(trigger: number): string;
  91180. }
  91181. }
  91182. declare module BABYLON {
  91183. /**
  91184. * Class used to represent a sprite
  91185. * @see http://doc.babylonjs.com/babylon101/sprites
  91186. */
  91187. export class Sprite {
  91188. /** defines the name */
  91189. name: string;
  91190. /** Gets or sets the current world position */
  91191. position: Vector3;
  91192. /** Gets or sets the main color */
  91193. color: Color4;
  91194. /** Gets or sets the width */
  91195. width: number;
  91196. /** Gets or sets the height */
  91197. height: number;
  91198. /** Gets or sets rotation angle */
  91199. angle: number;
  91200. /** Gets or sets the cell index in the sprite sheet */
  91201. cellIndex: number;
  91202. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91203. cellRef: string;
  91204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91205. invertU: number;
  91206. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91207. invertV: number;
  91208. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91209. disposeWhenFinishedAnimating: boolean;
  91210. /** Gets the list of attached animations */
  91211. animations: Animation[];
  91212. /** Gets or sets a boolean indicating if the sprite can be picked */
  91213. isPickable: boolean;
  91214. /**
  91215. * Gets or sets the associated action manager
  91216. */
  91217. actionManager: Nullable<ActionManager>;
  91218. private _animationStarted;
  91219. private _loopAnimation;
  91220. private _fromIndex;
  91221. private _toIndex;
  91222. private _delay;
  91223. private _direction;
  91224. private _manager;
  91225. private _time;
  91226. private _onAnimationEnd;
  91227. /**
  91228. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91229. */
  91230. isVisible: boolean;
  91231. /**
  91232. * Gets or sets the sprite size
  91233. */
  91234. get size(): number;
  91235. set size(value: number);
  91236. /**
  91237. * Creates a new Sprite
  91238. * @param name defines the name
  91239. * @param manager defines the manager
  91240. */
  91241. constructor(
  91242. /** defines the name */
  91243. name: string, manager: ISpriteManager);
  91244. /**
  91245. * Starts an animation
  91246. * @param from defines the initial key
  91247. * @param to defines the end key
  91248. * @param loop defines if the animation must loop
  91249. * @param delay defines the start delay (in ms)
  91250. * @param onAnimationEnd defines a callback to call when animation ends
  91251. */
  91252. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91253. /** Stops current animation (if any) */
  91254. stopAnimation(): void;
  91255. /** @hidden */
  91256. _animate(deltaTime: number): void;
  91257. /** Release associated resources */
  91258. dispose(): void;
  91259. }
  91260. }
  91261. declare module BABYLON {
  91262. /**
  91263. * Information about the result of picking within a scene
  91264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91265. */
  91266. export class PickingInfo {
  91267. /** @hidden */
  91268. _pickingUnavailable: boolean;
  91269. /**
  91270. * If the pick collided with an object
  91271. */
  91272. hit: boolean;
  91273. /**
  91274. * Distance away where the pick collided
  91275. */
  91276. distance: number;
  91277. /**
  91278. * The location of pick collision
  91279. */
  91280. pickedPoint: Nullable<Vector3>;
  91281. /**
  91282. * The mesh corresponding the the pick collision
  91283. */
  91284. pickedMesh: Nullable<AbstractMesh>;
  91285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91286. bu: number;
  91287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91288. bv: number;
  91289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91290. faceId: number;
  91291. /** Id of the the submesh that was picked */
  91292. subMeshId: number;
  91293. /** If a sprite was picked, this will be the sprite the pick collided with */
  91294. pickedSprite: Nullable<Sprite>;
  91295. /**
  91296. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91297. */
  91298. originMesh: Nullable<AbstractMesh>;
  91299. /**
  91300. * The ray that was used to perform the picking.
  91301. */
  91302. ray: Nullable<Ray>;
  91303. /**
  91304. * Gets the normal correspodning to the face the pick collided with
  91305. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91306. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91307. * @returns The normal correspodning to the face the pick collided with
  91308. */
  91309. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91310. /**
  91311. * Gets the texture coordinates of where the pick occured
  91312. * @returns the vector containing the coordnates of the texture
  91313. */
  91314. getTextureCoordinates(): Nullable<Vector2>;
  91315. }
  91316. }
  91317. declare module BABYLON {
  91318. /**
  91319. * Gather the list of pointer event types as constants.
  91320. */
  91321. export class PointerEventTypes {
  91322. /**
  91323. * 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.
  91324. */
  91325. static readonly POINTERDOWN: number;
  91326. /**
  91327. * The pointerup event is fired when a pointer is no longer active.
  91328. */
  91329. static readonly POINTERUP: number;
  91330. /**
  91331. * The pointermove event is fired when a pointer changes coordinates.
  91332. */
  91333. static readonly POINTERMOVE: number;
  91334. /**
  91335. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91336. */
  91337. static readonly POINTERWHEEL: number;
  91338. /**
  91339. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91340. */
  91341. static readonly POINTERPICK: number;
  91342. /**
  91343. * The pointertap event is fired when a the object has been touched and released without drag.
  91344. */
  91345. static readonly POINTERTAP: number;
  91346. /**
  91347. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91348. */
  91349. static readonly POINTERDOUBLETAP: number;
  91350. }
  91351. /**
  91352. * Base class of pointer info types.
  91353. */
  91354. export class PointerInfoBase {
  91355. /**
  91356. * Defines the type of event (PointerEventTypes)
  91357. */
  91358. type: number;
  91359. /**
  91360. * Defines the related dom event
  91361. */
  91362. event: PointerEvent | MouseWheelEvent;
  91363. /**
  91364. * Instantiates the base class of pointers info.
  91365. * @param type Defines the type of event (PointerEventTypes)
  91366. * @param event Defines the related dom event
  91367. */
  91368. constructor(
  91369. /**
  91370. * Defines the type of event (PointerEventTypes)
  91371. */
  91372. type: number,
  91373. /**
  91374. * Defines the related dom event
  91375. */
  91376. event: PointerEvent | MouseWheelEvent);
  91377. }
  91378. /**
  91379. * This class is used to store pointer related info for the onPrePointerObservable event.
  91380. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91381. */
  91382. export class PointerInfoPre extends PointerInfoBase {
  91383. /**
  91384. * Ray from a pointer if availible (eg. 6dof controller)
  91385. */
  91386. ray: Nullable<Ray>;
  91387. /**
  91388. * Defines the local position of the pointer on the canvas.
  91389. */
  91390. localPosition: Vector2;
  91391. /**
  91392. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91393. */
  91394. skipOnPointerObservable: boolean;
  91395. /**
  91396. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91397. * @param type Defines the type of event (PointerEventTypes)
  91398. * @param event Defines the related dom event
  91399. * @param localX Defines the local x coordinates of the pointer when the event occured
  91400. * @param localY Defines the local y coordinates of the pointer when the event occured
  91401. */
  91402. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91403. }
  91404. /**
  91405. * This type contains all the data related to a pointer event in Babylon.js.
  91406. * 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.
  91407. */
  91408. export class PointerInfo extends PointerInfoBase {
  91409. /**
  91410. * Defines the picking info associated to the info (if any)\
  91411. */
  91412. pickInfo: Nullable<PickingInfo>;
  91413. /**
  91414. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91415. * @param type Defines the type of event (PointerEventTypes)
  91416. * @param event Defines the related dom event
  91417. * @param pickInfo Defines the picking info associated to the info (if any)\
  91418. */
  91419. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91420. /**
  91421. * Defines the picking info associated to the info (if any)\
  91422. */
  91423. pickInfo: Nullable<PickingInfo>);
  91424. }
  91425. /**
  91426. * Data relating to a touch event on the screen.
  91427. */
  91428. export interface PointerTouch {
  91429. /**
  91430. * X coordinate of touch.
  91431. */
  91432. x: number;
  91433. /**
  91434. * Y coordinate of touch.
  91435. */
  91436. y: number;
  91437. /**
  91438. * Id of touch. Unique for each finger.
  91439. */
  91440. pointerId: number;
  91441. /**
  91442. * Event type passed from DOM.
  91443. */
  91444. type: any;
  91445. }
  91446. }
  91447. declare module BABYLON {
  91448. /**
  91449. * Manage the mouse inputs to control the movement of a free camera.
  91450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91451. */
  91452. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91453. /**
  91454. * Define if touch is enabled in the mouse input
  91455. */
  91456. touchEnabled: boolean;
  91457. /**
  91458. * Defines the camera the input is attached to.
  91459. */
  91460. camera: FreeCamera;
  91461. /**
  91462. * Defines the buttons associated with the input to handle camera move.
  91463. */
  91464. buttons: number[];
  91465. /**
  91466. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91467. */
  91468. angularSensibility: number;
  91469. private _pointerInput;
  91470. private _onMouseMove;
  91471. private _observer;
  91472. private previousPosition;
  91473. /**
  91474. * Observable for when a pointer move event occurs containing the move offset
  91475. */
  91476. onPointerMovedObservable: Observable<{
  91477. offsetX: number;
  91478. offsetY: number;
  91479. }>;
  91480. /**
  91481. * @hidden
  91482. * If the camera should be rotated automatically based on pointer movement
  91483. */
  91484. _allowCameraRotation: boolean;
  91485. /**
  91486. * Manage the mouse inputs to control the movement of a free camera.
  91487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91488. * @param touchEnabled Defines if touch is enabled or not
  91489. */
  91490. constructor(
  91491. /**
  91492. * Define if touch is enabled in the mouse input
  91493. */
  91494. touchEnabled?: boolean);
  91495. /**
  91496. * Attach the input controls to a specific dom element to get the input from.
  91497. * @param element Defines the element the controls should be listened from
  91498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91499. */
  91500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91501. /**
  91502. * Called on JS contextmenu event.
  91503. * Override this method to provide functionality.
  91504. */
  91505. protected onContextMenu(evt: PointerEvent): void;
  91506. /**
  91507. * Detach the current controls from the specified dom element.
  91508. * @param element Defines the element to stop listening the inputs from
  91509. */
  91510. detachControl(element: Nullable<HTMLElement>): void;
  91511. /**
  91512. * Gets the class name of the current intput.
  91513. * @returns the class name
  91514. */
  91515. getClassName(): string;
  91516. /**
  91517. * Get the friendly name associated with the input class.
  91518. * @returns the input friendly name
  91519. */
  91520. getSimpleName(): string;
  91521. }
  91522. }
  91523. declare module BABYLON {
  91524. /**
  91525. * Manage the touch inputs to control the movement of a free camera.
  91526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91527. */
  91528. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91529. /**
  91530. * Defines the camera the input is attached to.
  91531. */
  91532. camera: FreeCamera;
  91533. /**
  91534. * Defines the touch sensibility for rotation.
  91535. * The higher the faster.
  91536. */
  91537. touchAngularSensibility: number;
  91538. /**
  91539. * Defines the touch sensibility for move.
  91540. * The higher the faster.
  91541. */
  91542. touchMoveSensibility: number;
  91543. private _offsetX;
  91544. private _offsetY;
  91545. private _pointerPressed;
  91546. private _pointerInput;
  91547. private _observer;
  91548. private _onLostFocus;
  91549. /**
  91550. * Attach the input controls to a specific dom element to get the input from.
  91551. * @param element Defines the element the controls should be listened from
  91552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91553. */
  91554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91555. /**
  91556. * Detach the current controls from the specified dom element.
  91557. * @param element Defines the element to stop listening the inputs from
  91558. */
  91559. detachControl(element: Nullable<HTMLElement>): void;
  91560. /**
  91561. * Update the current camera state depending on the inputs that have been used this frame.
  91562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91563. */
  91564. checkInputs(): void;
  91565. /**
  91566. * Gets the class name of the current intput.
  91567. * @returns the class name
  91568. */
  91569. getClassName(): string;
  91570. /**
  91571. * Get the friendly name associated with the input class.
  91572. * @returns the input friendly name
  91573. */
  91574. getSimpleName(): string;
  91575. }
  91576. }
  91577. declare module BABYLON {
  91578. /**
  91579. * Default Inputs manager for the FreeCamera.
  91580. * It groups all the default supported inputs for ease of use.
  91581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91582. */
  91583. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91584. /**
  91585. * @hidden
  91586. */
  91587. _mouseInput: Nullable<FreeCameraMouseInput>;
  91588. /**
  91589. * Instantiates a new FreeCameraInputsManager.
  91590. * @param camera Defines the camera the inputs belong to
  91591. */
  91592. constructor(camera: FreeCamera);
  91593. /**
  91594. * Add keyboard input support to the input manager.
  91595. * @returns the current input manager
  91596. */
  91597. addKeyboard(): FreeCameraInputsManager;
  91598. /**
  91599. * Add mouse input support to the input manager.
  91600. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91601. * @returns the current input manager
  91602. */
  91603. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91604. /**
  91605. * Removes the mouse input support from the manager
  91606. * @returns the current input manager
  91607. */
  91608. removeMouse(): FreeCameraInputsManager;
  91609. /**
  91610. * Add touch input support to the input manager.
  91611. * @returns the current input manager
  91612. */
  91613. addTouch(): FreeCameraInputsManager;
  91614. /**
  91615. * Remove all attached input methods from a camera
  91616. */
  91617. clear(): void;
  91618. }
  91619. }
  91620. declare module BABYLON {
  91621. /**
  91622. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91623. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91625. */
  91626. export class FreeCamera extends TargetCamera {
  91627. /**
  91628. * Define the collision ellipsoid of the camera.
  91629. * This is helpful to simulate a camera body like the player body around the camera
  91630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91631. */
  91632. ellipsoid: Vector3;
  91633. /**
  91634. * Define an offset for the position of the ellipsoid around the camera.
  91635. * This can be helpful to determine the center of the body near the gravity center of the body
  91636. * instead of its head.
  91637. */
  91638. ellipsoidOffset: Vector3;
  91639. /**
  91640. * Enable or disable collisions of the camera with the rest of the scene objects.
  91641. */
  91642. checkCollisions: boolean;
  91643. /**
  91644. * Enable or disable gravity on the camera.
  91645. */
  91646. applyGravity: boolean;
  91647. /**
  91648. * Define the input manager associated to the camera.
  91649. */
  91650. inputs: FreeCameraInputsManager;
  91651. /**
  91652. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91653. * Higher values reduce sensitivity.
  91654. */
  91655. get angularSensibility(): number;
  91656. /**
  91657. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91658. * Higher values reduce sensitivity.
  91659. */
  91660. set angularSensibility(value: number);
  91661. /**
  91662. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91663. */
  91664. get keysUp(): number[];
  91665. set keysUp(value: number[]);
  91666. /**
  91667. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91668. */
  91669. get keysDown(): number[];
  91670. set keysDown(value: number[]);
  91671. /**
  91672. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91673. */
  91674. get keysLeft(): number[];
  91675. set keysLeft(value: number[]);
  91676. /**
  91677. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91678. */
  91679. get keysRight(): number[];
  91680. set keysRight(value: number[]);
  91681. /**
  91682. * Event raised when the camera collide with a mesh in the scene.
  91683. */
  91684. onCollide: (collidedMesh: AbstractMesh) => void;
  91685. private _collider;
  91686. private _needMoveForGravity;
  91687. private _oldPosition;
  91688. private _diffPosition;
  91689. private _newPosition;
  91690. /** @hidden */
  91691. _localDirection: Vector3;
  91692. /** @hidden */
  91693. _transformedDirection: Vector3;
  91694. /**
  91695. * Instantiates a Free Camera.
  91696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91697. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91699. * @param name Define the name of the camera in the scene
  91700. * @param position Define the start position of the camera in the scene
  91701. * @param scene Define the scene the camera belongs to
  91702. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91703. */
  91704. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91705. /**
  91706. * Attached controls to the current camera.
  91707. * @param element Defines the element the controls should be listened from
  91708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91709. */
  91710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91711. /**
  91712. * Detach the current controls from the camera.
  91713. * The camera will stop reacting to inputs.
  91714. * @param element Defines the element to stop listening the inputs from
  91715. */
  91716. detachControl(element: HTMLElement): void;
  91717. private _collisionMask;
  91718. /**
  91719. * Define a collision mask to limit the list of object the camera can collide with
  91720. */
  91721. get collisionMask(): number;
  91722. set collisionMask(mask: number);
  91723. /** @hidden */
  91724. _collideWithWorld(displacement: Vector3): void;
  91725. private _onCollisionPositionChange;
  91726. /** @hidden */
  91727. _checkInputs(): void;
  91728. /** @hidden */
  91729. _decideIfNeedsToMove(): boolean;
  91730. /** @hidden */
  91731. _updatePosition(): void;
  91732. /**
  91733. * Destroy the camera and release the current resources hold by it.
  91734. */
  91735. dispose(): void;
  91736. /**
  91737. * Gets the current object class name.
  91738. * @return the class name
  91739. */
  91740. getClassName(): string;
  91741. }
  91742. }
  91743. declare module BABYLON {
  91744. /**
  91745. * Represents a gamepad control stick position
  91746. */
  91747. export class StickValues {
  91748. /**
  91749. * The x component of the control stick
  91750. */
  91751. x: number;
  91752. /**
  91753. * The y component of the control stick
  91754. */
  91755. y: number;
  91756. /**
  91757. * Initializes the gamepad x and y control stick values
  91758. * @param x The x component of the gamepad control stick value
  91759. * @param y The y component of the gamepad control stick value
  91760. */
  91761. constructor(
  91762. /**
  91763. * The x component of the control stick
  91764. */
  91765. x: number,
  91766. /**
  91767. * The y component of the control stick
  91768. */
  91769. y: number);
  91770. }
  91771. /**
  91772. * An interface which manages callbacks for gamepad button changes
  91773. */
  91774. export interface GamepadButtonChanges {
  91775. /**
  91776. * Called when a gamepad has been changed
  91777. */
  91778. changed: boolean;
  91779. /**
  91780. * Called when a gamepad press event has been triggered
  91781. */
  91782. pressChanged: boolean;
  91783. /**
  91784. * Called when a touch event has been triggered
  91785. */
  91786. touchChanged: boolean;
  91787. /**
  91788. * Called when a value has changed
  91789. */
  91790. valueChanged: boolean;
  91791. }
  91792. /**
  91793. * Represents a gamepad
  91794. */
  91795. export class Gamepad {
  91796. /**
  91797. * The id of the gamepad
  91798. */
  91799. id: string;
  91800. /**
  91801. * The index of the gamepad
  91802. */
  91803. index: number;
  91804. /**
  91805. * The browser gamepad
  91806. */
  91807. browserGamepad: any;
  91808. /**
  91809. * Specifies what type of gamepad this represents
  91810. */
  91811. type: number;
  91812. private _leftStick;
  91813. private _rightStick;
  91814. /** @hidden */
  91815. _isConnected: boolean;
  91816. private _leftStickAxisX;
  91817. private _leftStickAxisY;
  91818. private _rightStickAxisX;
  91819. private _rightStickAxisY;
  91820. /**
  91821. * Triggered when the left control stick has been changed
  91822. */
  91823. private _onleftstickchanged;
  91824. /**
  91825. * Triggered when the right control stick has been changed
  91826. */
  91827. private _onrightstickchanged;
  91828. /**
  91829. * Represents a gamepad controller
  91830. */
  91831. static GAMEPAD: number;
  91832. /**
  91833. * Represents a generic controller
  91834. */
  91835. static GENERIC: number;
  91836. /**
  91837. * Represents an XBox controller
  91838. */
  91839. static XBOX: number;
  91840. /**
  91841. * Represents a pose-enabled controller
  91842. */
  91843. static POSE_ENABLED: number;
  91844. /**
  91845. * Represents an Dual Shock controller
  91846. */
  91847. static DUALSHOCK: number;
  91848. /**
  91849. * Specifies whether the left control stick should be Y-inverted
  91850. */
  91851. protected _invertLeftStickY: boolean;
  91852. /**
  91853. * Specifies if the gamepad has been connected
  91854. */
  91855. get isConnected(): boolean;
  91856. /**
  91857. * Initializes the gamepad
  91858. * @param id The id of the gamepad
  91859. * @param index The index of the gamepad
  91860. * @param browserGamepad The browser gamepad
  91861. * @param leftStickX The x component of the left joystick
  91862. * @param leftStickY The y component of the left joystick
  91863. * @param rightStickX The x component of the right joystick
  91864. * @param rightStickY The y component of the right joystick
  91865. */
  91866. constructor(
  91867. /**
  91868. * The id of the gamepad
  91869. */
  91870. id: string,
  91871. /**
  91872. * The index of the gamepad
  91873. */
  91874. index: number,
  91875. /**
  91876. * The browser gamepad
  91877. */
  91878. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91879. /**
  91880. * Callback triggered when the left joystick has changed
  91881. * @param callback
  91882. */
  91883. onleftstickchanged(callback: (values: StickValues) => void): void;
  91884. /**
  91885. * Callback triggered when the right joystick has changed
  91886. * @param callback
  91887. */
  91888. onrightstickchanged(callback: (values: StickValues) => void): void;
  91889. /**
  91890. * Gets the left joystick
  91891. */
  91892. get leftStick(): StickValues;
  91893. /**
  91894. * Sets the left joystick values
  91895. */
  91896. set leftStick(newValues: StickValues);
  91897. /**
  91898. * Gets the right joystick
  91899. */
  91900. get rightStick(): StickValues;
  91901. /**
  91902. * Sets the right joystick value
  91903. */
  91904. set rightStick(newValues: StickValues);
  91905. /**
  91906. * Updates the gamepad joystick positions
  91907. */
  91908. update(): void;
  91909. /**
  91910. * Disposes the gamepad
  91911. */
  91912. dispose(): void;
  91913. }
  91914. /**
  91915. * Represents a generic gamepad
  91916. */
  91917. export class GenericPad extends Gamepad {
  91918. private _buttons;
  91919. private _onbuttondown;
  91920. private _onbuttonup;
  91921. /**
  91922. * Observable triggered when a button has been pressed
  91923. */
  91924. onButtonDownObservable: Observable<number>;
  91925. /**
  91926. * Observable triggered when a button has been released
  91927. */
  91928. onButtonUpObservable: Observable<number>;
  91929. /**
  91930. * Callback triggered when a button has been pressed
  91931. * @param callback Called when a button has been pressed
  91932. */
  91933. onbuttondown(callback: (buttonPressed: number) => void): void;
  91934. /**
  91935. * Callback triggered when a button has been released
  91936. * @param callback Called when a button has been released
  91937. */
  91938. onbuttonup(callback: (buttonReleased: number) => void): void;
  91939. /**
  91940. * Initializes the generic gamepad
  91941. * @param id The id of the generic gamepad
  91942. * @param index The index of the generic gamepad
  91943. * @param browserGamepad The browser gamepad
  91944. */
  91945. constructor(id: string, index: number, browserGamepad: any);
  91946. private _setButtonValue;
  91947. /**
  91948. * Updates the generic gamepad
  91949. */
  91950. update(): void;
  91951. /**
  91952. * Disposes the generic gamepad
  91953. */
  91954. dispose(): void;
  91955. }
  91956. }
  91957. declare module BABYLON {
  91958. /**
  91959. * Defines the types of pose enabled controllers that are supported
  91960. */
  91961. export enum PoseEnabledControllerType {
  91962. /**
  91963. * HTC Vive
  91964. */
  91965. VIVE = 0,
  91966. /**
  91967. * Oculus Rift
  91968. */
  91969. OCULUS = 1,
  91970. /**
  91971. * Windows mixed reality
  91972. */
  91973. WINDOWS = 2,
  91974. /**
  91975. * Samsung gear VR
  91976. */
  91977. GEAR_VR = 3,
  91978. /**
  91979. * Google Daydream
  91980. */
  91981. DAYDREAM = 4,
  91982. /**
  91983. * Generic
  91984. */
  91985. GENERIC = 5
  91986. }
  91987. /**
  91988. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91989. */
  91990. export interface MutableGamepadButton {
  91991. /**
  91992. * Value of the button/trigger
  91993. */
  91994. value: number;
  91995. /**
  91996. * If the button/trigger is currently touched
  91997. */
  91998. touched: boolean;
  91999. /**
  92000. * If the button/trigger is currently pressed
  92001. */
  92002. pressed: boolean;
  92003. }
  92004. /**
  92005. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92006. * @hidden
  92007. */
  92008. export interface ExtendedGamepadButton extends GamepadButton {
  92009. /**
  92010. * If the button/trigger is currently pressed
  92011. */
  92012. readonly pressed: boolean;
  92013. /**
  92014. * If the button/trigger is currently touched
  92015. */
  92016. readonly touched: boolean;
  92017. /**
  92018. * Value of the button/trigger
  92019. */
  92020. readonly value: number;
  92021. }
  92022. /** @hidden */
  92023. export interface _GamePadFactory {
  92024. /**
  92025. * Returns whether or not the current gamepad can be created for this type of controller.
  92026. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92027. * @returns true if it can be created, otherwise false
  92028. */
  92029. canCreate(gamepadInfo: any): boolean;
  92030. /**
  92031. * Creates a new instance of the Gamepad.
  92032. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92033. * @returns the new gamepad instance
  92034. */
  92035. create(gamepadInfo: any): Gamepad;
  92036. }
  92037. /**
  92038. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92039. */
  92040. export class PoseEnabledControllerHelper {
  92041. /** @hidden */
  92042. static _ControllerFactories: _GamePadFactory[];
  92043. /** @hidden */
  92044. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92045. /**
  92046. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92047. * @param vrGamepad the gamepad to initialized
  92048. * @returns a vr controller of the type the gamepad identified as
  92049. */
  92050. static InitiateController(vrGamepad: any): Gamepad;
  92051. }
  92052. /**
  92053. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92054. */
  92055. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92056. /**
  92057. * If the controller is used in a webXR session
  92058. */
  92059. isXR: boolean;
  92060. private _deviceRoomPosition;
  92061. private _deviceRoomRotationQuaternion;
  92062. /**
  92063. * The device position in babylon space
  92064. */
  92065. devicePosition: Vector3;
  92066. /**
  92067. * The device rotation in babylon space
  92068. */
  92069. deviceRotationQuaternion: Quaternion;
  92070. /**
  92071. * The scale factor of the device in babylon space
  92072. */
  92073. deviceScaleFactor: number;
  92074. /**
  92075. * (Likely devicePosition should be used instead) The device position in its room space
  92076. */
  92077. position: Vector3;
  92078. /**
  92079. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92080. */
  92081. rotationQuaternion: Quaternion;
  92082. /**
  92083. * The type of controller (Eg. Windows mixed reality)
  92084. */
  92085. controllerType: PoseEnabledControllerType;
  92086. protected _calculatedPosition: Vector3;
  92087. private _calculatedRotation;
  92088. /**
  92089. * The raw pose from the device
  92090. */
  92091. rawPose: DevicePose;
  92092. private _trackPosition;
  92093. private _maxRotationDistFromHeadset;
  92094. private _draggedRoomRotation;
  92095. /**
  92096. * @hidden
  92097. */
  92098. _disableTrackPosition(fixedPosition: Vector3): void;
  92099. /**
  92100. * Internal, the mesh attached to the controller
  92101. * @hidden
  92102. */
  92103. _mesh: Nullable<AbstractMesh>;
  92104. private _poseControlledCamera;
  92105. private _leftHandSystemQuaternion;
  92106. /**
  92107. * Internal, matrix used to convert room space to babylon space
  92108. * @hidden
  92109. */
  92110. _deviceToWorld: Matrix;
  92111. /**
  92112. * Node to be used when casting a ray from the controller
  92113. * @hidden
  92114. */
  92115. _pointingPoseNode: Nullable<TransformNode>;
  92116. /**
  92117. * Name of the child mesh that can be used to cast a ray from the controller
  92118. */
  92119. static readonly POINTING_POSE: string;
  92120. /**
  92121. * Creates a new PoseEnabledController from a gamepad
  92122. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92123. */
  92124. constructor(browserGamepad: any);
  92125. private _workingMatrix;
  92126. /**
  92127. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92128. */
  92129. update(): void;
  92130. /**
  92131. * Updates only the pose device and mesh without doing any button event checking
  92132. */
  92133. protected _updatePoseAndMesh(): void;
  92134. /**
  92135. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92136. * @param poseData raw pose fromthe device
  92137. */
  92138. updateFromDevice(poseData: DevicePose): void;
  92139. /**
  92140. * @hidden
  92141. */
  92142. _meshAttachedObservable: Observable<AbstractMesh>;
  92143. /**
  92144. * Attaches a mesh to the controller
  92145. * @param mesh the mesh to be attached
  92146. */
  92147. attachToMesh(mesh: AbstractMesh): void;
  92148. /**
  92149. * Attaches the controllers mesh to a camera
  92150. * @param camera the camera the mesh should be attached to
  92151. */
  92152. attachToPoseControlledCamera(camera: TargetCamera): void;
  92153. /**
  92154. * Disposes of the controller
  92155. */
  92156. dispose(): void;
  92157. /**
  92158. * The mesh that is attached to the controller
  92159. */
  92160. get mesh(): Nullable<AbstractMesh>;
  92161. /**
  92162. * Gets the ray of the controller in the direction the controller is pointing
  92163. * @param length the length the resulting ray should be
  92164. * @returns a ray in the direction the controller is pointing
  92165. */
  92166. getForwardRay(length?: number): Ray;
  92167. }
  92168. }
  92169. declare module BABYLON {
  92170. /**
  92171. * Defines the WebVRController object that represents controllers tracked in 3D space
  92172. */
  92173. export abstract class WebVRController extends PoseEnabledController {
  92174. /**
  92175. * Internal, the default controller model for the controller
  92176. */
  92177. protected _defaultModel: Nullable<AbstractMesh>;
  92178. /**
  92179. * Fired when the trigger state has changed
  92180. */
  92181. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92182. /**
  92183. * Fired when the main button state has changed
  92184. */
  92185. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92186. /**
  92187. * Fired when the secondary button state has changed
  92188. */
  92189. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92190. /**
  92191. * Fired when the pad state has changed
  92192. */
  92193. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92194. /**
  92195. * Fired when controllers stick values have changed
  92196. */
  92197. onPadValuesChangedObservable: Observable<StickValues>;
  92198. /**
  92199. * Array of button availible on the controller
  92200. */
  92201. protected _buttons: Array<MutableGamepadButton>;
  92202. private _onButtonStateChange;
  92203. /**
  92204. * Fired when a controller button's state has changed
  92205. * @param callback the callback containing the button that was modified
  92206. */
  92207. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92208. /**
  92209. * X and Y axis corresponding to the controllers joystick
  92210. */
  92211. pad: StickValues;
  92212. /**
  92213. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92214. */
  92215. hand: string;
  92216. /**
  92217. * The default controller model for the controller
  92218. */
  92219. get defaultModel(): Nullable<AbstractMesh>;
  92220. /**
  92221. * Creates a new WebVRController from a gamepad
  92222. * @param vrGamepad the gamepad that the WebVRController should be created from
  92223. */
  92224. constructor(vrGamepad: any);
  92225. /**
  92226. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92227. */
  92228. update(): void;
  92229. /**
  92230. * Function to be called when a button is modified
  92231. */
  92232. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92233. /**
  92234. * Loads a mesh and attaches it to the controller
  92235. * @param scene the scene the mesh should be added to
  92236. * @param meshLoaded callback for when the mesh has been loaded
  92237. */
  92238. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92239. private _setButtonValue;
  92240. private _changes;
  92241. private _checkChanges;
  92242. /**
  92243. * Disposes of th webVRCOntroller
  92244. */
  92245. dispose(): void;
  92246. }
  92247. }
  92248. declare module BABYLON {
  92249. /**
  92250. * The HemisphericLight simulates the ambient environment light,
  92251. * so the passed direction is the light reflection direction, not the incoming direction.
  92252. */
  92253. export class HemisphericLight extends Light {
  92254. /**
  92255. * The groundColor is the light in the opposite direction to the one specified during creation.
  92256. * 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.
  92257. */
  92258. groundColor: Color3;
  92259. /**
  92260. * The light reflection direction, not the incoming direction.
  92261. */
  92262. direction: Vector3;
  92263. /**
  92264. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92265. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92266. * The HemisphericLight can't cast shadows.
  92267. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92268. * @param name The friendly name of the light
  92269. * @param direction The direction of the light reflection
  92270. * @param scene The scene the light belongs to
  92271. */
  92272. constructor(name: string, direction: Vector3, scene: Scene);
  92273. protected _buildUniformLayout(): void;
  92274. /**
  92275. * Returns the string "HemisphericLight".
  92276. * @return The class name
  92277. */
  92278. getClassName(): string;
  92279. /**
  92280. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92281. * Returns the updated direction.
  92282. * @param target The target the direction should point to
  92283. * @return The computed direction
  92284. */
  92285. setDirectionToTarget(target: Vector3): Vector3;
  92286. /**
  92287. * Returns the shadow generator associated to the light.
  92288. * @returns Always null for hemispheric lights because it does not support shadows.
  92289. */
  92290. getShadowGenerator(): Nullable<IShadowGenerator>;
  92291. /**
  92292. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92293. * @param effect The effect to update
  92294. * @param lightIndex The index of the light in the effect to update
  92295. * @returns The hemispheric light
  92296. */
  92297. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92298. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92299. /**
  92300. * Computes the world matrix of the node
  92301. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92302. * @param useWasUpdatedFlag defines a reserved property
  92303. * @returns the world matrix
  92304. */
  92305. computeWorldMatrix(): Matrix;
  92306. /**
  92307. * Returns the integer 3.
  92308. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92309. */
  92310. getTypeID(): number;
  92311. /**
  92312. * Prepares the list of defines specific to the light type.
  92313. * @param defines the list of defines
  92314. * @param lightIndex defines the index of the light for the effect
  92315. */
  92316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92317. }
  92318. }
  92319. declare module BABYLON {
  92320. /** @hidden */
  92321. export var vrMultiviewToSingleviewPixelShader: {
  92322. name: string;
  92323. shader: string;
  92324. };
  92325. }
  92326. declare module BABYLON {
  92327. /**
  92328. * Renders to multiple views with a single draw call
  92329. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92330. */
  92331. export class MultiviewRenderTarget extends RenderTargetTexture {
  92332. /**
  92333. * Creates a multiview render target
  92334. * @param scene scene used with the render target
  92335. * @param size the size of the render target (used for each view)
  92336. */
  92337. constructor(scene: Scene, size?: number | {
  92338. width: number;
  92339. height: number;
  92340. } | {
  92341. ratio: number;
  92342. });
  92343. /**
  92344. * @hidden
  92345. * @param faceIndex the face index, if its a cube texture
  92346. */
  92347. _bindFrameBuffer(faceIndex?: number): void;
  92348. /**
  92349. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92350. * @returns the view count
  92351. */
  92352. getViewCount(): number;
  92353. }
  92354. }
  92355. declare module BABYLON {
  92356. /**
  92357. * Represents a camera frustum
  92358. */
  92359. export class Frustum {
  92360. /**
  92361. * Gets the planes representing the frustum
  92362. * @param transform matrix to be applied to the returned planes
  92363. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92364. */
  92365. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92366. /**
  92367. * Gets the near frustum plane transformed by the transform matrix
  92368. * @param transform transformation matrix to be applied to the resulting frustum plane
  92369. * @param frustumPlane the resuling frustum plane
  92370. */
  92371. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92372. /**
  92373. * Gets the far frustum plane transformed by the transform matrix
  92374. * @param transform transformation matrix to be applied to the resulting frustum plane
  92375. * @param frustumPlane the resuling frustum plane
  92376. */
  92377. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92378. /**
  92379. * Gets the left frustum plane transformed by the transform matrix
  92380. * @param transform transformation matrix to be applied to the resulting frustum plane
  92381. * @param frustumPlane the resuling frustum plane
  92382. */
  92383. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92384. /**
  92385. * Gets the right frustum plane transformed by the transform matrix
  92386. * @param transform transformation matrix to be applied to the resulting frustum plane
  92387. * @param frustumPlane the resuling frustum plane
  92388. */
  92389. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92390. /**
  92391. * Gets the top frustum plane transformed by the transform matrix
  92392. * @param transform transformation matrix to be applied to the resulting frustum plane
  92393. * @param frustumPlane the resuling frustum plane
  92394. */
  92395. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92396. /**
  92397. * Gets the bottom frustum plane transformed by the transform matrix
  92398. * @param transform transformation matrix to be applied to the resulting frustum plane
  92399. * @param frustumPlane the resuling frustum plane
  92400. */
  92401. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92402. /**
  92403. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92404. * @param transform transformation matrix to be applied to the resulting frustum planes
  92405. * @param frustumPlanes the resuling frustum planes
  92406. */
  92407. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92408. }
  92409. }
  92410. declare module BABYLON {
  92411. interface Engine {
  92412. /**
  92413. * Creates a new multiview render target
  92414. * @param width defines the width of the texture
  92415. * @param height defines the height of the texture
  92416. * @returns the created multiview texture
  92417. */
  92418. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92419. /**
  92420. * Binds a multiview framebuffer to be drawn to
  92421. * @param multiviewTexture texture to bind
  92422. */
  92423. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92424. }
  92425. interface Camera {
  92426. /**
  92427. * @hidden
  92428. * 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)
  92429. */
  92430. _useMultiviewToSingleView: boolean;
  92431. /**
  92432. * @hidden
  92433. * 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)
  92434. */
  92435. _multiviewTexture: Nullable<RenderTargetTexture>;
  92436. /**
  92437. * @hidden
  92438. * ensures the multiview texture of the camera exists and has the specified width/height
  92439. * @param width height to set on the multiview texture
  92440. * @param height width to set on the multiview texture
  92441. */
  92442. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92443. }
  92444. interface Scene {
  92445. /** @hidden */
  92446. _transformMatrixR: Matrix;
  92447. /** @hidden */
  92448. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92449. /** @hidden */
  92450. _createMultiviewUbo(): void;
  92451. /** @hidden */
  92452. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92453. /** @hidden */
  92454. _renderMultiviewToSingleView(camera: Camera): void;
  92455. }
  92456. }
  92457. declare module BABYLON {
  92458. /**
  92459. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92460. * This will not be used for webXR as it supports displaying texture arrays directly
  92461. */
  92462. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92463. /**
  92464. * Initializes a VRMultiviewToSingleview
  92465. * @param name name of the post process
  92466. * @param camera camera to be applied to
  92467. * @param scaleFactor scaling factor to the size of the output texture
  92468. */
  92469. constructor(name: string, camera: Camera, scaleFactor: number);
  92470. }
  92471. }
  92472. declare module BABYLON {
  92473. /**
  92474. * Interface used to define additional presentation attributes
  92475. */
  92476. export interface IVRPresentationAttributes {
  92477. /**
  92478. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92479. */
  92480. highRefreshRate: boolean;
  92481. /**
  92482. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92483. */
  92484. foveationLevel: number;
  92485. }
  92486. interface Engine {
  92487. /** @hidden */
  92488. _vrDisplay: any;
  92489. /** @hidden */
  92490. _vrSupported: boolean;
  92491. /** @hidden */
  92492. _oldSize: Size;
  92493. /** @hidden */
  92494. _oldHardwareScaleFactor: number;
  92495. /** @hidden */
  92496. _vrExclusivePointerMode: boolean;
  92497. /** @hidden */
  92498. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92499. /** @hidden */
  92500. _onVRDisplayPointerRestricted: () => void;
  92501. /** @hidden */
  92502. _onVRDisplayPointerUnrestricted: () => void;
  92503. /** @hidden */
  92504. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92505. /** @hidden */
  92506. _onVrDisplayDisconnect: Nullable<() => void>;
  92507. /** @hidden */
  92508. _onVrDisplayPresentChange: Nullable<() => void>;
  92509. /**
  92510. * Observable signaled when VR display mode changes
  92511. */
  92512. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92513. /**
  92514. * Observable signaled when VR request present is complete
  92515. */
  92516. onVRRequestPresentComplete: Observable<boolean>;
  92517. /**
  92518. * Observable signaled when VR request present starts
  92519. */
  92520. onVRRequestPresentStart: Observable<Engine>;
  92521. /**
  92522. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92523. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92524. */
  92525. isInVRExclusivePointerMode: boolean;
  92526. /**
  92527. * Gets a boolean indicating if a webVR device was detected
  92528. * @returns true if a webVR device was detected
  92529. */
  92530. isVRDevicePresent(): boolean;
  92531. /**
  92532. * Gets the current webVR device
  92533. * @returns the current webVR device (or null)
  92534. */
  92535. getVRDevice(): any;
  92536. /**
  92537. * Initializes a webVR display and starts listening to display change events
  92538. * The onVRDisplayChangedObservable will be notified upon these changes
  92539. * @returns A promise containing a VRDisplay and if vr is supported
  92540. */
  92541. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92542. /** @hidden */
  92543. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92544. /**
  92545. * Gets or sets the presentation attributes used to configure VR rendering
  92546. */
  92547. vrPresentationAttributes?: IVRPresentationAttributes;
  92548. /**
  92549. * Call this function to switch to webVR mode
  92550. * Will do nothing if webVR is not supported or if there is no webVR device
  92551. * @param options the webvr options provided to the camera. mainly used for multiview
  92552. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92553. */
  92554. enableVR(options: WebVROptions): void;
  92555. /** @hidden */
  92556. _onVRFullScreenTriggered(): void;
  92557. }
  92558. }
  92559. declare module BABYLON {
  92560. /**
  92561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92562. * IMPORTANT!! The data is right-hand data.
  92563. * @export
  92564. * @interface DevicePose
  92565. */
  92566. export interface DevicePose {
  92567. /**
  92568. * The position of the device, values in array are [x,y,z].
  92569. */
  92570. readonly position: Nullable<Float32Array>;
  92571. /**
  92572. * The linearVelocity of the device, values in array are [x,y,z].
  92573. */
  92574. readonly linearVelocity: Nullable<Float32Array>;
  92575. /**
  92576. * The linearAcceleration of the device, values in array are [x,y,z].
  92577. */
  92578. readonly linearAcceleration: Nullable<Float32Array>;
  92579. /**
  92580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92581. */
  92582. readonly orientation: Nullable<Float32Array>;
  92583. /**
  92584. * The angularVelocity of the device, values in array are [x,y,z].
  92585. */
  92586. readonly angularVelocity: Nullable<Float32Array>;
  92587. /**
  92588. * The angularAcceleration of the device, values in array are [x,y,z].
  92589. */
  92590. readonly angularAcceleration: Nullable<Float32Array>;
  92591. }
  92592. /**
  92593. * Interface representing a pose controlled object in Babylon.
  92594. * A pose controlled object has both regular pose values as well as pose values
  92595. * from an external device such as a VR head mounted display
  92596. */
  92597. export interface PoseControlled {
  92598. /**
  92599. * The position of the object in babylon space.
  92600. */
  92601. position: Vector3;
  92602. /**
  92603. * The rotation quaternion of the object in babylon space.
  92604. */
  92605. rotationQuaternion: Quaternion;
  92606. /**
  92607. * The position of the device in babylon space.
  92608. */
  92609. devicePosition?: Vector3;
  92610. /**
  92611. * The rotation quaternion of the device in babylon space.
  92612. */
  92613. deviceRotationQuaternion: Quaternion;
  92614. /**
  92615. * The raw pose coming from the device.
  92616. */
  92617. rawPose: Nullable<DevicePose>;
  92618. /**
  92619. * The scale of the device to be used when translating from device space to babylon space.
  92620. */
  92621. deviceScaleFactor: number;
  92622. /**
  92623. * Updates the poseControlled values based on the input device pose.
  92624. * @param poseData the pose data to update the object with
  92625. */
  92626. updateFromDevice(poseData: DevicePose): void;
  92627. }
  92628. /**
  92629. * Set of options to customize the webVRCamera
  92630. */
  92631. export interface WebVROptions {
  92632. /**
  92633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92634. */
  92635. trackPosition?: boolean;
  92636. /**
  92637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92638. */
  92639. positionScale?: number;
  92640. /**
  92641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92642. */
  92643. displayName?: string;
  92644. /**
  92645. * Should the native controller meshes be initialized. (default: true)
  92646. */
  92647. controllerMeshes?: boolean;
  92648. /**
  92649. * Creating a default HemiLight only on controllers. (default: true)
  92650. */
  92651. defaultLightingOnControllers?: boolean;
  92652. /**
  92653. * If you don't want to use the default VR button of the helper. (default: false)
  92654. */
  92655. useCustomVRButton?: boolean;
  92656. /**
  92657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92658. */
  92659. customVRButton?: HTMLButtonElement;
  92660. /**
  92661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92662. */
  92663. rayLength?: number;
  92664. /**
  92665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92666. */
  92667. defaultHeight?: number;
  92668. /**
  92669. * If multiview should be used if availible (default: false)
  92670. */
  92671. useMultiview?: boolean;
  92672. }
  92673. /**
  92674. * This represents a WebVR camera.
  92675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92676. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92677. */
  92678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92679. private webVROptions;
  92680. /**
  92681. * @hidden
  92682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92683. */
  92684. _vrDevice: any;
  92685. /**
  92686. * The rawPose of the vrDevice.
  92687. */
  92688. rawPose: Nullable<DevicePose>;
  92689. private _onVREnabled;
  92690. private _specsVersion;
  92691. private _attached;
  92692. private _frameData;
  92693. protected _descendants: Array<Node>;
  92694. private _deviceRoomPosition;
  92695. /** @hidden */
  92696. _deviceRoomRotationQuaternion: Quaternion;
  92697. private _standingMatrix;
  92698. /**
  92699. * Represents device position in babylon space.
  92700. */
  92701. devicePosition: Vector3;
  92702. /**
  92703. * Represents device rotation in babylon space.
  92704. */
  92705. deviceRotationQuaternion: Quaternion;
  92706. /**
  92707. * The scale of the device to be used when translating from device space to babylon space.
  92708. */
  92709. deviceScaleFactor: number;
  92710. private _deviceToWorld;
  92711. private _worldToDevice;
  92712. /**
  92713. * References to the webVR controllers for the vrDevice.
  92714. */
  92715. controllers: Array<WebVRController>;
  92716. /**
  92717. * Emits an event when a controller is attached.
  92718. */
  92719. onControllersAttachedObservable: Observable<WebVRController[]>;
  92720. /**
  92721. * Emits an event when a controller's mesh has been loaded;
  92722. */
  92723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92724. /**
  92725. * Emits an event when the HMD's pose has been updated.
  92726. */
  92727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92728. private _poseSet;
  92729. /**
  92730. * If the rig cameras be used as parent instead of this camera.
  92731. */
  92732. rigParenting: boolean;
  92733. private _lightOnControllers;
  92734. private _defaultHeight?;
  92735. /**
  92736. * Instantiates a WebVRFreeCamera.
  92737. * @param name The name of the WebVRFreeCamera
  92738. * @param position The starting anchor position for the camera
  92739. * @param scene The scene the camera belongs to
  92740. * @param webVROptions a set of customizable options for the webVRCamera
  92741. */
  92742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92743. /**
  92744. * Gets the device distance from the ground in meters.
  92745. * @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.
  92746. */
  92747. deviceDistanceToRoomGround(): number;
  92748. /**
  92749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92751. */
  92752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92753. /**
  92754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92755. * @returns A promise with a boolean set to if the standing matrix is supported.
  92756. */
  92757. useStandingMatrixAsync(): Promise<boolean>;
  92758. /**
  92759. * Disposes the camera
  92760. */
  92761. dispose(): void;
  92762. /**
  92763. * Gets a vrController by name.
  92764. * @param name The name of the controller to retreive
  92765. * @returns the controller matching the name specified or null if not found
  92766. */
  92767. getControllerByName(name: string): Nullable<WebVRController>;
  92768. private _leftController;
  92769. /**
  92770. * The controller corresponding to the users left hand.
  92771. */
  92772. get leftController(): Nullable<WebVRController>;
  92773. private _rightController;
  92774. /**
  92775. * The controller corresponding to the users right hand.
  92776. */
  92777. get rightController(): Nullable<WebVRController>;
  92778. /**
  92779. * Casts a ray forward from the vrCamera's gaze.
  92780. * @param length Length of the ray (default: 100)
  92781. * @returns the ray corresponding to the gaze
  92782. */
  92783. getForwardRay(length?: number): Ray;
  92784. /**
  92785. * @hidden
  92786. * Updates the camera based on device's frame data
  92787. */
  92788. _checkInputs(): void;
  92789. /**
  92790. * Updates the poseControlled values based on the input device pose.
  92791. * @param poseData Pose coming from the device
  92792. */
  92793. updateFromDevice(poseData: DevicePose): void;
  92794. private _htmlElementAttached;
  92795. private _detachIfAttached;
  92796. /**
  92797. * WebVR's attach control will start broadcasting frames to the device.
  92798. * Note that in certain browsers (chrome for example) this function must be called
  92799. * within a user-interaction callback. Example:
  92800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92801. *
  92802. * @param element html element to attach the vrDevice to
  92803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92804. */
  92805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92806. /**
  92807. * Detaches the camera from the html element and disables VR
  92808. *
  92809. * @param element html element to detach from
  92810. */
  92811. detachControl(element: HTMLElement): void;
  92812. /**
  92813. * @returns the name of this class
  92814. */
  92815. getClassName(): string;
  92816. /**
  92817. * Calls resetPose on the vrDisplay
  92818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92819. */
  92820. resetToCurrentRotation(): void;
  92821. /**
  92822. * @hidden
  92823. * Updates the rig cameras (left and right eye)
  92824. */
  92825. _updateRigCameras(): void;
  92826. private _workingVector;
  92827. private _oneVector;
  92828. private _workingMatrix;
  92829. private updateCacheCalled;
  92830. private _correctPositionIfNotTrackPosition;
  92831. /**
  92832. * @hidden
  92833. * Updates the cached values of the camera
  92834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92835. */
  92836. _updateCache(ignoreParentClass?: boolean): void;
  92837. /**
  92838. * @hidden
  92839. * Get current device position in babylon world
  92840. */
  92841. _computeDevicePosition(): void;
  92842. /**
  92843. * Updates the current device position and rotation in the babylon world
  92844. */
  92845. update(): void;
  92846. /**
  92847. * @hidden
  92848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92849. * @returns an identity matrix
  92850. */
  92851. _getViewMatrix(): Matrix;
  92852. private _tmpMatrix;
  92853. /**
  92854. * This function is called by the two RIG cameras.
  92855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92856. * @hidden
  92857. */
  92858. _getWebVRViewMatrix(): Matrix;
  92859. /** @hidden */
  92860. _getWebVRProjectionMatrix(): Matrix;
  92861. private _onGamepadConnectedObserver;
  92862. private _onGamepadDisconnectedObserver;
  92863. private _updateCacheWhenTrackingDisabledObserver;
  92864. /**
  92865. * Initializes the controllers and their meshes
  92866. */
  92867. initControllers(): void;
  92868. }
  92869. }
  92870. declare module BABYLON {
  92871. /**
  92872. * Size options for a post process
  92873. */
  92874. export type PostProcessOptions = {
  92875. width: number;
  92876. height: number;
  92877. };
  92878. /**
  92879. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92880. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92881. */
  92882. export class PostProcess {
  92883. /** Name of the PostProcess. */
  92884. name: string;
  92885. /**
  92886. * Gets or sets the unique id of the post process
  92887. */
  92888. uniqueId: number;
  92889. /**
  92890. * Width of the texture to apply the post process on
  92891. */
  92892. width: number;
  92893. /**
  92894. * Height of the texture to apply the post process on
  92895. */
  92896. height: number;
  92897. /**
  92898. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92899. * @hidden
  92900. */
  92901. _outputTexture: Nullable<InternalTexture>;
  92902. /**
  92903. * Sampling mode used by the shader
  92904. * See https://doc.babylonjs.com/classes/3.1/texture
  92905. */
  92906. renderTargetSamplingMode: number;
  92907. /**
  92908. * Clear color to use when screen clearing
  92909. */
  92910. clearColor: Color4;
  92911. /**
  92912. * If the buffer needs to be cleared before applying the post process. (default: true)
  92913. * Should be set to false if shader will overwrite all previous pixels.
  92914. */
  92915. autoClear: boolean;
  92916. /**
  92917. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92918. */
  92919. alphaMode: number;
  92920. /**
  92921. * Sets the setAlphaBlendConstants of the babylon engine
  92922. */
  92923. alphaConstants: Color4;
  92924. /**
  92925. * Animations to be used for the post processing
  92926. */
  92927. animations: Animation[];
  92928. /**
  92929. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92930. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92931. */
  92932. enablePixelPerfectMode: boolean;
  92933. /**
  92934. * Force the postprocess to be applied without taking in account viewport
  92935. */
  92936. forceFullscreenViewport: boolean;
  92937. /**
  92938. * List of inspectable custom properties (used by the Inspector)
  92939. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92940. */
  92941. inspectableCustomProperties: IInspectable[];
  92942. /**
  92943. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92944. *
  92945. * | Value | Type | Description |
  92946. * | ----- | ----------------------------------- | ----------- |
  92947. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92948. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92949. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92950. *
  92951. */
  92952. scaleMode: number;
  92953. /**
  92954. * Force textures to be a power of two (default: false)
  92955. */
  92956. alwaysForcePOT: boolean;
  92957. private _samples;
  92958. /**
  92959. * Number of sample textures (default: 1)
  92960. */
  92961. get samples(): number;
  92962. set samples(n: number);
  92963. /**
  92964. * Modify the scale of the post process to be the same as the viewport (default: false)
  92965. */
  92966. adaptScaleToCurrentViewport: boolean;
  92967. private _camera;
  92968. private _scene;
  92969. private _engine;
  92970. private _options;
  92971. private _reusable;
  92972. private _textureType;
  92973. private _textureFormat;
  92974. /**
  92975. * Smart array of input and output textures for the post process.
  92976. * @hidden
  92977. */
  92978. _textures: SmartArray<InternalTexture>;
  92979. /**
  92980. * The index in _textures that corresponds to the output texture.
  92981. * @hidden
  92982. */
  92983. _currentRenderTextureInd: number;
  92984. private _effect;
  92985. private _samplers;
  92986. private _fragmentUrl;
  92987. private _vertexUrl;
  92988. private _parameters;
  92989. private _scaleRatio;
  92990. protected _indexParameters: any;
  92991. private _shareOutputWithPostProcess;
  92992. private _texelSize;
  92993. private _forcedOutputTexture;
  92994. /**
  92995. * Returns the fragment url or shader name used in the post process.
  92996. * @returns the fragment url or name in the shader store.
  92997. */
  92998. getEffectName(): string;
  92999. /**
  93000. * An event triggered when the postprocess is activated.
  93001. */
  93002. onActivateObservable: Observable<Camera>;
  93003. private _onActivateObserver;
  93004. /**
  93005. * A function that is added to the onActivateObservable
  93006. */
  93007. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93008. /**
  93009. * An event triggered when the postprocess changes its size.
  93010. */
  93011. onSizeChangedObservable: Observable<PostProcess>;
  93012. private _onSizeChangedObserver;
  93013. /**
  93014. * A function that is added to the onSizeChangedObservable
  93015. */
  93016. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93017. /**
  93018. * An event triggered when the postprocess applies its effect.
  93019. */
  93020. onApplyObservable: Observable<Effect>;
  93021. private _onApplyObserver;
  93022. /**
  93023. * A function that is added to the onApplyObservable
  93024. */
  93025. set onApply(callback: (effect: Effect) => void);
  93026. /**
  93027. * An event triggered before rendering the postprocess
  93028. */
  93029. onBeforeRenderObservable: Observable<Effect>;
  93030. private _onBeforeRenderObserver;
  93031. /**
  93032. * A function that is added to the onBeforeRenderObservable
  93033. */
  93034. set onBeforeRender(callback: (effect: Effect) => void);
  93035. /**
  93036. * An event triggered after rendering the postprocess
  93037. */
  93038. onAfterRenderObservable: Observable<Effect>;
  93039. private _onAfterRenderObserver;
  93040. /**
  93041. * A function that is added to the onAfterRenderObservable
  93042. */
  93043. set onAfterRender(callback: (efect: Effect) => void);
  93044. /**
  93045. * 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
  93046. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93047. */
  93048. get inputTexture(): InternalTexture;
  93049. set inputTexture(value: InternalTexture);
  93050. /**
  93051. * Gets the camera which post process is applied to.
  93052. * @returns The camera the post process is applied to.
  93053. */
  93054. getCamera(): Camera;
  93055. /**
  93056. * Gets the texel size of the postprocess.
  93057. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93058. */
  93059. get texelSize(): Vector2;
  93060. /**
  93061. * Creates a new instance PostProcess
  93062. * @param name The name of the PostProcess.
  93063. * @param fragmentUrl The url of the fragment shader to be used.
  93064. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93065. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93067. * @param camera The camera to apply the render pass to.
  93068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93069. * @param engine The engine which the post process will be applied. (default: current engine)
  93070. * @param reusable If the post process can be reused on the same frame. (default: false)
  93071. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93072. * @param textureType Type of textures used when performing the post process. (default: 0)
  93073. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93074. * @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
  93075. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93076. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93077. */
  93078. constructor(
  93079. /** Name of the PostProcess. */
  93080. 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, textureFormat?: number);
  93081. /**
  93082. * Gets a string idenfifying the name of the class
  93083. * @returns "PostProcess" string
  93084. */
  93085. getClassName(): string;
  93086. /**
  93087. * Gets the engine which this post process belongs to.
  93088. * @returns The engine the post process was enabled with.
  93089. */
  93090. getEngine(): Engine;
  93091. /**
  93092. * The effect that is created when initializing the post process.
  93093. * @returns The created effect corresponding the the postprocess.
  93094. */
  93095. getEffect(): Effect;
  93096. /**
  93097. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93098. * @param postProcess The post process to share the output with.
  93099. * @returns This post process.
  93100. */
  93101. shareOutputWith(postProcess: PostProcess): PostProcess;
  93102. /**
  93103. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93104. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93105. */
  93106. useOwnOutput(): void;
  93107. /**
  93108. * Updates the effect with the current post process compile time values and recompiles the shader.
  93109. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93110. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93111. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93112. * @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
  93113. * @param onCompiled Called when the shader has been compiled.
  93114. * @param onError Called if there is an error when compiling a shader.
  93115. */
  93116. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93117. /**
  93118. * The post process is reusable if it can be used multiple times within one frame.
  93119. * @returns If the post process is reusable
  93120. */
  93121. isReusable(): boolean;
  93122. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93123. markTextureDirty(): void;
  93124. /**
  93125. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93126. * 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.
  93127. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93128. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93129. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93130. * @returns The target texture that was bound to be written to.
  93131. */
  93132. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93133. /**
  93134. * If the post process is supported.
  93135. */
  93136. get isSupported(): boolean;
  93137. /**
  93138. * The aspect ratio of the output texture.
  93139. */
  93140. get aspectRatio(): number;
  93141. /**
  93142. * Get a value indicating if the post-process is ready to be used
  93143. * @returns true if the post-process is ready (shader is compiled)
  93144. */
  93145. isReady(): boolean;
  93146. /**
  93147. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93148. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93149. */
  93150. apply(): Nullable<Effect>;
  93151. private _disposeTextures;
  93152. /**
  93153. * Disposes the post process.
  93154. * @param camera The camera to dispose the post process on.
  93155. */
  93156. dispose(camera?: Camera): void;
  93157. }
  93158. }
  93159. declare module BABYLON {
  93160. /** @hidden */
  93161. export var kernelBlurVaryingDeclaration: {
  93162. name: string;
  93163. shader: string;
  93164. };
  93165. }
  93166. declare module BABYLON {
  93167. /** @hidden */
  93168. export var kernelBlurFragment: {
  93169. name: string;
  93170. shader: string;
  93171. };
  93172. }
  93173. declare module BABYLON {
  93174. /** @hidden */
  93175. export var kernelBlurFragment2: {
  93176. name: string;
  93177. shader: string;
  93178. };
  93179. }
  93180. declare module BABYLON {
  93181. /** @hidden */
  93182. export var kernelBlurPixelShader: {
  93183. name: string;
  93184. shader: string;
  93185. };
  93186. }
  93187. declare module BABYLON {
  93188. /** @hidden */
  93189. export var kernelBlurVertex: {
  93190. name: string;
  93191. shader: string;
  93192. };
  93193. }
  93194. declare module BABYLON {
  93195. /** @hidden */
  93196. export var kernelBlurVertexShader: {
  93197. name: string;
  93198. shader: string;
  93199. };
  93200. }
  93201. declare module BABYLON {
  93202. /**
  93203. * The Blur Post Process which blurs an image based on a kernel and direction.
  93204. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93205. */
  93206. export class BlurPostProcess extends PostProcess {
  93207. /** The direction in which to blur the image. */
  93208. direction: Vector2;
  93209. private blockCompilation;
  93210. protected _kernel: number;
  93211. protected _idealKernel: number;
  93212. protected _packedFloat: boolean;
  93213. private _staticDefines;
  93214. /**
  93215. * Sets the length in pixels of the blur sample region
  93216. */
  93217. set kernel(v: number);
  93218. /**
  93219. * Gets the length in pixels of the blur sample region
  93220. */
  93221. get kernel(): number;
  93222. /**
  93223. * Sets wether or not the blur needs to unpack/repack floats
  93224. */
  93225. set packedFloat(v: boolean);
  93226. /**
  93227. * Gets wether or not the blur is unpacking/repacking floats
  93228. */
  93229. get packedFloat(): boolean;
  93230. /**
  93231. * Creates a new instance BlurPostProcess
  93232. * @param name The name of the effect.
  93233. * @param direction The direction in which to blur the image.
  93234. * @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.
  93235. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93236. * @param camera The camera to apply the render pass to.
  93237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93238. * @param engine The engine which the post process will be applied. (default: current engine)
  93239. * @param reusable If the post process can be reused on the same frame. (default: false)
  93240. * @param textureType Type of textures used when performing the post process. (default: 0)
  93241. * @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)
  93242. */
  93243. constructor(name: string,
  93244. /** The direction in which to blur the image. */
  93245. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93246. /**
  93247. * Updates the effect with the current post process compile time values and recompiles the shader.
  93248. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93249. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93250. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93251. * @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
  93252. * @param onCompiled Called when the shader has been compiled.
  93253. * @param onError Called if there is an error when compiling a shader.
  93254. */
  93255. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93256. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93257. /**
  93258. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93259. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93260. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93261. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93262. * The gaps between physical kernels are compensated for in the weighting of the samples
  93263. * @param idealKernel Ideal blur kernel.
  93264. * @return Nearest best kernel.
  93265. */
  93266. protected _nearestBestKernel(idealKernel: number): number;
  93267. /**
  93268. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93269. * @param x The point on the Gaussian distribution to sample.
  93270. * @return the value of the Gaussian function at x.
  93271. */
  93272. protected _gaussianWeight(x: number): number;
  93273. /**
  93274. * Generates a string that can be used as a floating point number in GLSL.
  93275. * @param x Value to print.
  93276. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93277. * @return GLSL float string.
  93278. */
  93279. protected _glslFloat(x: number, decimalFigures?: number): string;
  93280. }
  93281. }
  93282. declare module BABYLON {
  93283. /**
  93284. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93285. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93286. * You can then easily use it as a reflectionTexture on a flat surface.
  93287. * In case the surface is not a plane, please consider relying on reflection probes.
  93288. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93289. */
  93290. export class MirrorTexture extends RenderTargetTexture {
  93291. private scene;
  93292. /**
  93293. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93294. * 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.
  93295. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93296. */
  93297. mirrorPlane: Plane;
  93298. /**
  93299. * Define the blur ratio used to blur the reflection if needed.
  93300. */
  93301. set blurRatio(value: number);
  93302. get blurRatio(): number;
  93303. /**
  93304. * Define the adaptive blur kernel used to blur the reflection if needed.
  93305. * This will autocompute the closest best match for the `blurKernel`
  93306. */
  93307. set adaptiveBlurKernel(value: number);
  93308. /**
  93309. * Define the blur kernel used to blur the reflection if needed.
  93310. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93311. */
  93312. set blurKernel(value: number);
  93313. /**
  93314. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93316. */
  93317. set blurKernelX(value: number);
  93318. get blurKernelX(): number;
  93319. /**
  93320. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93321. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93322. */
  93323. set blurKernelY(value: number);
  93324. get blurKernelY(): number;
  93325. private _autoComputeBlurKernel;
  93326. protected _onRatioRescale(): void;
  93327. private _updateGammaSpace;
  93328. private _imageProcessingConfigChangeObserver;
  93329. private _transformMatrix;
  93330. private _mirrorMatrix;
  93331. private _savedViewMatrix;
  93332. private _blurX;
  93333. private _blurY;
  93334. private _adaptiveBlurKernel;
  93335. private _blurKernelX;
  93336. private _blurKernelY;
  93337. private _blurRatio;
  93338. /**
  93339. * Instantiates a Mirror Texture.
  93340. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93341. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93342. * You can then easily use it as a reflectionTexture on a flat surface.
  93343. * In case the surface is not a plane, please consider relying on reflection probes.
  93344. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93345. * @param name
  93346. * @param size
  93347. * @param scene
  93348. * @param generateMipMaps
  93349. * @param type
  93350. * @param samplingMode
  93351. * @param generateDepthBuffer
  93352. */
  93353. constructor(name: string, size: number | {
  93354. width: number;
  93355. height: number;
  93356. } | {
  93357. ratio: number;
  93358. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93359. private _preparePostProcesses;
  93360. /**
  93361. * Clone the mirror texture.
  93362. * @returns the cloned texture
  93363. */
  93364. clone(): MirrorTexture;
  93365. /**
  93366. * Serialize the texture to a JSON representation you could use in Parse later on
  93367. * @returns the serialized JSON representation
  93368. */
  93369. serialize(): any;
  93370. /**
  93371. * Dispose the texture and release its associated resources.
  93372. */
  93373. dispose(): void;
  93374. }
  93375. }
  93376. declare module BABYLON {
  93377. /**
  93378. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93379. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93380. */
  93381. export class Texture extends BaseTexture {
  93382. /**
  93383. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93384. */
  93385. static SerializeBuffers: boolean;
  93386. /** @hidden */
  93387. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93388. /** @hidden */
  93389. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93390. /** @hidden */
  93391. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93392. /** nearest is mag = nearest and min = nearest and mip = linear */
  93393. static readonly NEAREST_SAMPLINGMODE: number;
  93394. /** nearest is mag = nearest and min = nearest and mip = linear */
  93395. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93396. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93397. static readonly BILINEAR_SAMPLINGMODE: number;
  93398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93399. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93400. /** Trilinear is mag = linear and min = linear and mip = linear */
  93401. static readonly TRILINEAR_SAMPLINGMODE: number;
  93402. /** Trilinear is mag = linear and min = linear and mip = linear */
  93403. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93404. /** mag = nearest and min = nearest and mip = nearest */
  93405. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93406. /** mag = nearest and min = linear and mip = nearest */
  93407. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93408. /** mag = nearest and min = linear and mip = linear */
  93409. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93410. /** mag = nearest and min = linear and mip = none */
  93411. static readonly NEAREST_LINEAR: number;
  93412. /** mag = nearest and min = nearest and mip = none */
  93413. static readonly NEAREST_NEAREST: number;
  93414. /** mag = linear and min = nearest and mip = nearest */
  93415. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93416. /** mag = linear and min = nearest and mip = linear */
  93417. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93418. /** mag = linear and min = linear and mip = none */
  93419. static readonly LINEAR_LINEAR: number;
  93420. /** mag = linear and min = nearest and mip = none */
  93421. static readonly LINEAR_NEAREST: number;
  93422. /** Explicit coordinates mode */
  93423. static readonly EXPLICIT_MODE: number;
  93424. /** Spherical coordinates mode */
  93425. static readonly SPHERICAL_MODE: number;
  93426. /** Planar coordinates mode */
  93427. static readonly PLANAR_MODE: number;
  93428. /** Cubic coordinates mode */
  93429. static readonly CUBIC_MODE: number;
  93430. /** Projection coordinates mode */
  93431. static readonly PROJECTION_MODE: number;
  93432. /** Inverse Cubic coordinates mode */
  93433. static readonly SKYBOX_MODE: number;
  93434. /** Inverse Cubic coordinates mode */
  93435. static readonly INVCUBIC_MODE: number;
  93436. /** Equirectangular coordinates mode */
  93437. static readonly EQUIRECTANGULAR_MODE: number;
  93438. /** Equirectangular Fixed coordinates mode */
  93439. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93440. /** Equirectangular Fixed Mirrored coordinates mode */
  93441. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93442. /** Texture is not repeating outside of 0..1 UVs */
  93443. static readonly CLAMP_ADDRESSMODE: number;
  93444. /** Texture is repeating outside of 0..1 UVs */
  93445. static readonly WRAP_ADDRESSMODE: number;
  93446. /** Texture is repeating and mirrored */
  93447. static readonly MIRROR_ADDRESSMODE: number;
  93448. /**
  93449. * 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
  93450. */
  93451. static UseSerializedUrlIfAny: boolean;
  93452. /**
  93453. * Define the url of the texture.
  93454. */
  93455. url: Nullable<string>;
  93456. /**
  93457. * Define an offset on the texture to offset the u coordinates of the UVs
  93458. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93459. */
  93460. uOffset: number;
  93461. /**
  93462. * Define an offset on the texture to offset the v coordinates of the UVs
  93463. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93464. */
  93465. vOffset: number;
  93466. /**
  93467. * Define an offset on the texture to scale the u coordinates of the UVs
  93468. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93469. */
  93470. uScale: number;
  93471. /**
  93472. * Define an offset on the texture to scale the v coordinates of the UVs
  93473. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93474. */
  93475. vScale: number;
  93476. /**
  93477. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93478. * @see http://doc.babylonjs.com/how_to/more_materials
  93479. */
  93480. uAng: number;
  93481. /**
  93482. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93483. * @see http://doc.babylonjs.com/how_to/more_materials
  93484. */
  93485. vAng: number;
  93486. /**
  93487. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93488. * @see http://doc.babylonjs.com/how_to/more_materials
  93489. */
  93490. wAng: number;
  93491. /**
  93492. * Defines the center of rotation (U)
  93493. */
  93494. uRotationCenter: number;
  93495. /**
  93496. * Defines the center of rotation (V)
  93497. */
  93498. vRotationCenter: number;
  93499. /**
  93500. * Defines the center of rotation (W)
  93501. */
  93502. wRotationCenter: number;
  93503. /**
  93504. * Are mip maps generated for this texture or not.
  93505. */
  93506. get noMipmap(): boolean;
  93507. /**
  93508. * List of inspectable custom properties (used by the Inspector)
  93509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93510. */
  93511. inspectableCustomProperties: Nullable<IInspectable[]>;
  93512. private _noMipmap;
  93513. /** @hidden */
  93514. _invertY: boolean;
  93515. private _rowGenerationMatrix;
  93516. private _cachedTextureMatrix;
  93517. private _projectionModeMatrix;
  93518. private _t0;
  93519. private _t1;
  93520. private _t2;
  93521. private _cachedUOffset;
  93522. private _cachedVOffset;
  93523. private _cachedUScale;
  93524. private _cachedVScale;
  93525. private _cachedUAng;
  93526. private _cachedVAng;
  93527. private _cachedWAng;
  93528. private _cachedProjectionMatrixId;
  93529. private _cachedCoordinatesMode;
  93530. /** @hidden */
  93531. protected _initialSamplingMode: number;
  93532. /** @hidden */
  93533. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93534. private _deleteBuffer;
  93535. protected _format: Nullable<number>;
  93536. private _delayedOnLoad;
  93537. private _delayedOnError;
  93538. private _mimeType?;
  93539. /**
  93540. * Observable triggered once the texture has been loaded.
  93541. */
  93542. onLoadObservable: Observable<Texture>;
  93543. protected _isBlocking: boolean;
  93544. /**
  93545. * Is the texture preventing material to render while loading.
  93546. * If false, a default texture will be used instead of the loading one during the preparation step.
  93547. */
  93548. set isBlocking(value: boolean);
  93549. get isBlocking(): boolean;
  93550. /**
  93551. * Get the current sampling mode associated with the texture.
  93552. */
  93553. get samplingMode(): number;
  93554. /**
  93555. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93556. */
  93557. get invertY(): boolean;
  93558. /**
  93559. * Instantiates a new texture.
  93560. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93561. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93562. * @param url defines the url of the picture to load as a texture
  93563. * @param scene defines the scene or engine the texture will belong to
  93564. * @param noMipmap defines if the texture will require mip maps or not
  93565. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93566. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93567. * @param onLoad defines a callback triggered when the texture has been loaded
  93568. * @param onError defines a callback triggered when an error occurred during the loading session
  93569. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93570. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93571. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93572. * @param mimeType defines an optional mime type information
  93573. */
  93574. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  93575. /**
  93576. * Update the url (and optional buffer) of this texture if url was null during construction.
  93577. * @param url the url of the texture
  93578. * @param buffer the buffer of the texture (defaults to null)
  93579. * @param onLoad callback called when the texture is loaded (defaults to null)
  93580. */
  93581. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93582. /**
  93583. * Finish the loading sequence of a texture flagged as delayed load.
  93584. * @hidden
  93585. */
  93586. delayLoad(): void;
  93587. private _prepareRowForTextureGeneration;
  93588. /**
  93589. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93590. * @returns the transform matrix of the texture.
  93591. */
  93592. getTextureMatrix(uBase?: number): Matrix;
  93593. /**
  93594. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93595. * @returns The reflection texture transform
  93596. */
  93597. getReflectionTextureMatrix(): Matrix;
  93598. /**
  93599. * Clones the texture.
  93600. * @returns the cloned texture
  93601. */
  93602. clone(): Texture;
  93603. /**
  93604. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93605. * @returns The JSON representation of the texture
  93606. */
  93607. serialize(): any;
  93608. /**
  93609. * Get the current class name of the texture useful for serialization or dynamic coding.
  93610. * @returns "Texture"
  93611. */
  93612. getClassName(): string;
  93613. /**
  93614. * Dispose the texture and release its associated resources.
  93615. */
  93616. dispose(): void;
  93617. /**
  93618. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93619. * @param parsedTexture Define the JSON representation of the texture
  93620. * @param scene Define the scene the parsed texture should be instantiated in
  93621. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93622. * @returns The parsed texture if successful
  93623. */
  93624. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93625. /**
  93626. * Creates a texture from its base 64 representation.
  93627. * @param data Define the base64 payload without the data: prefix
  93628. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93629. * @param scene Define the scene the texture should belong to
  93630. * @param noMipmap Forces the texture to not create mip map information if true
  93631. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93632. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93633. * @param onLoad define a callback triggered when the texture has been loaded
  93634. * @param onError define a callback triggered when an error occurred during the loading session
  93635. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93636. * @returns the created texture
  93637. */
  93638. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93639. /**
  93640. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93641. * @param data Define the base64 payload without the data: prefix
  93642. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93643. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93644. * @param scene Define the scene the texture should belong to
  93645. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93646. * @param noMipmap Forces the texture to not create mip map information if true
  93647. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93648. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93649. * @param onLoad define a callback triggered when the texture has been loaded
  93650. * @param onError define a callback triggered when an error occurred during the loading session
  93651. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93652. * @returns the created texture
  93653. */
  93654. 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;
  93655. }
  93656. }
  93657. declare module BABYLON {
  93658. /**
  93659. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93660. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93661. */
  93662. export class PostProcessManager {
  93663. private _scene;
  93664. private _indexBuffer;
  93665. private _vertexBuffers;
  93666. /**
  93667. * Creates a new instance PostProcess
  93668. * @param scene The scene that the post process is associated with.
  93669. */
  93670. constructor(scene: Scene);
  93671. private _prepareBuffers;
  93672. private _buildIndexBuffer;
  93673. /**
  93674. * Rebuilds the vertex buffers of the manager.
  93675. * @hidden
  93676. */
  93677. _rebuild(): void;
  93678. /**
  93679. * Prepares a frame to be run through a post process.
  93680. * @param sourceTexture The input texture to the post procesess. (default: null)
  93681. * @param postProcesses An array of post processes to be run. (default: null)
  93682. * @returns True if the post processes were able to be run.
  93683. * @hidden
  93684. */
  93685. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93686. /**
  93687. * Manually render a set of post processes to a texture.
  93688. * @param postProcesses An array of post processes to be run.
  93689. * @param targetTexture The target texture to render to.
  93690. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93691. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93692. * @param lodLevel defines which lod of the texture to render to
  93693. */
  93694. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93695. /**
  93696. * Finalize the result of the output of the postprocesses.
  93697. * @param doNotPresent If true the result will not be displayed to the screen.
  93698. * @param targetTexture The target texture to render to.
  93699. * @param faceIndex The index of the face to bind the target texture to.
  93700. * @param postProcesses The array of post processes to render.
  93701. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93702. * @hidden
  93703. */
  93704. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93705. /**
  93706. * Disposes of the post process manager.
  93707. */
  93708. dispose(): void;
  93709. }
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * This Helps creating a texture that will be created from a camera in your scene.
  93714. * It is basically a dynamic texture that could be used to create special effects for instance.
  93715. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93716. */
  93717. export class RenderTargetTexture extends Texture {
  93718. isCube: boolean;
  93719. /**
  93720. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93721. */
  93722. static readonly REFRESHRATE_RENDER_ONCE: number;
  93723. /**
  93724. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93725. */
  93726. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93727. /**
  93728. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93729. * the central point of your effect and can save a lot of performances.
  93730. */
  93731. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93732. /**
  93733. * Use this predicate to dynamically define the list of mesh you want to render.
  93734. * If set, the renderList property will be overwritten.
  93735. */
  93736. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93737. private _renderList;
  93738. /**
  93739. * Use this list to define the list of mesh you want to render.
  93740. */
  93741. get renderList(): Nullable<Array<AbstractMesh>>;
  93742. set renderList(value: Nullable<Array<AbstractMesh>>);
  93743. /**
  93744. * Use this function to overload the renderList array at rendering time.
  93745. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93746. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93747. * the cube (if the RTT is a cube, else layerOrFace=0).
  93748. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93749. */
  93750. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93751. private _hookArray;
  93752. /**
  93753. * Define if particles should be rendered in your texture.
  93754. */
  93755. renderParticles: boolean;
  93756. /**
  93757. * Define if sprites should be rendered in your texture.
  93758. */
  93759. renderSprites: boolean;
  93760. /**
  93761. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93762. */
  93763. coordinatesMode: number;
  93764. /**
  93765. * Define the camera used to render the texture.
  93766. */
  93767. activeCamera: Nullable<Camera>;
  93768. /**
  93769. * Override the render function of the texture with your own one.
  93770. */
  93771. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93772. /**
  93773. * Define if camera post processes should be use while rendering the texture.
  93774. */
  93775. useCameraPostProcesses: boolean;
  93776. /**
  93777. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93778. */
  93779. ignoreCameraViewport: boolean;
  93780. private _postProcessManager;
  93781. private _postProcesses;
  93782. private _resizeObserver;
  93783. /**
  93784. * An event triggered when the texture is unbind.
  93785. */
  93786. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93787. /**
  93788. * An event triggered when the texture is unbind.
  93789. */
  93790. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93791. private _onAfterUnbindObserver;
  93792. /**
  93793. * Set a after unbind callback in the texture.
  93794. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93795. */
  93796. set onAfterUnbind(callback: () => void);
  93797. /**
  93798. * An event triggered before rendering the texture
  93799. */
  93800. onBeforeRenderObservable: Observable<number>;
  93801. private _onBeforeRenderObserver;
  93802. /**
  93803. * Set a before render callback in the texture.
  93804. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93805. */
  93806. set onBeforeRender(callback: (faceIndex: number) => void);
  93807. /**
  93808. * An event triggered after rendering the texture
  93809. */
  93810. onAfterRenderObservable: Observable<number>;
  93811. private _onAfterRenderObserver;
  93812. /**
  93813. * Set a after render callback in the texture.
  93814. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93815. */
  93816. set onAfterRender(callback: (faceIndex: number) => void);
  93817. /**
  93818. * An event triggered after the texture clear
  93819. */
  93820. onClearObservable: Observable<Engine>;
  93821. private _onClearObserver;
  93822. /**
  93823. * Set a clear callback in the texture.
  93824. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93825. */
  93826. set onClear(callback: (Engine: Engine) => void);
  93827. /**
  93828. * An event triggered when the texture is resized.
  93829. */
  93830. onResizeObservable: Observable<RenderTargetTexture>;
  93831. /**
  93832. * Define the clear color of the Render Target if it should be different from the scene.
  93833. */
  93834. clearColor: Color4;
  93835. protected _size: number | {
  93836. width: number;
  93837. height: number;
  93838. layers?: number;
  93839. };
  93840. protected _initialSizeParameter: number | {
  93841. width: number;
  93842. height: number;
  93843. } | {
  93844. ratio: number;
  93845. };
  93846. protected _sizeRatio: Nullable<number>;
  93847. /** @hidden */
  93848. _generateMipMaps: boolean;
  93849. protected _renderingManager: RenderingManager;
  93850. /** @hidden */
  93851. _waitingRenderList: string[];
  93852. protected _doNotChangeAspectRatio: boolean;
  93853. protected _currentRefreshId: number;
  93854. protected _refreshRate: number;
  93855. protected _textureMatrix: Matrix;
  93856. protected _samples: number;
  93857. protected _renderTargetOptions: RenderTargetCreationOptions;
  93858. /**
  93859. * Gets render target creation options that were used.
  93860. */
  93861. get renderTargetOptions(): RenderTargetCreationOptions;
  93862. protected _engine: Engine;
  93863. protected _onRatioRescale(): void;
  93864. /**
  93865. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93866. * It must define where the camera used to render the texture is set
  93867. */
  93868. boundingBoxPosition: Vector3;
  93869. private _boundingBoxSize;
  93870. /**
  93871. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93872. * When defined, the cubemap will switch to local mode
  93873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93874. * @example https://www.babylonjs-playground.com/#RNASML
  93875. */
  93876. set boundingBoxSize(value: Vector3);
  93877. get boundingBoxSize(): Vector3;
  93878. /**
  93879. * In case the RTT has been created with a depth texture, get the associated
  93880. * depth texture.
  93881. * Otherwise, return null.
  93882. */
  93883. get depthStencilTexture(): Nullable<InternalTexture>;
  93884. /**
  93885. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93886. * or used a shadow, depth texture...
  93887. * @param name The friendly name of the texture
  93888. * @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)
  93889. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93890. * @param generateMipMaps True if mip maps need to be generated after render.
  93891. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93892. * @param type The type of the buffer in the RTT (int, half float, float...)
  93893. * @param isCube True if a cube texture needs to be created
  93894. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93895. * @param generateDepthBuffer True to generate a depth buffer
  93896. * @param generateStencilBuffer True to generate a stencil buffer
  93897. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93898. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93899. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93900. */
  93901. constructor(name: string, size: number | {
  93902. width: number;
  93903. height: number;
  93904. layers?: number;
  93905. } | {
  93906. ratio: number;
  93907. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93908. /**
  93909. * Creates a depth stencil texture.
  93910. * This is only available in WebGL 2 or with the depth texture extension available.
  93911. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93912. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93913. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93914. */
  93915. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93916. private _processSizeParameter;
  93917. /**
  93918. * Define the number of samples to use in case of MSAA.
  93919. * It defaults to one meaning no MSAA has been enabled.
  93920. */
  93921. get samples(): number;
  93922. set samples(value: number);
  93923. /**
  93924. * Resets the refresh counter of the texture and start bak from scratch.
  93925. * Could be useful to regenerate the texture if it is setup to render only once.
  93926. */
  93927. resetRefreshCounter(): void;
  93928. /**
  93929. * Define the refresh rate of the texture or the rendering frequency.
  93930. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93931. */
  93932. get refreshRate(): number;
  93933. set refreshRate(value: number);
  93934. /**
  93935. * Adds a post process to the render target rendering passes.
  93936. * @param postProcess define the post process to add
  93937. */
  93938. addPostProcess(postProcess: PostProcess): void;
  93939. /**
  93940. * Clear all the post processes attached to the render target
  93941. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93942. */
  93943. clearPostProcesses(dispose?: boolean): void;
  93944. /**
  93945. * Remove one of the post process from the list of attached post processes to the texture
  93946. * @param postProcess define the post process to remove from the list
  93947. */
  93948. removePostProcess(postProcess: PostProcess): void;
  93949. /** @hidden */
  93950. _shouldRender(): boolean;
  93951. /**
  93952. * Gets the actual render size of the texture.
  93953. * @returns the width of the render size
  93954. */
  93955. getRenderSize(): number;
  93956. /**
  93957. * Gets the actual render width of the texture.
  93958. * @returns the width of the render size
  93959. */
  93960. getRenderWidth(): number;
  93961. /**
  93962. * Gets the actual render height of the texture.
  93963. * @returns the height of the render size
  93964. */
  93965. getRenderHeight(): number;
  93966. /**
  93967. * Gets the actual number of layers of the texture.
  93968. * @returns the number of layers
  93969. */
  93970. getRenderLayers(): number;
  93971. /**
  93972. * Get if the texture can be rescaled or not.
  93973. */
  93974. get canRescale(): boolean;
  93975. /**
  93976. * Resize the texture using a ratio.
  93977. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93978. */
  93979. scale(ratio: number): void;
  93980. /**
  93981. * Get the texture reflection matrix used to rotate/transform the reflection.
  93982. * @returns the reflection matrix
  93983. */
  93984. getReflectionTextureMatrix(): Matrix;
  93985. /**
  93986. * Resize the texture to a new desired size.
  93987. * Be carrefull as it will recreate all the data in the new texture.
  93988. * @param size Define the new size. It can be:
  93989. * - a number for squared texture,
  93990. * - an object containing { width: number, height: number }
  93991. * - or an object containing a ratio { ratio: number }
  93992. */
  93993. resize(size: number | {
  93994. width: number;
  93995. height: number;
  93996. } | {
  93997. ratio: number;
  93998. }): void;
  93999. private _defaultRenderListPrepared;
  94000. /**
  94001. * Renders all the objects from the render list into the texture.
  94002. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94003. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94004. */
  94005. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94006. private _bestReflectionRenderTargetDimension;
  94007. private _prepareRenderingManager;
  94008. /**
  94009. * @hidden
  94010. * @param faceIndex face index to bind to if this is a cubetexture
  94011. * @param layer defines the index of the texture to bind in the array
  94012. */
  94013. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94014. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94015. private renderToTarget;
  94016. /**
  94017. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94018. * This allowed control for front to back rendering or reversly depending of the special needs.
  94019. *
  94020. * @param renderingGroupId The rendering group id corresponding to its index
  94021. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94022. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94023. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94024. */
  94025. 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;
  94026. /**
  94027. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94028. *
  94029. * @param renderingGroupId The rendering group id corresponding to its index
  94030. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94031. */
  94032. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94033. /**
  94034. * Clones the texture.
  94035. * @returns the cloned texture
  94036. */
  94037. clone(): RenderTargetTexture;
  94038. /**
  94039. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94040. * @returns The JSON representation of the texture
  94041. */
  94042. serialize(): any;
  94043. /**
  94044. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94045. */
  94046. disposeFramebufferObjects(): void;
  94047. /**
  94048. * Dispose the texture and release its associated resources.
  94049. */
  94050. dispose(): void;
  94051. /** @hidden */
  94052. _rebuild(): void;
  94053. /**
  94054. * Clear the info related to rendering groups preventing retention point in material dispose.
  94055. */
  94056. freeRenderingGroups(): void;
  94057. /**
  94058. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94059. * @returns the view count
  94060. */
  94061. getViewCount(): number;
  94062. }
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Options for compiling materials.
  94067. */
  94068. export interface IMaterialCompilationOptions {
  94069. /**
  94070. * Defines whether clip planes are enabled.
  94071. */
  94072. clipPlane: boolean;
  94073. /**
  94074. * Defines whether instances are enabled.
  94075. */
  94076. useInstances: boolean;
  94077. }
  94078. /**
  94079. * Base class for the main features of a material in Babylon.js
  94080. */
  94081. export class Material implements IAnimatable {
  94082. /**
  94083. * Returns the triangle fill mode
  94084. */
  94085. static readonly TriangleFillMode: number;
  94086. /**
  94087. * Returns the wireframe mode
  94088. */
  94089. static readonly WireFrameFillMode: number;
  94090. /**
  94091. * Returns the point fill mode
  94092. */
  94093. static readonly PointFillMode: number;
  94094. /**
  94095. * Returns the point list draw mode
  94096. */
  94097. static readonly PointListDrawMode: number;
  94098. /**
  94099. * Returns the line list draw mode
  94100. */
  94101. static readonly LineListDrawMode: number;
  94102. /**
  94103. * Returns the line loop draw mode
  94104. */
  94105. static readonly LineLoopDrawMode: number;
  94106. /**
  94107. * Returns the line strip draw mode
  94108. */
  94109. static readonly LineStripDrawMode: number;
  94110. /**
  94111. * Returns the triangle strip draw mode
  94112. */
  94113. static readonly TriangleStripDrawMode: number;
  94114. /**
  94115. * Returns the triangle fan draw mode
  94116. */
  94117. static readonly TriangleFanDrawMode: number;
  94118. /**
  94119. * Stores the clock-wise side orientation
  94120. */
  94121. static readonly ClockWiseSideOrientation: number;
  94122. /**
  94123. * Stores the counter clock-wise side orientation
  94124. */
  94125. static readonly CounterClockWiseSideOrientation: number;
  94126. /**
  94127. * The dirty texture flag value
  94128. */
  94129. static readonly TextureDirtyFlag: number;
  94130. /**
  94131. * The dirty light flag value
  94132. */
  94133. static readonly LightDirtyFlag: number;
  94134. /**
  94135. * The dirty fresnel flag value
  94136. */
  94137. static readonly FresnelDirtyFlag: number;
  94138. /**
  94139. * The dirty attribute flag value
  94140. */
  94141. static readonly AttributesDirtyFlag: number;
  94142. /**
  94143. * The dirty misc flag value
  94144. */
  94145. static readonly MiscDirtyFlag: number;
  94146. /**
  94147. * The all dirty flag value
  94148. */
  94149. static readonly AllDirtyFlag: number;
  94150. /**
  94151. * The ID of the material
  94152. */
  94153. id: string;
  94154. /**
  94155. * Gets or sets the unique id of the material
  94156. */
  94157. uniqueId: number;
  94158. /**
  94159. * The name of the material
  94160. */
  94161. name: string;
  94162. /**
  94163. * Gets or sets user defined metadata
  94164. */
  94165. metadata: any;
  94166. /**
  94167. * For internal use only. Please do not use.
  94168. */
  94169. reservedDataStore: any;
  94170. /**
  94171. * Specifies if the ready state should be checked on each call
  94172. */
  94173. checkReadyOnEveryCall: boolean;
  94174. /**
  94175. * Specifies if the ready state should be checked once
  94176. */
  94177. checkReadyOnlyOnce: boolean;
  94178. /**
  94179. * The state of the material
  94180. */
  94181. state: string;
  94182. /**
  94183. * The alpha value of the material
  94184. */
  94185. protected _alpha: number;
  94186. /**
  94187. * List of inspectable custom properties (used by the Inspector)
  94188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94189. */
  94190. inspectableCustomProperties: IInspectable[];
  94191. /**
  94192. * Sets the alpha value of the material
  94193. */
  94194. set alpha(value: number);
  94195. /**
  94196. * Gets the alpha value of the material
  94197. */
  94198. get alpha(): number;
  94199. /**
  94200. * Specifies if back face culling is enabled
  94201. */
  94202. protected _backFaceCulling: boolean;
  94203. /**
  94204. * Sets the back-face culling state
  94205. */
  94206. set backFaceCulling(value: boolean);
  94207. /**
  94208. * Gets the back-face culling state
  94209. */
  94210. get backFaceCulling(): boolean;
  94211. /**
  94212. * Stores the value for side orientation
  94213. */
  94214. sideOrientation: number;
  94215. /**
  94216. * Callback triggered when the material is compiled
  94217. */
  94218. onCompiled: Nullable<(effect: Effect) => void>;
  94219. /**
  94220. * Callback triggered when an error occurs
  94221. */
  94222. onError: Nullable<(effect: Effect, errors: string) => void>;
  94223. /**
  94224. * Callback triggered to get the render target textures
  94225. */
  94226. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94227. /**
  94228. * Gets a boolean indicating that current material needs to register RTT
  94229. */
  94230. get hasRenderTargetTextures(): boolean;
  94231. /**
  94232. * Specifies if the material should be serialized
  94233. */
  94234. doNotSerialize: boolean;
  94235. /**
  94236. * @hidden
  94237. */
  94238. _storeEffectOnSubMeshes: boolean;
  94239. /**
  94240. * Stores the animations for the material
  94241. */
  94242. animations: Nullable<Array<Animation>>;
  94243. /**
  94244. * An event triggered when the material is disposed
  94245. */
  94246. onDisposeObservable: Observable<Material>;
  94247. /**
  94248. * An observer which watches for dispose events
  94249. */
  94250. private _onDisposeObserver;
  94251. private _onUnBindObservable;
  94252. /**
  94253. * Called during a dispose event
  94254. */
  94255. set onDispose(callback: () => void);
  94256. private _onBindObservable;
  94257. /**
  94258. * An event triggered when the material is bound
  94259. */
  94260. get onBindObservable(): Observable<AbstractMesh>;
  94261. /**
  94262. * An observer which watches for bind events
  94263. */
  94264. private _onBindObserver;
  94265. /**
  94266. * Called during a bind event
  94267. */
  94268. set onBind(callback: (Mesh: AbstractMesh) => void);
  94269. /**
  94270. * An event triggered when the material is unbound
  94271. */
  94272. get onUnBindObservable(): Observable<Material>;
  94273. /**
  94274. * Stores the value of the alpha mode
  94275. */
  94276. private _alphaMode;
  94277. /**
  94278. * Sets the value of the alpha mode.
  94279. *
  94280. * | Value | Type | Description |
  94281. * | --- | --- | --- |
  94282. * | 0 | ALPHA_DISABLE | |
  94283. * | 1 | ALPHA_ADD | |
  94284. * | 2 | ALPHA_COMBINE | |
  94285. * | 3 | ALPHA_SUBTRACT | |
  94286. * | 4 | ALPHA_MULTIPLY | |
  94287. * | 5 | ALPHA_MAXIMIZED | |
  94288. * | 6 | ALPHA_ONEONE | |
  94289. * | 7 | ALPHA_PREMULTIPLIED | |
  94290. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94291. * | 9 | ALPHA_INTERPOLATE | |
  94292. * | 10 | ALPHA_SCREENMODE | |
  94293. *
  94294. */
  94295. set alphaMode(value: number);
  94296. /**
  94297. * Gets the value of the alpha mode
  94298. */
  94299. get alphaMode(): number;
  94300. /**
  94301. * Stores the state of the need depth pre-pass value
  94302. */
  94303. private _needDepthPrePass;
  94304. /**
  94305. * Sets the need depth pre-pass value
  94306. */
  94307. set needDepthPrePass(value: boolean);
  94308. /**
  94309. * Gets the depth pre-pass value
  94310. */
  94311. get needDepthPrePass(): boolean;
  94312. /**
  94313. * Specifies if depth writing should be disabled
  94314. */
  94315. disableDepthWrite: boolean;
  94316. /**
  94317. * Specifies if depth writing should be forced
  94318. */
  94319. forceDepthWrite: boolean;
  94320. /**
  94321. * Specifies the depth function that should be used. 0 means the default engine function
  94322. */
  94323. depthFunction: number;
  94324. /**
  94325. * Specifies if there should be a separate pass for culling
  94326. */
  94327. separateCullingPass: boolean;
  94328. /**
  94329. * Stores the state specifing if fog should be enabled
  94330. */
  94331. private _fogEnabled;
  94332. /**
  94333. * Sets the state for enabling fog
  94334. */
  94335. set fogEnabled(value: boolean);
  94336. /**
  94337. * Gets the value of the fog enabled state
  94338. */
  94339. get fogEnabled(): boolean;
  94340. /**
  94341. * Stores the size of points
  94342. */
  94343. pointSize: number;
  94344. /**
  94345. * Stores the z offset value
  94346. */
  94347. zOffset: number;
  94348. /**
  94349. * Gets a value specifying if wireframe mode is enabled
  94350. */
  94351. get wireframe(): boolean;
  94352. /**
  94353. * Sets the state of wireframe mode
  94354. */
  94355. set wireframe(value: boolean);
  94356. /**
  94357. * Gets the value specifying if point clouds are enabled
  94358. */
  94359. get pointsCloud(): boolean;
  94360. /**
  94361. * Sets the state of point cloud mode
  94362. */
  94363. set pointsCloud(value: boolean);
  94364. /**
  94365. * Gets the material fill mode
  94366. */
  94367. get fillMode(): number;
  94368. /**
  94369. * Sets the material fill mode
  94370. */
  94371. set fillMode(value: number);
  94372. /**
  94373. * @hidden
  94374. * Stores the effects for the material
  94375. */
  94376. _effect: Nullable<Effect>;
  94377. /**
  94378. * Specifies if uniform buffers should be used
  94379. */
  94380. private _useUBO;
  94381. /**
  94382. * Stores a reference to the scene
  94383. */
  94384. private _scene;
  94385. /**
  94386. * Stores the fill mode state
  94387. */
  94388. private _fillMode;
  94389. /**
  94390. * Specifies if the depth write state should be cached
  94391. */
  94392. private _cachedDepthWriteState;
  94393. /**
  94394. * Specifies if the depth function state should be cached
  94395. */
  94396. private _cachedDepthFunctionState;
  94397. /**
  94398. * Stores the uniform buffer
  94399. */
  94400. protected _uniformBuffer: UniformBuffer;
  94401. /** @hidden */
  94402. _indexInSceneMaterialArray: number;
  94403. /** @hidden */
  94404. meshMap: Nullable<{
  94405. [id: string]: AbstractMesh | undefined;
  94406. }>;
  94407. /**
  94408. * Creates a material instance
  94409. * @param name defines the name of the material
  94410. * @param scene defines the scene to reference
  94411. * @param doNotAdd specifies if the material should be added to the scene
  94412. */
  94413. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94414. /**
  94415. * Returns a string representation of the current material
  94416. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94417. * @returns a string with material information
  94418. */
  94419. toString(fullDetails?: boolean): string;
  94420. /**
  94421. * Gets the class name of the material
  94422. * @returns a string with the class name of the material
  94423. */
  94424. getClassName(): string;
  94425. /**
  94426. * Specifies if updates for the material been locked
  94427. */
  94428. get isFrozen(): boolean;
  94429. /**
  94430. * Locks updates for the material
  94431. */
  94432. freeze(): void;
  94433. /**
  94434. * Unlocks updates for the material
  94435. */
  94436. unfreeze(): void;
  94437. /**
  94438. * Specifies if the material is ready to be used
  94439. * @param mesh defines the mesh to check
  94440. * @param useInstances specifies if instances should be used
  94441. * @returns a boolean indicating if the material is ready to be used
  94442. */
  94443. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94444. /**
  94445. * Specifies that the submesh is ready to be used
  94446. * @param mesh defines the mesh to check
  94447. * @param subMesh defines which submesh to check
  94448. * @param useInstances specifies that instances should be used
  94449. * @returns a boolean indicating that the submesh is ready or not
  94450. */
  94451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94452. /**
  94453. * Returns the material effect
  94454. * @returns the effect associated with the material
  94455. */
  94456. getEffect(): Nullable<Effect>;
  94457. /**
  94458. * Returns the current scene
  94459. * @returns a Scene
  94460. */
  94461. getScene(): Scene;
  94462. /**
  94463. * Specifies if the material will require alpha blending
  94464. * @returns a boolean specifying if alpha blending is needed
  94465. */
  94466. needAlphaBlending(): boolean;
  94467. /**
  94468. * Specifies if the mesh will require alpha blending
  94469. * @param mesh defines the mesh to check
  94470. * @returns a boolean specifying if alpha blending is needed for the mesh
  94471. */
  94472. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94473. /**
  94474. * Specifies if this material should be rendered in alpha test mode
  94475. * @returns a boolean specifying if an alpha test is needed.
  94476. */
  94477. needAlphaTesting(): boolean;
  94478. /**
  94479. * Gets the texture used for the alpha test
  94480. * @returns the texture to use for alpha testing
  94481. */
  94482. getAlphaTestTexture(): Nullable<BaseTexture>;
  94483. /**
  94484. * Marks the material to indicate that it needs to be re-calculated
  94485. */
  94486. markDirty(): void;
  94487. /** @hidden */
  94488. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94489. /**
  94490. * Binds the material to the mesh
  94491. * @param world defines the world transformation matrix
  94492. * @param mesh defines the mesh to bind the material to
  94493. */
  94494. bind(world: Matrix, mesh?: Mesh): void;
  94495. /**
  94496. * Binds the submesh to the material
  94497. * @param world defines the world transformation matrix
  94498. * @param mesh defines the mesh containing the submesh
  94499. * @param subMesh defines the submesh to bind the material to
  94500. */
  94501. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94502. /**
  94503. * Binds the world matrix to the material
  94504. * @param world defines the world transformation matrix
  94505. */
  94506. bindOnlyWorldMatrix(world: Matrix): void;
  94507. /**
  94508. * Binds the scene's uniform buffer to the effect.
  94509. * @param effect defines the effect to bind to the scene uniform buffer
  94510. * @param sceneUbo defines the uniform buffer storing scene data
  94511. */
  94512. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94513. /**
  94514. * Binds the view matrix to the effect
  94515. * @param effect defines the effect to bind the view matrix to
  94516. */
  94517. bindView(effect: Effect): void;
  94518. /**
  94519. * Binds the view projection matrix to the effect
  94520. * @param effect defines the effect to bind the view projection matrix to
  94521. */
  94522. bindViewProjection(effect: Effect): void;
  94523. /**
  94524. * Specifies if material alpha testing should be turned on for the mesh
  94525. * @param mesh defines the mesh to check
  94526. */
  94527. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94528. /**
  94529. * Processes to execute after binding the material to a mesh
  94530. * @param mesh defines the rendered mesh
  94531. */
  94532. protected _afterBind(mesh?: Mesh): void;
  94533. /**
  94534. * Unbinds the material from the mesh
  94535. */
  94536. unbind(): void;
  94537. /**
  94538. * Gets the active textures from the material
  94539. * @returns an array of textures
  94540. */
  94541. getActiveTextures(): BaseTexture[];
  94542. /**
  94543. * Specifies if the material uses a texture
  94544. * @param texture defines the texture to check against the material
  94545. * @returns a boolean specifying if the material uses the texture
  94546. */
  94547. hasTexture(texture: BaseTexture): boolean;
  94548. /**
  94549. * Makes a duplicate of the material, and gives it a new name
  94550. * @param name defines the new name for the duplicated material
  94551. * @returns the cloned material
  94552. */
  94553. clone(name: string): Nullable<Material>;
  94554. /**
  94555. * Gets the meshes bound to the material
  94556. * @returns an array of meshes bound to the material
  94557. */
  94558. getBindedMeshes(): AbstractMesh[];
  94559. /**
  94560. * Force shader compilation
  94561. * @param mesh defines the mesh associated with this material
  94562. * @param onCompiled defines a function to execute once the material is compiled
  94563. * @param options defines the options to configure the compilation
  94564. * @param onError defines a function to execute if the material fails compiling
  94565. */
  94566. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94567. /**
  94568. * Force shader compilation
  94569. * @param mesh defines the mesh that will use this material
  94570. * @param options defines additional options for compiling the shaders
  94571. * @returns a promise that resolves when the compilation completes
  94572. */
  94573. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94574. private static readonly _AllDirtyCallBack;
  94575. private static readonly _ImageProcessingDirtyCallBack;
  94576. private static readonly _TextureDirtyCallBack;
  94577. private static readonly _FresnelDirtyCallBack;
  94578. private static readonly _MiscDirtyCallBack;
  94579. private static readonly _LightsDirtyCallBack;
  94580. private static readonly _AttributeDirtyCallBack;
  94581. private static _FresnelAndMiscDirtyCallBack;
  94582. private static _TextureAndMiscDirtyCallBack;
  94583. private static readonly _DirtyCallbackArray;
  94584. private static readonly _RunDirtyCallBacks;
  94585. /**
  94586. * Marks a define in the material to indicate that it needs to be re-computed
  94587. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94588. */
  94589. markAsDirty(flag: number): void;
  94590. /**
  94591. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94592. * @param func defines a function which checks material defines against the submeshes
  94593. */
  94594. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94595. /**
  94596. * Indicates that we need to re-calculated for all submeshes
  94597. */
  94598. protected _markAllSubMeshesAsAllDirty(): void;
  94599. /**
  94600. * Indicates that image processing needs to be re-calculated for all submeshes
  94601. */
  94602. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94603. /**
  94604. * Indicates that textures need to be re-calculated for all submeshes
  94605. */
  94606. protected _markAllSubMeshesAsTexturesDirty(): void;
  94607. /**
  94608. * Indicates that fresnel needs to be re-calculated for all submeshes
  94609. */
  94610. protected _markAllSubMeshesAsFresnelDirty(): void;
  94611. /**
  94612. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94613. */
  94614. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94615. /**
  94616. * Indicates that lights need to be re-calculated for all submeshes
  94617. */
  94618. protected _markAllSubMeshesAsLightsDirty(): void;
  94619. /**
  94620. * Indicates that attributes need to be re-calculated for all submeshes
  94621. */
  94622. protected _markAllSubMeshesAsAttributesDirty(): void;
  94623. /**
  94624. * Indicates that misc needs to be re-calculated for all submeshes
  94625. */
  94626. protected _markAllSubMeshesAsMiscDirty(): void;
  94627. /**
  94628. * Indicates that textures and misc need to be re-calculated for all submeshes
  94629. */
  94630. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94631. /**
  94632. * Disposes the material
  94633. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94634. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94635. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94636. */
  94637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94638. /** @hidden */
  94639. private releaseVertexArrayObject;
  94640. /**
  94641. * Serializes this material
  94642. * @returns the serialized material object
  94643. */
  94644. serialize(): any;
  94645. /**
  94646. * Creates a material from parsed material data
  94647. * @param parsedMaterial defines parsed material data
  94648. * @param scene defines the hosting scene
  94649. * @param rootUrl defines the root URL to use to load textures
  94650. * @returns a new material
  94651. */
  94652. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94653. }
  94654. }
  94655. declare module BABYLON {
  94656. /**
  94657. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94658. * separate meshes. This can be use to improve performances.
  94659. * @see http://doc.babylonjs.com/how_to/multi_materials
  94660. */
  94661. export class MultiMaterial extends Material {
  94662. private _subMaterials;
  94663. /**
  94664. * Gets or Sets the list of Materials used within the multi material.
  94665. * They need to be ordered according to the submeshes order in the associated mesh
  94666. */
  94667. get subMaterials(): Nullable<Material>[];
  94668. set subMaterials(value: Nullable<Material>[]);
  94669. /**
  94670. * Function used to align with Node.getChildren()
  94671. * @returns the list of Materials used within the multi material
  94672. */
  94673. getChildren(): Nullable<Material>[];
  94674. /**
  94675. * Instantiates a new Multi Material
  94676. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94677. * separate meshes. This can be use to improve performances.
  94678. * @see http://doc.babylonjs.com/how_to/multi_materials
  94679. * @param name Define the name in the scene
  94680. * @param scene Define the scene the material belongs to
  94681. */
  94682. constructor(name: string, scene: Scene);
  94683. private _hookArray;
  94684. /**
  94685. * Get one of the submaterial by its index in the submaterials array
  94686. * @param index The index to look the sub material at
  94687. * @returns The Material if the index has been defined
  94688. */
  94689. getSubMaterial(index: number): Nullable<Material>;
  94690. /**
  94691. * Get the list of active textures for the whole sub materials list.
  94692. * @returns All the textures that will be used during the rendering
  94693. */
  94694. getActiveTextures(): BaseTexture[];
  94695. /**
  94696. * Gets the current class name of the material e.g. "MultiMaterial"
  94697. * Mainly use in serialization.
  94698. * @returns the class name
  94699. */
  94700. getClassName(): string;
  94701. /**
  94702. * Checks if the material is ready to render the requested sub mesh
  94703. * @param mesh Define the mesh the submesh belongs to
  94704. * @param subMesh Define the sub mesh to look readyness for
  94705. * @param useInstances Define whether or not the material is used with instances
  94706. * @returns true if ready, otherwise false
  94707. */
  94708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94709. /**
  94710. * Clones the current material and its related sub materials
  94711. * @param name Define the name of the newly cloned material
  94712. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94713. * @returns the cloned material
  94714. */
  94715. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94716. /**
  94717. * Serializes the materials into a JSON representation.
  94718. * @returns the JSON representation
  94719. */
  94720. serialize(): any;
  94721. /**
  94722. * Dispose the material and release its associated resources
  94723. * @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)
  94724. * @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)
  94725. * @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)
  94726. */
  94727. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94728. /**
  94729. * Creates a MultiMaterial from parsed MultiMaterial data.
  94730. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94731. * @param scene defines the hosting scene
  94732. * @returns a new MultiMaterial
  94733. */
  94734. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94735. }
  94736. }
  94737. declare module BABYLON {
  94738. /**
  94739. * Base class for submeshes
  94740. */
  94741. export class BaseSubMesh {
  94742. /** @hidden */
  94743. _materialDefines: Nullable<MaterialDefines>;
  94744. /** @hidden */
  94745. _materialEffect: Nullable<Effect>;
  94746. /**
  94747. * Gets material defines used by the effect associated to the sub mesh
  94748. */
  94749. get materialDefines(): Nullable<MaterialDefines>;
  94750. /**
  94751. * Sets material defines used by the effect associated to the sub mesh
  94752. */
  94753. set materialDefines(defines: Nullable<MaterialDefines>);
  94754. /**
  94755. * Gets associated effect
  94756. */
  94757. get effect(): Nullable<Effect>;
  94758. /**
  94759. * Sets associated effect (effect used to render this submesh)
  94760. * @param effect defines the effect to associate with
  94761. * @param defines defines the set of defines used to compile this effect
  94762. */
  94763. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94764. }
  94765. /**
  94766. * Defines a subdivision inside a mesh
  94767. */
  94768. export class SubMesh extends BaseSubMesh implements ICullable {
  94769. /** the material index to use */
  94770. materialIndex: number;
  94771. /** vertex index start */
  94772. verticesStart: number;
  94773. /** vertices count */
  94774. verticesCount: number;
  94775. /** index start */
  94776. indexStart: number;
  94777. /** indices count */
  94778. indexCount: number;
  94779. /** @hidden */
  94780. _linesIndexCount: number;
  94781. private _mesh;
  94782. private _renderingMesh;
  94783. private _boundingInfo;
  94784. private _linesIndexBuffer;
  94785. /** @hidden */
  94786. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94787. /** @hidden */
  94788. _trianglePlanes: Plane[];
  94789. /** @hidden */
  94790. _lastColliderTransformMatrix: Nullable<Matrix>;
  94791. /** @hidden */
  94792. _renderId: number;
  94793. /** @hidden */
  94794. _alphaIndex: number;
  94795. /** @hidden */
  94796. _distanceToCamera: number;
  94797. /** @hidden */
  94798. _id: number;
  94799. private _currentMaterial;
  94800. /**
  94801. * Add a new submesh to a mesh
  94802. * @param materialIndex defines the material index to use
  94803. * @param verticesStart defines vertex index start
  94804. * @param verticesCount defines vertices count
  94805. * @param indexStart defines index start
  94806. * @param indexCount defines indices count
  94807. * @param mesh defines the parent mesh
  94808. * @param renderingMesh defines an optional rendering mesh
  94809. * @param createBoundingBox defines if bounding box should be created for this submesh
  94810. * @returns the new submesh
  94811. */
  94812. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94813. /**
  94814. * Creates a new submesh
  94815. * @param materialIndex defines the material index to use
  94816. * @param verticesStart defines vertex index start
  94817. * @param verticesCount defines vertices count
  94818. * @param indexStart defines index start
  94819. * @param indexCount defines indices count
  94820. * @param mesh defines the parent mesh
  94821. * @param renderingMesh defines an optional rendering mesh
  94822. * @param createBoundingBox defines if bounding box should be created for this submesh
  94823. */
  94824. constructor(
  94825. /** the material index to use */
  94826. materialIndex: number,
  94827. /** vertex index start */
  94828. verticesStart: number,
  94829. /** vertices count */
  94830. verticesCount: number,
  94831. /** index start */
  94832. indexStart: number,
  94833. /** indices count */
  94834. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94835. /**
  94836. * Returns true if this submesh covers the entire parent mesh
  94837. * @ignorenaming
  94838. */
  94839. get IsGlobal(): boolean;
  94840. /**
  94841. * Returns the submesh BoudingInfo object
  94842. * @returns current bounding info (or mesh's one if the submesh is global)
  94843. */
  94844. getBoundingInfo(): BoundingInfo;
  94845. /**
  94846. * Sets the submesh BoundingInfo
  94847. * @param boundingInfo defines the new bounding info to use
  94848. * @returns the SubMesh
  94849. */
  94850. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94851. /**
  94852. * Returns the mesh of the current submesh
  94853. * @return the parent mesh
  94854. */
  94855. getMesh(): AbstractMesh;
  94856. /**
  94857. * Returns the rendering mesh of the submesh
  94858. * @returns the rendering mesh (could be different from parent mesh)
  94859. */
  94860. getRenderingMesh(): Mesh;
  94861. /**
  94862. * Returns the submesh material
  94863. * @returns null or the current material
  94864. */
  94865. getMaterial(): Nullable<Material>;
  94866. /**
  94867. * Sets a new updated BoundingInfo object to the submesh
  94868. * @param data defines an optional position array to use to determine the bounding info
  94869. * @returns the SubMesh
  94870. */
  94871. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94872. /** @hidden */
  94873. _checkCollision(collider: Collider): boolean;
  94874. /**
  94875. * Updates the submesh BoundingInfo
  94876. * @param world defines the world matrix to use to update the bounding info
  94877. * @returns the submesh
  94878. */
  94879. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94880. /**
  94881. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94882. * @param frustumPlanes defines the frustum planes
  94883. * @returns true if the submesh is intersecting with the frustum
  94884. */
  94885. isInFrustum(frustumPlanes: Plane[]): boolean;
  94886. /**
  94887. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94888. * @param frustumPlanes defines the frustum planes
  94889. * @returns true if the submesh is inside the frustum
  94890. */
  94891. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94892. /**
  94893. * Renders the submesh
  94894. * @param enableAlphaMode defines if alpha needs to be used
  94895. * @returns the submesh
  94896. */
  94897. render(enableAlphaMode: boolean): SubMesh;
  94898. /**
  94899. * @hidden
  94900. */
  94901. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94902. /**
  94903. * Checks if the submesh intersects with a ray
  94904. * @param ray defines the ray to test
  94905. * @returns true is the passed ray intersects the submesh bounding box
  94906. */
  94907. canIntersects(ray: Ray): boolean;
  94908. /**
  94909. * Intersects current submesh with a ray
  94910. * @param ray defines the ray to test
  94911. * @param positions defines mesh's positions array
  94912. * @param indices defines mesh's indices array
  94913. * @param fastCheck defines if only bounding info should be used
  94914. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94915. * @returns intersection info or null if no intersection
  94916. */
  94917. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94918. /** @hidden */
  94919. private _intersectLines;
  94920. /** @hidden */
  94921. private _intersectUnIndexedLines;
  94922. /** @hidden */
  94923. private _intersectTriangles;
  94924. /** @hidden */
  94925. private _intersectUnIndexedTriangles;
  94926. /** @hidden */
  94927. _rebuild(): void;
  94928. /**
  94929. * Creates a new submesh from the passed mesh
  94930. * @param newMesh defines the new hosting mesh
  94931. * @param newRenderingMesh defines an optional rendering mesh
  94932. * @returns the new submesh
  94933. */
  94934. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94935. /**
  94936. * Release associated resources
  94937. */
  94938. dispose(): void;
  94939. /**
  94940. * Gets the class name
  94941. * @returns the string "SubMesh".
  94942. */
  94943. getClassName(): string;
  94944. /**
  94945. * Creates a new submesh from indices data
  94946. * @param materialIndex the index of the main mesh material
  94947. * @param startIndex the index where to start the copy in the mesh indices array
  94948. * @param indexCount the number of indices to copy then from the startIndex
  94949. * @param mesh the main mesh to create the submesh from
  94950. * @param renderingMesh the optional rendering mesh
  94951. * @returns a new submesh
  94952. */
  94953. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94954. }
  94955. }
  94956. declare module BABYLON {
  94957. /**
  94958. * Class used to represent data loading progression
  94959. */
  94960. export class SceneLoaderFlags {
  94961. private static _ForceFullSceneLoadingForIncremental;
  94962. private static _ShowLoadingScreen;
  94963. private static _CleanBoneMatrixWeights;
  94964. private static _loggingLevel;
  94965. /**
  94966. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94967. */
  94968. static get ForceFullSceneLoadingForIncremental(): boolean;
  94969. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94970. /**
  94971. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94972. */
  94973. static get ShowLoadingScreen(): boolean;
  94974. static set ShowLoadingScreen(value: boolean);
  94975. /**
  94976. * Defines the current logging level (while loading the scene)
  94977. * @ignorenaming
  94978. */
  94979. static get loggingLevel(): number;
  94980. static set loggingLevel(value: number);
  94981. /**
  94982. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94983. */
  94984. static get CleanBoneMatrixWeights(): boolean;
  94985. static set CleanBoneMatrixWeights(value: boolean);
  94986. }
  94987. }
  94988. declare module BABYLON {
  94989. /**
  94990. * Class used to store geometry data (vertex buffers + index buffer)
  94991. */
  94992. export class Geometry implements IGetSetVerticesData {
  94993. /**
  94994. * Gets or sets the ID of the geometry
  94995. */
  94996. id: string;
  94997. /**
  94998. * Gets or sets the unique ID of the geometry
  94999. */
  95000. uniqueId: number;
  95001. /**
  95002. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95003. */
  95004. delayLoadState: number;
  95005. /**
  95006. * Gets the file containing the data to load when running in delay load state
  95007. */
  95008. delayLoadingFile: Nullable<string>;
  95009. /**
  95010. * Callback called when the geometry is updated
  95011. */
  95012. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95013. private _scene;
  95014. private _engine;
  95015. private _meshes;
  95016. private _totalVertices;
  95017. /** @hidden */
  95018. _indices: IndicesArray;
  95019. /** @hidden */
  95020. _vertexBuffers: {
  95021. [key: string]: VertexBuffer;
  95022. };
  95023. private _isDisposed;
  95024. private _extend;
  95025. private _boundingBias;
  95026. /** @hidden */
  95027. _delayInfo: Array<string>;
  95028. private _indexBuffer;
  95029. private _indexBufferIsUpdatable;
  95030. /** @hidden */
  95031. _boundingInfo: Nullable<BoundingInfo>;
  95032. /** @hidden */
  95033. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95034. /** @hidden */
  95035. _softwareSkinningFrameId: number;
  95036. private _vertexArrayObjects;
  95037. private _updatable;
  95038. /** @hidden */
  95039. _positions: Nullable<Vector3[]>;
  95040. /**
  95041. * 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
  95042. */
  95043. get boundingBias(): Vector2;
  95044. /**
  95045. * 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
  95046. */
  95047. set boundingBias(value: Vector2);
  95048. /**
  95049. * Static function used to attach a new empty geometry to a mesh
  95050. * @param mesh defines the mesh to attach the geometry to
  95051. * @returns the new Geometry
  95052. */
  95053. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95054. /**
  95055. * Creates a new geometry
  95056. * @param id defines the unique ID
  95057. * @param scene defines the hosting scene
  95058. * @param vertexData defines the VertexData used to get geometry data
  95059. * @param updatable defines if geometry must be updatable (false by default)
  95060. * @param mesh defines the mesh that will be associated with the geometry
  95061. */
  95062. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95063. /**
  95064. * Gets the current extend of the geometry
  95065. */
  95066. get extend(): {
  95067. minimum: Vector3;
  95068. maximum: Vector3;
  95069. };
  95070. /**
  95071. * Gets the hosting scene
  95072. * @returns the hosting Scene
  95073. */
  95074. getScene(): Scene;
  95075. /**
  95076. * Gets the hosting engine
  95077. * @returns the hosting Engine
  95078. */
  95079. getEngine(): Engine;
  95080. /**
  95081. * Defines if the geometry is ready to use
  95082. * @returns true if the geometry is ready to be used
  95083. */
  95084. isReady(): boolean;
  95085. /**
  95086. * Gets a value indicating that the geometry should not be serialized
  95087. */
  95088. get doNotSerialize(): boolean;
  95089. /** @hidden */
  95090. _rebuild(): void;
  95091. /**
  95092. * Affects all geometry data in one call
  95093. * @param vertexData defines the geometry data
  95094. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95095. */
  95096. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95097. /**
  95098. * Set specific vertex data
  95099. * @param kind defines the data kind (Position, normal, etc...)
  95100. * @param data defines the vertex data to use
  95101. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95102. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95103. */
  95104. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95105. /**
  95106. * Removes a specific vertex data
  95107. * @param kind defines the data kind (Position, normal, etc...)
  95108. */
  95109. removeVerticesData(kind: string): void;
  95110. /**
  95111. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95112. * @param buffer defines the vertex buffer to use
  95113. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95114. */
  95115. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95116. /**
  95117. * Update a specific vertex buffer
  95118. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95119. * It will do nothing if the buffer is not updatable
  95120. * @param kind defines the data kind (Position, normal, etc...)
  95121. * @param data defines the data to use
  95122. * @param offset defines the offset in the target buffer where to store the data
  95123. * @param useBytes set to true if the offset is in bytes
  95124. */
  95125. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95126. /**
  95127. * Update a specific vertex buffer
  95128. * This function will create a new buffer if the current one is not updatable
  95129. * @param kind defines the data kind (Position, normal, etc...)
  95130. * @param data defines the data to use
  95131. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95132. */
  95133. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95134. private _updateBoundingInfo;
  95135. /** @hidden */
  95136. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95137. /**
  95138. * Gets total number of vertices
  95139. * @returns the total number of vertices
  95140. */
  95141. getTotalVertices(): number;
  95142. /**
  95143. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95144. * @param kind defines the data kind (Position, normal, etc...)
  95145. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95146. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95147. * @returns a float array containing vertex data
  95148. */
  95149. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95150. /**
  95151. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95152. * @param kind defines the data kind (Position, normal, etc...)
  95153. * @returns true if the vertex buffer with the specified kind is updatable
  95154. */
  95155. isVertexBufferUpdatable(kind: string): boolean;
  95156. /**
  95157. * Gets a specific vertex buffer
  95158. * @param kind defines the data kind (Position, normal, etc...)
  95159. * @returns a VertexBuffer
  95160. */
  95161. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95162. /**
  95163. * Returns all vertex buffers
  95164. * @return an object holding all vertex buffers indexed by kind
  95165. */
  95166. getVertexBuffers(): Nullable<{
  95167. [key: string]: VertexBuffer;
  95168. }>;
  95169. /**
  95170. * Gets a boolean indicating if specific vertex buffer is present
  95171. * @param kind defines the data kind (Position, normal, etc...)
  95172. * @returns true if data is present
  95173. */
  95174. isVerticesDataPresent(kind: string): boolean;
  95175. /**
  95176. * Gets a list of all attached data kinds (Position, normal, etc...)
  95177. * @returns a list of string containing all kinds
  95178. */
  95179. getVerticesDataKinds(): string[];
  95180. /**
  95181. * Update index buffer
  95182. * @param indices defines the indices to store in the index buffer
  95183. * @param offset defines the offset in the target buffer where to store the data
  95184. * @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)
  95185. */
  95186. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95187. /**
  95188. * Creates a new index buffer
  95189. * @param indices defines the indices to store in the index buffer
  95190. * @param totalVertices defines the total number of vertices (could be null)
  95191. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95192. */
  95193. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95194. /**
  95195. * Return the total number of indices
  95196. * @returns the total number of indices
  95197. */
  95198. getTotalIndices(): number;
  95199. /**
  95200. * Gets the index buffer array
  95201. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95203. * @returns the index buffer array
  95204. */
  95205. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95206. /**
  95207. * Gets the index buffer
  95208. * @return the index buffer
  95209. */
  95210. getIndexBuffer(): Nullable<DataBuffer>;
  95211. /** @hidden */
  95212. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95213. /**
  95214. * Release the associated resources for a specific mesh
  95215. * @param mesh defines the source mesh
  95216. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95217. */
  95218. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95219. /**
  95220. * Apply current geometry to a given mesh
  95221. * @param mesh defines the mesh to apply geometry to
  95222. */
  95223. applyToMesh(mesh: Mesh): void;
  95224. private _updateExtend;
  95225. private _applyToMesh;
  95226. private notifyUpdate;
  95227. /**
  95228. * Load the geometry if it was flagged as delay loaded
  95229. * @param scene defines the hosting scene
  95230. * @param onLoaded defines a callback called when the geometry is loaded
  95231. */
  95232. load(scene: Scene, onLoaded?: () => void): void;
  95233. private _queueLoad;
  95234. /**
  95235. * Invert the geometry to move from a right handed system to a left handed one.
  95236. */
  95237. toLeftHanded(): void;
  95238. /** @hidden */
  95239. _resetPointsArrayCache(): void;
  95240. /** @hidden */
  95241. _generatePointsArray(): boolean;
  95242. /**
  95243. * Gets a value indicating if the geometry is disposed
  95244. * @returns true if the geometry was disposed
  95245. */
  95246. isDisposed(): boolean;
  95247. private _disposeVertexArrayObjects;
  95248. /**
  95249. * Free all associated resources
  95250. */
  95251. dispose(): void;
  95252. /**
  95253. * Clone the current geometry into a new geometry
  95254. * @param id defines the unique ID of the new geometry
  95255. * @returns a new geometry object
  95256. */
  95257. copy(id: string): Geometry;
  95258. /**
  95259. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95260. * @return a JSON representation of the current geometry data (without the vertices data)
  95261. */
  95262. serialize(): any;
  95263. private toNumberArray;
  95264. /**
  95265. * Serialize all vertices data into a JSON oject
  95266. * @returns a JSON representation of the current geometry data
  95267. */
  95268. serializeVerticeData(): any;
  95269. /**
  95270. * Extracts a clone of a mesh geometry
  95271. * @param mesh defines the source mesh
  95272. * @param id defines the unique ID of the new geometry object
  95273. * @returns the new geometry object
  95274. */
  95275. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95276. /**
  95277. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95278. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95279. * Be aware Math.random() could cause collisions, but:
  95280. * "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"
  95281. * @returns a string containing a new GUID
  95282. */
  95283. static RandomId(): string;
  95284. /** @hidden */
  95285. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95286. private static _CleanMatricesWeights;
  95287. /**
  95288. * Create a new geometry from persisted data (Using .babylon file format)
  95289. * @param parsedVertexData defines the persisted data
  95290. * @param scene defines the hosting scene
  95291. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95292. * @returns the new geometry object
  95293. */
  95294. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95295. }
  95296. }
  95297. declare module BABYLON {
  95298. /**
  95299. * Define an interface for all classes that will get and set the data on vertices
  95300. */
  95301. export interface IGetSetVerticesData {
  95302. /**
  95303. * Gets a boolean indicating if specific vertex data is present
  95304. * @param kind defines the vertex data kind to use
  95305. * @returns true is data kind is present
  95306. */
  95307. isVerticesDataPresent(kind: string): boolean;
  95308. /**
  95309. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95310. * @param kind defines the data kind (Position, normal, etc...)
  95311. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95312. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95313. * @returns a float array containing vertex data
  95314. */
  95315. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95316. /**
  95317. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95318. * @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.
  95319. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95320. * @returns the indices array or an empty array if the mesh has no geometry
  95321. */
  95322. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95323. /**
  95324. * Set specific vertex data
  95325. * @param kind defines the data kind (Position, normal, etc...)
  95326. * @param data defines the vertex data to use
  95327. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95328. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95329. */
  95330. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95331. /**
  95332. * Update a specific associated vertex buffer
  95333. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95334. * - VertexBuffer.PositionKind
  95335. * - VertexBuffer.UVKind
  95336. * - VertexBuffer.UV2Kind
  95337. * - VertexBuffer.UV3Kind
  95338. * - VertexBuffer.UV4Kind
  95339. * - VertexBuffer.UV5Kind
  95340. * - VertexBuffer.UV6Kind
  95341. * - VertexBuffer.ColorKind
  95342. * - VertexBuffer.MatricesIndicesKind
  95343. * - VertexBuffer.MatricesIndicesExtraKind
  95344. * - VertexBuffer.MatricesWeightsKind
  95345. * - VertexBuffer.MatricesWeightsExtraKind
  95346. * @param data defines the data source
  95347. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95348. * @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)
  95349. */
  95350. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95351. /**
  95352. * Creates a new index buffer
  95353. * @param indices defines the indices to store in the index buffer
  95354. * @param totalVertices defines the total number of vertices (could be null)
  95355. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95356. */
  95357. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95358. }
  95359. /**
  95360. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95361. */
  95362. export class VertexData {
  95363. /**
  95364. * Mesh side orientation : usually the external or front surface
  95365. */
  95366. static readonly FRONTSIDE: number;
  95367. /**
  95368. * Mesh side orientation : usually the internal or back surface
  95369. */
  95370. static readonly BACKSIDE: number;
  95371. /**
  95372. * Mesh side orientation : both internal and external or front and back surfaces
  95373. */
  95374. static readonly DOUBLESIDE: number;
  95375. /**
  95376. * Mesh side orientation : by default, `FRONTSIDE`
  95377. */
  95378. static readonly DEFAULTSIDE: number;
  95379. /**
  95380. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95381. */
  95382. positions: Nullable<FloatArray>;
  95383. /**
  95384. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95385. */
  95386. normals: Nullable<FloatArray>;
  95387. /**
  95388. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95389. */
  95390. tangents: Nullable<FloatArray>;
  95391. /**
  95392. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95393. */
  95394. uvs: Nullable<FloatArray>;
  95395. /**
  95396. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95397. */
  95398. uvs2: Nullable<FloatArray>;
  95399. /**
  95400. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95401. */
  95402. uvs3: Nullable<FloatArray>;
  95403. /**
  95404. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95405. */
  95406. uvs4: Nullable<FloatArray>;
  95407. /**
  95408. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95409. */
  95410. uvs5: Nullable<FloatArray>;
  95411. /**
  95412. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95413. */
  95414. uvs6: Nullable<FloatArray>;
  95415. /**
  95416. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95417. */
  95418. colors: Nullable<FloatArray>;
  95419. /**
  95420. * 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).
  95421. */
  95422. matricesIndices: Nullable<FloatArray>;
  95423. /**
  95424. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95425. */
  95426. matricesWeights: Nullable<FloatArray>;
  95427. /**
  95428. * An array extending the number of possible indices
  95429. */
  95430. matricesIndicesExtra: Nullable<FloatArray>;
  95431. /**
  95432. * An array extending the number of possible weights when the number of indices is extended
  95433. */
  95434. matricesWeightsExtra: Nullable<FloatArray>;
  95435. /**
  95436. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95437. */
  95438. indices: Nullable<IndicesArray>;
  95439. /**
  95440. * Uses the passed data array to set the set the values for the specified kind of data
  95441. * @param data a linear array of floating numbers
  95442. * @param kind the type of data that is being set, eg positions, colors etc
  95443. */
  95444. set(data: FloatArray, kind: string): void;
  95445. /**
  95446. * Associates the vertexData to the passed Mesh.
  95447. * Sets it as updatable or not (default `false`)
  95448. * @param mesh the mesh the vertexData is applied to
  95449. * @param updatable when used and having the value true allows new data to update the vertexData
  95450. * @returns the VertexData
  95451. */
  95452. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95453. /**
  95454. * Associates the vertexData to the passed Geometry.
  95455. * Sets it as updatable or not (default `false`)
  95456. * @param geometry the geometry the vertexData is applied to
  95457. * @param updatable when used and having the value true allows new data to update the vertexData
  95458. * @returns VertexData
  95459. */
  95460. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95461. /**
  95462. * Updates the associated mesh
  95463. * @param mesh the mesh to be updated
  95464. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95465. * @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
  95466. * @returns VertexData
  95467. */
  95468. updateMesh(mesh: Mesh): VertexData;
  95469. /**
  95470. * Updates the associated geometry
  95471. * @param geometry the geometry to be updated
  95472. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95473. * @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
  95474. * @returns VertexData.
  95475. */
  95476. updateGeometry(geometry: Geometry): VertexData;
  95477. private _applyTo;
  95478. private _update;
  95479. /**
  95480. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95481. * @param matrix the transforming matrix
  95482. * @returns the VertexData
  95483. */
  95484. transform(matrix: Matrix): VertexData;
  95485. /**
  95486. * Merges the passed VertexData into the current one
  95487. * @param other the VertexData to be merged into the current one
  95488. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95489. * @returns the modified VertexData
  95490. */
  95491. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95492. private _mergeElement;
  95493. private _validate;
  95494. /**
  95495. * Serializes the VertexData
  95496. * @returns a serialized object
  95497. */
  95498. serialize(): any;
  95499. /**
  95500. * Extracts the vertexData from a mesh
  95501. * @param mesh the mesh from which to extract the VertexData
  95502. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95503. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95504. * @returns the object VertexData associated to the passed mesh
  95505. */
  95506. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95507. /**
  95508. * Extracts the vertexData from the geometry
  95509. * @param geometry the geometry from which to extract the VertexData
  95510. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95511. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95512. * @returns the object VertexData associated to the passed mesh
  95513. */
  95514. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95515. private static _ExtractFrom;
  95516. /**
  95517. * Creates the VertexData for a Ribbon
  95518. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95519. * * pathArray array of paths, each of which an array of successive Vector3
  95520. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95521. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95522. * * 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
  95523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95524. * * 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)
  95525. * * 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)
  95526. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95527. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95528. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95529. * @returns the VertexData of the ribbon
  95530. */
  95531. static CreateRibbon(options: {
  95532. pathArray: Vector3[][];
  95533. closeArray?: boolean;
  95534. closePath?: boolean;
  95535. offset?: number;
  95536. sideOrientation?: number;
  95537. frontUVs?: Vector4;
  95538. backUVs?: Vector4;
  95539. invertUV?: boolean;
  95540. uvs?: Vector2[];
  95541. colors?: Color4[];
  95542. }): VertexData;
  95543. /**
  95544. * Creates the VertexData for a box
  95545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95546. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95547. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95548. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95549. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95550. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95551. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95553. * * 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)
  95554. * * 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)
  95555. * @returns the VertexData of the box
  95556. */
  95557. static CreateBox(options: {
  95558. size?: number;
  95559. width?: number;
  95560. height?: number;
  95561. depth?: number;
  95562. faceUV?: Vector4[];
  95563. faceColors?: Color4[];
  95564. sideOrientation?: number;
  95565. frontUVs?: Vector4;
  95566. backUVs?: Vector4;
  95567. }): VertexData;
  95568. /**
  95569. * Creates the VertexData for a tiled box
  95570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95571. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95572. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95573. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95575. * @returns the VertexData of the box
  95576. */
  95577. static CreateTiledBox(options: {
  95578. pattern?: number;
  95579. width?: number;
  95580. height?: number;
  95581. depth?: number;
  95582. tileSize?: number;
  95583. tileWidth?: number;
  95584. tileHeight?: number;
  95585. alignHorizontal?: number;
  95586. alignVertical?: number;
  95587. faceUV?: Vector4[];
  95588. faceColors?: Color4[];
  95589. sideOrientation?: number;
  95590. }): VertexData;
  95591. /**
  95592. * Creates the VertexData for a tiled plane
  95593. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95594. * * pattern a limited pattern arrangement depending on the number
  95595. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95596. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95597. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95599. * * 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)
  95600. * * 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)
  95601. * @returns the VertexData of the tiled plane
  95602. */
  95603. static CreateTiledPlane(options: {
  95604. pattern?: number;
  95605. tileSize?: number;
  95606. tileWidth?: number;
  95607. tileHeight?: number;
  95608. size?: number;
  95609. width?: number;
  95610. height?: number;
  95611. alignHorizontal?: number;
  95612. alignVertical?: number;
  95613. sideOrientation?: number;
  95614. frontUVs?: Vector4;
  95615. backUVs?: Vector4;
  95616. }): VertexData;
  95617. /**
  95618. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95619. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95620. * * segments sets the number of horizontal strips optional, default 32
  95621. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95622. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95623. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95624. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95625. * * 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
  95626. * * 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
  95627. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95628. * * 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)
  95629. * * 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)
  95630. * @returns the VertexData of the ellipsoid
  95631. */
  95632. static CreateSphere(options: {
  95633. segments?: number;
  95634. diameter?: number;
  95635. diameterX?: number;
  95636. diameterY?: number;
  95637. diameterZ?: number;
  95638. arc?: number;
  95639. slice?: number;
  95640. sideOrientation?: number;
  95641. frontUVs?: Vector4;
  95642. backUVs?: Vector4;
  95643. }): VertexData;
  95644. /**
  95645. * Creates the VertexData for a cylinder, cone or prism
  95646. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95647. * * height sets the height (y direction) of the cylinder, optional, default 2
  95648. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95649. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95650. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95651. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95652. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95653. * * 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
  95654. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95655. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95656. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95657. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95659. * * 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)
  95660. * * 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)
  95661. * @returns the VertexData of the cylinder, cone or prism
  95662. */
  95663. static CreateCylinder(options: {
  95664. height?: number;
  95665. diameterTop?: number;
  95666. diameterBottom?: number;
  95667. diameter?: number;
  95668. tessellation?: number;
  95669. subdivisions?: number;
  95670. arc?: number;
  95671. faceColors?: Color4[];
  95672. faceUV?: Vector4[];
  95673. hasRings?: boolean;
  95674. enclose?: boolean;
  95675. sideOrientation?: number;
  95676. frontUVs?: Vector4;
  95677. backUVs?: Vector4;
  95678. }): VertexData;
  95679. /**
  95680. * Creates the VertexData for a torus
  95681. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95682. * * diameter the diameter of the torus, optional default 1
  95683. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95684. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95686. * * 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)
  95687. * * 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)
  95688. * @returns the VertexData of the torus
  95689. */
  95690. static CreateTorus(options: {
  95691. diameter?: number;
  95692. thickness?: number;
  95693. tessellation?: number;
  95694. sideOrientation?: number;
  95695. frontUVs?: Vector4;
  95696. backUVs?: Vector4;
  95697. }): VertexData;
  95698. /**
  95699. * Creates the VertexData of the LineSystem
  95700. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95701. * - lines an array of lines, each line being an array of successive Vector3
  95702. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95703. * @returns the VertexData of the LineSystem
  95704. */
  95705. static CreateLineSystem(options: {
  95706. lines: Vector3[][];
  95707. colors?: Nullable<Color4[][]>;
  95708. }): VertexData;
  95709. /**
  95710. * Create the VertexData for a DashedLines
  95711. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95712. * - points an array successive Vector3
  95713. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95714. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95715. * - dashNb the intended total number of dashes, optional, default 200
  95716. * @returns the VertexData for the DashedLines
  95717. */
  95718. static CreateDashedLines(options: {
  95719. points: Vector3[];
  95720. dashSize?: number;
  95721. gapSize?: number;
  95722. dashNb?: number;
  95723. }): VertexData;
  95724. /**
  95725. * Creates the VertexData for a Ground
  95726. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95727. * - width the width (x direction) of the ground, optional, default 1
  95728. * - height the height (z direction) of the ground, optional, default 1
  95729. * - subdivisions the number of subdivisions per side, optional, default 1
  95730. * @returns the VertexData of the Ground
  95731. */
  95732. static CreateGround(options: {
  95733. width?: number;
  95734. height?: number;
  95735. subdivisions?: number;
  95736. subdivisionsX?: number;
  95737. subdivisionsY?: number;
  95738. }): VertexData;
  95739. /**
  95740. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95741. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95742. * * xmin the ground minimum X coordinate, optional, default -1
  95743. * * zmin the ground minimum Z coordinate, optional, default -1
  95744. * * xmax the ground maximum X coordinate, optional, default 1
  95745. * * zmax the ground maximum Z coordinate, optional, default 1
  95746. * * 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}
  95747. * * 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}
  95748. * @returns the VertexData of the TiledGround
  95749. */
  95750. static CreateTiledGround(options: {
  95751. xmin: number;
  95752. zmin: number;
  95753. xmax: number;
  95754. zmax: number;
  95755. subdivisions?: {
  95756. w: number;
  95757. h: number;
  95758. };
  95759. precision?: {
  95760. w: number;
  95761. h: number;
  95762. };
  95763. }): VertexData;
  95764. /**
  95765. * Creates the VertexData of the Ground designed from a heightmap
  95766. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95767. * * width the width (x direction) of the ground
  95768. * * height the height (z direction) of the ground
  95769. * * subdivisions the number of subdivisions per side
  95770. * * minHeight the minimum altitude on the ground, optional, default 0
  95771. * * maxHeight the maximum altitude on the ground, optional default 1
  95772. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95773. * * buffer the array holding the image color data
  95774. * * bufferWidth the width of image
  95775. * * bufferHeight the height of image
  95776. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95777. * @returns the VertexData of the Ground designed from a heightmap
  95778. */
  95779. static CreateGroundFromHeightMap(options: {
  95780. width: number;
  95781. height: number;
  95782. subdivisions: number;
  95783. minHeight: number;
  95784. maxHeight: number;
  95785. colorFilter: Color3;
  95786. buffer: Uint8Array;
  95787. bufferWidth: number;
  95788. bufferHeight: number;
  95789. alphaFilter: number;
  95790. }): VertexData;
  95791. /**
  95792. * Creates the VertexData for a Plane
  95793. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95794. * * size sets the width and height of the plane to the value of size, optional default 1
  95795. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95796. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95798. * * 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)
  95799. * * 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)
  95800. * @returns the VertexData of the box
  95801. */
  95802. static CreatePlane(options: {
  95803. size?: number;
  95804. width?: number;
  95805. height?: number;
  95806. sideOrientation?: number;
  95807. frontUVs?: Vector4;
  95808. backUVs?: Vector4;
  95809. }): VertexData;
  95810. /**
  95811. * Creates the VertexData of the Disc or regular Polygon
  95812. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95813. * * radius the radius of the disc, optional default 0.5
  95814. * * tessellation the number of polygon sides, optional, default 64
  95815. * * 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
  95816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95817. * * 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)
  95818. * * 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)
  95819. * @returns the VertexData of the box
  95820. */
  95821. static CreateDisc(options: {
  95822. radius?: number;
  95823. tessellation?: number;
  95824. arc?: number;
  95825. sideOrientation?: number;
  95826. frontUVs?: Vector4;
  95827. backUVs?: Vector4;
  95828. }): VertexData;
  95829. /**
  95830. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95831. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95832. * @param polygon a mesh built from polygonTriangulation.build()
  95833. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95834. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95835. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95836. * @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)
  95837. * @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)
  95838. * @returns the VertexData of the Polygon
  95839. */
  95840. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95841. /**
  95842. * Creates the VertexData of the IcoSphere
  95843. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95844. * * radius the radius of the IcoSphere, optional default 1
  95845. * * radiusX allows stretching in the x direction, optional, default radius
  95846. * * radiusY allows stretching in the y direction, optional, default radius
  95847. * * radiusZ allows stretching in the z direction, optional, default radius
  95848. * * flat when true creates a flat shaded mesh, optional, default true
  95849. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95851. * * 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)
  95852. * * 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)
  95853. * @returns the VertexData of the IcoSphere
  95854. */
  95855. static CreateIcoSphere(options: {
  95856. radius?: number;
  95857. radiusX?: number;
  95858. radiusY?: number;
  95859. radiusZ?: number;
  95860. flat?: boolean;
  95861. subdivisions?: number;
  95862. sideOrientation?: number;
  95863. frontUVs?: Vector4;
  95864. backUVs?: Vector4;
  95865. }): VertexData;
  95866. /**
  95867. * Creates the VertexData for a Polyhedron
  95868. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95869. * * type provided types are:
  95870. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95871. * * 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)
  95872. * * size the size of the IcoSphere, optional default 1
  95873. * * sizeX allows stretching in the x direction, optional, default size
  95874. * * sizeY allows stretching in the y direction, optional, default size
  95875. * * sizeZ allows stretching in the z direction, optional, default size
  95876. * * 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
  95877. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95878. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95879. * * flat when true creates a flat shaded mesh, optional, default true
  95880. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95881. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95882. * * 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)
  95883. * * 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)
  95884. * @returns the VertexData of the Polyhedron
  95885. */
  95886. static CreatePolyhedron(options: {
  95887. type?: number;
  95888. size?: number;
  95889. sizeX?: number;
  95890. sizeY?: number;
  95891. sizeZ?: number;
  95892. custom?: any;
  95893. faceUV?: Vector4[];
  95894. faceColors?: Color4[];
  95895. flat?: boolean;
  95896. sideOrientation?: number;
  95897. frontUVs?: Vector4;
  95898. backUVs?: Vector4;
  95899. }): VertexData;
  95900. /**
  95901. * Creates the VertexData for a TorusKnot
  95902. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95903. * * radius the radius of the torus knot, optional, default 2
  95904. * * tube the thickness of the tube, optional, default 0.5
  95905. * * radialSegments the number of sides on each tube segments, optional, default 32
  95906. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95907. * * p the number of windings around the z axis, optional, default 2
  95908. * * q the number of windings around the x axis, optional, default 3
  95909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95910. * * 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)
  95911. * * 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)
  95912. * @returns the VertexData of the Torus Knot
  95913. */
  95914. static CreateTorusKnot(options: {
  95915. radius?: number;
  95916. tube?: number;
  95917. radialSegments?: number;
  95918. tubularSegments?: number;
  95919. p?: number;
  95920. q?: number;
  95921. sideOrientation?: number;
  95922. frontUVs?: Vector4;
  95923. backUVs?: Vector4;
  95924. }): VertexData;
  95925. /**
  95926. * Compute normals for given positions and indices
  95927. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95928. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95929. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95930. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95931. * * facetNormals : optional array of facet normals (vector3)
  95932. * * facetPositions : optional array of facet positions (vector3)
  95933. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95934. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95935. * * bInfo : optional bounding info, required for facetPartitioning computation
  95936. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95937. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95938. * * useRightHandedSystem: optional boolean to for right handed system computation
  95939. * * depthSort : optional boolean to enable the facet depth sort computation
  95940. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95941. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95942. */
  95943. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95944. facetNormals?: any;
  95945. facetPositions?: any;
  95946. facetPartitioning?: any;
  95947. ratio?: number;
  95948. bInfo?: any;
  95949. bbSize?: Vector3;
  95950. subDiv?: any;
  95951. useRightHandedSystem?: boolean;
  95952. depthSort?: boolean;
  95953. distanceTo?: Vector3;
  95954. depthSortedFacets?: any;
  95955. }): void;
  95956. /** @hidden */
  95957. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95958. /**
  95959. * Applies VertexData created from the imported parameters to the geometry
  95960. * @param parsedVertexData the parsed data from an imported file
  95961. * @param geometry the geometry to apply the VertexData to
  95962. */
  95963. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95964. }
  95965. }
  95966. declare module BABYLON {
  95967. /**
  95968. * Defines a target to use with MorphTargetManager
  95969. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95970. */
  95971. export class MorphTarget implements IAnimatable {
  95972. /** defines the name of the target */
  95973. name: string;
  95974. /**
  95975. * Gets or sets the list of animations
  95976. */
  95977. animations: Animation[];
  95978. private _scene;
  95979. private _positions;
  95980. private _normals;
  95981. private _tangents;
  95982. private _uvs;
  95983. private _influence;
  95984. private _uniqueId;
  95985. /**
  95986. * Observable raised when the influence changes
  95987. */
  95988. onInfluenceChanged: Observable<boolean>;
  95989. /** @hidden */
  95990. _onDataLayoutChanged: Observable<void>;
  95991. /**
  95992. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95993. */
  95994. get influence(): number;
  95995. set influence(influence: number);
  95996. /**
  95997. * Gets or sets the id of the morph Target
  95998. */
  95999. id: string;
  96000. private _animationPropertiesOverride;
  96001. /**
  96002. * Gets or sets the animation properties override
  96003. */
  96004. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96005. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96006. /**
  96007. * Creates a new MorphTarget
  96008. * @param name defines the name of the target
  96009. * @param influence defines the influence to use
  96010. * @param scene defines the scene the morphtarget belongs to
  96011. */
  96012. constructor(
  96013. /** defines the name of the target */
  96014. name: string, influence?: number, scene?: Nullable<Scene>);
  96015. /**
  96016. * Gets the unique ID of this manager
  96017. */
  96018. get uniqueId(): number;
  96019. /**
  96020. * Gets a boolean defining if the target contains position data
  96021. */
  96022. get hasPositions(): boolean;
  96023. /**
  96024. * Gets a boolean defining if the target contains normal data
  96025. */
  96026. get hasNormals(): boolean;
  96027. /**
  96028. * Gets a boolean defining if the target contains tangent data
  96029. */
  96030. get hasTangents(): boolean;
  96031. /**
  96032. * Gets a boolean defining if the target contains texture coordinates data
  96033. */
  96034. get hasUVs(): boolean;
  96035. /**
  96036. * Affects position data to this target
  96037. * @param data defines the position data to use
  96038. */
  96039. setPositions(data: Nullable<FloatArray>): void;
  96040. /**
  96041. * Gets the position data stored in this target
  96042. * @returns a FloatArray containing the position data (or null if not present)
  96043. */
  96044. getPositions(): Nullable<FloatArray>;
  96045. /**
  96046. * Affects normal data to this target
  96047. * @param data defines the normal data to use
  96048. */
  96049. setNormals(data: Nullable<FloatArray>): void;
  96050. /**
  96051. * Gets the normal data stored in this target
  96052. * @returns a FloatArray containing the normal data (or null if not present)
  96053. */
  96054. getNormals(): Nullable<FloatArray>;
  96055. /**
  96056. * Affects tangent data to this target
  96057. * @param data defines the tangent data to use
  96058. */
  96059. setTangents(data: Nullable<FloatArray>): void;
  96060. /**
  96061. * Gets the tangent data stored in this target
  96062. * @returns a FloatArray containing the tangent data (or null if not present)
  96063. */
  96064. getTangents(): Nullable<FloatArray>;
  96065. /**
  96066. * Affects texture coordinates data to this target
  96067. * @param data defines the texture coordinates data to use
  96068. */
  96069. setUVs(data: Nullable<FloatArray>): void;
  96070. /**
  96071. * Gets the texture coordinates data stored in this target
  96072. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96073. */
  96074. getUVs(): Nullable<FloatArray>;
  96075. /**
  96076. * Clone the current target
  96077. * @returns a new MorphTarget
  96078. */
  96079. clone(): MorphTarget;
  96080. /**
  96081. * Serializes the current target into a Serialization object
  96082. * @returns the serialized object
  96083. */
  96084. serialize(): any;
  96085. /**
  96086. * Returns the string "MorphTarget"
  96087. * @returns "MorphTarget"
  96088. */
  96089. getClassName(): string;
  96090. /**
  96091. * Creates a new target from serialized data
  96092. * @param serializationObject defines the serialized data to use
  96093. * @returns a new MorphTarget
  96094. */
  96095. static Parse(serializationObject: any): MorphTarget;
  96096. /**
  96097. * Creates a MorphTarget from mesh data
  96098. * @param mesh defines the source mesh
  96099. * @param name defines the name to use for the new target
  96100. * @param influence defines the influence to attach to the target
  96101. * @returns a new MorphTarget
  96102. */
  96103. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96104. }
  96105. }
  96106. declare module BABYLON {
  96107. /**
  96108. * This class is used to deform meshes using morphing between different targets
  96109. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96110. */
  96111. export class MorphTargetManager {
  96112. private _targets;
  96113. private _targetInfluenceChangedObservers;
  96114. private _targetDataLayoutChangedObservers;
  96115. private _activeTargets;
  96116. private _scene;
  96117. private _influences;
  96118. private _supportsNormals;
  96119. private _supportsTangents;
  96120. private _supportsUVs;
  96121. private _vertexCount;
  96122. private _uniqueId;
  96123. private _tempInfluences;
  96124. /**
  96125. * Gets or sets a boolean indicating if normals must be morphed
  96126. */
  96127. enableNormalMorphing: boolean;
  96128. /**
  96129. * Gets or sets a boolean indicating if tangents must be morphed
  96130. */
  96131. enableTangentMorphing: boolean;
  96132. /**
  96133. * Gets or sets a boolean indicating if UV must be morphed
  96134. */
  96135. enableUVMorphing: boolean;
  96136. /**
  96137. * Creates a new MorphTargetManager
  96138. * @param scene defines the current scene
  96139. */
  96140. constructor(scene?: Nullable<Scene>);
  96141. /**
  96142. * Gets the unique ID of this manager
  96143. */
  96144. get uniqueId(): number;
  96145. /**
  96146. * Gets the number of vertices handled by this manager
  96147. */
  96148. get vertexCount(): number;
  96149. /**
  96150. * Gets a boolean indicating if this manager supports morphing of normals
  96151. */
  96152. get supportsNormals(): boolean;
  96153. /**
  96154. * Gets a boolean indicating if this manager supports morphing of tangents
  96155. */
  96156. get supportsTangents(): boolean;
  96157. /**
  96158. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96159. */
  96160. get supportsUVs(): boolean;
  96161. /**
  96162. * Gets the number of targets stored in this manager
  96163. */
  96164. get numTargets(): number;
  96165. /**
  96166. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96167. */
  96168. get numInfluencers(): number;
  96169. /**
  96170. * Gets the list of influences (one per target)
  96171. */
  96172. get influences(): Float32Array;
  96173. /**
  96174. * Gets the active target at specified index. An active target is a target with an influence > 0
  96175. * @param index defines the index to check
  96176. * @returns the requested target
  96177. */
  96178. getActiveTarget(index: number): MorphTarget;
  96179. /**
  96180. * Gets the target at specified index
  96181. * @param index defines the index to check
  96182. * @returns the requested target
  96183. */
  96184. getTarget(index: number): MorphTarget;
  96185. /**
  96186. * Add a new target to this manager
  96187. * @param target defines the target to add
  96188. */
  96189. addTarget(target: MorphTarget): void;
  96190. /**
  96191. * Removes a target from the manager
  96192. * @param target defines the target to remove
  96193. */
  96194. removeTarget(target: MorphTarget): void;
  96195. /**
  96196. * Clone the current manager
  96197. * @returns a new MorphTargetManager
  96198. */
  96199. clone(): MorphTargetManager;
  96200. /**
  96201. * Serializes the current manager into a Serialization object
  96202. * @returns the serialized object
  96203. */
  96204. serialize(): any;
  96205. private _syncActiveTargets;
  96206. /**
  96207. * Syncrhonize the targets with all the meshes using this morph target manager
  96208. */
  96209. synchronize(): void;
  96210. /**
  96211. * Creates a new MorphTargetManager from serialized data
  96212. * @param serializationObject defines the serialized data
  96213. * @param scene defines the hosting scene
  96214. * @returns the new MorphTargetManager
  96215. */
  96216. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96217. }
  96218. }
  96219. declare module BABYLON {
  96220. /**
  96221. * Class used to represent a specific level of detail of a mesh
  96222. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96223. */
  96224. export class MeshLODLevel {
  96225. /** Defines the distance where this level should start being displayed */
  96226. distance: number;
  96227. /** Defines the mesh to use to render this level */
  96228. mesh: Nullable<Mesh>;
  96229. /**
  96230. * Creates a new LOD level
  96231. * @param distance defines the distance where this level should star being displayed
  96232. * @param mesh defines the mesh to use to render this level
  96233. */
  96234. constructor(
  96235. /** Defines the distance where this level should start being displayed */
  96236. distance: number,
  96237. /** Defines the mesh to use to render this level */
  96238. mesh: Nullable<Mesh>);
  96239. }
  96240. }
  96241. declare module BABYLON {
  96242. /**
  96243. * Mesh representing the gorund
  96244. */
  96245. export class GroundMesh extends Mesh {
  96246. /** If octree should be generated */
  96247. generateOctree: boolean;
  96248. private _heightQuads;
  96249. /** @hidden */
  96250. _subdivisionsX: number;
  96251. /** @hidden */
  96252. _subdivisionsY: number;
  96253. /** @hidden */
  96254. _width: number;
  96255. /** @hidden */
  96256. _height: number;
  96257. /** @hidden */
  96258. _minX: number;
  96259. /** @hidden */
  96260. _maxX: number;
  96261. /** @hidden */
  96262. _minZ: number;
  96263. /** @hidden */
  96264. _maxZ: number;
  96265. constructor(name: string, scene: Scene);
  96266. /**
  96267. * "GroundMesh"
  96268. * @returns "GroundMesh"
  96269. */
  96270. getClassName(): string;
  96271. /**
  96272. * The minimum of x and y subdivisions
  96273. */
  96274. get subdivisions(): number;
  96275. /**
  96276. * X subdivisions
  96277. */
  96278. get subdivisionsX(): number;
  96279. /**
  96280. * Y subdivisions
  96281. */
  96282. get subdivisionsY(): number;
  96283. /**
  96284. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96285. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96286. * @param chunksCount the number of subdivisions for x and y
  96287. * @param octreeBlocksSize (Default: 32)
  96288. */
  96289. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96290. /**
  96291. * Returns a height (y) value in the Worl system :
  96292. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96293. * @param x x coordinate
  96294. * @param z z coordinate
  96295. * @returns the ground y position if (x, z) are outside the ground surface.
  96296. */
  96297. getHeightAtCoordinates(x: number, z: number): number;
  96298. /**
  96299. * Returns a normalized vector (Vector3) orthogonal to the ground
  96300. * at the ground coordinates (x, z) expressed in the World system.
  96301. * @param x x coordinate
  96302. * @param z z coordinate
  96303. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96304. */
  96305. getNormalAtCoordinates(x: number, z: number): Vector3;
  96306. /**
  96307. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96308. * at the ground coordinates (x, z) expressed in the World system.
  96309. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96310. * @param x x coordinate
  96311. * @param z z coordinate
  96312. * @param ref vector to store the result
  96313. * @returns the GroundMesh.
  96314. */
  96315. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96316. /**
  96317. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96318. * if the ground has been updated.
  96319. * This can be used in the render loop.
  96320. * @returns the GroundMesh.
  96321. */
  96322. updateCoordinateHeights(): GroundMesh;
  96323. private _getFacetAt;
  96324. private _initHeightQuads;
  96325. private _computeHeightQuads;
  96326. /**
  96327. * Serializes this ground mesh
  96328. * @param serializationObject object to write serialization to
  96329. */
  96330. serialize(serializationObject: any): void;
  96331. /**
  96332. * Parses a serialized ground mesh
  96333. * @param parsedMesh the serialized mesh
  96334. * @param scene the scene to create the ground mesh in
  96335. * @returns the created ground mesh
  96336. */
  96337. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96338. }
  96339. }
  96340. declare module BABYLON {
  96341. /**
  96342. * Interface for Physics-Joint data
  96343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96344. */
  96345. export interface PhysicsJointData {
  96346. /**
  96347. * The main pivot of the joint
  96348. */
  96349. mainPivot?: Vector3;
  96350. /**
  96351. * The connected pivot of the joint
  96352. */
  96353. connectedPivot?: Vector3;
  96354. /**
  96355. * The main axis of the joint
  96356. */
  96357. mainAxis?: Vector3;
  96358. /**
  96359. * The connected axis of the joint
  96360. */
  96361. connectedAxis?: Vector3;
  96362. /**
  96363. * The collision of the joint
  96364. */
  96365. collision?: boolean;
  96366. /**
  96367. * Native Oimo/Cannon/Energy data
  96368. */
  96369. nativeParams?: any;
  96370. }
  96371. /**
  96372. * This is a holder class for the physics joint created by the physics plugin
  96373. * It holds a set of functions to control the underlying joint
  96374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96375. */
  96376. export class PhysicsJoint {
  96377. /**
  96378. * The type of the physics joint
  96379. */
  96380. type: number;
  96381. /**
  96382. * The data for the physics joint
  96383. */
  96384. jointData: PhysicsJointData;
  96385. private _physicsJoint;
  96386. protected _physicsPlugin: IPhysicsEnginePlugin;
  96387. /**
  96388. * Initializes the physics joint
  96389. * @param type The type of the physics joint
  96390. * @param jointData The data for the physics joint
  96391. */
  96392. constructor(
  96393. /**
  96394. * The type of the physics joint
  96395. */
  96396. type: number,
  96397. /**
  96398. * The data for the physics joint
  96399. */
  96400. jointData: PhysicsJointData);
  96401. /**
  96402. * Gets the physics joint
  96403. */
  96404. get physicsJoint(): any;
  96405. /**
  96406. * Sets the physics joint
  96407. */
  96408. set physicsJoint(newJoint: any);
  96409. /**
  96410. * Sets the physics plugin
  96411. */
  96412. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96413. /**
  96414. * Execute a function that is physics-plugin specific.
  96415. * @param {Function} func the function that will be executed.
  96416. * It accepts two parameters: the physics world and the physics joint
  96417. */
  96418. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96419. /**
  96420. * Distance-Joint type
  96421. */
  96422. static DistanceJoint: number;
  96423. /**
  96424. * Hinge-Joint type
  96425. */
  96426. static HingeJoint: number;
  96427. /**
  96428. * Ball-and-Socket joint type
  96429. */
  96430. static BallAndSocketJoint: number;
  96431. /**
  96432. * Wheel-Joint type
  96433. */
  96434. static WheelJoint: number;
  96435. /**
  96436. * Slider-Joint type
  96437. */
  96438. static SliderJoint: number;
  96439. /**
  96440. * Prismatic-Joint type
  96441. */
  96442. static PrismaticJoint: number;
  96443. /**
  96444. * Universal-Joint type
  96445. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96446. */
  96447. static UniversalJoint: number;
  96448. /**
  96449. * Hinge-Joint 2 type
  96450. */
  96451. static Hinge2Joint: number;
  96452. /**
  96453. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96454. */
  96455. static PointToPointJoint: number;
  96456. /**
  96457. * Spring-Joint type
  96458. */
  96459. static SpringJoint: number;
  96460. /**
  96461. * Lock-Joint type
  96462. */
  96463. static LockJoint: number;
  96464. }
  96465. /**
  96466. * A class representing a physics distance joint
  96467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96468. */
  96469. export class DistanceJoint extends PhysicsJoint {
  96470. /**
  96471. *
  96472. * @param jointData The data for the Distance-Joint
  96473. */
  96474. constructor(jointData: DistanceJointData);
  96475. /**
  96476. * Update the predefined distance.
  96477. * @param maxDistance The maximum preferred distance
  96478. * @param minDistance The minimum preferred distance
  96479. */
  96480. updateDistance(maxDistance: number, minDistance?: number): void;
  96481. }
  96482. /**
  96483. * Represents a Motor-Enabled Joint
  96484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96485. */
  96486. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96487. /**
  96488. * Initializes the Motor-Enabled Joint
  96489. * @param type The type of the joint
  96490. * @param jointData The physica joint data for the joint
  96491. */
  96492. constructor(type: number, jointData: PhysicsJointData);
  96493. /**
  96494. * Set the motor values.
  96495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96496. * @param force the force to apply
  96497. * @param maxForce max force for this motor.
  96498. */
  96499. setMotor(force?: number, maxForce?: number): void;
  96500. /**
  96501. * Set the motor's limits.
  96502. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96503. * @param upperLimit The upper limit of the motor
  96504. * @param lowerLimit The lower limit of the motor
  96505. */
  96506. setLimit(upperLimit: number, lowerLimit?: number): void;
  96507. }
  96508. /**
  96509. * This class represents a single physics Hinge-Joint
  96510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96511. */
  96512. export class HingeJoint extends MotorEnabledJoint {
  96513. /**
  96514. * Initializes the Hinge-Joint
  96515. * @param jointData The joint data for the Hinge-Joint
  96516. */
  96517. constructor(jointData: PhysicsJointData);
  96518. /**
  96519. * Set the motor values.
  96520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96521. * @param {number} force the force to apply
  96522. * @param {number} maxForce max force for this motor.
  96523. */
  96524. setMotor(force?: number, maxForce?: number): void;
  96525. /**
  96526. * Set the motor's limits.
  96527. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96528. * @param upperLimit The upper limit of the motor
  96529. * @param lowerLimit The lower limit of the motor
  96530. */
  96531. setLimit(upperLimit: number, lowerLimit?: number): void;
  96532. }
  96533. /**
  96534. * This class represents a dual hinge physics joint (same as wheel joint)
  96535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96536. */
  96537. export class Hinge2Joint extends MotorEnabledJoint {
  96538. /**
  96539. * Initializes the Hinge2-Joint
  96540. * @param jointData The joint data for the Hinge2-Joint
  96541. */
  96542. constructor(jointData: PhysicsJointData);
  96543. /**
  96544. * Set the motor values.
  96545. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96546. * @param {number} targetSpeed the speed the motor is to reach
  96547. * @param {number} maxForce max force for this motor.
  96548. * @param {motorIndex} the motor's index, 0 or 1.
  96549. */
  96550. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96551. /**
  96552. * Set the motor limits.
  96553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96554. * @param {number} upperLimit the upper limit
  96555. * @param {number} lowerLimit lower limit
  96556. * @param {motorIndex} the motor's index, 0 or 1.
  96557. */
  96558. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96559. }
  96560. /**
  96561. * Interface for a motor enabled joint
  96562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96563. */
  96564. export interface IMotorEnabledJoint {
  96565. /**
  96566. * Physics joint
  96567. */
  96568. physicsJoint: any;
  96569. /**
  96570. * Sets the motor of the motor-enabled joint
  96571. * @param force The force of the motor
  96572. * @param maxForce The maximum force of the motor
  96573. * @param motorIndex The index of the motor
  96574. */
  96575. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96576. /**
  96577. * Sets the limit of the motor
  96578. * @param upperLimit The upper limit of the motor
  96579. * @param lowerLimit The lower limit of the motor
  96580. * @param motorIndex The index of the motor
  96581. */
  96582. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96583. }
  96584. /**
  96585. * Joint data for a Distance-Joint
  96586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96587. */
  96588. export interface DistanceJointData extends PhysicsJointData {
  96589. /**
  96590. * Max distance the 2 joint objects can be apart
  96591. */
  96592. maxDistance: number;
  96593. }
  96594. /**
  96595. * Joint data from a spring joint
  96596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96597. */
  96598. export interface SpringJointData extends PhysicsJointData {
  96599. /**
  96600. * Length of the spring
  96601. */
  96602. length: number;
  96603. /**
  96604. * Stiffness of the spring
  96605. */
  96606. stiffness: number;
  96607. /**
  96608. * Damping of the spring
  96609. */
  96610. damping: number;
  96611. /** this callback will be called when applying the force to the impostors. */
  96612. forceApplicationCallback: () => void;
  96613. }
  96614. }
  96615. declare module BABYLON {
  96616. /**
  96617. * Holds the data for the raycast result
  96618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96619. */
  96620. export class PhysicsRaycastResult {
  96621. private _hasHit;
  96622. private _hitDistance;
  96623. private _hitNormalWorld;
  96624. private _hitPointWorld;
  96625. private _rayFromWorld;
  96626. private _rayToWorld;
  96627. /**
  96628. * Gets if there was a hit
  96629. */
  96630. get hasHit(): boolean;
  96631. /**
  96632. * Gets the distance from the hit
  96633. */
  96634. get hitDistance(): number;
  96635. /**
  96636. * Gets the hit normal/direction in the world
  96637. */
  96638. get hitNormalWorld(): Vector3;
  96639. /**
  96640. * Gets the hit point in the world
  96641. */
  96642. get hitPointWorld(): Vector3;
  96643. /**
  96644. * Gets the ray "start point" of the ray in the world
  96645. */
  96646. get rayFromWorld(): Vector3;
  96647. /**
  96648. * Gets the ray "end point" of the ray in the world
  96649. */
  96650. get rayToWorld(): Vector3;
  96651. /**
  96652. * Sets the hit data (normal & point in world space)
  96653. * @param hitNormalWorld defines the normal in world space
  96654. * @param hitPointWorld defines the point in world space
  96655. */
  96656. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96657. /**
  96658. * Sets the distance from the start point to the hit point
  96659. * @param distance
  96660. */
  96661. setHitDistance(distance: number): void;
  96662. /**
  96663. * Calculates the distance manually
  96664. */
  96665. calculateHitDistance(): void;
  96666. /**
  96667. * Resets all the values to default
  96668. * @param from The from point on world space
  96669. * @param to The to point on world space
  96670. */
  96671. reset(from?: Vector3, to?: Vector3): void;
  96672. }
  96673. /**
  96674. * Interface for the size containing width and height
  96675. */
  96676. interface IXYZ {
  96677. /**
  96678. * X
  96679. */
  96680. x: number;
  96681. /**
  96682. * Y
  96683. */
  96684. y: number;
  96685. /**
  96686. * Z
  96687. */
  96688. z: number;
  96689. }
  96690. }
  96691. declare module BABYLON {
  96692. /**
  96693. * Interface used to describe a physics joint
  96694. */
  96695. export interface PhysicsImpostorJoint {
  96696. /** Defines the main impostor to which the joint is linked */
  96697. mainImpostor: PhysicsImpostor;
  96698. /** Defines the impostor that is connected to the main impostor using this joint */
  96699. connectedImpostor: PhysicsImpostor;
  96700. /** Defines the joint itself */
  96701. joint: PhysicsJoint;
  96702. }
  96703. /** @hidden */
  96704. export interface IPhysicsEnginePlugin {
  96705. world: any;
  96706. name: string;
  96707. setGravity(gravity: Vector3): void;
  96708. setTimeStep(timeStep: number): void;
  96709. getTimeStep(): number;
  96710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96714. removePhysicsBody(impostor: PhysicsImpostor): void;
  96715. generateJoint(joint: PhysicsImpostorJoint): void;
  96716. removeJoint(joint: PhysicsImpostorJoint): void;
  96717. isSupported(): boolean;
  96718. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96723. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96725. getBodyMass(impostor: PhysicsImpostor): number;
  96726. getBodyFriction(impostor: PhysicsImpostor): number;
  96727. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96728. getBodyRestitution(impostor: PhysicsImpostor): number;
  96729. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96730. getBodyPressure?(impostor: PhysicsImpostor): number;
  96731. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96732. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96733. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96734. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96735. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96736. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96737. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96738. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96739. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96740. sleepBody(impostor: PhysicsImpostor): void;
  96741. wakeUpBody(impostor: PhysicsImpostor): void;
  96742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96746. getRadius(impostor: PhysicsImpostor): number;
  96747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96749. dispose(): void;
  96750. }
  96751. /**
  96752. * Interface used to define a physics engine
  96753. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96754. */
  96755. export interface IPhysicsEngine {
  96756. /**
  96757. * Gets the gravity vector used by the simulation
  96758. */
  96759. gravity: Vector3;
  96760. /**
  96761. * Sets the gravity vector used by the simulation
  96762. * @param gravity defines the gravity vector to use
  96763. */
  96764. setGravity(gravity: Vector3): void;
  96765. /**
  96766. * Set the time step of the physics engine.
  96767. * Default is 1/60.
  96768. * To slow it down, enter 1/600 for example.
  96769. * To speed it up, 1/30
  96770. * @param newTimeStep the new timestep to apply to this world.
  96771. */
  96772. setTimeStep(newTimeStep: number): void;
  96773. /**
  96774. * Get the time step of the physics engine.
  96775. * @returns the current time step
  96776. */
  96777. getTimeStep(): number;
  96778. /**
  96779. * Set the sub time step of the physics engine.
  96780. * Default is 0 meaning there is no sub steps
  96781. * To increase physics resolution precision, set a small value (like 1 ms)
  96782. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96783. */
  96784. setSubTimeStep(subTimeStep: number): void;
  96785. /**
  96786. * Get the sub time step of the physics engine.
  96787. * @returns the current sub time step
  96788. */
  96789. getSubTimeStep(): number;
  96790. /**
  96791. * Release all resources
  96792. */
  96793. dispose(): void;
  96794. /**
  96795. * Gets the name of the current physics plugin
  96796. * @returns the name of the plugin
  96797. */
  96798. getPhysicsPluginName(): string;
  96799. /**
  96800. * Adding a new impostor for the impostor tracking.
  96801. * This will be done by the impostor itself.
  96802. * @param impostor the impostor to add
  96803. */
  96804. addImpostor(impostor: PhysicsImpostor): void;
  96805. /**
  96806. * Remove an impostor from the engine.
  96807. * This impostor and its mesh will not longer be updated by the physics engine.
  96808. * @param impostor the impostor to remove
  96809. */
  96810. removeImpostor(impostor: PhysicsImpostor): void;
  96811. /**
  96812. * Add a joint to the physics engine
  96813. * @param mainImpostor defines the main impostor to which the joint is added.
  96814. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96815. * @param joint defines the joint that will connect both impostors.
  96816. */
  96817. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96818. /**
  96819. * Removes a joint from the simulation
  96820. * @param mainImpostor defines the impostor used with the joint
  96821. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96822. * @param joint defines the joint to remove
  96823. */
  96824. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96825. /**
  96826. * Gets the current plugin used to run the simulation
  96827. * @returns current plugin
  96828. */
  96829. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96830. /**
  96831. * Gets the list of physic impostors
  96832. * @returns an array of PhysicsImpostor
  96833. */
  96834. getImpostors(): Array<PhysicsImpostor>;
  96835. /**
  96836. * Gets the impostor for a physics enabled object
  96837. * @param object defines the object impersonated by the impostor
  96838. * @returns the PhysicsImpostor or null if not found
  96839. */
  96840. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96841. /**
  96842. * Gets the impostor for a physics body object
  96843. * @param body defines physics body used by the impostor
  96844. * @returns the PhysicsImpostor or null if not found
  96845. */
  96846. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96847. /**
  96848. * Does a raycast in the physics world
  96849. * @param from when should the ray start?
  96850. * @param to when should the ray end?
  96851. * @returns PhysicsRaycastResult
  96852. */
  96853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96854. /**
  96855. * Called by the scene. No need to call it.
  96856. * @param delta defines the timespam between frames
  96857. */
  96858. _step(delta: number): void;
  96859. }
  96860. }
  96861. declare module BABYLON {
  96862. /**
  96863. * The interface for the physics imposter parameters
  96864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96865. */
  96866. export interface PhysicsImpostorParameters {
  96867. /**
  96868. * The mass of the physics imposter
  96869. */
  96870. mass: number;
  96871. /**
  96872. * The friction of the physics imposter
  96873. */
  96874. friction?: number;
  96875. /**
  96876. * The coefficient of restitution of the physics imposter
  96877. */
  96878. restitution?: number;
  96879. /**
  96880. * The native options of the physics imposter
  96881. */
  96882. nativeOptions?: any;
  96883. /**
  96884. * Specifies if the parent should be ignored
  96885. */
  96886. ignoreParent?: boolean;
  96887. /**
  96888. * Specifies if bi-directional transformations should be disabled
  96889. */
  96890. disableBidirectionalTransformation?: boolean;
  96891. /**
  96892. * The pressure inside the physics imposter, soft object only
  96893. */
  96894. pressure?: number;
  96895. /**
  96896. * The stiffness the physics imposter, soft object only
  96897. */
  96898. stiffness?: number;
  96899. /**
  96900. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96901. */
  96902. velocityIterations?: number;
  96903. /**
  96904. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96905. */
  96906. positionIterations?: number;
  96907. /**
  96908. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96909. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96910. * Add to fix multiple points
  96911. */
  96912. fixedPoints?: number;
  96913. /**
  96914. * The collision margin around a soft object
  96915. */
  96916. margin?: number;
  96917. /**
  96918. * The collision margin around a soft object
  96919. */
  96920. damping?: number;
  96921. /**
  96922. * The path for a rope based on an extrusion
  96923. */
  96924. path?: any;
  96925. /**
  96926. * The shape of an extrusion used for a rope based on an extrusion
  96927. */
  96928. shape?: any;
  96929. }
  96930. /**
  96931. * Interface for a physics-enabled object
  96932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96933. */
  96934. export interface IPhysicsEnabledObject {
  96935. /**
  96936. * The position of the physics-enabled object
  96937. */
  96938. position: Vector3;
  96939. /**
  96940. * The rotation of the physics-enabled object
  96941. */
  96942. rotationQuaternion: Nullable<Quaternion>;
  96943. /**
  96944. * The scale of the physics-enabled object
  96945. */
  96946. scaling: Vector3;
  96947. /**
  96948. * The rotation of the physics-enabled object
  96949. */
  96950. rotation?: Vector3;
  96951. /**
  96952. * The parent of the physics-enabled object
  96953. */
  96954. parent?: any;
  96955. /**
  96956. * The bounding info of the physics-enabled object
  96957. * @returns The bounding info of the physics-enabled object
  96958. */
  96959. getBoundingInfo(): BoundingInfo;
  96960. /**
  96961. * Computes the world matrix
  96962. * @param force Specifies if the world matrix should be computed by force
  96963. * @returns A world matrix
  96964. */
  96965. computeWorldMatrix(force: boolean): Matrix;
  96966. /**
  96967. * Gets the world matrix
  96968. * @returns A world matrix
  96969. */
  96970. getWorldMatrix?(): Matrix;
  96971. /**
  96972. * Gets the child meshes
  96973. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96974. * @returns An array of abstract meshes
  96975. */
  96976. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96977. /**
  96978. * Gets the vertex data
  96979. * @param kind The type of vertex data
  96980. * @returns A nullable array of numbers, or a float32 array
  96981. */
  96982. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96983. /**
  96984. * Gets the indices from the mesh
  96985. * @returns A nullable array of index arrays
  96986. */
  96987. getIndices?(): Nullable<IndicesArray>;
  96988. /**
  96989. * Gets the scene from the mesh
  96990. * @returns the indices array or null
  96991. */
  96992. getScene?(): Scene;
  96993. /**
  96994. * Gets the absolute position from the mesh
  96995. * @returns the absolute position
  96996. */
  96997. getAbsolutePosition(): Vector3;
  96998. /**
  96999. * Gets the absolute pivot point from the mesh
  97000. * @returns the absolute pivot point
  97001. */
  97002. getAbsolutePivotPoint(): Vector3;
  97003. /**
  97004. * Rotates the mesh
  97005. * @param axis The axis of rotation
  97006. * @param amount The amount of rotation
  97007. * @param space The space of the rotation
  97008. * @returns The rotation transform node
  97009. */
  97010. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97011. /**
  97012. * Translates the mesh
  97013. * @param axis The axis of translation
  97014. * @param distance The distance of translation
  97015. * @param space The space of the translation
  97016. * @returns The transform node
  97017. */
  97018. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97019. /**
  97020. * Sets the absolute position of the mesh
  97021. * @param absolutePosition The absolute position of the mesh
  97022. * @returns The transform node
  97023. */
  97024. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97025. /**
  97026. * Gets the class name of the mesh
  97027. * @returns The class name
  97028. */
  97029. getClassName(): string;
  97030. }
  97031. /**
  97032. * Represents a physics imposter
  97033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97034. */
  97035. export class PhysicsImpostor {
  97036. /**
  97037. * The physics-enabled object used as the physics imposter
  97038. */
  97039. object: IPhysicsEnabledObject;
  97040. /**
  97041. * The type of the physics imposter
  97042. */
  97043. type: number;
  97044. private _options;
  97045. private _scene?;
  97046. /**
  97047. * The default object size of the imposter
  97048. */
  97049. static DEFAULT_OBJECT_SIZE: Vector3;
  97050. /**
  97051. * The identity quaternion of the imposter
  97052. */
  97053. static IDENTITY_QUATERNION: Quaternion;
  97054. /** @hidden */
  97055. _pluginData: any;
  97056. private _physicsEngine;
  97057. private _physicsBody;
  97058. private _bodyUpdateRequired;
  97059. private _onBeforePhysicsStepCallbacks;
  97060. private _onAfterPhysicsStepCallbacks;
  97061. /** @hidden */
  97062. _onPhysicsCollideCallbacks: Array<{
  97063. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97064. otherImpostors: Array<PhysicsImpostor>;
  97065. }>;
  97066. private _deltaPosition;
  97067. private _deltaRotation;
  97068. private _deltaRotationConjugated;
  97069. /** @hidden */
  97070. _isFromLine: boolean;
  97071. private _parent;
  97072. private _isDisposed;
  97073. private static _tmpVecs;
  97074. private static _tmpQuat;
  97075. /**
  97076. * Specifies if the physics imposter is disposed
  97077. */
  97078. get isDisposed(): boolean;
  97079. /**
  97080. * Gets the mass of the physics imposter
  97081. */
  97082. get mass(): number;
  97083. set mass(value: number);
  97084. /**
  97085. * Gets the coefficient of friction
  97086. */
  97087. get friction(): number;
  97088. /**
  97089. * Sets the coefficient of friction
  97090. */
  97091. set friction(value: number);
  97092. /**
  97093. * Gets the coefficient of restitution
  97094. */
  97095. get restitution(): number;
  97096. /**
  97097. * Sets the coefficient of restitution
  97098. */
  97099. set restitution(value: number);
  97100. /**
  97101. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97102. */
  97103. get pressure(): number;
  97104. /**
  97105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97106. */
  97107. set pressure(value: number);
  97108. /**
  97109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97110. */
  97111. get stiffness(): number;
  97112. /**
  97113. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97114. */
  97115. set stiffness(value: number);
  97116. /**
  97117. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97118. */
  97119. get velocityIterations(): number;
  97120. /**
  97121. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97122. */
  97123. set velocityIterations(value: number);
  97124. /**
  97125. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97126. */
  97127. get positionIterations(): number;
  97128. /**
  97129. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97130. */
  97131. set positionIterations(value: number);
  97132. /**
  97133. * The unique id of the physics imposter
  97134. * set by the physics engine when adding this impostor to the array
  97135. */
  97136. uniqueId: number;
  97137. /**
  97138. * @hidden
  97139. */
  97140. soft: boolean;
  97141. /**
  97142. * @hidden
  97143. */
  97144. segments: number;
  97145. private _joints;
  97146. /**
  97147. * Initializes the physics imposter
  97148. * @param object The physics-enabled object used as the physics imposter
  97149. * @param type The type of the physics imposter
  97150. * @param _options The options for the physics imposter
  97151. * @param _scene The Babylon scene
  97152. */
  97153. constructor(
  97154. /**
  97155. * The physics-enabled object used as the physics imposter
  97156. */
  97157. object: IPhysicsEnabledObject,
  97158. /**
  97159. * The type of the physics imposter
  97160. */
  97161. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97162. /**
  97163. * This function will completly initialize this impostor.
  97164. * It will create a new body - but only if this mesh has no parent.
  97165. * If it has, this impostor will not be used other than to define the impostor
  97166. * of the child mesh.
  97167. * @hidden
  97168. */
  97169. _init(): void;
  97170. private _getPhysicsParent;
  97171. /**
  97172. * Should a new body be generated.
  97173. * @returns boolean specifying if body initialization is required
  97174. */
  97175. isBodyInitRequired(): boolean;
  97176. /**
  97177. * Sets the updated scaling
  97178. * @param updated Specifies if the scaling is updated
  97179. */
  97180. setScalingUpdated(): void;
  97181. /**
  97182. * Force a regeneration of this or the parent's impostor's body.
  97183. * Use under cautious - This will remove all joints already implemented.
  97184. */
  97185. forceUpdate(): void;
  97186. /**
  97187. * Gets the body that holds this impostor. Either its own, or its parent.
  97188. */
  97189. get physicsBody(): any;
  97190. /**
  97191. * Get the parent of the physics imposter
  97192. * @returns Physics imposter or null
  97193. */
  97194. get parent(): Nullable<PhysicsImpostor>;
  97195. /**
  97196. * Sets the parent of the physics imposter
  97197. */
  97198. set parent(value: Nullable<PhysicsImpostor>);
  97199. /**
  97200. * Set the physics body. Used mainly by the physics engine/plugin
  97201. */
  97202. set physicsBody(physicsBody: any);
  97203. /**
  97204. * Resets the update flags
  97205. */
  97206. resetUpdateFlags(): void;
  97207. /**
  97208. * Gets the object extend size
  97209. * @returns the object extend size
  97210. */
  97211. getObjectExtendSize(): Vector3;
  97212. /**
  97213. * Gets the object center
  97214. * @returns The object center
  97215. */
  97216. getObjectCenter(): Vector3;
  97217. /**
  97218. * Get a specific parameter from the options parameters
  97219. * @param paramName The object parameter name
  97220. * @returns The object parameter
  97221. */
  97222. getParam(paramName: string): any;
  97223. /**
  97224. * Sets a specific parameter in the options given to the physics plugin
  97225. * @param paramName The parameter name
  97226. * @param value The value of the parameter
  97227. */
  97228. setParam(paramName: string, value: number): void;
  97229. /**
  97230. * Specifically change the body's mass option. Won't recreate the physics body object
  97231. * @param mass The mass of the physics imposter
  97232. */
  97233. setMass(mass: number): void;
  97234. /**
  97235. * Gets the linear velocity
  97236. * @returns linear velocity or null
  97237. */
  97238. getLinearVelocity(): Nullable<Vector3>;
  97239. /**
  97240. * Sets the linear velocity
  97241. * @param velocity linear velocity or null
  97242. */
  97243. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97244. /**
  97245. * Gets the angular velocity
  97246. * @returns angular velocity or null
  97247. */
  97248. getAngularVelocity(): Nullable<Vector3>;
  97249. /**
  97250. * Sets the angular velocity
  97251. * @param velocity The velocity or null
  97252. */
  97253. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97254. /**
  97255. * Execute a function with the physics plugin native code
  97256. * Provide a function the will have two variables - the world object and the physics body object
  97257. * @param func The function to execute with the physics plugin native code
  97258. */
  97259. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97260. /**
  97261. * Register a function that will be executed before the physics world is stepping forward
  97262. * @param func The function to execute before the physics world is stepped forward
  97263. */
  97264. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97265. /**
  97266. * Unregister a function that will be executed before the physics world is stepping forward
  97267. * @param func The function to execute before the physics world is stepped forward
  97268. */
  97269. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97270. /**
  97271. * Register a function that will be executed after the physics step
  97272. * @param func The function to execute after physics step
  97273. */
  97274. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97275. /**
  97276. * Unregisters a function that will be executed after the physics step
  97277. * @param func The function to execute after physics step
  97278. */
  97279. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97280. /**
  97281. * register a function that will be executed when this impostor collides against a different body
  97282. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97283. * @param func Callback that is executed on collision
  97284. */
  97285. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97286. /**
  97287. * Unregisters the physics imposter on contact
  97288. * @param collideAgainst The physics object to collide against
  97289. * @param func Callback to execute on collision
  97290. */
  97291. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97292. private _tmpQuat;
  97293. private _tmpQuat2;
  97294. /**
  97295. * Get the parent rotation
  97296. * @returns The parent rotation
  97297. */
  97298. getParentsRotation(): Quaternion;
  97299. /**
  97300. * this function is executed by the physics engine.
  97301. */
  97302. beforeStep: () => void;
  97303. /**
  97304. * this function is executed by the physics engine
  97305. */
  97306. afterStep: () => void;
  97307. /**
  97308. * Legacy collision detection event support
  97309. */
  97310. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97311. /**
  97312. * event and body object due to cannon's event-based architecture.
  97313. */
  97314. onCollide: (e: {
  97315. body: any;
  97316. }) => void;
  97317. /**
  97318. * Apply a force
  97319. * @param force The force to apply
  97320. * @param contactPoint The contact point for the force
  97321. * @returns The physics imposter
  97322. */
  97323. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97324. /**
  97325. * Apply an impulse
  97326. * @param force The impulse force
  97327. * @param contactPoint The contact point for the impulse force
  97328. * @returns The physics imposter
  97329. */
  97330. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97331. /**
  97332. * A help function to create a joint
  97333. * @param otherImpostor A physics imposter used to create a joint
  97334. * @param jointType The type of joint
  97335. * @param jointData The data for the joint
  97336. * @returns The physics imposter
  97337. */
  97338. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97339. /**
  97340. * Add a joint to this impostor with a different impostor
  97341. * @param otherImpostor A physics imposter used to add a joint
  97342. * @param joint The joint to add
  97343. * @returns The physics imposter
  97344. */
  97345. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97346. /**
  97347. * Add an anchor to a cloth impostor
  97348. * @param otherImpostor rigid impostor to anchor to
  97349. * @param width ratio across width from 0 to 1
  97350. * @param height ratio up height from 0 to 1
  97351. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97352. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97353. * @returns impostor the soft imposter
  97354. */
  97355. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97356. /**
  97357. * Add a hook to a rope impostor
  97358. * @param otherImpostor rigid impostor to anchor to
  97359. * @param length ratio across rope from 0 to 1
  97360. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97362. * @returns impostor the rope imposter
  97363. */
  97364. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97365. /**
  97366. * Will keep this body still, in a sleep mode.
  97367. * @returns the physics imposter
  97368. */
  97369. sleep(): PhysicsImpostor;
  97370. /**
  97371. * Wake the body up.
  97372. * @returns The physics imposter
  97373. */
  97374. wakeUp(): PhysicsImpostor;
  97375. /**
  97376. * Clones the physics imposter
  97377. * @param newObject The physics imposter clones to this physics-enabled object
  97378. * @returns A nullable physics imposter
  97379. */
  97380. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97381. /**
  97382. * Disposes the physics imposter
  97383. */
  97384. dispose(): void;
  97385. /**
  97386. * Sets the delta position
  97387. * @param position The delta position amount
  97388. */
  97389. setDeltaPosition(position: Vector3): void;
  97390. /**
  97391. * Sets the delta rotation
  97392. * @param rotation The delta rotation amount
  97393. */
  97394. setDeltaRotation(rotation: Quaternion): void;
  97395. /**
  97396. * Gets the box size of the physics imposter and stores the result in the input parameter
  97397. * @param result Stores the box size
  97398. * @returns The physics imposter
  97399. */
  97400. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97401. /**
  97402. * Gets the radius of the physics imposter
  97403. * @returns Radius of the physics imposter
  97404. */
  97405. getRadius(): number;
  97406. /**
  97407. * Sync a bone with this impostor
  97408. * @param bone The bone to sync to the impostor.
  97409. * @param boneMesh The mesh that the bone is influencing.
  97410. * @param jointPivot The pivot of the joint / bone in local space.
  97411. * @param distToJoint Optional distance from the impostor to the joint.
  97412. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97413. */
  97414. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97415. /**
  97416. * Sync impostor to a bone
  97417. * @param bone The bone that the impostor will be synced to.
  97418. * @param boneMesh The mesh that the bone is influencing.
  97419. * @param jointPivot The pivot of the joint / bone in local space.
  97420. * @param distToJoint Optional distance from the impostor to the joint.
  97421. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97422. * @param boneAxis Optional vector3 axis the bone is aligned with
  97423. */
  97424. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97425. /**
  97426. * No-Imposter type
  97427. */
  97428. static NoImpostor: number;
  97429. /**
  97430. * Sphere-Imposter type
  97431. */
  97432. static SphereImpostor: number;
  97433. /**
  97434. * Box-Imposter type
  97435. */
  97436. static BoxImpostor: number;
  97437. /**
  97438. * Plane-Imposter type
  97439. */
  97440. static PlaneImpostor: number;
  97441. /**
  97442. * Mesh-imposter type
  97443. */
  97444. static MeshImpostor: number;
  97445. /**
  97446. * Capsule-Impostor type (Ammo.js plugin only)
  97447. */
  97448. static CapsuleImpostor: number;
  97449. /**
  97450. * Cylinder-Imposter type
  97451. */
  97452. static CylinderImpostor: number;
  97453. /**
  97454. * Particle-Imposter type
  97455. */
  97456. static ParticleImpostor: number;
  97457. /**
  97458. * Heightmap-Imposter type
  97459. */
  97460. static HeightmapImpostor: number;
  97461. /**
  97462. * ConvexHull-Impostor type (Ammo.js plugin only)
  97463. */
  97464. static ConvexHullImpostor: number;
  97465. /**
  97466. * Custom-Imposter type (Ammo.js plugin only)
  97467. */
  97468. static CustomImpostor: number;
  97469. /**
  97470. * Rope-Imposter type
  97471. */
  97472. static RopeImpostor: number;
  97473. /**
  97474. * Cloth-Imposter type
  97475. */
  97476. static ClothImpostor: number;
  97477. /**
  97478. * Softbody-Imposter type
  97479. */
  97480. static SoftbodyImpostor: number;
  97481. }
  97482. }
  97483. declare module BABYLON {
  97484. /**
  97485. * @hidden
  97486. **/
  97487. export class _CreationDataStorage {
  97488. closePath?: boolean;
  97489. closeArray?: boolean;
  97490. idx: number[];
  97491. dashSize: number;
  97492. gapSize: number;
  97493. path3D: Path3D;
  97494. pathArray: Vector3[][];
  97495. arc: number;
  97496. radius: number;
  97497. cap: number;
  97498. tessellation: number;
  97499. }
  97500. /**
  97501. * @hidden
  97502. **/
  97503. class _InstanceDataStorage {
  97504. visibleInstances: any;
  97505. batchCache: _InstancesBatch;
  97506. instancesBufferSize: number;
  97507. instancesBuffer: Nullable<Buffer>;
  97508. instancesData: Float32Array;
  97509. overridenInstanceCount: number;
  97510. isFrozen: boolean;
  97511. previousBatch: Nullable<_InstancesBatch>;
  97512. hardwareInstancedRendering: boolean;
  97513. sideOrientation: number;
  97514. manualUpdate: boolean;
  97515. }
  97516. /**
  97517. * @hidden
  97518. **/
  97519. export class _InstancesBatch {
  97520. mustReturn: boolean;
  97521. visibleInstances: Nullable<InstancedMesh[]>[];
  97522. renderSelf: boolean[];
  97523. hardwareInstancedRendering: boolean[];
  97524. }
  97525. /**
  97526. * Class used to represent renderable models
  97527. */
  97528. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97529. /**
  97530. * Mesh side orientation : usually the external or front surface
  97531. */
  97532. static readonly FRONTSIDE: number;
  97533. /**
  97534. * Mesh side orientation : usually the internal or back surface
  97535. */
  97536. static readonly BACKSIDE: number;
  97537. /**
  97538. * Mesh side orientation : both internal and external or front and back surfaces
  97539. */
  97540. static readonly DOUBLESIDE: number;
  97541. /**
  97542. * Mesh side orientation : by default, `FRONTSIDE`
  97543. */
  97544. static readonly DEFAULTSIDE: number;
  97545. /**
  97546. * Mesh cap setting : no cap
  97547. */
  97548. static readonly NO_CAP: number;
  97549. /**
  97550. * Mesh cap setting : one cap at the beginning of the mesh
  97551. */
  97552. static readonly CAP_START: number;
  97553. /**
  97554. * Mesh cap setting : one cap at the end of the mesh
  97555. */
  97556. static readonly CAP_END: number;
  97557. /**
  97558. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97559. */
  97560. static readonly CAP_ALL: number;
  97561. /**
  97562. * Mesh pattern setting : no flip or rotate
  97563. */
  97564. static readonly NO_FLIP: number;
  97565. /**
  97566. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97567. */
  97568. static readonly FLIP_TILE: number;
  97569. /**
  97570. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97571. */
  97572. static readonly ROTATE_TILE: number;
  97573. /**
  97574. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97575. */
  97576. static readonly FLIP_ROW: number;
  97577. /**
  97578. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97579. */
  97580. static readonly ROTATE_ROW: number;
  97581. /**
  97582. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97583. */
  97584. static readonly FLIP_N_ROTATE_TILE: number;
  97585. /**
  97586. * Mesh pattern setting : rotate pattern and rotate
  97587. */
  97588. static readonly FLIP_N_ROTATE_ROW: number;
  97589. /**
  97590. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97591. */
  97592. static readonly CENTER: number;
  97593. /**
  97594. * Mesh tile positioning : part tiles on left
  97595. */
  97596. static readonly LEFT: number;
  97597. /**
  97598. * Mesh tile positioning : part tiles on right
  97599. */
  97600. static readonly RIGHT: number;
  97601. /**
  97602. * Mesh tile positioning : part tiles on top
  97603. */
  97604. static readonly TOP: number;
  97605. /**
  97606. * Mesh tile positioning : part tiles on bottom
  97607. */
  97608. static readonly BOTTOM: number;
  97609. /**
  97610. * Gets the default side orientation.
  97611. * @param orientation the orientation to value to attempt to get
  97612. * @returns the default orientation
  97613. * @hidden
  97614. */
  97615. static _GetDefaultSideOrientation(orientation?: number): number;
  97616. private _internalMeshDataInfo;
  97617. /**
  97618. * An event triggered before rendering the mesh
  97619. */
  97620. get onBeforeRenderObservable(): Observable<Mesh>;
  97621. /**
  97622. * An event triggered before binding the mesh
  97623. */
  97624. get onBeforeBindObservable(): Observable<Mesh>;
  97625. /**
  97626. * An event triggered after rendering the mesh
  97627. */
  97628. get onAfterRenderObservable(): Observable<Mesh>;
  97629. /**
  97630. * An event triggered before drawing the mesh
  97631. */
  97632. get onBeforeDrawObservable(): Observable<Mesh>;
  97633. private _onBeforeDrawObserver;
  97634. /**
  97635. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97636. */
  97637. set onBeforeDraw(callback: () => void);
  97638. get hasInstances(): boolean;
  97639. /**
  97640. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97641. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97642. */
  97643. delayLoadState: number;
  97644. /**
  97645. * Gets the list of instances created from this mesh
  97646. * it is not supposed to be modified manually.
  97647. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97648. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97649. */
  97650. instances: InstancedMesh[];
  97651. /**
  97652. * Gets the file containing delay loading data for this mesh
  97653. */
  97654. delayLoadingFile: string;
  97655. /** @hidden */
  97656. _binaryInfo: any;
  97657. /**
  97658. * User defined function used to change how LOD level selection is done
  97659. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97660. */
  97661. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97662. /**
  97663. * Gets or sets the morph target manager
  97664. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97665. */
  97666. get morphTargetManager(): Nullable<MorphTargetManager>;
  97667. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97668. /** @hidden */
  97669. _creationDataStorage: Nullable<_CreationDataStorage>;
  97670. /** @hidden */
  97671. _geometry: Nullable<Geometry>;
  97672. /** @hidden */
  97673. _delayInfo: Array<string>;
  97674. /** @hidden */
  97675. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97676. /** @hidden */
  97677. _instanceDataStorage: _InstanceDataStorage;
  97678. private _effectiveMaterial;
  97679. /** @hidden */
  97680. _shouldGenerateFlatShading: boolean;
  97681. /** @hidden */
  97682. _originalBuilderSideOrientation: number;
  97683. /**
  97684. * Use this property to change the original side orientation defined at construction time
  97685. */
  97686. overrideMaterialSideOrientation: Nullable<number>;
  97687. /**
  97688. * Gets the source mesh (the one used to clone this one from)
  97689. */
  97690. get source(): Nullable<Mesh>;
  97691. /**
  97692. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97693. */
  97694. get isUnIndexed(): boolean;
  97695. set isUnIndexed(value: boolean);
  97696. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97697. get worldMatrixInstancedBuffer(): Float32Array;
  97698. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97699. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97700. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97701. /**
  97702. * @constructor
  97703. * @param name The value used by scene.getMeshByName() to do a lookup.
  97704. * @param scene The scene to add this mesh to.
  97705. * @param parent The parent of this mesh, if it has one
  97706. * @param source An optional Mesh from which geometry is shared, cloned.
  97707. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97708. * When false, achieved by calling a clone(), also passing False.
  97709. * This will make creation of children, recursive.
  97710. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97711. */
  97712. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97713. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97714. doNotInstantiate: boolean;
  97715. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97716. /**
  97717. * Gets the class name
  97718. * @returns the string "Mesh".
  97719. */
  97720. getClassName(): string;
  97721. /** @hidden */
  97722. get _isMesh(): boolean;
  97723. /**
  97724. * Returns a description of this mesh
  97725. * @param fullDetails define if full details about this mesh must be used
  97726. * @returns a descriptive string representing this mesh
  97727. */
  97728. toString(fullDetails?: boolean): string;
  97729. /** @hidden */
  97730. _unBindEffect(): void;
  97731. /**
  97732. * Gets a boolean indicating if this mesh has LOD
  97733. */
  97734. get hasLODLevels(): boolean;
  97735. /**
  97736. * Gets the list of MeshLODLevel associated with the current mesh
  97737. * @returns an array of MeshLODLevel
  97738. */
  97739. getLODLevels(): MeshLODLevel[];
  97740. private _sortLODLevels;
  97741. /**
  97742. * Add a mesh as LOD level triggered at the given distance.
  97743. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97744. * @param distance The distance from the center of the object to show this level
  97745. * @param mesh The mesh to be added as LOD level (can be null)
  97746. * @return This mesh (for chaining)
  97747. */
  97748. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97749. /**
  97750. * Returns the LOD level mesh at the passed distance or null if not found.
  97751. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97752. * @param distance The distance from the center of the object to show this level
  97753. * @returns a Mesh or `null`
  97754. */
  97755. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97756. /**
  97757. * Remove a mesh from the LOD array
  97758. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97759. * @param mesh defines the mesh to be removed
  97760. * @return This mesh (for chaining)
  97761. */
  97762. removeLODLevel(mesh: Mesh): Mesh;
  97763. /**
  97764. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97765. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97766. * @param camera defines the camera to use to compute distance
  97767. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97768. * @return This mesh (for chaining)
  97769. */
  97770. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97771. /**
  97772. * Gets the mesh internal Geometry object
  97773. */
  97774. get geometry(): Nullable<Geometry>;
  97775. /**
  97776. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97777. * @returns the total number of vertices
  97778. */
  97779. getTotalVertices(): number;
  97780. /**
  97781. * Returns the content of an associated vertex buffer
  97782. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97783. * - VertexBuffer.PositionKind
  97784. * - VertexBuffer.UVKind
  97785. * - VertexBuffer.UV2Kind
  97786. * - VertexBuffer.UV3Kind
  97787. * - VertexBuffer.UV4Kind
  97788. * - VertexBuffer.UV5Kind
  97789. * - VertexBuffer.UV6Kind
  97790. * - VertexBuffer.ColorKind
  97791. * - VertexBuffer.MatricesIndicesKind
  97792. * - VertexBuffer.MatricesIndicesExtraKind
  97793. * - VertexBuffer.MatricesWeightsKind
  97794. * - VertexBuffer.MatricesWeightsExtraKind
  97795. * @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
  97796. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97797. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97798. */
  97799. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97800. /**
  97801. * Returns the mesh VertexBuffer object from the requested `kind`
  97802. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97803. * - VertexBuffer.PositionKind
  97804. * - VertexBuffer.NormalKind
  97805. * - VertexBuffer.UVKind
  97806. * - VertexBuffer.UV2Kind
  97807. * - VertexBuffer.UV3Kind
  97808. * - VertexBuffer.UV4Kind
  97809. * - VertexBuffer.UV5Kind
  97810. * - VertexBuffer.UV6Kind
  97811. * - VertexBuffer.ColorKind
  97812. * - VertexBuffer.MatricesIndicesKind
  97813. * - VertexBuffer.MatricesIndicesExtraKind
  97814. * - VertexBuffer.MatricesWeightsKind
  97815. * - VertexBuffer.MatricesWeightsExtraKind
  97816. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97817. */
  97818. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97819. /**
  97820. * Tests if a specific vertex buffer is associated with this mesh
  97821. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97822. * - VertexBuffer.PositionKind
  97823. * - VertexBuffer.NormalKind
  97824. * - VertexBuffer.UVKind
  97825. * - VertexBuffer.UV2Kind
  97826. * - VertexBuffer.UV3Kind
  97827. * - VertexBuffer.UV4Kind
  97828. * - VertexBuffer.UV5Kind
  97829. * - VertexBuffer.UV6Kind
  97830. * - VertexBuffer.ColorKind
  97831. * - VertexBuffer.MatricesIndicesKind
  97832. * - VertexBuffer.MatricesIndicesExtraKind
  97833. * - VertexBuffer.MatricesWeightsKind
  97834. * - VertexBuffer.MatricesWeightsExtraKind
  97835. * @returns a boolean
  97836. */
  97837. isVerticesDataPresent(kind: string): boolean;
  97838. /**
  97839. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97840. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97841. * - VertexBuffer.PositionKind
  97842. * - VertexBuffer.UVKind
  97843. * - VertexBuffer.UV2Kind
  97844. * - VertexBuffer.UV3Kind
  97845. * - VertexBuffer.UV4Kind
  97846. * - VertexBuffer.UV5Kind
  97847. * - VertexBuffer.UV6Kind
  97848. * - VertexBuffer.ColorKind
  97849. * - VertexBuffer.MatricesIndicesKind
  97850. * - VertexBuffer.MatricesIndicesExtraKind
  97851. * - VertexBuffer.MatricesWeightsKind
  97852. * - VertexBuffer.MatricesWeightsExtraKind
  97853. * @returns a boolean
  97854. */
  97855. isVertexBufferUpdatable(kind: string): boolean;
  97856. /**
  97857. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97858. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97859. * - VertexBuffer.PositionKind
  97860. * - VertexBuffer.NormalKind
  97861. * - VertexBuffer.UVKind
  97862. * - VertexBuffer.UV2Kind
  97863. * - VertexBuffer.UV3Kind
  97864. * - VertexBuffer.UV4Kind
  97865. * - VertexBuffer.UV5Kind
  97866. * - VertexBuffer.UV6Kind
  97867. * - VertexBuffer.ColorKind
  97868. * - VertexBuffer.MatricesIndicesKind
  97869. * - VertexBuffer.MatricesIndicesExtraKind
  97870. * - VertexBuffer.MatricesWeightsKind
  97871. * - VertexBuffer.MatricesWeightsExtraKind
  97872. * @returns an array of strings
  97873. */
  97874. getVerticesDataKinds(): string[];
  97875. /**
  97876. * Returns a positive integer : the total number of indices in this mesh geometry.
  97877. * @returns the numner of indices or zero if the mesh has no geometry.
  97878. */
  97879. getTotalIndices(): number;
  97880. /**
  97881. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97882. * @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.
  97883. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97884. * @returns the indices array or an empty array if the mesh has no geometry
  97885. */
  97886. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97887. get isBlocked(): boolean;
  97888. /**
  97889. * Determine if the current mesh is ready to be rendered
  97890. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97891. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97892. * @returns true if all associated assets are ready (material, textures, shaders)
  97893. */
  97894. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97895. /**
  97896. * 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.
  97897. */
  97898. get areNormalsFrozen(): boolean;
  97899. /**
  97900. * 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.
  97901. * @returns the current mesh
  97902. */
  97903. freezeNormals(): Mesh;
  97904. /**
  97905. * 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
  97906. * @returns the current mesh
  97907. */
  97908. unfreezeNormals(): Mesh;
  97909. /**
  97910. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97911. */
  97912. set overridenInstanceCount(count: number);
  97913. /** @hidden */
  97914. _preActivate(): Mesh;
  97915. /** @hidden */
  97916. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97917. /** @hidden */
  97918. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97919. /**
  97920. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97921. * This means the mesh underlying bounding box and sphere are recomputed.
  97922. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97923. * @returns the current mesh
  97924. */
  97925. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97926. /** @hidden */
  97927. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97928. /**
  97929. * This function will subdivide the mesh into multiple submeshes
  97930. * @param count defines the expected number of submeshes
  97931. */
  97932. subdivide(count: number): void;
  97933. /**
  97934. * Copy a FloatArray into a specific associated vertex buffer
  97935. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97936. * - VertexBuffer.PositionKind
  97937. * - VertexBuffer.UVKind
  97938. * - VertexBuffer.UV2Kind
  97939. * - VertexBuffer.UV3Kind
  97940. * - VertexBuffer.UV4Kind
  97941. * - VertexBuffer.UV5Kind
  97942. * - VertexBuffer.UV6Kind
  97943. * - VertexBuffer.ColorKind
  97944. * - VertexBuffer.MatricesIndicesKind
  97945. * - VertexBuffer.MatricesIndicesExtraKind
  97946. * - VertexBuffer.MatricesWeightsKind
  97947. * - VertexBuffer.MatricesWeightsExtraKind
  97948. * @param data defines the data source
  97949. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97950. * @param stride defines the data stride size (can be null)
  97951. * @returns the current mesh
  97952. */
  97953. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97954. /**
  97955. * Delete a vertex buffer associated with this mesh
  97956. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97957. * - VertexBuffer.PositionKind
  97958. * - VertexBuffer.UVKind
  97959. * - VertexBuffer.UV2Kind
  97960. * - VertexBuffer.UV3Kind
  97961. * - VertexBuffer.UV4Kind
  97962. * - VertexBuffer.UV5Kind
  97963. * - VertexBuffer.UV6Kind
  97964. * - VertexBuffer.ColorKind
  97965. * - VertexBuffer.MatricesIndicesKind
  97966. * - VertexBuffer.MatricesIndicesExtraKind
  97967. * - VertexBuffer.MatricesWeightsKind
  97968. * - VertexBuffer.MatricesWeightsExtraKind
  97969. */
  97970. removeVerticesData(kind: string): void;
  97971. /**
  97972. * Flags an associated vertex buffer as updatable
  97973. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97974. * - VertexBuffer.PositionKind
  97975. * - VertexBuffer.UVKind
  97976. * - VertexBuffer.UV2Kind
  97977. * - VertexBuffer.UV3Kind
  97978. * - VertexBuffer.UV4Kind
  97979. * - VertexBuffer.UV5Kind
  97980. * - VertexBuffer.UV6Kind
  97981. * - VertexBuffer.ColorKind
  97982. * - VertexBuffer.MatricesIndicesKind
  97983. * - VertexBuffer.MatricesIndicesExtraKind
  97984. * - VertexBuffer.MatricesWeightsKind
  97985. * - VertexBuffer.MatricesWeightsExtraKind
  97986. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97987. */
  97988. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97989. /**
  97990. * Sets the mesh global Vertex Buffer
  97991. * @param buffer defines the buffer to use
  97992. * @returns the current mesh
  97993. */
  97994. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97995. /**
  97996. * Update a specific associated vertex buffer
  97997. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97998. * - VertexBuffer.PositionKind
  97999. * - VertexBuffer.UVKind
  98000. * - VertexBuffer.UV2Kind
  98001. * - VertexBuffer.UV3Kind
  98002. * - VertexBuffer.UV4Kind
  98003. * - VertexBuffer.UV5Kind
  98004. * - VertexBuffer.UV6Kind
  98005. * - VertexBuffer.ColorKind
  98006. * - VertexBuffer.MatricesIndicesKind
  98007. * - VertexBuffer.MatricesIndicesExtraKind
  98008. * - VertexBuffer.MatricesWeightsKind
  98009. * - VertexBuffer.MatricesWeightsExtraKind
  98010. * @param data defines the data source
  98011. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98012. * @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)
  98013. * @returns the current mesh
  98014. */
  98015. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98016. /**
  98017. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98018. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98019. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98020. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98021. * @returns the current mesh
  98022. */
  98023. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98024. /**
  98025. * Creates a un-shared specific occurence of the geometry for the mesh.
  98026. * @returns the current mesh
  98027. */
  98028. makeGeometryUnique(): Mesh;
  98029. /**
  98030. * Set the index buffer of this mesh
  98031. * @param indices defines the source data
  98032. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98033. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98034. * @returns the current mesh
  98035. */
  98036. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98037. /**
  98038. * Update the current index buffer
  98039. * @param indices defines the source data
  98040. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98041. * @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)
  98042. * @returns the current mesh
  98043. */
  98044. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98045. /**
  98046. * Invert the geometry to move from a right handed system to a left handed one.
  98047. * @returns the current mesh
  98048. */
  98049. toLeftHanded(): Mesh;
  98050. /** @hidden */
  98051. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98052. /** @hidden */
  98053. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98054. /**
  98055. * Registers for this mesh a javascript function called just before the rendering process
  98056. * @param func defines the function to call before rendering this mesh
  98057. * @returns the current mesh
  98058. */
  98059. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98060. /**
  98061. * Disposes a previously registered javascript function called before the rendering
  98062. * @param func defines the function to remove
  98063. * @returns the current mesh
  98064. */
  98065. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98066. /**
  98067. * Registers for this mesh a javascript function called just after the rendering is complete
  98068. * @param func defines the function to call after rendering this mesh
  98069. * @returns the current mesh
  98070. */
  98071. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98072. /**
  98073. * Disposes a previously registered javascript function called after the rendering.
  98074. * @param func defines the function to remove
  98075. * @returns the current mesh
  98076. */
  98077. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98078. /** @hidden */
  98079. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98080. /** @hidden */
  98081. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98082. /** @hidden */
  98083. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98084. /** @hidden */
  98085. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98086. /** @hidden */
  98087. _rebuild(): void;
  98088. /** @hidden */
  98089. _freeze(): void;
  98090. /** @hidden */
  98091. _unFreeze(): void;
  98092. /**
  98093. * 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
  98094. * @param subMesh defines the subMesh to render
  98095. * @param enableAlphaMode defines if alpha mode can be changed
  98096. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98097. * @returns the current mesh
  98098. */
  98099. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98100. private _onBeforeDraw;
  98101. /**
  98102. * Renormalize the mesh and patch it up if there are no weights
  98103. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98104. * However in the case of zero weights then we set just a single influence to 1.
  98105. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98106. */
  98107. cleanMatrixWeights(): void;
  98108. private normalizeSkinFourWeights;
  98109. private normalizeSkinWeightsAndExtra;
  98110. /**
  98111. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98112. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98113. * the user know there was an issue with importing the mesh
  98114. * @returns a validation object with skinned, valid and report string
  98115. */
  98116. validateSkinning(): {
  98117. skinned: boolean;
  98118. valid: boolean;
  98119. report: string;
  98120. };
  98121. /** @hidden */
  98122. _checkDelayState(): Mesh;
  98123. private _queueLoad;
  98124. /**
  98125. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98126. * A mesh is in the frustum if its bounding box intersects the frustum
  98127. * @param frustumPlanes defines the frustum to test
  98128. * @returns true if the mesh is in the frustum planes
  98129. */
  98130. isInFrustum(frustumPlanes: Plane[]): boolean;
  98131. /**
  98132. * Sets the mesh material by the material or multiMaterial `id` property
  98133. * @param id is a string identifying the material or the multiMaterial
  98134. * @returns the current mesh
  98135. */
  98136. setMaterialByID(id: string): Mesh;
  98137. /**
  98138. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98139. * @returns an array of IAnimatable
  98140. */
  98141. getAnimatables(): IAnimatable[];
  98142. /**
  98143. * Modifies the mesh geometry according to the passed transformation matrix.
  98144. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98145. * The mesh normals are modified using the same transformation.
  98146. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98147. * @param transform defines the transform matrix to use
  98148. * @see http://doc.babylonjs.com/resources/baking_transformations
  98149. * @returns the current mesh
  98150. */
  98151. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98152. /**
  98153. * Modifies the mesh geometry according to its own current World Matrix.
  98154. * The mesh World Matrix is then reset.
  98155. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98156. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98157. * @see http://doc.babylonjs.com/resources/baking_transformations
  98158. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98159. * @returns the current mesh
  98160. */
  98161. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98162. /** @hidden */
  98163. get _positions(): Nullable<Vector3[]>;
  98164. /** @hidden */
  98165. _resetPointsArrayCache(): Mesh;
  98166. /** @hidden */
  98167. _generatePointsArray(): boolean;
  98168. /**
  98169. * Returns a new Mesh object generated from the current mesh properties.
  98170. * This method must not get confused with createInstance()
  98171. * @param name is a string, the name given to the new mesh
  98172. * @param newParent can be any Node object (default `null`)
  98173. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98174. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98175. * @returns a new mesh
  98176. */
  98177. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98178. /**
  98179. * Releases resources associated with this mesh.
  98180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98182. */
  98183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98184. /** @hidden */
  98185. _disposeInstanceSpecificData(): void;
  98186. /**
  98187. * Modifies the mesh geometry according to a displacement map.
  98188. * 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.
  98189. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98190. * @param url is a string, the URL from the image file is to be downloaded.
  98191. * @param minHeight is the lower limit of the displacement.
  98192. * @param maxHeight is the upper limit of the displacement.
  98193. * @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.
  98194. * @param uvOffset is an optional vector2 used to offset UV.
  98195. * @param uvScale is an optional vector2 used to scale UV.
  98196. * @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.
  98197. * @returns the Mesh.
  98198. */
  98199. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98200. /**
  98201. * Modifies the mesh geometry according to a displacementMap buffer.
  98202. * 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.
  98203. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98204. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98205. * @param heightMapWidth is the width of the buffer image.
  98206. * @param heightMapHeight is the height of the buffer image.
  98207. * @param minHeight is the lower limit of the displacement.
  98208. * @param maxHeight is the upper limit of the displacement.
  98209. * @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.
  98210. * @param uvOffset is an optional vector2 used to offset UV.
  98211. * @param uvScale is an optional vector2 used to scale UV.
  98212. * @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.
  98213. * @returns the Mesh.
  98214. */
  98215. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98216. /**
  98217. * Modify the mesh to get a flat shading rendering.
  98218. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98219. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98220. * @returns current mesh
  98221. */
  98222. convertToFlatShadedMesh(): Mesh;
  98223. /**
  98224. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98225. * In other words, more vertices, no more indices and a single bigger VBO.
  98226. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98227. * @returns current mesh
  98228. */
  98229. convertToUnIndexedMesh(): Mesh;
  98230. /**
  98231. * Inverses facet orientations.
  98232. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98233. * @param flipNormals will also inverts the normals
  98234. * @returns current mesh
  98235. */
  98236. flipFaces(flipNormals?: boolean): Mesh;
  98237. /**
  98238. * Increase the number of facets and hence vertices in a mesh
  98239. * Vertex normals are interpolated from existing vertex normals
  98240. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98241. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98242. */
  98243. increaseVertices(numberPerEdge: number): void;
  98244. /**
  98245. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98246. * This will undo any application of covertToFlatShadedMesh
  98247. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98248. */
  98249. forceSharedVertices(): void;
  98250. /** @hidden */
  98251. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98252. /** @hidden */
  98253. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98254. /**
  98255. * Creates a new InstancedMesh object from the mesh model.
  98256. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98257. * @param name defines the name of the new instance
  98258. * @returns a new InstancedMesh
  98259. */
  98260. createInstance(name: string): InstancedMesh;
  98261. /**
  98262. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98263. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98264. * @returns the current mesh
  98265. */
  98266. synchronizeInstances(): Mesh;
  98267. /**
  98268. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98269. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98270. * This should be used together with the simplification to avoid disappearing triangles.
  98271. * @param successCallback an optional success callback to be called after the optimization finished.
  98272. * @returns the current mesh
  98273. */
  98274. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98275. /**
  98276. * Serialize current mesh
  98277. * @param serializationObject defines the object which will receive the serialization data
  98278. */
  98279. serialize(serializationObject: any): void;
  98280. /** @hidden */
  98281. _syncGeometryWithMorphTargetManager(): void;
  98282. /** @hidden */
  98283. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98284. /**
  98285. * Returns a new Mesh object parsed from the source provided.
  98286. * @param parsedMesh is the source
  98287. * @param scene defines the hosting scene
  98288. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98289. * @returns a new Mesh
  98290. */
  98291. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98292. /**
  98293. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98294. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98295. * @param name defines the name of the mesh to create
  98296. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98297. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98298. * @param closePath creates a seam between the first and the last points of each path of the path array
  98299. * @param offset is taken in account only if the `pathArray` is containing a single path
  98300. * @param scene defines the hosting scene
  98301. * @param updatable defines if the mesh must be flagged as updatable
  98302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98303. * @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)
  98304. * @returns a new Mesh
  98305. */
  98306. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98307. /**
  98308. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98309. * @param name defines the name of the mesh to create
  98310. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98311. * @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
  98312. * @param scene defines the hosting scene
  98313. * @param updatable defines if the mesh must be flagged as updatable
  98314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98315. * @returns a new Mesh
  98316. */
  98317. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98318. /**
  98319. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98320. * @param name defines the name of the mesh to create
  98321. * @param size sets the size (float) of each box side (default 1)
  98322. * @param scene defines the hosting scene
  98323. * @param updatable defines if the mesh must be flagged as updatable
  98324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98325. * @returns a new Mesh
  98326. */
  98327. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98328. /**
  98329. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98330. * @param name defines the name of the mesh to create
  98331. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98332. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98333. * @param scene defines the hosting scene
  98334. * @param updatable defines if the mesh must be flagged as updatable
  98335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98336. * @returns a new Mesh
  98337. */
  98338. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98339. /**
  98340. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98341. * @param name defines the name of the mesh to create
  98342. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98343. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98344. * @param scene defines the hosting scene
  98345. * @returns a new Mesh
  98346. */
  98347. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98348. /**
  98349. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98350. * @param name defines the name of the mesh to create
  98351. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98352. * @param diameterTop set the top cap diameter (floats, default 1)
  98353. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98354. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98355. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98356. * @param scene defines the hosting scene
  98357. * @param updatable defines if the mesh must be flagged as updatable
  98358. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98359. * @returns a new Mesh
  98360. */
  98361. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98362. /**
  98363. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98364. * @param name defines the name of the mesh to create
  98365. * @param diameter sets the diameter size (float) of the torus (default 1)
  98366. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98367. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98368. * @param scene defines the hosting scene
  98369. * @param updatable defines if the mesh must be flagged as updatable
  98370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98371. * @returns a new Mesh
  98372. */
  98373. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98374. /**
  98375. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98376. * @param name defines the name of the mesh to create
  98377. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98378. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98379. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98380. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98381. * @param p the number of windings on X axis (positive integers, default 2)
  98382. * @param q the number of windings on Y axis (positive integers, default 3)
  98383. * @param scene defines the hosting scene
  98384. * @param updatable defines if the mesh must be flagged as updatable
  98385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98386. * @returns a new Mesh
  98387. */
  98388. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98389. /**
  98390. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98391. * @param name defines the name of the mesh to create
  98392. * @param points is an array successive Vector3
  98393. * @param scene defines the hosting scene
  98394. * @param updatable defines if the mesh must be flagged as updatable
  98395. * @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).
  98396. * @returns a new Mesh
  98397. */
  98398. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98399. /**
  98400. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98401. * @param name defines the name of the mesh to create
  98402. * @param points is an array successive Vector3
  98403. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98404. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98405. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98406. * @param scene defines the hosting scene
  98407. * @param updatable defines if the mesh must be flagged as updatable
  98408. * @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)
  98409. * @returns a new Mesh
  98410. */
  98411. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98412. /**
  98413. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98414. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98415. * 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.
  98416. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98417. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98418. * Remember you can only change the shape positions, not their number when updating a polygon.
  98419. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98420. * @param name defines the name of the mesh to create
  98421. * @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
  98422. * @param scene defines the hosting scene
  98423. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98424. * @param updatable defines if the mesh must be flagged as updatable
  98425. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98426. * @param earcutInjection can be used to inject your own earcut reference
  98427. * @returns a new Mesh
  98428. */
  98429. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98430. /**
  98431. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98433. * @param name defines the name of the mesh to create
  98434. * @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
  98435. * @param depth defines the height of extrusion
  98436. * @param scene defines the hosting scene
  98437. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98438. * @param updatable defines if the mesh must be flagged as updatable
  98439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98440. * @param earcutInjection can be used to inject your own earcut reference
  98441. * @returns a new Mesh
  98442. */
  98443. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98444. /**
  98445. * Creates an extruded shape mesh.
  98446. * 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
  98447. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98448. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98449. * @param name defines the name of the mesh to create
  98450. * @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
  98451. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98452. * @param scale is the value to scale the shape
  98453. * @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
  98454. * @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
  98455. * @param scene defines the hosting scene
  98456. * @param updatable defines if the mesh must be flagged as updatable
  98457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98458. * @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)
  98459. * @returns a new Mesh
  98460. */
  98461. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98462. /**
  98463. * Creates an custom extruded shape mesh.
  98464. * The custom extrusion is a parametric shape.
  98465. * It has no predefined shape. Its final shape will depend on the input parameters.
  98466. * Please consider using the same method from the MeshBuilder class instead
  98467. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98468. * @param name defines the name of the mesh to create
  98469. * @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
  98470. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98471. * @param scaleFunction is a custom Javascript function called on each path point
  98472. * @param rotationFunction is a custom Javascript function called on each path point
  98473. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98474. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98475. * @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
  98476. * @param scene defines the hosting scene
  98477. * @param updatable defines if the mesh must be flagged as updatable
  98478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98479. * @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)
  98480. * @returns a new Mesh
  98481. */
  98482. 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;
  98483. /**
  98484. * Creates lathe mesh.
  98485. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98486. * Please consider using the same method from the MeshBuilder class instead
  98487. * @param name defines the name of the mesh to create
  98488. * @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
  98489. * @param radius is the radius value of the lathe
  98490. * @param tessellation is the side number of the lathe.
  98491. * @param scene defines the hosting scene
  98492. * @param updatable defines if the mesh must be flagged as updatable
  98493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98494. * @returns a new Mesh
  98495. */
  98496. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98497. /**
  98498. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98499. * @param name defines the name of the mesh to create
  98500. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98501. * @param scene defines the hosting scene
  98502. * @param updatable defines if the mesh must be flagged as updatable
  98503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98504. * @returns a new Mesh
  98505. */
  98506. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98507. /**
  98508. * Creates a ground mesh.
  98509. * Please consider using the same method from the MeshBuilder class instead
  98510. * @param name defines the name of the mesh to create
  98511. * @param width set the width of the ground
  98512. * @param height set the height of the ground
  98513. * @param subdivisions sets the number of subdivisions per side
  98514. * @param scene defines the hosting scene
  98515. * @param updatable defines if the mesh must be flagged as updatable
  98516. * @returns a new Mesh
  98517. */
  98518. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98519. /**
  98520. * Creates a tiled ground mesh.
  98521. * Please consider using the same method from the MeshBuilder class instead
  98522. * @param name defines the name of the mesh to create
  98523. * @param xmin set the ground minimum X coordinate
  98524. * @param zmin set the ground minimum Y coordinate
  98525. * @param xmax set the ground maximum X coordinate
  98526. * @param zmax set the ground maximum Z coordinate
  98527. * @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
  98528. * @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
  98529. * @param scene defines the hosting scene
  98530. * @param updatable defines if the mesh must be flagged as updatable
  98531. * @returns a new Mesh
  98532. */
  98533. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98534. w: number;
  98535. h: number;
  98536. }, precision: {
  98537. w: number;
  98538. h: number;
  98539. }, scene: Scene, updatable?: boolean): Mesh;
  98540. /**
  98541. * Creates a ground mesh from a height map.
  98542. * Please consider using the same method from the MeshBuilder class instead
  98543. * @see http://doc.babylonjs.com/babylon101/height_map
  98544. * @param name defines the name of the mesh to create
  98545. * @param url sets the URL of the height map image resource
  98546. * @param width set the ground width size
  98547. * @param height set the ground height size
  98548. * @param subdivisions sets the number of subdivision per side
  98549. * @param minHeight is the minimum altitude on the ground
  98550. * @param maxHeight is the maximum altitude on the ground
  98551. * @param scene defines the hosting scene
  98552. * @param updatable defines if the mesh must be flagged as updatable
  98553. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98554. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98555. * @returns a new Mesh
  98556. */
  98557. 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;
  98558. /**
  98559. * Creates a tube mesh.
  98560. * The tube is a parametric shape.
  98561. * It has no predefined shape. Its final shape will depend on the input parameters.
  98562. * Please consider using the same method from the MeshBuilder class instead
  98563. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98564. * @param name defines the name of the mesh to create
  98565. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98566. * @param radius sets the tube radius size
  98567. * @param tessellation is the number of sides on the tubular surface
  98568. * @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
  98569. * @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
  98570. * @param scene defines the hosting scene
  98571. * @param updatable defines if the mesh must be flagged as updatable
  98572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98573. * @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)
  98574. * @returns a new Mesh
  98575. */
  98576. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98577. (i: number, distance: number): number;
  98578. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98579. /**
  98580. * Creates a polyhedron mesh.
  98581. * Please consider using the same method from the MeshBuilder class instead.
  98582. * * 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
  98583. * * The parameter `size` (positive float, default 1) sets the polygon size
  98584. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98585. * * 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`
  98586. * * 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
  98587. * * 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)`)
  98588. * * 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
  98589. * * 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
  98590. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98591. * * If you create a double-sided mesh, you can choose what parts of 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
  98592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98593. * @param name defines the name of the mesh to create
  98594. * @param options defines the options used to create the mesh
  98595. * @param scene defines the hosting scene
  98596. * @returns a new Mesh
  98597. */
  98598. static CreatePolyhedron(name: string, options: {
  98599. type?: number;
  98600. size?: number;
  98601. sizeX?: number;
  98602. sizeY?: number;
  98603. sizeZ?: number;
  98604. custom?: any;
  98605. faceUV?: Vector4[];
  98606. faceColors?: Color4[];
  98607. updatable?: boolean;
  98608. sideOrientation?: number;
  98609. }, scene: Scene): Mesh;
  98610. /**
  98611. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98612. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98613. * * 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`)
  98614. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98615. * * 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
  98616. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98617. * * If you create a double-sided mesh, you can choose what parts of 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
  98618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98619. * @param name defines the name of the mesh
  98620. * @param options defines the options used to create the mesh
  98621. * @param scene defines the hosting scene
  98622. * @returns a new Mesh
  98623. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98624. */
  98625. static CreateIcoSphere(name: string, options: {
  98626. radius?: number;
  98627. flat?: boolean;
  98628. subdivisions?: number;
  98629. sideOrientation?: number;
  98630. updatable?: boolean;
  98631. }, scene: Scene): Mesh;
  98632. /**
  98633. * Creates a decal mesh.
  98634. * Please consider using the same method from the MeshBuilder class instead.
  98635. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98636. * @param name defines the name of the mesh
  98637. * @param sourceMesh defines the mesh receiving the decal
  98638. * @param position sets the position of the decal in world coordinates
  98639. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98640. * @param size sets the decal scaling
  98641. * @param angle sets the angle to rotate the decal
  98642. * @returns a new Mesh
  98643. */
  98644. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98645. /**
  98646. * Prepare internal position array for software CPU skinning
  98647. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98648. */
  98649. setPositionsForCPUSkinning(): Float32Array;
  98650. /**
  98651. * Prepare internal normal array for software CPU skinning
  98652. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98653. */
  98654. setNormalsForCPUSkinning(): Float32Array;
  98655. /**
  98656. * Updates the vertex buffer by applying transformation from the bones
  98657. * @param skeleton defines the skeleton to apply to current mesh
  98658. * @returns the current mesh
  98659. */
  98660. applySkeleton(skeleton: Skeleton): Mesh;
  98661. /**
  98662. * 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
  98663. * @param meshes defines the list of meshes to scan
  98664. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98665. */
  98666. static MinMax(meshes: AbstractMesh[]): {
  98667. min: Vector3;
  98668. max: Vector3;
  98669. };
  98670. /**
  98671. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98672. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98673. * @returns a vector3
  98674. */
  98675. static Center(meshesOrMinMaxVector: {
  98676. min: Vector3;
  98677. max: Vector3;
  98678. } | AbstractMesh[]): Vector3;
  98679. /**
  98680. * Merge the array of meshes into a single mesh for performance reasons.
  98681. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98682. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98683. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98684. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98685. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98686. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98687. * @returns a new mesh
  98688. */
  98689. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98690. /** @hidden */
  98691. addInstance(instance: InstancedMesh): void;
  98692. /** @hidden */
  98693. removeInstance(instance: InstancedMesh): void;
  98694. }
  98695. }
  98696. declare module BABYLON {
  98697. /**
  98698. * This is the base class of all the camera used in the application.
  98699. * @see http://doc.babylonjs.com/features/cameras
  98700. */
  98701. export class Camera extends Node {
  98702. /** @hidden */
  98703. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98704. /**
  98705. * This is the default projection mode used by the cameras.
  98706. * It helps recreating a feeling of perspective and better appreciate depth.
  98707. * This is the best way to simulate real life cameras.
  98708. */
  98709. static readonly PERSPECTIVE_CAMERA: number;
  98710. /**
  98711. * This helps creating camera with an orthographic mode.
  98712. * 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.
  98713. */
  98714. static readonly ORTHOGRAPHIC_CAMERA: number;
  98715. /**
  98716. * This is the default FOV mode for perspective cameras.
  98717. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98718. */
  98719. static readonly FOVMODE_VERTICAL_FIXED: number;
  98720. /**
  98721. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98722. */
  98723. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98724. /**
  98725. * This specifies ther is no need for a camera rig.
  98726. * Basically only one eye is rendered corresponding to the camera.
  98727. */
  98728. static readonly RIG_MODE_NONE: number;
  98729. /**
  98730. * Simulates a camera Rig with one blue eye and one red eye.
  98731. * This can be use with 3d blue and red glasses.
  98732. */
  98733. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98734. /**
  98735. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98736. */
  98737. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98738. /**
  98739. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98740. */
  98741. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98742. /**
  98743. * Defines that both eyes of the camera will be rendered over under each other.
  98744. */
  98745. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98746. /**
  98747. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98748. */
  98749. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98750. /**
  98751. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98752. */
  98753. static readonly RIG_MODE_VR: number;
  98754. /**
  98755. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98756. */
  98757. static readonly RIG_MODE_WEBVR: number;
  98758. /**
  98759. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98760. */
  98761. static readonly RIG_MODE_CUSTOM: number;
  98762. /**
  98763. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98764. */
  98765. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98766. /**
  98767. * Define the input manager associated with the camera.
  98768. */
  98769. inputs: CameraInputsManager<Camera>;
  98770. /** @hidden */
  98771. _position: Vector3;
  98772. /**
  98773. * Define the current local position of the camera in the scene
  98774. */
  98775. get position(): Vector3;
  98776. set position(newPosition: Vector3);
  98777. /**
  98778. * The vector the camera should consider as up.
  98779. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98780. */
  98781. upVector: Vector3;
  98782. /**
  98783. * Define the current limit on the left side for an orthographic camera
  98784. * In scene unit
  98785. */
  98786. orthoLeft: Nullable<number>;
  98787. /**
  98788. * Define the current limit on the right side for an orthographic camera
  98789. * In scene unit
  98790. */
  98791. orthoRight: Nullable<number>;
  98792. /**
  98793. * Define the current limit on the bottom side for an orthographic camera
  98794. * In scene unit
  98795. */
  98796. orthoBottom: Nullable<number>;
  98797. /**
  98798. * Define the current limit on the top side for an orthographic camera
  98799. * In scene unit
  98800. */
  98801. orthoTop: Nullable<number>;
  98802. /**
  98803. * Field Of View is set in Radians. (default is 0.8)
  98804. */
  98805. fov: number;
  98806. /**
  98807. * Define the minimum distance the camera can see from.
  98808. * This is important to note that the depth buffer are not infinite and the closer it starts
  98809. * the more your scene might encounter depth fighting issue.
  98810. */
  98811. minZ: number;
  98812. /**
  98813. * Define the maximum distance the camera can see to.
  98814. * This is important to note that the depth buffer are not infinite and the further it end
  98815. * the more your scene might encounter depth fighting issue.
  98816. */
  98817. maxZ: number;
  98818. /**
  98819. * Define the default inertia of the camera.
  98820. * This helps giving a smooth feeling to the camera movement.
  98821. */
  98822. inertia: number;
  98823. /**
  98824. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98825. */
  98826. mode: number;
  98827. /**
  98828. * Define whether the camera is intermediate.
  98829. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98830. */
  98831. isIntermediate: boolean;
  98832. /**
  98833. * Define the viewport of the camera.
  98834. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98835. */
  98836. viewport: Viewport;
  98837. /**
  98838. * Restricts the camera to viewing objects with the same layerMask.
  98839. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98840. */
  98841. layerMask: number;
  98842. /**
  98843. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98844. */
  98845. fovMode: number;
  98846. /**
  98847. * Rig mode of the camera.
  98848. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98849. * This is normally controlled byt the camera themselves as internal use.
  98850. */
  98851. cameraRigMode: number;
  98852. /**
  98853. * Defines the distance between both "eyes" in case of a RIG
  98854. */
  98855. interaxialDistance: number;
  98856. /**
  98857. * Defines if stereoscopic rendering is done side by side or over under.
  98858. */
  98859. isStereoscopicSideBySide: boolean;
  98860. /**
  98861. * 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
  98862. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98863. * else in the scene. (Eg. security camera)
  98864. *
  98865. * 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)
  98866. */
  98867. customRenderTargets: RenderTargetTexture[];
  98868. /**
  98869. * When set, the camera will render to this render target instead of the default canvas
  98870. *
  98871. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98872. */
  98873. outputRenderTarget: Nullable<RenderTargetTexture>;
  98874. /**
  98875. * Observable triggered when the camera view matrix has changed.
  98876. */
  98877. onViewMatrixChangedObservable: Observable<Camera>;
  98878. /**
  98879. * Observable triggered when the camera Projection matrix has changed.
  98880. */
  98881. onProjectionMatrixChangedObservable: Observable<Camera>;
  98882. /**
  98883. * Observable triggered when the inputs have been processed.
  98884. */
  98885. onAfterCheckInputsObservable: Observable<Camera>;
  98886. /**
  98887. * Observable triggered when reset has been called and applied to the camera.
  98888. */
  98889. onRestoreStateObservable: Observable<Camera>;
  98890. /**
  98891. * Is this camera a part of a rig system?
  98892. */
  98893. isRigCamera: boolean;
  98894. /**
  98895. * If isRigCamera set to true this will be set with the parent camera.
  98896. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98897. */
  98898. rigParent?: Camera;
  98899. /** @hidden */
  98900. _cameraRigParams: any;
  98901. /** @hidden */
  98902. _rigCameras: Camera[];
  98903. /** @hidden */
  98904. _rigPostProcess: Nullable<PostProcess>;
  98905. protected _webvrViewMatrix: Matrix;
  98906. /** @hidden */
  98907. _skipRendering: boolean;
  98908. /** @hidden */
  98909. _projectionMatrix: Matrix;
  98910. /** @hidden */
  98911. _postProcesses: Nullable<PostProcess>[];
  98912. /** @hidden */
  98913. _activeMeshes: SmartArray<AbstractMesh>;
  98914. protected _globalPosition: Vector3;
  98915. /** @hidden */
  98916. _computedViewMatrix: Matrix;
  98917. private _doNotComputeProjectionMatrix;
  98918. private _transformMatrix;
  98919. private _frustumPlanes;
  98920. private _refreshFrustumPlanes;
  98921. private _storedFov;
  98922. private _stateStored;
  98923. /**
  98924. * Instantiates a new camera object.
  98925. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98926. * @see http://doc.babylonjs.com/features/cameras
  98927. * @param name Defines the name of the camera in the scene
  98928. * @param position Defines the position of the camera
  98929. * @param scene Defines the scene the camera belongs too
  98930. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98931. */
  98932. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98933. /**
  98934. * Store current camera state (fov, position, etc..)
  98935. * @returns the camera
  98936. */
  98937. storeState(): Camera;
  98938. /**
  98939. * Restores the camera state values if it has been stored. You must call storeState() first
  98940. */
  98941. protected _restoreStateValues(): boolean;
  98942. /**
  98943. * Restored camera state. You must call storeState() first.
  98944. * @returns true if restored and false otherwise
  98945. */
  98946. restoreState(): boolean;
  98947. /**
  98948. * Gets the class name of the camera.
  98949. * @returns the class name
  98950. */
  98951. getClassName(): string;
  98952. /** @hidden */
  98953. readonly _isCamera: boolean;
  98954. /**
  98955. * Gets a string representation of the camera useful for debug purpose.
  98956. * @param fullDetails Defines that a more verboe level of logging is required
  98957. * @returns the string representation
  98958. */
  98959. toString(fullDetails?: boolean): string;
  98960. /**
  98961. * Gets the current world space position of the camera.
  98962. */
  98963. get globalPosition(): Vector3;
  98964. /**
  98965. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98966. * @returns the active meshe list
  98967. */
  98968. getActiveMeshes(): SmartArray<AbstractMesh>;
  98969. /**
  98970. * Check whether a mesh is part of the current active mesh list of the camera
  98971. * @param mesh Defines the mesh to check
  98972. * @returns true if active, false otherwise
  98973. */
  98974. isActiveMesh(mesh: Mesh): boolean;
  98975. /**
  98976. * Is this camera ready to be used/rendered
  98977. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98978. * @return true if the camera is ready
  98979. */
  98980. isReady(completeCheck?: boolean): boolean;
  98981. /** @hidden */
  98982. _initCache(): void;
  98983. /** @hidden */
  98984. _updateCache(ignoreParentClass?: boolean): void;
  98985. /** @hidden */
  98986. _isSynchronized(): boolean;
  98987. /** @hidden */
  98988. _isSynchronizedViewMatrix(): boolean;
  98989. /** @hidden */
  98990. _isSynchronizedProjectionMatrix(): boolean;
  98991. /**
  98992. * Attach the input controls to a specific dom element to get the input from.
  98993. * @param element Defines the element the controls should be listened from
  98994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98995. */
  98996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98997. /**
  98998. * Detach the current controls from the specified dom element.
  98999. * @param element Defines the element to stop listening the inputs from
  99000. */
  99001. detachControl(element: HTMLElement): void;
  99002. /**
  99003. * Update the camera state according to the different inputs gathered during the frame.
  99004. */
  99005. update(): void;
  99006. /** @hidden */
  99007. _checkInputs(): void;
  99008. /** @hidden */
  99009. get rigCameras(): Camera[];
  99010. /**
  99011. * Gets the post process used by the rig cameras
  99012. */
  99013. get rigPostProcess(): Nullable<PostProcess>;
  99014. /**
  99015. * Internal, gets the first post proces.
  99016. * @returns the first post process to be run on this camera.
  99017. */
  99018. _getFirstPostProcess(): Nullable<PostProcess>;
  99019. private _cascadePostProcessesToRigCams;
  99020. /**
  99021. * Attach a post process to the camera.
  99022. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99023. * @param postProcess The post process to attach to the camera
  99024. * @param insertAt The position of the post process in case several of them are in use in the scene
  99025. * @returns the position the post process has been inserted at
  99026. */
  99027. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99028. /**
  99029. * Detach a post process to the camera.
  99030. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99031. * @param postProcess The post process to detach from the camera
  99032. */
  99033. detachPostProcess(postProcess: PostProcess): void;
  99034. /**
  99035. * Gets the current world matrix of the camera
  99036. */
  99037. getWorldMatrix(): Matrix;
  99038. /** @hidden */
  99039. _getViewMatrix(): Matrix;
  99040. /**
  99041. * Gets the current view matrix of the camera.
  99042. * @param force forces the camera to recompute the matrix without looking at the cached state
  99043. * @returns the view matrix
  99044. */
  99045. getViewMatrix(force?: boolean): Matrix;
  99046. /**
  99047. * Freeze the projection matrix.
  99048. * It will prevent the cache check of the camera projection compute and can speed up perf
  99049. * if no parameter of the camera are meant to change
  99050. * @param projection Defines manually a projection if necessary
  99051. */
  99052. freezeProjectionMatrix(projection?: Matrix): void;
  99053. /**
  99054. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99055. */
  99056. unfreezeProjectionMatrix(): void;
  99057. /**
  99058. * Gets the current projection matrix of the camera.
  99059. * @param force forces the camera to recompute the matrix without looking at the cached state
  99060. * @returns the projection matrix
  99061. */
  99062. getProjectionMatrix(force?: boolean): Matrix;
  99063. /**
  99064. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99065. * @returns a Matrix
  99066. */
  99067. getTransformationMatrix(): Matrix;
  99068. private _updateFrustumPlanes;
  99069. /**
  99070. * Checks if a cullable object (mesh...) is in the camera frustum
  99071. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99072. * @param target The object to check
  99073. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99074. * @returns true if the object is in frustum otherwise false
  99075. */
  99076. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99077. /**
  99078. * Checks if a cullable object (mesh...) is in the camera frustum
  99079. * Unlike isInFrustum this cheks the full bounding box
  99080. * @param target The object to check
  99081. * @returns true if the object is in frustum otherwise false
  99082. */
  99083. isCompletelyInFrustum(target: ICullable): boolean;
  99084. /**
  99085. * Gets a ray in the forward direction from the camera.
  99086. * @param length Defines the length of the ray to create
  99087. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99088. * @param origin Defines the start point of the ray which defaults to the camera position
  99089. * @returns the forward ray
  99090. */
  99091. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99092. /**
  99093. * Releases resources associated with this node.
  99094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99096. */
  99097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99098. /** @hidden */
  99099. _isLeftCamera: boolean;
  99100. /**
  99101. * Gets the left camera of a rig setup in case of Rigged Camera
  99102. */
  99103. get isLeftCamera(): boolean;
  99104. /** @hidden */
  99105. _isRightCamera: boolean;
  99106. /**
  99107. * Gets the right camera of a rig setup in case of Rigged Camera
  99108. */
  99109. get isRightCamera(): boolean;
  99110. /**
  99111. * Gets the left camera of a rig setup in case of Rigged Camera
  99112. */
  99113. get leftCamera(): Nullable<FreeCamera>;
  99114. /**
  99115. * Gets the right camera of a rig setup in case of Rigged Camera
  99116. */
  99117. get rightCamera(): Nullable<FreeCamera>;
  99118. /**
  99119. * Gets the left camera target of a rig setup in case of Rigged Camera
  99120. * @returns the target position
  99121. */
  99122. getLeftTarget(): Nullable<Vector3>;
  99123. /**
  99124. * Gets the right camera target of a rig setup in case of Rigged Camera
  99125. * @returns the target position
  99126. */
  99127. getRightTarget(): Nullable<Vector3>;
  99128. /**
  99129. * @hidden
  99130. */
  99131. setCameraRigMode(mode: number, rigParams: any): void;
  99132. /** @hidden */
  99133. static _setStereoscopicRigMode(camera: Camera): void;
  99134. /** @hidden */
  99135. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99136. /** @hidden */
  99137. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99138. /** @hidden */
  99139. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99140. /** @hidden */
  99141. _getVRProjectionMatrix(): Matrix;
  99142. protected _updateCameraRotationMatrix(): void;
  99143. protected _updateWebVRCameraRotationMatrix(): void;
  99144. /**
  99145. * This function MUST be overwritten by the different WebVR cameras available.
  99146. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99147. * @hidden
  99148. */
  99149. _getWebVRProjectionMatrix(): Matrix;
  99150. /**
  99151. * This function MUST be overwritten by the different WebVR cameras available.
  99152. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99153. * @hidden
  99154. */
  99155. _getWebVRViewMatrix(): Matrix;
  99156. /** @hidden */
  99157. setCameraRigParameter(name: string, value: any): void;
  99158. /**
  99159. * needs to be overridden by children so sub has required properties to be copied
  99160. * @hidden
  99161. */
  99162. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99163. /**
  99164. * May need to be overridden by children
  99165. * @hidden
  99166. */
  99167. _updateRigCameras(): void;
  99168. /** @hidden */
  99169. _setupInputs(): void;
  99170. /**
  99171. * Serialiaze the camera setup to a json represention
  99172. * @returns the JSON representation
  99173. */
  99174. serialize(): any;
  99175. /**
  99176. * Clones the current camera.
  99177. * @param name The cloned camera name
  99178. * @returns the cloned camera
  99179. */
  99180. clone(name: string): Camera;
  99181. /**
  99182. * Gets the direction of the camera relative to a given local axis.
  99183. * @param localAxis Defines the reference axis to provide a relative direction.
  99184. * @return the direction
  99185. */
  99186. getDirection(localAxis: Vector3): Vector3;
  99187. /**
  99188. * Returns the current camera absolute rotation
  99189. */
  99190. get absoluteRotation(): Quaternion;
  99191. /**
  99192. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99193. * @param localAxis Defines the reference axis to provide a relative direction.
  99194. * @param result Defines the vector to store the result in
  99195. */
  99196. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99197. /**
  99198. * Gets a camera constructor for a given camera type
  99199. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99200. * @param name The name of the camera the result will be able to instantiate
  99201. * @param scene The scene the result will construct the camera in
  99202. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99203. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99204. * @returns a factory method to construc the camera
  99205. */
  99206. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99207. /**
  99208. * Compute the world matrix of the camera.
  99209. * @returns the camera world matrix
  99210. */
  99211. computeWorldMatrix(): Matrix;
  99212. /**
  99213. * Parse a JSON and creates the camera from the parsed information
  99214. * @param parsedCamera The JSON to parse
  99215. * @param scene The scene to instantiate the camera in
  99216. * @returns the newly constructed camera
  99217. */
  99218. static Parse(parsedCamera: any, scene: Scene): Camera;
  99219. }
  99220. }
  99221. declare module BABYLON {
  99222. /**
  99223. * Class containing static functions to help procedurally build meshes
  99224. */
  99225. export class DiscBuilder {
  99226. /**
  99227. * Creates a plane polygonal mesh. By default, this is a disc
  99228. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99229. * * 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
  99230. * * 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
  99231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99234. * @param name defines the name of the mesh
  99235. * @param options defines the options used to create the mesh
  99236. * @param scene defines the hosting scene
  99237. * @returns the plane polygonal mesh
  99238. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99239. */
  99240. static CreateDisc(name: string, options: {
  99241. radius?: number;
  99242. tessellation?: number;
  99243. arc?: number;
  99244. updatable?: boolean;
  99245. sideOrientation?: number;
  99246. frontUVs?: Vector4;
  99247. backUVs?: Vector4;
  99248. }, scene?: Nullable<Scene>): Mesh;
  99249. }
  99250. }
  99251. declare module BABYLON {
  99252. /**
  99253. * This represents all the required information to add a fresnel effect on a material:
  99254. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99255. */
  99256. export class FresnelParameters {
  99257. private _isEnabled;
  99258. /**
  99259. * Define if the fresnel effect is enable or not.
  99260. */
  99261. get isEnabled(): boolean;
  99262. set isEnabled(value: boolean);
  99263. /**
  99264. * Define the color used on edges (grazing angle)
  99265. */
  99266. leftColor: Color3;
  99267. /**
  99268. * Define the color used on center
  99269. */
  99270. rightColor: Color3;
  99271. /**
  99272. * Define bias applied to computed fresnel term
  99273. */
  99274. bias: number;
  99275. /**
  99276. * Defined the power exponent applied to fresnel term
  99277. */
  99278. power: number;
  99279. /**
  99280. * Clones the current fresnel and its valuues
  99281. * @returns a clone fresnel configuration
  99282. */
  99283. clone(): FresnelParameters;
  99284. /**
  99285. * Serializes the current fresnel parameters to a JSON representation.
  99286. * @return the JSON serialization
  99287. */
  99288. serialize(): any;
  99289. /**
  99290. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99291. * @param parsedFresnelParameters Define the JSON representation
  99292. * @returns the parsed parameters
  99293. */
  99294. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99295. }
  99296. }
  99297. declare module BABYLON {
  99298. /**
  99299. * Base class of materials working in push mode in babylon JS
  99300. * @hidden
  99301. */
  99302. export class PushMaterial extends Material {
  99303. protected _activeEffect: Effect;
  99304. protected _normalMatrix: Matrix;
  99305. /**
  99306. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99307. * This means that the material can keep using a previous shader while a new one is being compiled.
  99308. * This is mostly used when shader parallel compilation is supported (true by default)
  99309. */
  99310. allowShaderHotSwapping: boolean;
  99311. constructor(name: string, scene: Scene);
  99312. getEffect(): Effect;
  99313. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99314. /**
  99315. * Binds the given world matrix to the active effect
  99316. *
  99317. * @param world the matrix to bind
  99318. */
  99319. bindOnlyWorldMatrix(world: Matrix): void;
  99320. /**
  99321. * Binds the given normal matrix to the active effect
  99322. *
  99323. * @param normalMatrix the matrix to bind
  99324. */
  99325. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99326. bind(world: Matrix, mesh?: Mesh): void;
  99327. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99328. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99329. }
  99330. }
  99331. declare module BABYLON {
  99332. /**
  99333. * This groups all the flags used to control the materials channel.
  99334. */
  99335. export class MaterialFlags {
  99336. private static _DiffuseTextureEnabled;
  99337. /**
  99338. * Are diffuse textures enabled in the application.
  99339. */
  99340. static get DiffuseTextureEnabled(): boolean;
  99341. static set DiffuseTextureEnabled(value: boolean);
  99342. private static _AmbientTextureEnabled;
  99343. /**
  99344. * Are ambient textures enabled in the application.
  99345. */
  99346. static get AmbientTextureEnabled(): boolean;
  99347. static set AmbientTextureEnabled(value: boolean);
  99348. private static _OpacityTextureEnabled;
  99349. /**
  99350. * Are opacity textures enabled in the application.
  99351. */
  99352. static get OpacityTextureEnabled(): boolean;
  99353. static set OpacityTextureEnabled(value: boolean);
  99354. private static _ReflectionTextureEnabled;
  99355. /**
  99356. * Are reflection textures enabled in the application.
  99357. */
  99358. static get ReflectionTextureEnabled(): boolean;
  99359. static set ReflectionTextureEnabled(value: boolean);
  99360. private static _EmissiveTextureEnabled;
  99361. /**
  99362. * Are emissive textures enabled in the application.
  99363. */
  99364. static get EmissiveTextureEnabled(): boolean;
  99365. static set EmissiveTextureEnabled(value: boolean);
  99366. private static _SpecularTextureEnabled;
  99367. /**
  99368. * Are specular textures enabled in the application.
  99369. */
  99370. static get SpecularTextureEnabled(): boolean;
  99371. static set SpecularTextureEnabled(value: boolean);
  99372. private static _BumpTextureEnabled;
  99373. /**
  99374. * Are bump textures enabled in the application.
  99375. */
  99376. static get BumpTextureEnabled(): boolean;
  99377. static set BumpTextureEnabled(value: boolean);
  99378. private static _LightmapTextureEnabled;
  99379. /**
  99380. * Are lightmap textures enabled in the application.
  99381. */
  99382. static get LightmapTextureEnabled(): boolean;
  99383. static set LightmapTextureEnabled(value: boolean);
  99384. private static _RefractionTextureEnabled;
  99385. /**
  99386. * Are refraction textures enabled in the application.
  99387. */
  99388. static get RefractionTextureEnabled(): boolean;
  99389. static set RefractionTextureEnabled(value: boolean);
  99390. private static _ColorGradingTextureEnabled;
  99391. /**
  99392. * Are color grading textures enabled in the application.
  99393. */
  99394. static get ColorGradingTextureEnabled(): boolean;
  99395. static set ColorGradingTextureEnabled(value: boolean);
  99396. private static _FresnelEnabled;
  99397. /**
  99398. * Are fresnels enabled in the application.
  99399. */
  99400. static get FresnelEnabled(): boolean;
  99401. static set FresnelEnabled(value: boolean);
  99402. private static _ClearCoatTextureEnabled;
  99403. /**
  99404. * Are clear coat textures enabled in the application.
  99405. */
  99406. static get ClearCoatTextureEnabled(): boolean;
  99407. static set ClearCoatTextureEnabled(value: boolean);
  99408. private static _ClearCoatBumpTextureEnabled;
  99409. /**
  99410. * Are clear coat bump textures enabled in the application.
  99411. */
  99412. static get ClearCoatBumpTextureEnabled(): boolean;
  99413. static set ClearCoatBumpTextureEnabled(value: boolean);
  99414. private static _ClearCoatTintTextureEnabled;
  99415. /**
  99416. * Are clear coat tint textures enabled in the application.
  99417. */
  99418. static get ClearCoatTintTextureEnabled(): boolean;
  99419. static set ClearCoatTintTextureEnabled(value: boolean);
  99420. private static _SheenTextureEnabled;
  99421. /**
  99422. * Are sheen textures enabled in the application.
  99423. */
  99424. static get SheenTextureEnabled(): boolean;
  99425. static set SheenTextureEnabled(value: boolean);
  99426. private static _AnisotropicTextureEnabled;
  99427. /**
  99428. * Are anisotropic textures enabled in the application.
  99429. */
  99430. static get AnisotropicTextureEnabled(): boolean;
  99431. static set AnisotropicTextureEnabled(value: boolean);
  99432. private static _ThicknessTextureEnabled;
  99433. /**
  99434. * Are thickness textures enabled in the application.
  99435. */
  99436. static get ThicknessTextureEnabled(): boolean;
  99437. static set ThicknessTextureEnabled(value: boolean);
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /** @hidden */
  99442. export var defaultFragmentDeclaration: {
  99443. name: string;
  99444. shader: string;
  99445. };
  99446. }
  99447. declare module BABYLON {
  99448. /** @hidden */
  99449. export var defaultUboDeclaration: {
  99450. name: string;
  99451. shader: string;
  99452. };
  99453. }
  99454. declare module BABYLON {
  99455. /** @hidden */
  99456. export var lightFragmentDeclaration: {
  99457. name: string;
  99458. shader: string;
  99459. };
  99460. }
  99461. declare module BABYLON {
  99462. /** @hidden */
  99463. export var lightUboDeclaration: {
  99464. name: string;
  99465. shader: string;
  99466. };
  99467. }
  99468. declare module BABYLON {
  99469. /** @hidden */
  99470. export var lightsFragmentFunctions: {
  99471. name: string;
  99472. shader: string;
  99473. };
  99474. }
  99475. declare module BABYLON {
  99476. /** @hidden */
  99477. export var shadowsFragmentFunctions: {
  99478. name: string;
  99479. shader: string;
  99480. };
  99481. }
  99482. declare module BABYLON {
  99483. /** @hidden */
  99484. export var fresnelFunction: {
  99485. name: string;
  99486. shader: string;
  99487. };
  99488. }
  99489. declare module BABYLON {
  99490. /** @hidden */
  99491. export var reflectionFunction: {
  99492. name: string;
  99493. shader: string;
  99494. };
  99495. }
  99496. declare module BABYLON {
  99497. /** @hidden */
  99498. export var bumpFragmentFunctions: {
  99499. name: string;
  99500. shader: string;
  99501. };
  99502. }
  99503. declare module BABYLON {
  99504. /** @hidden */
  99505. export var logDepthDeclaration: {
  99506. name: string;
  99507. shader: string;
  99508. };
  99509. }
  99510. declare module BABYLON {
  99511. /** @hidden */
  99512. export var bumpFragment: {
  99513. name: string;
  99514. shader: string;
  99515. };
  99516. }
  99517. declare module BABYLON {
  99518. /** @hidden */
  99519. export var depthPrePass: {
  99520. name: string;
  99521. shader: string;
  99522. };
  99523. }
  99524. declare module BABYLON {
  99525. /** @hidden */
  99526. export var lightFragment: {
  99527. name: string;
  99528. shader: string;
  99529. };
  99530. }
  99531. declare module BABYLON {
  99532. /** @hidden */
  99533. export var logDepthFragment: {
  99534. name: string;
  99535. shader: string;
  99536. };
  99537. }
  99538. declare module BABYLON {
  99539. /** @hidden */
  99540. export var defaultPixelShader: {
  99541. name: string;
  99542. shader: string;
  99543. };
  99544. }
  99545. declare module BABYLON {
  99546. /** @hidden */
  99547. export var defaultVertexDeclaration: {
  99548. name: string;
  99549. shader: string;
  99550. };
  99551. }
  99552. declare module BABYLON {
  99553. /** @hidden */
  99554. export var bumpVertexDeclaration: {
  99555. name: string;
  99556. shader: string;
  99557. };
  99558. }
  99559. declare module BABYLON {
  99560. /** @hidden */
  99561. export var bumpVertex: {
  99562. name: string;
  99563. shader: string;
  99564. };
  99565. }
  99566. declare module BABYLON {
  99567. /** @hidden */
  99568. export var fogVertex: {
  99569. name: string;
  99570. shader: string;
  99571. };
  99572. }
  99573. declare module BABYLON {
  99574. /** @hidden */
  99575. export var shadowsVertex: {
  99576. name: string;
  99577. shader: string;
  99578. };
  99579. }
  99580. declare module BABYLON {
  99581. /** @hidden */
  99582. export var pointCloudVertex: {
  99583. name: string;
  99584. shader: string;
  99585. };
  99586. }
  99587. declare module BABYLON {
  99588. /** @hidden */
  99589. export var logDepthVertex: {
  99590. name: string;
  99591. shader: string;
  99592. };
  99593. }
  99594. declare module BABYLON {
  99595. /** @hidden */
  99596. export var defaultVertexShader: {
  99597. name: string;
  99598. shader: string;
  99599. };
  99600. }
  99601. declare module BABYLON {
  99602. /** @hidden */
  99603. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99604. MAINUV1: boolean;
  99605. MAINUV2: boolean;
  99606. DIFFUSE: boolean;
  99607. DIFFUSEDIRECTUV: number;
  99608. AMBIENT: boolean;
  99609. AMBIENTDIRECTUV: number;
  99610. OPACITY: boolean;
  99611. OPACITYDIRECTUV: number;
  99612. OPACITYRGB: boolean;
  99613. REFLECTION: boolean;
  99614. EMISSIVE: boolean;
  99615. EMISSIVEDIRECTUV: number;
  99616. SPECULAR: boolean;
  99617. SPECULARDIRECTUV: number;
  99618. BUMP: boolean;
  99619. BUMPDIRECTUV: number;
  99620. PARALLAX: boolean;
  99621. PARALLAXOCCLUSION: boolean;
  99622. SPECULAROVERALPHA: boolean;
  99623. CLIPPLANE: boolean;
  99624. CLIPPLANE2: boolean;
  99625. CLIPPLANE3: boolean;
  99626. CLIPPLANE4: boolean;
  99627. CLIPPLANE5: boolean;
  99628. CLIPPLANE6: boolean;
  99629. ALPHATEST: boolean;
  99630. DEPTHPREPASS: boolean;
  99631. ALPHAFROMDIFFUSE: boolean;
  99632. POINTSIZE: boolean;
  99633. FOG: boolean;
  99634. SPECULARTERM: boolean;
  99635. DIFFUSEFRESNEL: boolean;
  99636. OPACITYFRESNEL: boolean;
  99637. REFLECTIONFRESNEL: boolean;
  99638. REFRACTIONFRESNEL: boolean;
  99639. EMISSIVEFRESNEL: boolean;
  99640. FRESNEL: boolean;
  99641. NORMAL: boolean;
  99642. UV1: boolean;
  99643. UV2: boolean;
  99644. VERTEXCOLOR: boolean;
  99645. VERTEXALPHA: boolean;
  99646. NUM_BONE_INFLUENCERS: number;
  99647. BonesPerMesh: number;
  99648. BONETEXTURE: boolean;
  99649. INSTANCES: boolean;
  99650. GLOSSINESS: boolean;
  99651. ROUGHNESS: boolean;
  99652. EMISSIVEASILLUMINATION: boolean;
  99653. LINKEMISSIVEWITHDIFFUSE: boolean;
  99654. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99655. LIGHTMAP: boolean;
  99656. LIGHTMAPDIRECTUV: number;
  99657. OBJECTSPACE_NORMALMAP: boolean;
  99658. USELIGHTMAPASSHADOWMAP: boolean;
  99659. REFLECTIONMAP_3D: boolean;
  99660. REFLECTIONMAP_SPHERICAL: boolean;
  99661. REFLECTIONMAP_PLANAR: boolean;
  99662. REFLECTIONMAP_CUBIC: boolean;
  99663. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99664. REFLECTIONMAP_PROJECTION: boolean;
  99665. REFLECTIONMAP_SKYBOX: boolean;
  99666. REFLECTIONMAP_EXPLICIT: boolean;
  99667. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99668. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99669. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99670. INVERTCUBICMAP: boolean;
  99671. LOGARITHMICDEPTH: boolean;
  99672. REFRACTION: boolean;
  99673. REFRACTIONMAP_3D: boolean;
  99674. REFLECTIONOVERALPHA: boolean;
  99675. TWOSIDEDLIGHTING: boolean;
  99676. SHADOWFLOAT: boolean;
  99677. MORPHTARGETS: boolean;
  99678. MORPHTARGETS_NORMAL: boolean;
  99679. MORPHTARGETS_TANGENT: boolean;
  99680. MORPHTARGETS_UV: boolean;
  99681. NUM_MORPH_INFLUENCERS: number;
  99682. NONUNIFORMSCALING: boolean;
  99683. PREMULTIPLYALPHA: boolean;
  99684. IMAGEPROCESSING: boolean;
  99685. VIGNETTE: boolean;
  99686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99687. VIGNETTEBLENDMODEOPAQUE: boolean;
  99688. TONEMAPPING: boolean;
  99689. TONEMAPPING_ACES: boolean;
  99690. CONTRAST: boolean;
  99691. COLORCURVES: boolean;
  99692. COLORGRADING: boolean;
  99693. COLORGRADING3D: boolean;
  99694. SAMPLER3DGREENDEPTH: boolean;
  99695. SAMPLER3DBGRMAP: boolean;
  99696. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99697. MULTIVIEW: boolean;
  99698. /**
  99699. * If the reflection texture on this material is in linear color space
  99700. * @hidden
  99701. */
  99702. IS_REFLECTION_LINEAR: boolean;
  99703. /**
  99704. * If the refraction texture on this material is in linear color space
  99705. * @hidden
  99706. */
  99707. IS_REFRACTION_LINEAR: boolean;
  99708. EXPOSURE: boolean;
  99709. constructor();
  99710. setReflectionMode(modeToEnable: string): void;
  99711. }
  99712. /**
  99713. * This is the default material used in Babylon. It is the best trade off between quality
  99714. * and performances.
  99715. * @see http://doc.babylonjs.com/babylon101/materials
  99716. */
  99717. export class StandardMaterial extends PushMaterial {
  99718. private _diffuseTexture;
  99719. /**
  99720. * The basic texture of the material as viewed under a light.
  99721. */
  99722. diffuseTexture: Nullable<BaseTexture>;
  99723. private _ambientTexture;
  99724. /**
  99725. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99726. */
  99727. ambientTexture: Nullable<BaseTexture>;
  99728. private _opacityTexture;
  99729. /**
  99730. * Define the transparency of the material from a texture.
  99731. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99732. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99733. */
  99734. opacityTexture: Nullable<BaseTexture>;
  99735. private _reflectionTexture;
  99736. /**
  99737. * Define the texture used to display the reflection.
  99738. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99739. */
  99740. reflectionTexture: Nullable<BaseTexture>;
  99741. private _emissiveTexture;
  99742. /**
  99743. * Define texture of the material as if self lit.
  99744. * This will be mixed in the final result even in the absence of light.
  99745. */
  99746. emissiveTexture: Nullable<BaseTexture>;
  99747. private _specularTexture;
  99748. /**
  99749. * Define how the color and intensity of the highlight given by the light in the material.
  99750. */
  99751. specularTexture: Nullable<BaseTexture>;
  99752. private _bumpTexture;
  99753. /**
  99754. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99755. * 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.
  99756. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99757. */
  99758. bumpTexture: Nullable<BaseTexture>;
  99759. private _lightmapTexture;
  99760. /**
  99761. * Complex lighting can be computationally expensive to compute at runtime.
  99762. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99763. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99764. */
  99765. lightmapTexture: Nullable<BaseTexture>;
  99766. private _refractionTexture;
  99767. /**
  99768. * Define the texture used to display the refraction.
  99769. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99770. */
  99771. refractionTexture: Nullable<BaseTexture>;
  99772. /**
  99773. * The color of the material lit by the environmental background lighting.
  99774. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99775. */
  99776. ambientColor: Color3;
  99777. /**
  99778. * The basic color of the material as viewed under a light.
  99779. */
  99780. diffuseColor: Color3;
  99781. /**
  99782. * Define how the color and intensity of the highlight given by the light in the material.
  99783. */
  99784. specularColor: Color3;
  99785. /**
  99786. * Define the color of the material as if self lit.
  99787. * This will be mixed in the final result even in the absence of light.
  99788. */
  99789. emissiveColor: Color3;
  99790. /**
  99791. * Defines how sharp are the highlights in the material.
  99792. * The bigger the value the sharper giving a more glossy feeling to the result.
  99793. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99794. */
  99795. specularPower: number;
  99796. private _useAlphaFromDiffuseTexture;
  99797. /**
  99798. * Does the transparency come from the diffuse texture alpha channel.
  99799. */
  99800. useAlphaFromDiffuseTexture: boolean;
  99801. private _useEmissiveAsIllumination;
  99802. /**
  99803. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99804. */
  99805. useEmissiveAsIllumination: boolean;
  99806. private _linkEmissiveWithDiffuse;
  99807. /**
  99808. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99809. * the emissive level when the final color is close to one.
  99810. */
  99811. linkEmissiveWithDiffuse: boolean;
  99812. private _useSpecularOverAlpha;
  99813. /**
  99814. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99815. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99816. */
  99817. useSpecularOverAlpha: boolean;
  99818. private _useReflectionOverAlpha;
  99819. /**
  99820. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99821. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99822. */
  99823. useReflectionOverAlpha: boolean;
  99824. private _disableLighting;
  99825. /**
  99826. * Does lights from the scene impacts this material.
  99827. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99828. */
  99829. disableLighting: boolean;
  99830. private _useObjectSpaceNormalMap;
  99831. /**
  99832. * Allows using an object space normal map (instead of tangent space).
  99833. */
  99834. useObjectSpaceNormalMap: boolean;
  99835. private _useParallax;
  99836. /**
  99837. * Is parallax enabled or not.
  99838. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99839. */
  99840. useParallax: boolean;
  99841. private _useParallaxOcclusion;
  99842. /**
  99843. * Is parallax occlusion enabled or not.
  99844. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99845. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99846. */
  99847. useParallaxOcclusion: boolean;
  99848. /**
  99849. * 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.
  99850. */
  99851. parallaxScaleBias: number;
  99852. private _roughness;
  99853. /**
  99854. * Helps to define how blurry the reflections should appears in the material.
  99855. */
  99856. roughness: number;
  99857. /**
  99858. * In case of refraction, define the value of the index of refraction.
  99859. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99860. */
  99861. indexOfRefraction: number;
  99862. /**
  99863. * Invert the refraction texture alongside the y axis.
  99864. * It can be useful with procedural textures or probe for instance.
  99865. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99866. */
  99867. invertRefractionY: boolean;
  99868. /**
  99869. * Defines the alpha limits in alpha test mode.
  99870. */
  99871. alphaCutOff: number;
  99872. private _useLightmapAsShadowmap;
  99873. /**
  99874. * In case of light mapping, define whether the map contains light or shadow informations.
  99875. */
  99876. useLightmapAsShadowmap: boolean;
  99877. private _diffuseFresnelParameters;
  99878. /**
  99879. * Define the diffuse fresnel parameters of the material.
  99880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99881. */
  99882. diffuseFresnelParameters: FresnelParameters;
  99883. private _opacityFresnelParameters;
  99884. /**
  99885. * Define the opacity fresnel parameters of the material.
  99886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99887. */
  99888. opacityFresnelParameters: FresnelParameters;
  99889. private _reflectionFresnelParameters;
  99890. /**
  99891. * Define the reflection fresnel parameters of the material.
  99892. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99893. */
  99894. reflectionFresnelParameters: FresnelParameters;
  99895. private _refractionFresnelParameters;
  99896. /**
  99897. * Define the refraction fresnel parameters of the material.
  99898. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99899. */
  99900. refractionFresnelParameters: FresnelParameters;
  99901. private _emissiveFresnelParameters;
  99902. /**
  99903. * Define the emissive fresnel parameters of the material.
  99904. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99905. */
  99906. emissiveFresnelParameters: FresnelParameters;
  99907. private _useReflectionFresnelFromSpecular;
  99908. /**
  99909. * If true automatically deducts the fresnels values from the material specularity.
  99910. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99911. */
  99912. useReflectionFresnelFromSpecular: boolean;
  99913. private _useGlossinessFromSpecularMapAlpha;
  99914. /**
  99915. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99916. */
  99917. useGlossinessFromSpecularMapAlpha: boolean;
  99918. private _maxSimultaneousLights;
  99919. /**
  99920. * Defines the maximum number of lights that can be used in the material
  99921. */
  99922. maxSimultaneousLights: number;
  99923. private _invertNormalMapX;
  99924. /**
  99925. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99926. */
  99927. invertNormalMapX: boolean;
  99928. private _invertNormalMapY;
  99929. /**
  99930. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99931. */
  99932. invertNormalMapY: boolean;
  99933. private _twoSidedLighting;
  99934. /**
  99935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99936. */
  99937. twoSidedLighting: boolean;
  99938. /**
  99939. * Default configuration related to image processing available in the standard Material.
  99940. */
  99941. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99942. /**
  99943. * Gets the image processing configuration used either in this material.
  99944. */
  99945. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99946. /**
  99947. * Sets the Default image processing configuration used either in the this material.
  99948. *
  99949. * If sets to null, the scene one is in use.
  99950. */
  99951. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99952. /**
  99953. * Keep track of the image processing observer to allow dispose and replace.
  99954. */
  99955. private _imageProcessingObserver;
  99956. /**
  99957. * Attaches a new image processing configuration to the Standard Material.
  99958. * @param configuration
  99959. */
  99960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99961. /**
  99962. * Gets wether the color curves effect is enabled.
  99963. */
  99964. get cameraColorCurvesEnabled(): boolean;
  99965. /**
  99966. * Sets wether the color curves effect is enabled.
  99967. */
  99968. set cameraColorCurvesEnabled(value: boolean);
  99969. /**
  99970. * Gets wether the color grading effect is enabled.
  99971. */
  99972. get cameraColorGradingEnabled(): boolean;
  99973. /**
  99974. * Gets wether the color grading effect is enabled.
  99975. */
  99976. set cameraColorGradingEnabled(value: boolean);
  99977. /**
  99978. * Gets wether tonemapping is enabled or not.
  99979. */
  99980. get cameraToneMappingEnabled(): boolean;
  99981. /**
  99982. * Sets wether tonemapping is enabled or not
  99983. */
  99984. set cameraToneMappingEnabled(value: boolean);
  99985. /**
  99986. * The camera exposure used on this material.
  99987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99988. * This corresponds to a photographic exposure.
  99989. */
  99990. get cameraExposure(): number;
  99991. /**
  99992. * The camera exposure used on this material.
  99993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99994. * This corresponds to a photographic exposure.
  99995. */
  99996. set cameraExposure(value: number);
  99997. /**
  99998. * Gets The camera contrast used on this material.
  99999. */
  100000. get cameraContrast(): number;
  100001. /**
  100002. * Sets The camera contrast used on this material.
  100003. */
  100004. set cameraContrast(value: number);
  100005. /**
  100006. * Gets the Color Grading 2D Lookup Texture.
  100007. */
  100008. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100009. /**
  100010. * Sets the Color Grading 2D Lookup Texture.
  100011. */
  100012. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100013. /**
  100014. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100015. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100016. * 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;
  100017. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100018. */
  100019. get cameraColorCurves(): Nullable<ColorCurves>;
  100020. /**
  100021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100023. * 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;
  100024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100025. */
  100026. set cameraColorCurves(value: Nullable<ColorCurves>);
  100027. /**
  100028. * Custom callback helping to override the default shader used in the material.
  100029. */
  100030. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100031. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100032. protected _worldViewProjectionMatrix: Matrix;
  100033. protected _globalAmbientColor: Color3;
  100034. protected _useLogarithmicDepth: boolean;
  100035. protected _rebuildInParallel: boolean;
  100036. /**
  100037. * Instantiates a new standard material.
  100038. * This is the default material used in Babylon. It is the best trade off between quality
  100039. * and performances.
  100040. * @see http://doc.babylonjs.com/babylon101/materials
  100041. * @param name Define the name of the material in the scene
  100042. * @param scene Define the scene the material belong to
  100043. */
  100044. constructor(name: string, scene: Scene);
  100045. /**
  100046. * Gets a boolean indicating that current material needs to register RTT
  100047. */
  100048. get hasRenderTargetTextures(): boolean;
  100049. /**
  100050. * Gets the current class name of the material e.g. "StandardMaterial"
  100051. * Mainly use in serialization.
  100052. * @returns the class name
  100053. */
  100054. getClassName(): string;
  100055. /**
  100056. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100057. * You can try switching to logarithmic depth.
  100058. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100059. */
  100060. get useLogarithmicDepth(): boolean;
  100061. set useLogarithmicDepth(value: boolean);
  100062. /**
  100063. * Specifies if the material will require alpha blending
  100064. * @returns a boolean specifying if alpha blending is needed
  100065. */
  100066. needAlphaBlending(): boolean;
  100067. /**
  100068. * Specifies if this material should be rendered in alpha test mode
  100069. * @returns a boolean specifying if an alpha test is needed.
  100070. */
  100071. needAlphaTesting(): boolean;
  100072. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100073. /**
  100074. * Get the texture used for alpha test purpose.
  100075. * @returns the diffuse texture in case of the standard material.
  100076. */
  100077. getAlphaTestTexture(): Nullable<BaseTexture>;
  100078. /**
  100079. * Get if the submesh is ready to be used and all its information available.
  100080. * Child classes can use it to update shaders
  100081. * @param mesh defines the mesh to check
  100082. * @param subMesh defines which submesh to check
  100083. * @param useInstances specifies that instances should be used
  100084. * @returns a boolean indicating that the submesh is ready or not
  100085. */
  100086. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100087. /**
  100088. * Builds the material UBO layouts.
  100089. * Used internally during the effect preparation.
  100090. */
  100091. buildUniformLayout(): void;
  100092. /**
  100093. * Unbinds the material from the mesh
  100094. */
  100095. unbind(): void;
  100096. /**
  100097. * Binds the submesh to this material by preparing the effect and shader to draw
  100098. * @param world defines the world transformation matrix
  100099. * @param mesh defines the mesh containing the submesh
  100100. * @param subMesh defines the submesh to bind the material to
  100101. */
  100102. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100103. /**
  100104. * Get the list of animatables in the material.
  100105. * @returns the list of animatables object used in the material
  100106. */
  100107. getAnimatables(): IAnimatable[];
  100108. /**
  100109. * Gets the active textures from the material
  100110. * @returns an array of textures
  100111. */
  100112. getActiveTextures(): BaseTexture[];
  100113. /**
  100114. * Specifies if the material uses a texture
  100115. * @param texture defines the texture to check against the material
  100116. * @returns a boolean specifying if the material uses the texture
  100117. */
  100118. hasTexture(texture: BaseTexture): boolean;
  100119. /**
  100120. * Disposes the material
  100121. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100122. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100123. */
  100124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100125. /**
  100126. * Makes a duplicate of the material, and gives it a new name
  100127. * @param name defines the new name for the duplicated material
  100128. * @returns the cloned material
  100129. */
  100130. clone(name: string): StandardMaterial;
  100131. /**
  100132. * Serializes this material in a JSON representation
  100133. * @returns the serialized material object
  100134. */
  100135. serialize(): any;
  100136. /**
  100137. * Creates a standard material from parsed material data
  100138. * @param source defines the JSON representation of the material
  100139. * @param scene defines the hosting scene
  100140. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100141. * @returns a new standard material
  100142. */
  100143. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100144. /**
  100145. * Are diffuse textures enabled in the application.
  100146. */
  100147. static get DiffuseTextureEnabled(): boolean;
  100148. static set DiffuseTextureEnabled(value: boolean);
  100149. /**
  100150. * Are ambient textures enabled in the application.
  100151. */
  100152. static get AmbientTextureEnabled(): boolean;
  100153. static set AmbientTextureEnabled(value: boolean);
  100154. /**
  100155. * Are opacity textures enabled in the application.
  100156. */
  100157. static get OpacityTextureEnabled(): boolean;
  100158. static set OpacityTextureEnabled(value: boolean);
  100159. /**
  100160. * Are reflection textures enabled in the application.
  100161. */
  100162. static get ReflectionTextureEnabled(): boolean;
  100163. static set ReflectionTextureEnabled(value: boolean);
  100164. /**
  100165. * Are emissive textures enabled in the application.
  100166. */
  100167. static get EmissiveTextureEnabled(): boolean;
  100168. static set EmissiveTextureEnabled(value: boolean);
  100169. /**
  100170. * Are specular textures enabled in the application.
  100171. */
  100172. static get SpecularTextureEnabled(): boolean;
  100173. static set SpecularTextureEnabled(value: boolean);
  100174. /**
  100175. * Are bump textures enabled in the application.
  100176. */
  100177. static get BumpTextureEnabled(): boolean;
  100178. static set BumpTextureEnabled(value: boolean);
  100179. /**
  100180. * Are lightmap textures enabled in the application.
  100181. */
  100182. static get LightmapTextureEnabled(): boolean;
  100183. static set LightmapTextureEnabled(value: boolean);
  100184. /**
  100185. * Are refraction textures enabled in the application.
  100186. */
  100187. static get RefractionTextureEnabled(): boolean;
  100188. static set RefractionTextureEnabled(value: boolean);
  100189. /**
  100190. * Are color grading textures enabled in the application.
  100191. */
  100192. static get ColorGradingTextureEnabled(): boolean;
  100193. static set ColorGradingTextureEnabled(value: boolean);
  100194. /**
  100195. * Are fresnels enabled in the application.
  100196. */
  100197. static get FresnelEnabled(): boolean;
  100198. static set FresnelEnabled(value: boolean);
  100199. }
  100200. }
  100201. declare module BABYLON {
  100202. /**
  100203. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100204. *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.
  100205. * The SPS is also a particle system. It provides some methods to manage the particles.
  100206. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100207. *
  100208. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100209. */
  100210. export class SolidParticleSystem implements IDisposable {
  100211. /**
  100212. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100213. * Example : var p = SPS.particles[i];
  100214. */
  100215. particles: SolidParticle[];
  100216. /**
  100217. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100218. */
  100219. nbParticles: number;
  100220. /**
  100221. * If the particles must ever face the camera (default false). Useful for planar particles.
  100222. */
  100223. billboard: boolean;
  100224. /**
  100225. * Recompute normals when adding a shape
  100226. */
  100227. recomputeNormals: boolean;
  100228. /**
  100229. * This a counter ofr your own usage. It's not set by any SPS functions.
  100230. */
  100231. counter: number;
  100232. /**
  100233. * The SPS name. This name is also given to the underlying mesh.
  100234. */
  100235. name: string;
  100236. /**
  100237. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100238. */
  100239. mesh: Mesh;
  100240. /**
  100241. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100242. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100243. */
  100244. vars: any;
  100245. /**
  100246. * This array is populated when the SPS is set as 'pickable'.
  100247. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100248. * Each element of this array is an object `{idx: int, faceId: int}`.
  100249. * `idx` is the picked particle index in the `SPS.particles` array
  100250. * `faceId` is the picked face index counted within this particle.
  100251. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100252. */
  100253. pickedParticles: {
  100254. idx: number;
  100255. faceId: number;
  100256. }[];
  100257. /**
  100258. * This array is populated when `enableDepthSort` is set to true.
  100259. * Each element of this array is an instance of the class DepthSortedParticle.
  100260. */
  100261. depthSortedParticles: DepthSortedParticle[];
  100262. /**
  100263. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100264. * @hidden
  100265. */
  100266. _bSphereOnly: boolean;
  100267. /**
  100268. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100269. * @hidden
  100270. */
  100271. _bSphereRadiusFactor: number;
  100272. private _scene;
  100273. private _positions;
  100274. private _indices;
  100275. private _normals;
  100276. private _colors;
  100277. private _uvs;
  100278. private _indices32;
  100279. private _positions32;
  100280. private _normals32;
  100281. private _fixedNormal32;
  100282. private _colors32;
  100283. private _uvs32;
  100284. private _index;
  100285. private _updatable;
  100286. private _pickable;
  100287. private _isVisibilityBoxLocked;
  100288. private _alwaysVisible;
  100289. private _depthSort;
  100290. private _expandable;
  100291. private _shapeCounter;
  100292. private _copy;
  100293. private _color;
  100294. private _computeParticleColor;
  100295. private _computeParticleTexture;
  100296. private _computeParticleRotation;
  100297. private _computeParticleVertex;
  100298. private _computeBoundingBox;
  100299. private _depthSortParticles;
  100300. private _camera;
  100301. private _mustUnrotateFixedNormals;
  100302. private _particlesIntersect;
  100303. private _needs32Bits;
  100304. private _isNotBuilt;
  100305. private _lastParticleId;
  100306. private _idxOfId;
  100307. private _multimaterialEnabled;
  100308. private _useModelMaterial;
  100309. private _indicesByMaterial;
  100310. private _materialIndexes;
  100311. private _depthSortFunction;
  100312. private _materialSortFunction;
  100313. private _materials;
  100314. private _multimaterial;
  100315. private _materialIndexesById;
  100316. private _defaultMaterial;
  100317. private _autoUpdateSubMeshes;
  100318. /**
  100319. * Creates a SPS (Solid Particle System) object.
  100320. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100321. * @param scene (Scene) is the scene in which the SPS is added.
  100322. * @param options defines the options of the sps e.g.
  100323. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100324. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100325. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100326. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  100327. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100328. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100329. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100330. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100331. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100332. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100333. */
  100334. constructor(name: string, scene: Scene, options?: {
  100335. updatable?: boolean;
  100336. isPickable?: boolean;
  100337. enableDepthSort?: boolean;
  100338. particleIntersection?: boolean;
  100339. boundingSphereOnly?: boolean;
  100340. bSphereRadiusFactor?: number;
  100341. expandable?: boolean;
  100342. useModelMaterial?: boolean;
  100343. enableMultiMaterial?: boolean;
  100344. });
  100345. /**
  100346. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100347. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100348. * @returns the created mesh
  100349. */
  100350. buildMesh(): Mesh;
  100351. /**
  100352. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100353. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100354. * Thus the particles generated from `digest()` have their property `position` set yet.
  100355. * @param mesh ( Mesh ) is the mesh to be digested
  100356. * @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
  100357. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100358. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100359. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100360. * @returns the current SPS
  100361. */
  100362. digest(mesh: Mesh, options?: {
  100363. facetNb?: number;
  100364. number?: number;
  100365. delta?: number;
  100366. storage?: [];
  100367. }): SolidParticleSystem;
  100368. /**
  100369. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100370. * @hidden
  100371. */
  100372. private _unrotateFixedNormals;
  100373. /**
  100374. * Resets the temporary working copy particle
  100375. * @hidden
  100376. */
  100377. private _resetCopy;
  100378. /**
  100379. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100380. * @param p the current index in the positions array to be updated
  100381. * @param ind the current index in the indices array
  100382. * @param shape a Vector3 array, the shape geometry
  100383. * @param positions the positions array to be updated
  100384. * @param meshInd the shape indices array
  100385. * @param indices the indices array to be updated
  100386. * @param meshUV the shape uv array
  100387. * @param uvs the uv array to be updated
  100388. * @param meshCol the shape color array
  100389. * @param colors the color array to be updated
  100390. * @param meshNor the shape normals array
  100391. * @param normals the normals array to be updated
  100392. * @param idx the particle index
  100393. * @param idxInShape the particle index in its shape
  100394. * @param options the addShape() method passed options
  100395. * @model the particle model
  100396. * @hidden
  100397. */
  100398. private _meshBuilder;
  100399. /**
  100400. * Returns a shape Vector3 array from positions float array
  100401. * @param positions float array
  100402. * @returns a vector3 array
  100403. * @hidden
  100404. */
  100405. private _posToShape;
  100406. /**
  100407. * Returns a shapeUV array from a float uvs (array deep copy)
  100408. * @param uvs as a float array
  100409. * @returns a shapeUV array
  100410. * @hidden
  100411. */
  100412. private _uvsToShapeUV;
  100413. /**
  100414. * Adds a new particle object in the particles array
  100415. * @param idx particle index in particles array
  100416. * @param id particle id
  100417. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100418. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100419. * @param model particle ModelShape object
  100420. * @param shapeId model shape identifier
  100421. * @param idxInShape index of the particle in the current model
  100422. * @param bInfo model bounding info object
  100423. * @param storage target storage array, if any
  100424. * @hidden
  100425. */
  100426. private _addParticle;
  100427. /**
  100428. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100429. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100430. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100431. * @param nb (positive integer) the number of particles to be created from this model
  100432. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100433. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100434. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100435. * @returns the number of shapes in the system
  100436. */
  100437. addShape(mesh: Mesh, nb: number, options?: {
  100438. positionFunction?: any;
  100439. vertexFunction?: any;
  100440. storage?: [];
  100441. }): number;
  100442. /**
  100443. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100444. * @hidden
  100445. */
  100446. private _rebuildParticle;
  100447. /**
  100448. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100449. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  100450. * @returns the SPS.
  100451. */
  100452. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100453. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100454. * Returns an array with the removed particles.
  100455. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  100456. * The SPS can't be empty so at least one particle needs to remain in place.
  100457. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100458. * @param start index of the first particle to remove
  100459. * @param end index of the last particle to remove (included)
  100460. * @returns an array populated with the removed particles
  100461. */
  100462. removeParticles(start: number, end: number): SolidParticle[];
  100463. /**
  100464. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100465. * @param solidParticleArray an array populated with Solid Particles objects
  100466. * @returns the SPS
  100467. */
  100468. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100469. /**
  100470. * Creates a new particle and modifies the SPS mesh geometry :
  100471. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100472. * - calls _addParticle() to populate the particle array
  100473. * factorized code from addShape() and insertParticlesFromArray()
  100474. * @param idx particle index in the particles array
  100475. * @param i particle index in its shape
  100476. * @param modelShape particle ModelShape object
  100477. * @param shape shape vertex array
  100478. * @param meshInd shape indices array
  100479. * @param meshUV shape uv array
  100480. * @param meshCol shape color array
  100481. * @param meshNor shape normals array
  100482. * @param bbInfo shape bounding info
  100483. * @param storage target particle storage
  100484. * @options addShape() passed options
  100485. * @hidden
  100486. */
  100487. private _insertNewParticle;
  100488. /**
  100489. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100490. * This method calls `updateParticle()` for each particle of the SPS.
  100491. * For an animated SPS, it is usually called within the render loop.
  100492. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  100493. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100494. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100495. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100496. * @returns the SPS.
  100497. */
  100498. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100499. /**
  100500. * Disposes the SPS.
  100501. */
  100502. dispose(): void;
  100503. /**
  100504. * Returns a SolidParticle object from its identifier : particle.id
  100505. * @param id (integer) the particle Id
  100506. * @returns the searched particle or null if not found in the SPS.
  100507. */
  100508. getParticleById(id: number): Nullable<SolidParticle>;
  100509. /**
  100510. * Returns a new array populated with the particles having the passed shapeId.
  100511. * @param shapeId (integer) the shape identifier
  100512. * @returns a new solid particle array
  100513. */
  100514. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100515. /**
  100516. * Populates the passed array "ref" with the particles having the passed shapeId.
  100517. * @param shapeId the shape identifier
  100518. * @returns the SPS
  100519. * @param ref
  100520. */
  100521. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100522. /**
  100523. * Computes the required SubMeshes according the materials assigned to the particles.
  100524. * @returns the solid particle system.
  100525. * Does nothing if called before the SPS mesh is built.
  100526. */
  100527. computeSubMeshes(): SolidParticleSystem;
  100528. /**
  100529. * Sorts the solid particles by material when MultiMaterial is enabled.
  100530. * Updates the indices32 array.
  100531. * Updates the indicesByMaterial array.
  100532. * Updates the mesh indices array.
  100533. * @returns the SPS
  100534. * @hidden
  100535. */
  100536. private _sortParticlesByMaterial;
  100537. /**
  100538. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100539. * @hidden
  100540. */
  100541. private _setMaterialIndexesById;
  100542. /**
  100543. * Returns an array with unique values of Materials from the passed array
  100544. * @param array the material array to be checked and filtered
  100545. * @hidden
  100546. */
  100547. private _filterUniqueMaterialId;
  100548. /**
  100549. * Sets a new Standard Material as _defaultMaterial if not already set.
  100550. * @hidden
  100551. */
  100552. private _setDefaultMaterial;
  100553. /**
  100554. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100556. * @returns the SPS.
  100557. */
  100558. refreshVisibleSize(): SolidParticleSystem;
  100559. /**
  100560. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100561. * @param size the size (float) of the visibility box
  100562. * note : this doesn't lock the SPS mesh bounding box.
  100563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100564. */
  100565. setVisibilityBox(size: number): void;
  100566. /**
  100567. * Gets whether the SPS as always visible or not
  100568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100569. */
  100570. get isAlwaysVisible(): boolean;
  100571. /**
  100572. * Sets the SPS as always visible or not
  100573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100574. */
  100575. set isAlwaysVisible(val: boolean);
  100576. /**
  100577. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100579. */
  100580. set isVisibilityBoxLocked(val: boolean);
  100581. /**
  100582. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100584. */
  100585. get isVisibilityBoxLocked(): boolean;
  100586. /**
  100587. * Tells to `setParticles()` to compute the particle rotations or not.
  100588. * Default value : true. The SPS is faster when it's set to false.
  100589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100590. */
  100591. set computeParticleRotation(val: boolean);
  100592. /**
  100593. * Tells to `setParticles()` to compute the particle colors or not.
  100594. * Default value : true. The SPS is faster when it's set to false.
  100595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100596. */
  100597. set computeParticleColor(val: boolean);
  100598. set computeParticleTexture(val: boolean);
  100599. /**
  100600. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100601. * Default value : false. The SPS is faster when it's set to false.
  100602. * Note : the particle custom vertex positions aren't stored values.
  100603. */
  100604. set computeParticleVertex(val: boolean);
  100605. /**
  100606. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100607. */
  100608. set computeBoundingBox(val: boolean);
  100609. /**
  100610. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100612. * Default : `true`
  100613. */
  100614. set depthSortParticles(val: boolean);
  100615. /**
  100616. * Gets if `setParticles()` computes the particle rotations or not.
  100617. * Default value : true. The SPS is faster when it's set to false.
  100618. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100619. */
  100620. get computeParticleRotation(): boolean;
  100621. /**
  100622. * Gets if `setParticles()` computes the particle colors or not.
  100623. * Default value : true. The SPS is faster when it's set to false.
  100624. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100625. */
  100626. get computeParticleColor(): boolean;
  100627. /**
  100628. * Gets if `setParticles()` computes the particle textures or not.
  100629. * Default value : true. The SPS is faster when it's set to false.
  100630. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100631. */
  100632. get computeParticleTexture(): boolean;
  100633. /**
  100634. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100635. * Default value : false. The SPS is faster when it's set to false.
  100636. * Note : the particle custom vertex positions aren't stored values.
  100637. */
  100638. get computeParticleVertex(): boolean;
  100639. /**
  100640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100641. */
  100642. get computeBoundingBox(): boolean;
  100643. /**
  100644. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100646. * Default : `true`
  100647. */
  100648. get depthSortParticles(): boolean;
  100649. /**
  100650. * Gets if the SPS is created as expandable at construction time.
  100651. * Default : `false`
  100652. */
  100653. get expandable(): boolean;
  100654. /**
  100655. * Gets if the SPS supports the Multi Materials
  100656. */
  100657. get multimaterialEnabled(): boolean;
  100658. /**
  100659. * Gets if the SPS uses the model materials for its own multimaterial.
  100660. */
  100661. get useModelMaterial(): boolean;
  100662. /**
  100663. * The SPS used material array.
  100664. */
  100665. get materials(): Material[];
  100666. /**
  100667. * Sets the SPS MultiMaterial from the passed materials.
  100668. * Note : the passed array is internally copied and not used then by reference.
  100669. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100670. */
  100671. setMultiMaterial(materials: Material[]): void;
  100672. /**
  100673. * The SPS computed multimaterial object
  100674. */
  100675. get multimaterial(): MultiMaterial;
  100676. set multimaterial(mm: MultiMaterial);
  100677. /**
  100678. * If the subMeshes must be updated on the next call to setParticles()
  100679. */
  100680. get autoUpdateSubMeshes(): boolean;
  100681. set autoUpdateSubMeshes(val: boolean);
  100682. /**
  100683. * This function does nothing. It may be overwritten to set all the particle first values.
  100684. * The SPS doesn't call this function, you may have to call it by your own.
  100685. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100686. */
  100687. initParticles(): void;
  100688. /**
  100689. * This function does nothing. It may be overwritten to recycle a particle.
  100690. * The SPS doesn't call this function, you may have to call it by your own.
  100691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100692. * @param particle The particle to recycle
  100693. * @returns the recycled particle
  100694. */
  100695. recycleParticle(particle: SolidParticle): SolidParticle;
  100696. /**
  100697. * Updates a particle : this function should be overwritten by the user.
  100698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100700. * @example : just set a particle position or velocity and recycle conditions
  100701. * @param particle The particle to update
  100702. * @returns the updated particle
  100703. */
  100704. updateParticle(particle: SolidParticle): SolidParticle;
  100705. /**
  100706. * Updates a vertex of a particle : it can be overwritten by the user.
  100707. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100708. * @param particle the current particle
  100709. * @param vertex the current index of the current particle
  100710. * @param pt the index of the current vertex in the particle shape
  100711. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100712. * @example : just set a vertex particle position
  100713. * @returns the updated vertex
  100714. */
  100715. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100716. /**
  100717. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100718. * This does nothing and may be overwritten by the user.
  100719. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100721. * @param update the boolean update value actually passed to setParticles()
  100722. */
  100723. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100724. /**
  100725. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100726. * This will be passed three parameters.
  100727. * This does nothing and may be overwritten by the user.
  100728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100730. * @param update the boolean update value actually passed to setParticles()
  100731. */
  100732. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100733. }
  100734. }
  100735. declare module BABYLON {
  100736. /**
  100737. * Represents one particle of a solid particle system.
  100738. */
  100739. export class SolidParticle {
  100740. /**
  100741. * particle global index
  100742. */
  100743. idx: number;
  100744. /**
  100745. * particle identifier
  100746. */
  100747. id: number;
  100748. /**
  100749. * The color of the particle
  100750. */
  100751. color: Nullable<Color4>;
  100752. /**
  100753. * The world space position of the particle.
  100754. */
  100755. position: Vector3;
  100756. /**
  100757. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100758. */
  100759. rotation: Vector3;
  100760. /**
  100761. * The world space rotation quaternion of the particle.
  100762. */
  100763. rotationQuaternion: Nullable<Quaternion>;
  100764. /**
  100765. * The scaling of the particle.
  100766. */
  100767. scaling: Vector3;
  100768. /**
  100769. * The uvs of the particle.
  100770. */
  100771. uvs: Vector4;
  100772. /**
  100773. * The current speed of the particle.
  100774. */
  100775. velocity: Vector3;
  100776. /**
  100777. * The pivot point in the particle local space.
  100778. */
  100779. pivot: Vector3;
  100780. /**
  100781. * Must the particle be translated from its pivot point in its local space ?
  100782. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100783. * Default : false
  100784. */
  100785. translateFromPivot: boolean;
  100786. /**
  100787. * Is the particle active or not ?
  100788. */
  100789. alive: boolean;
  100790. /**
  100791. * Is the particle visible or not ?
  100792. */
  100793. isVisible: boolean;
  100794. /**
  100795. * Index of this particle in the global "positions" array (Internal use)
  100796. * @hidden
  100797. */
  100798. _pos: number;
  100799. /**
  100800. * @hidden Index of this particle in the global "indices" array (Internal use)
  100801. */
  100802. _ind: number;
  100803. /**
  100804. * @hidden ModelShape of this particle (Internal use)
  100805. */
  100806. _model: ModelShape;
  100807. /**
  100808. * ModelShape id of this particle
  100809. */
  100810. shapeId: number;
  100811. /**
  100812. * Index of the particle in its shape id
  100813. */
  100814. idxInShape: number;
  100815. /**
  100816. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100817. */
  100818. _modelBoundingInfo: BoundingInfo;
  100819. /**
  100820. * @hidden Particle BoundingInfo object (Internal use)
  100821. */
  100822. _boundingInfo: BoundingInfo;
  100823. /**
  100824. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100825. */
  100826. _sps: SolidParticleSystem;
  100827. /**
  100828. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100829. */
  100830. _stillInvisible: boolean;
  100831. /**
  100832. * @hidden Last computed particle rotation matrix
  100833. */
  100834. _rotationMatrix: number[];
  100835. /**
  100836. * Parent particle Id, if any.
  100837. * Default null.
  100838. */
  100839. parentId: Nullable<number>;
  100840. /**
  100841. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100842. */
  100843. materialIndex: Nullable<number>;
  100844. /**
  100845. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100846. * The possible values are :
  100847. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100848. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100849. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100850. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100851. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100852. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100853. * */
  100854. cullingStrategy: number;
  100855. /**
  100856. * @hidden Internal global position in the SPS.
  100857. */
  100858. _globalPosition: Vector3;
  100859. /**
  100860. * Creates a Solid Particle object.
  100861. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100862. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100863. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100864. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100865. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100866. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100867. * @param shapeId (integer) is the model shape identifier in the SPS.
  100868. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100869. * @param sps defines the sps it is associated to
  100870. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100871. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100872. */
  100873. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100874. /**
  100875. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100876. * @param target the particle target
  100877. * @returns the current particle
  100878. */
  100879. copyToRef(target: SolidParticle): SolidParticle;
  100880. /**
  100881. * Legacy support, changed scale to scaling
  100882. */
  100883. get scale(): Vector3;
  100884. /**
  100885. * Legacy support, changed scale to scaling
  100886. */
  100887. set scale(scale: Vector3);
  100888. /**
  100889. * Legacy support, changed quaternion to rotationQuaternion
  100890. */
  100891. get quaternion(): Nullable<Quaternion>;
  100892. /**
  100893. * Legacy support, changed quaternion to rotationQuaternion
  100894. */
  100895. set quaternion(q: Nullable<Quaternion>);
  100896. /**
  100897. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100898. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100899. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100900. * @returns true if it intersects
  100901. */
  100902. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100903. /**
  100904. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100905. * A particle is in the frustum if its bounding box intersects the frustum
  100906. * @param frustumPlanes defines the frustum to test
  100907. * @returns true if the particle is in the frustum planes
  100908. */
  100909. isInFrustum(frustumPlanes: Plane[]): boolean;
  100910. /**
  100911. * get the rotation matrix of the particle
  100912. * @hidden
  100913. */
  100914. getRotationMatrix(m: Matrix): void;
  100915. }
  100916. /**
  100917. * Represents the shape of the model used by one particle of a solid particle system.
  100918. * SPS internal tool, don't use it manually.
  100919. */
  100920. export class ModelShape {
  100921. /**
  100922. * The shape id
  100923. * @hidden
  100924. */
  100925. shapeID: number;
  100926. /**
  100927. * flat array of model positions (internal use)
  100928. * @hidden
  100929. */
  100930. _shape: Vector3[];
  100931. /**
  100932. * flat array of model UVs (internal use)
  100933. * @hidden
  100934. */
  100935. _shapeUV: number[];
  100936. /**
  100937. * color array of the model
  100938. * @hidden
  100939. */
  100940. _shapeColors: number[];
  100941. /**
  100942. * indices array of the model
  100943. * @hidden
  100944. */
  100945. _indices: number[];
  100946. /**
  100947. * normals array of the model
  100948. * @hidden
  100949. */
  100950. _normals: number[];
  100951. /**
  100952. * length of the shape in the model indices array (internal use)
  100953. * @hidden
  100954. */
  100955. _indicesLength: number;
  100956. /**
  100957. * Custom position function (internal use)
  100958. * @hidden
  100959. */
  100960. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100961. /**
  100962. * Custom vertex function (internal use)
  100963. * @hidden
  100964. */
  100965. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100966. /**
  100967. * Model material (internal use)
  100968. * @hidden
  100969. */
  100970. _material: Nullable<Material>;
  100971. /**
  100972. * 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.
  100973. * SPS internal tool, don't use it manually.
  100974. * @hidden
  100975. */
  100976. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  100977. }
  100978. /**
  100979. * Represents a Depth Sorted Particle in the solid particle system.
  100980. * @hidden
  100981. */
  100982. export class DepthSortedParticle {
  100983. /**
  100984. * Index of the particle in the "indices" array
  100985. */
  100986. ind: number;
  100987. /**
  100988. * Length of the particle shape in the "indices" array
  100989. */
  100990. indicesLength: number;
  100991. /**
  100992. * Squared distance from the particle to the camera
  100993. */
  100994. sqDistance: number;
  100995. /**
  100996. * Material index when used with MultiMaterials
  100997. */
  100998. materialIndex: number;
  100999. /**
  101000. * Creates a new sorted particle
  101001. * @param materialIndex
  101002. */
  101003. constructor(ind: number, indLength: number, materialIndex: number);
  101004. }
  101005. }
  101006. declare module BABYLON {
  101007. /**
  101008. * @hidden
  101009. */
  101010. export class _MeshCollisionData {
  101011. _checkCollisions: boolean;
  101012. _collisionMask: number;
  101013. _collisionGroup: number;
  101014. _collider: Nullable<Collider>;
  101015. _oldPositionForCollisions: Vector3;
  101016. _diffPositionForCollisions: Vector3;
  101017. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101018. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101019. }
  101020. }
  101021. declare module BABYLON {
  101022. /** @hidden */
  101023. class _FacetDataStorage {
  101024. facetPositions: Vector3[];
  101025. facetNormals: Vector3[];
  101026. facetPartitioning: number[][];
  101027. facetNb: number;
  101028. partitioningSubdivisions: number;
  101029. partitioningBBoxRatio: number;
  101030. facetDataEnabled: boolean;
  101031. facetParameters: any;
  101032. bbSize: Vector3;
  101033. subDiv: {
  101034. max: number;
  101035. X: number;
  101036. Y: number;
  101037. Z: number;
  101038. };
  101039. facetDepthSort: boolean;
  101040. facetDepthSortEnabled: boolean;
  101041. depthSortedIndices: IndicesArray;
  101042. depthSortedFacets: {
  101043. ind: number;
  101044. sqDistance: number;
  101045. }[];
  101046. facetDepthSortFunction: (f1: {
  101047. ind: number;
  101048. sqDistance: number;
  101049. }, f2: {
  101050. ind: number;
  101051. sqDistance: number;
  101052. }) => number;
  101053. facetDepthSortFrom: Vector3;
  101054. facetDepthSortOrigin: Vector3;
  101055. invertedMatrix: Matrix;
  101056. }
  101057. /**
  101058. * @hidden
  101059. **/
  101060. class _InternalAbstractMeshDataInfo {
  101061. _hasVertexAlpha: boolean;
  101062. _useVertexColors: boolean;
  101063. _numBoneInfluencers: number;
  101064. _applyFog: boolean;
  101065. _receiveShadows: boolean;
  101066. _facetData: _FacetDataStorage;
  101067. _visibility: number;
  101068. _skeleton: Nullable<Skeleton>;
  101069. _layerMask: number;
  101070. _computeBonesUsingShaders: boolean;
  101071. _isActive: boolean;
  101072. _onlyForInstances: boolean;
  101073. _isActiveIntermediate: boolean;
  101074. _onlyForInstancesIntermediate: boolean;
  101075. _actAsRegularMesh: boolean;
  101076. }
  101077. /**
  101078. * Class used to store all common mesh properties
  101079. */
  101080. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101081. /** No occlusion */
  101082. static OCCLUSION_TYPE_NONE: number;
  101083. /** Occlusion set to optimisitic */
  101084. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101085. /** Occlusion set to strict */
  101086. static OCCLUSION_TYPE_STRICT: number;
  101087. /** Use an accurante occlusion algorithm */
  101088. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101089. /** Use a conservative occlusion algorithm */
  101090. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101091. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101092. * Test order :
  101093. * Is the bounding sphere outside the frustum ?
  101094. * If not, are the bounding box vertices outside the frustum ?
  101095. * It not, then the cullable object is in the frustum.
  101096. */
  101097. static readonly CULLINGSTRATEGY_STANDARD: number;
  101098. /** Culling strategy : Bounding Sphere Only.
  101099. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101100. * It's also less accurate than the standard because some not visible objects can still be selected.
  101101. * Test : is the bounding sphere outside the frustum ?
  101102. * If not, then the cullable object is in the frustum.
  101103. */
  101104. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101105. /** Culling strategy : Optimistic Inclusion.
  101106. * This in an inclusion test first, then the standard exclusion test.
  101107. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101108. * 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.
  101109. * Anyway, it's as accurate as the standard strategy.
  101110. * Test :
  101111. * Is the cullable object bounding sphere center in the frustum ?
  101112. * If not, apply the default culling strategy.
  101113. */
  101114. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101115. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101116. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101117. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101118. * 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.
  101119. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101120. * Test :
  101121. * Is the cullable object bounding sphere center in the frustum ?
  101122. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101123. */
  101124. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101125. /**
  101126. * No billboard
  101127. */
  101128. static get BILLBOARDMODE_NONE(): number;
  101129. /** Billboard on X axis */
  101130. static get BILLBOARDMODE_X(): number;
  101131. /** Billboard on Y axis */
  101132. static get BILLBOARDMODE_Y(): number;
  101133. /** Billboard on Z axis */
  101134. static get BILLBOARDMODE_Z(): number;
  101135. /** Billboard on all axes */
  101136. static get BILLBOARDMODE_ALL(): number;
  101137. /** Billboard on using position instead of orientation */
  101138. static get BILLBOARDMODE_USE_POSITION(): number;
  101139. /** @hidden */
  101140. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101141. /**
  101142. * The culling strategy to use to check whether the mesh must be rendered or not.
  101143. * This value can be changed at any time and will be used on the next render mesh selection.
  101144. * The possible values are :
  101145. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101146. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101147. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101148. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101149. * Please read each static variable documentation to get details about the culling process.
  101150. * */
  101151. cullingStrategy: number;
  101152. /**
  101153. * Gets the number of facets in the mesh
  101154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101155. */
  101156. get facetNb(): number;
  101157. /**
  101158. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101160. */
  101161. get partitioningSubdivisions(): number;
  101162. set partitioningSubdivisions(nb: number);
  101163. /**
  101164. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101165. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101167. */
  101168. get partitioningBBoxRatio(): number;
  101169. set partitioningBBoxRatio(ratio: number);
  101170. /**
  101171. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101172. * Works only for updatable meshes.
  101173. * Doesn't work with multi-materials
  101174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101175. */
  101176. get mustDepthSortFacets(): boolean;
  101177. set mustDepthSortFacets(sort: boolean);
  101178. /**
  101179. * The location (Vector3) where the facet depth sort must be computed from.
  101180. * By default, the active camera position.
  101181. * Used only when facet depth sort is enabled
  101182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101183. */
  101184. get facetDepthSortFrom(): Vector3;
  101185. set facetDepthSortFrom(location: Vector3);
  101186. /**
  101187. * gets a boolean indicating if facetData is enabled
  101188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101189. */
  101190. get isFacetDataEnabled(): boolean;
  101191. /** @hidden */
  101192. _updateNonUniformScalingState(value: boolean): boolean;
  101193. /**
  101194. * An event triggered when this mesh collides with another one
  101195. */
  101196. onCollideObservable: Observable<AbstractMesh>;
  101197. /** Set a function to call when this mesh collides with another one */
  101198. set onCollide(callback: () => void);
  101199. /**
  101200. * An event triggered when the collision's position changes
  101201. */
  101202. onCollisionPositionChangeObservable: Observable<Vector3>;
  101203. /** Set a function to call when the collision's position changes */
  101204. set onCollisionPositionChange(callback: () => void);
  101205. /**
  101206. * An event triggered when material is changed
  101207. */
  101208. onMaterialChangedObservable: Observable<AbstractMesh>;
  101209. /**
  101210. * Gets or sets the orientation for POV movement & rotation
  101211. */
  101212. definedFacingForward: boolean;
  101213. /** @hidden */
  101214. _occlusionQuery: Nullable<WebGLQuery>;
  101215. /** @hidden */
  101216. _renderingGroup: Nullable<RenderingGroup>;
  101217. /**
  101218. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101219. */
  101220. get visibility(): number;
  101221. /**
  101222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101223. */
  101224. set visibility(value: number);
  101225. /** Gets or sets the alpha index used to sort transparent meshes
  101226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101227. */
  101228. alphaIndex: number;
  101229. /**
  101230. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101231. */
  101232. isVisible: boolean;
  101233. /**
  101234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101235. */
  101236. isPickable: boolean;
  101237. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101238. showSubMeshesBoundingBox: boolean;
  101239. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101241. */
  101242. isBlocker: boolean;
  101243. /**
  101244. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101245. */
  101246. enablePointerMoveEvents: boolean;
  101247. /**
  101248. * Specifies the rendering group id for this mesh (0 by default)
  101249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101250. */
  101251. renderingGroupId: number;
  101252. private _material;
  101253. /** Gets or sets current material */
  101254. get material(): Nullable<Material>;
  101255. set material(value: Nullable<Material>);
  101256. /**
  101257. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101258. * @see http://doc.babylonjs.com/babylon101/shadows
  101259. */
  101260. get receiveShadows(): boolean;
  101261. set receiveShadows(value: boolean);
  101262. /** Defines color to use when rendering outline */
  101263. outlineColor: Color3;
  101264. /** Define width to use when rendering outline */
  101265. outlineWidth: number;
  101266. /** Defines color to use when rendering overlay */
  101267. overlayColor: Color3;
  101268. /** Defines alpha to use when rendering overlay */
  101269. overlayAlpha: number;
  101270. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101271. get hasVertexAlpha(): boolean;
  101272. set hasVertexAlpha(value: boolean);
  101273. /** 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) */
  101274. get useVertexColors(): boolean;
  101275. set useVertexColors(value: boolean);
  101276. /**
  101277. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101278. */
  101279. get computeBonesUsingShaders(): boolean;
  101280. set computeBonesUsingShaders(value: boolean);
  101281. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101282. get numBoneInfluencers(): number;
  101283. set numBoneInfluencers(value: number);
  101284. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101285. get applyFog(): boolean;
  101286. set applyFog(value: boolean);
  101287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101288. useOctreeForRenderingSelection: boolean;
  101289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101290. useOctreeForPicking: boolean;
  101291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101292. useOctreeForCollisions: boolean;
  101293. /**
  101294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101296. */
  101297. get layerMask(): number;
  101298. set layerMask(value: number);
  101299. /**
  101300. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101301. */
  101302. alwaysSelectAsActiveMesh: boolean;
  101303. /**
  101304. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101305. */
  101306. doNotSyncBoundingInfo: boolean;
  101307. /**
  101308. * Gets or sets the current action manager
  101309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101310. */
  101311. actionManager: Nullable<AbstractActionManager>;
  101312. private _meshCollisionData;
  101313. /**
  101314. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101316. */
  101317. ellipsoid: Vector3;
  101318. /**
  101319. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101321. */
  101322. ellipsoidOffset: Vector3;
  101323. /**
  101324. * Gets or sets a collision mask used to mask collisions (default is -1).
  101325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101326. */
  101327. get collisionMask(): number;
  101328. set collisionMask(mask: number);
  101329. /**
  101330. * Gets or sets the current collision group mask (-1 by default).
  101331. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101332. */
  101333. get collisionGroup(): number;
  101334. set collisionGroup(mask: number);
  101335. /**
  101336. * Defines edge width used when edgesRenderer is enabled
  101337. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101338. */
  101339. edgesWidth: number;
  101340. /**
  101341. * Defines edge color used when edgesRenderer is enabled
  101342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101343. */
  101344. edgesColor: Color4;
  101345. /** @hidden */
  101346. _edgesRenderer: Nullable<IEdgesRenderer>;
  101347. /** @hidden */
  101348. _masterMesh: Nullable<AbstractMesh>;
  101349. /** @hidden */
  101350. _boundingInfo: Nullable<BoundingInfo>;
  101351. /** @hidden */
  101352. _renderId: number;
  101353. /**
  101354. * Gets or sets the list of subMeshes
  101355. * @see http://doc.babylonjs.com/how_to/multi_materials
  101356. */
  101357. subMeshes: SubMesh[];
  101358. /** @hidden */
  101359. _intersectionsInProgress: AbstractMesh[];
  101360. /** @hidden */
  101361. _unIndexed: boolean;
  101362. /** @hidden */
  101363. _lightSources: Light[];
  101364. /** Gets the list of lights affecting that mesh */
  101365. get lightSources(): Light[];
  101366. /** @hidden */
  101367. get _positions(): Nullable<Vector3[]>;
  101368. /** @hidden */
  101369. _waitingData: {
  101370. lods: Nullable<any>;
  101371. actions: Nullable<any>;
  101372. freezeWorldMatrix: Nullable<boolean>;
  101373. };
  101374. /** @hidden */
  101375. _bonesTransformMatrices: Nullable<Float32Array>;
  101376. /** @hidden */
  101377. _transformMatrixTexture: Nullable<RawTexture>;
  101378. /**
  101379. * Gets or sets a skeleton to apply skining transformations
  101380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101381. */
  101382. set skeleton(value: Nullable<Skeleton>);
  101383. get skeleton(): Nullable<Skeleton>;
  101384. /**
  101385. * An event triggered when the mesh is rebuilt.
  101386. */
  101387. onRebuildObservable: Observable<AbstractMesh>;
  101388. /**
  101389. * Creates a new AbstractMesh
  101390. * @param name defines the name of the mesh
  101391. * @param scene defines the hosting scene
  101392. */
  101393. constructor(name: string, scene?: Nullable<Scene>);
  101394. /**
  101395. * Returns the string "AbstractMesh"
  101396. * @returns "AbstractMesh"
  101397. */
  101398. getClassName(): string;
  101399. /**
  101400. * Gets a string representation of the current mesh
  101401. * @param fullDetails defines a boolean indicating if full details must be included
  101402. * @returns a string representation of the current mesh
  101403. */
  101404. toString(fullDetails?: boolean): string;
  101405. /**
  101406. * @hidden
  101407. */
  101408. protected _getEffectiveParent(): Nullable<Node>;
  101409. /** @hidden */
  101410. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101411. /** @hidden */
  101412. _rebuild(): void;
  101413. /** @hidden */
  101414. _resyncLightSources(): void;
  101415. /** @hidden */
  101416. _resyncLightSource(light: Light): void;
  101417. /** @hidden */
  101418. _unBindEffect(): void;
  101419. /** @hidden */
  101420. _removeLightSource(light: Light, dispose: boolean): void;
  101421. private _markSubMeshesAsDirty;
  101422. /** @hidden */
  101423. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101424. /** @hidden */
  101425. _markSubMeshesAsAttributesDirty(): void;
  101426. /** @hidden */
  101427. _markSubMeshesAsMiscDirty(): void;
  101428. /**
  101429. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101430. */
  101431. get scaling(): Vector3;
  101432. set scaling(newScaling: Vector3);
  101433. /**
  101434. * Returns true if the mesh is blocked. Implemented by child classes
  101435. */
  101436. get isBlocked(): boolean;
  101437. /**
  101438. * Returns the mesh itself by default. Implemented by child classes
  101439. * @param camera defines the camera to use to pick the right LOD level
  101440. * @returns the currentAbstractMesh
  101441. */
  101442. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101443. /**
  101444. * Returns 0 by default. Implemented by child classes
  101445. * @returns an integer
  101446. */
  101447. getTotalVertices(): number;
  101448. /**
  101449. * Returns a positive integer : the total number of indices in this mesh geometry.
  101450. * @returns the numner of indices or zero if the mesh has no geometry.
  101451. */
  101452. getTotalIndices(): number;
  101453. /**
  101454. * Returns null by default. Implemented by child classes
  101455. * @returns null
  101456. */
  101457. getIndices(): Nullable<IndicesArray>;
  101458. /**
  101459. * Returns the array of the requested vertex data kind. Implemented by child classes
  101460. * @param kind defines the vertex data kind to use
  101461. * @returns null
  101462. */
  101463. getVerticesData(kind: string): Nullable<FloatArray>;
  101464. /**
  101465. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101466. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101467. * Note that a new underlying VertexBuffer object is created each call.
  101468. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101469. * @param kind defines vertex data kind:
  101470. * * VertexBuffer.PositionKind
  101471. * * VertexBuffer.UVKind
  101472. * * VertexBuffer.UV2Kind
  101473. * * VertexBuffer.UV3Kind
  101474. * * VertexBuffer.UV4Kind
  101475. * * VertexBuffer.UV5Kind
  101476. * * VertexBuffer.UV6Kind
  101477. * * VertexBuffer.ColorKind
  101478. * * VertexBuffer.MatricesIndicesKind
  101479. * * VertexBuffer.MatricesIndicesExtraKind
  101480. * * VertexBuffer.MatricesWeightsKind
  101481. * * VertexBuffer.MatricesWeightsExtraKind
  101482. * @param data defines the data source
  101483. * @param updatable defines if the data must be flagged as updatable (or static)
  101484. * @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
  101485. * @returns the current mesh
  101486. */
  101487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101488. /**
  101489. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101490. * If the mesh has no geometry, it is simply returned as it is.
  101491. * @param kind defines vertex data kind:
  101492. * * VertexBuffer.PositionKind
  101493. * * VertexBuffer.UVKind
  101494. * * VertexBuffer.UV2Kind
  101495. * * VertexBuffer.UV3Kind
  101496. * * VertexBuffer.UV4Kind
  101497. * * VertexBuffer.UV5Kind
  101498. * * VertexBuffer.UV6Kind
  101499. * * VertexBuffer.ColorKind
  101500. * * VertexBuffer.MatricesIndicesKind
  101501. * * VertexBuffer.MatricesIndicesExtraKind
  101502. * * VertexBuffer.MatricesWeightsKind
  101503. * * VertexBuffer.MatricesWeightsExtraKind
  101504. * @param data defines the data source
  101505. * @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
  101506. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101507. * @returns the current mesh
  101508. */
  101509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101510. /**
  101511. * Sets the mesh indices,
  101512. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101513. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101514. * @param totalVertices Defines the total number of vertices
  101515. * @returns the current mesh
  101516. */
  101517. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101518. /**
  101519. * Gets a boolean indicating if specific vertex data is present
  101520. * @param kind defines the vertex data kind to use
  101521. * @returns true is data kind is present
  101522. */
  101523. isVerticesDataPresent(kind: string): boolean;
  101524. /**
  101525. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101526. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101527. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101528. * @returns a BoundingInfo
  101529. */
  101530. getBoundingInfo(): BoundingInfo;
  101531. /**
  101532. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101533. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101534. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101535. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101536. * @returns the current mesh
  101537. */
  101538. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101539. /**
  101540. * Overwrite the current bounding info
  101541. * @param boundingInfo defines the new bounding info
  101542. * @returns the current mesh
  101543. */
  101544. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101545. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101546. get useBones(): boolean;
  101547. /** @hidden */
  101548. _preActivate(): void;
  101549. /** @hidden */
  101550. _preActivateForIntermediateRendering(renderId: number): void;
  101551. /** @hidden */
  101552. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101553. /** @hidden */
  101554. _postActivate(): void;
  101555. /** @hidden */
  101556. _freeze(): void;
  101557. /** @hidden */
  101558. _unFreeze(): void;
  101559. /**
  101560. * Gets the current world matrix
  101561. * @returns a Matrix
  101562. */
  101563. getWorldMatrix(): Matrix;
  101564. /** @hidden */
  101565. _getWorldMatrixDeterminant(): number;
  101566. /**
  101567. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101568. */
  101569. get isAnInstance(): boolean;
  101570. /**
  101571. * Gets a boolean indicating if this mesh has instances
  101572. */
  101573. get hasInstances(): boolean;
  101574. /**
  101575. * Perform relative position change from the point of view of behind the front of the mesh.
  101576. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101577. * Supports definition of mesh facing forward or backward
  101578. * @param amountRight defines the distance on the right axis
  101579. * @param amountUp defines the distance on the up axis
  101580. * @param amountForward defines the distance on the forward axis
  101581. * @returns the current mesh
  101582. */
  101583. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101584. /**
  101585. * Calculate relative position change from the point of view of behind the front of the mesh.
  101586. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101587. * Supports definition of mesh facing forward or backward
  101588. * @param amountRight defines the distance on the right axis
  101589. * @param amountUp defines the distance on the up axis
  101590. * @param amountForward defines the distance on the forward axis
  101591. * @returns the new displacement vector
  101592. */
  101593. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101594. /**
  101595. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101596. * Supports definition of mesh facing forward or backward
  101597. * @param flipBack defines the flip
  101598. * @param twirlClockwise defines the twirl
  101599. * @param tiltRight defines the tilt
  101600. * @returns the current mesh
  101601. */
  101602. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101603. /**
  101604. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101605. * Supports definition of mesh facing forward or backward.
  101606. * @param flipBack defines the flip
  101607. * @param twirlClockwise defines the twirl
  101608. * @param tiltRight defines the tilt
  101609. * @returns the new rotation vector
  101610. */
  101611. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101612. /**
  101613. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101614. * This means the mesh underlying bounding box and sphere are recomputed.
  101615. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101616. * @returns the current mesh
  101617. */
  101618. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101619. /** @hidden */
  101620. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101621. /** @hidden */
  101622. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101623. /** @hidden */
  101624. _updateBoundingInfo(): AbstractMesh;
  101625. /** @hidden */
  101626. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101627. /** @hidden */
  101628. protected _afterComputeWorldMatrix(): void;
  101629. /** @hidden */
  101630. get _effectiveMesh(): AbstractMesh;
  101631. /**
  101632. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101633. * A mesh is in the frustum if its bounding box intersects the frustum
  101634. * @param frustumPlanes defines the frustum to test
  101635. * @returns true if the mesh is in the frustum planes
  101636. */
  101637. isInFrustum(frustumPlanes: Plane[]): boolean;
  101638. /**
  101639. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101640. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101641. * @param frustumPlanes defines the frustum to test
  101642. * @returns true if the mesh is completely in the frustum planes
  101643. */
  101644. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101645. /**
  101646. * True if the mesh intersects another mesh or a SolidParticle object
  101647. * @param mesh defines a target mesh or SolidParticle to test
  101648. * @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)
  101649. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101650. * @returns true if there is an intersection
  101651. */
  101652. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101653. /**
  101654. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101655. * @param point defines the point to test
  101656. * @returns true if there is an intersection
  101657. */
  101658. intersectsPoint(point: Vector3): boolean;
  101659. /**
  101660. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101662. */
  101663. get checkCollisions(): boolean;
  101664. set checkCollisions(collisionEnabled: boolean);
  101665. /**
  101666. * Gets Collider object used to compute collisions (not physics)
  101667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101668. */
  101669. get collider(): Nullable<Collider>;
  101670. /**
  101671. * Move the mesh using collision engine
  101672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101673. * @param displacement defines the requested displacement vector
  101674. * @returns the current mesh
  101675. */
  101676. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101677. private _onCollisionPositionChange;
  101678. /** @hidden */
  101679. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101680. /** @hidden */
  101681. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101682. /** @hidden */
  101683. _checkCollision(collider: Collider): AbstractMesh;
  101684. /** @hidden */
  101685. _generatePointsArray(): boolean;
  101686. /**
  101687. * Checks if the passed Ray intersects with the mesh
  101688. * @param ray defines the ray to use
  101689. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101690. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101691. * @returns the picking info
  101692. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101693. */
  101694. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101695. /**
  101696. * Clones the current mesh
  101697. * @param name defines the mesh name
  101698. * @param newParent defines the new mesh parent
  101699. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101700. * @returns the new mesh
  101701. */
  101702. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101703. /**
  101704. * Disposes all the submeshes of the current meshnp
  101705. * @returns the current mesh
  101706. */
  101707. releaseSubMeshes(): AbstractMesh;
  101708. /**
  101709. * Releases resources associated with this abstract mesh.
  101710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101712. */
  101713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101714. /**
  101715. * Adds the passed mesh as a child to the current mesh
  101716. * @param mesh defines the child mesh
  101717. * @returns the current mesh
  101718. */
  101719. addChild(mesh: AbstractMesh): AbstractMesh;
  101720. /**
  101721. * Removes the passed mesh from the current mesh children list
  101722. * @param mesh defines the child mesh
  101723. * @returns the current mesh
  101724. */
  101725. removeChild(mesh: AbstractMesh): AbstractMesh;
  101726. /** @hidden */
  101727. private _initFacetData;
  101728. /**
  101729. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101730. * This method can be called within the render loop.
  101731. * 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
  101732. * @returns the current mesh
  101733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101734. */
  101735. updateFacetData(): AbstractMesh;
  101736. /**
  101737. * Returns the facetLocalNormals array.
  101738. * The normals are expressed in the mesh local spac
  101739. * @returns an array of Vector3
  101740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101741. */
  101742. getFacetLocalNormals(): Vector3[];
  101743. /**
  101744. * Returns the facetLocalPositions array.
  101745. * The facet positions are expressed in the mesh local space
  101746. * @returns an array of Vector3
  101747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101748. */
  101749. getFacetLocalPositions(): Vector3[];
  101750. /**
  101751. * Returns the facetLocalPartioning array
  101752. * @returns an array of array of numbers
  101753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101754. */
  101755. getFacetLocalPartitioning(): number[][];
  101756. /**
  101757. * Returns the i-th facet position in the world system.
  101758. * This method allocates a new Vector3 per call
  101759. * @param i defines the facet index
  101760. * @returns a new Vector3
  101761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101762. */
  101763. getFacetPosition(i: number): Vector3;
  101764. /**
  101765. * Sets the reference Vector3 with the i-th facet position in the world system
  101766. * @param i defines the facet index
  101767. * @param ref defines the target vector
  101768. * @returns the current mesh
  101769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101770. */
  101771. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101772. /**
  101773. * Returns the i-th facet normal in the world system.
  101774. * This method allocates a new Vector3 per call
  101775. * @param i defines the facet index
  101776. * @returns a new Vector3
  101777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101778. */
  101779. getFacetNormal(i: number): Vector3;
  101780. /**
  101781. * Sets the reference Vector3 with the i-th facet normal in the world system
  101782. * @param i defines the facet index
  101783. * @param ref defines the target vector
  101784. * @returns the current mesh
  101785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101786. */
  101787. getFacetNormalToRef(i: number, ref: Vector3): this;
  101788. /**
  101789. * 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)
  101790. * @param x defines x coordinate
  101791. * @param y defines y coordinate
  101792. * @param z defines z coordinate
  101793. * @returns the array of facet indexes
  101794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101795. */
  101796. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101797. /**
  101798. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101799. * @param projected sets as the (x,y,z) world projection on the facet
  101800. * @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
  101801. * @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
  101802. * @param x defines x coordinate
  101803. * @param y defines y coordinate
  101804. * @param z defines z coordinate
  101805. * @returns the face index if found (or null instead)
  101806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101807. */
  101808. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101809. /**
  101810. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101811. * @param projected sets as the (x,y,z) local projection on the facet
  101812. * @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
  101813. * @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
  101814. * @param x defines x coordinate
  101815. * @param y defines y coordinate
  101816. * @param z defines z coordinate
  101817. * @returns the face index if found (or null instead)
  101818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101819. */
  101820. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101821. /**
  101822. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101823. * @returns the parameters
  101824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101825. */
  101826. getFacetDataParameters(): any;
  101827. /**
  101828. * Disables the feature FacetData and frees the related memory
  101829. * @returns the current mesh
  101830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101831. */
  101832. disableFacetData(): AbstractMesh;
  101833. /**
  101834. * Updates the AbstractMesh indices array
  101835. * @param indices defines the data source
  101836. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101837. * @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)
  101838. * @returns the current mesh
  101839. */
  101840. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101841. /**
  101842. * Creates new normals data for the mesh
  101843. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101844. * @returns the current mesh
  101845. */
  101846. createNormals(updatable: boolean): AbstractMesh;
  101847. /**
  101848. * Align the mesh with a normal
  101849. * @param normal defines the normal to use
  101850. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101851. * @returns the current mesh
  101852. */
  101853. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101854. /** @hidden */
  101855. _checkOcclusionQuery(): boolean;
  101856. /**
  101857. * Disables the mesh edge rendering mode
  101858. * @returns the currentAbstractMesh
  101859. */
  101860. disableEdgesRendering(): AbstractMesh;
  101861. /**
  101862. * Enables the edge rendering mode on the mesh.
  101863. * This mode makes the mesh edges visible
  101864. * @param epsilon defines the maximal distance between two angles to detect a face
  101865. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101866. * @returns the currentAbstractMesh
  101867. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101868. */
  101869. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101870. }
  101871. }
  101872. declare module BABYLON {
  101873. /**
  101874. * Interface used to define ActionEvent
  101875. */
  101876. export interface IActionEvent {
  101877. /** The mesh or sprite that triggered the action */
  101878. source: any;
  101879. /** The X mouse cursor position at the time of the event */
  101880. pointerX: number;
  101881. /** The Y mouse cursor position at the time of the event */
  101882. pointerY: number;
  101883. /** The mesh that is currently pointed at (can be null) */
  101884. meshUnderPointer: Nullable<AbstractMesh>;
  101885. /** the original (browser) event that triggered the ActionEvent */
  101886. sourceEvent?: any;
  101887. /** additional data for the event */
  101888. additionalData?: any;
  101889. }
  101890. /**
  101891. * ActionEvent is the event being sent when an action is triggered.
  101892. */
  101893. export class ActionEvent implements IActionEvent {
  101894. /** The mesh or sprite that triggered the action */
  101895. source: any;
  101896. /** The X mouse cursor position at the time of the event */
  101897. pointerX: number;
  101898. /** The Y mouse cursor position at the time of the event */
  101899. pointerY: number;
  101900. /** The mesh that is currently pointed at (can be null) */
  101901. meshUnderPointer: Nullable<AbstractMesh>;
  101902. /** the original (browser) event that triggered the ActionEvent */
  101903. sourceEvent?: any;
  101904. /** additional data for the event */
  101905. additionalData?: any;
  101906. /**
  101907. * Creates a new ActionEvent
  101908. * @param source The mesh or sprite that triggered the action
  101909. * @param pointerX The X mouse cursor position at the time of the event
  101910. * @param pointerY The Y mouse cursor position at the time of the event
  101911. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101912. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101913. * @param additionalData additional data for the event
  101914. */
  101915. constructor(
  101916. /** The mesh or sprite that triggered the action */
  101917. source: any,
  101918. /** The X mouse cursor position at the time of the event */
  101919. pointerX: number,
  101920. /** The Y mouse cursor position at the time of the event */
  101921. pointerY: number,
  101922. /** The mesh that is currently pointed at (can be null) */
  101923. meshUnderPointer: Nullable<AbstractMesh>,
  101924. /** the original (browser) event that triggered the ActionEvent */
  101925. sourceEvent?: any,
  101926. /** additional data for the event */
  101927. additionalData?: any);
  101928. /**
  101929. * Helper function to auto-create an ActionEvent from a source mesh.
  101930. * @param source The source mesh that triggered the event
  101931. * @param evt The original (browser) event
  101932. * @param additionalData additional data for the event
  101933. * @returns the new ActionEvent
  101934. */
  101935. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101936. /**
  101937. * Helper function to auto-create an ActionEvent from a source sprite
  101938. * @param source The source sprite that triggered the event
  101939. * @param scene Scene associated with the sprite
  101940. * @param evt The original (browser) event
  101941. * @param additionalData additional data for the event
  101942. * @returns the new ActionEvent
  101943. */
  101944. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101945. /**
  101946. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101947. * @param scene the scene where the event occurred
  101948. * @param evt The original (browser) event
  101949. * @returns the new ActionEvent
  101950. */
  101951. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101952. /**
  101953. * Helper function to auto-create an ActionEvent from a primitive
  101954. * @param prim defines the target primitive
  101955. * @param pointerPos defines the pointer position
  101956. * @param evt The original (browser) event
  101957. * @param additionalData additional data for the event
  101958. * @returns the new ActionEvent
  101959. */
  101960. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101961. }
  101962. }
  101963. declare module BABYLON {
  101964. /**
  101965. * Abstract class used to decouple action Manager from scene and meshes.
  101966. * Do not instantiate.
  101967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101968. */
  101969. export abstract class AbstractActionManager implements IDisposable {
  101970. /** Gets the list of active triggers */
  101971. static Triggers: {
  101972. [key: string]: number;
  101973. };
  101974. /** Gets the cursor to use when hovering items */
  101975. hoverCursor: string;
  101976. /** Gets the list of actions */
  101977. actions: IAction[];
  101978. /**
  101979. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101980. */
  101981. isRecursive: boolean;
  101982. /**
  101983. * Releases all associated resources
  101984. */
  101985. abstract dispose(): void;
  101986. /**
  101987. * Does this action manager has pointer triggers
  101988. */
  101989. abstract get hasPointerTriggers(): boolean;
  101990. /**
  101991. * Does this action manager has pick triggers
  101992. */
  101993. abstract get hasPickTriggers(): boolean;
  101994. /**
  101995. * Process a specific trigger
  101996. * @param trigger defines the trigger to process
  101997. * @param evt defines the event details to be processed
  101998. */
  101999. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102000. /**
  102001. * Does this action manager handles actions of any of the given triggers
  102002. * @param triggers defines the triggers to be tested
  102003. * @return a boolean indicating whether one (or more) of the triggers is handled
  102004. */
  102005. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102006. /**
  102007. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102008. * speed.
  102009. * @param triggerA defines the trigger to be tested
  102010. * @param triggerB defines the trigger to be tested
  102011. * @return a boolean indicating whether one (or more) of the triggers is handled
  102012. */
  102013. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102014. /**
  102015. * Does this action manager handles actions of a given trigger
  102016. * @param trigger defines the trigger to be tested
  102017. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102018. * @return whether the trigger is handled
  102019. */
  102020. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102021. /**
  102022. * Serialize this manager to a JSON object
  102023. * @param name defines the property name to store this manager
  102024. * @returns a JSON representation of this manager
  102025. */
  102026. abstract serialize(name: string): any;
  102027. /**
  102028. * Registers an action to this action manager
  102029. * @param action defines the action to be registered
  102030. * @return the action amended (prepared) after registration
  102031. */
  102032. abstract registerAction(action: IAction): Nullable<IAction>;
  102033. /**
  102034. * Unregisters an action to this action manager
  102035. * @param action defines the action to be unregistered
  102036. * @return a boolean indicating whether the action has been unregistered
  102037. */
  102038. abstract unregisterAction(action: IAction): Boolean;
  102039. /**
  102040. * Does exist one action manager with at least one trigger
  102041. **/
  102042. static get HasTriggers(): boolean;
  102043. /**
  102044. * Does exist one action manager with at least one pick trigger
  102045. **/
  102046. static get HasPickTriggers(): boolean;
  102047. /**
  102048. * Does exist one action manager that handles actions of a given trigger
  102049. * @param trigger defines the trigger to be tested
  102050. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102051. **/
  102052. static HasSpecificTrigger(trigger: number): boolean;
  102053. }
  102054. }
  102055. declare module BABYLON {
  102056. /**
  102057. * Defines how a node can be built from a string name.
  102058. */
  102059. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102060. /**
  102061. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102062. */
  102063. export class Node implements IBehaviorAware<Node> {
  102064. /** @hidden */
  102065. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102066. private static _NodeConstructors;
  102067. /**
  102068. * Add a new node constructor
  102069. * @param type defines the type name of the node to construct
  102070. * @param constructorFunc defines the constructor function
  102071. */
  102072. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102073. /**
  102074. * Returns a node constructor based on type name
  102075. * @param type defines the type name
  102076. * @param name defines the new node name
  102077. * @param scene defines the hosting scene
  102078. * @param options defines optional options to transmit to constructors
  102079. * @returns the new constructor or null
  102080. */
  102081. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102082. /**
  102083. * Gets or sets the name of the node
  102084. */
  102085. name: string;
  102086. /**
  102087. * Gets or sets the id of the node
  102088. */
  102089. id: string;
  102090. /**
  102091. * Gets or sets the unique id of the node
  102092. */
  102093. uniqueId: number;
  102094. /**
  102095. * Gets or sets a string used to store user defined state for the node
  102096. */
  102097. state: string;
  102098. /**
  102099. * Gets or sets an object used to store user defined information for the node
  102100. */
  102101. metadata: any;
  102102. /**
  102103. * For internal use only. Please do not use.
  102104. */
  102105. reservedDataStore: any;
  102106. /**
  102107. * List of inspectable custom properties (used by the Inspector)
  102108. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102109. */
  102110. inspectableCustomProperties: IInspectable[];
  102111. private _doNotSerialize;
  102112. /**
  102113. * Gets or sets a boolean used to define if the node must be serialized
  102114. */
  102115. get doNotSerialize(): boolean;
  102116. set doNotSerialize(value: boolean);
  102117. /** @hidden */
  102118. _isDisposed: boolean;
  102119. /**
  102120. * Gets a list of Animations associated with the node
  102121. */
  102122. animations: Animation[];
  102123. protected _ranges: {
  102124. [name: string]: Nullable<AnimationRange>;
  102125. };
  102126. /**
  102127. * Callback raised when the node is ready to be used
  102128. */
  102129. onReady: Nullable<(node: Node) => void>;
  102130. private _isEnabled;
  102131. private _isParentEnabled;
  102132. private _isReady;
  102133. /** @hidden */
  102134. _currentRenderId: number;
  102135. private _parentUpdateId;
  102136. /** @hidden */
  102137. _childUpdateId: number;
  102138. /** @hidden */
  102139. _waitingParentId: Nullable<string>;
  102140. /** @hidden */
  102141. _scene: Scene;
  102142. /** @hidden */
  102143. _cache: any;
  102144. private _parentNode;
  102145. private _children;
  102146. /** @hidden */
  102147. _worldMatrix: Matrix;
  102148. /** @hidden */
  102149. _worldMatrixDeterminant: number;
  102150. /** @hidden */
  102151. _worldMatrixDeterminantIsDirty: boolean;
  102152. /** @hidden */
  102153. private _sceneRootNodesIndex;
  102154. /**
  102155. * Gets a boolean indicating if the node has been disposed
  102156. * @returns true if the node was disposed
  102157. */
  102158. isDisposed(): boolean;
  102159. /**
  102160. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102161. * @see https://doc.babylonjs.com/how_to/parenting
  102162. */
  102163. set parent(parent: Nullable<Node>);
  102164. get parent(): Nullable<Node>;
  102165. /** @hidden */
  102166. _addToSceneRootNodes(): void;
  102167. /** @hidden */
  102168. _removeFromSceneRootNodes(): void;
  102169. private _animationPropertiesOverride;
  102170. /**
  102171. * Gets or sets the animation properties override
  102172. */
  102173. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102174. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102175. /**
  102176. * Gets a string idenfifying the name of the class
  102177. * @returns "Node" string
  102178. */
  102179. getClassName(): string;
  102180. /** @hidden */
  102181. readonly _isNode: boolean;
  102182. /**
  102183. * An event triggered when the mesh is disposed
  102184. */
  102185. onDisposeObservable: Observable<Node>;
  102186. private _onDisposeObserver;
  102187. /**
  102188. * Sets a callback that will be raised when the node will be disposed
  102189. */
  102190. set onDispose(callback: () => void);
  102191. /**
  102192. * Creates a new Node
  102193. * @param name the name and id to be given to this node
  102194. * @param scene the scene this node will be added to
  102195. */
  102196. constructor(name: string, scene?: Nullable<Scene>);
  102197. /**
  102198. * Gets the scene of the node
  102199. * @returns a scene
  102200. */
  102201. getScene(): Scene;
  102202. /**
  102203. * Gets the engine of the node
  102204. * @returns a Engine
  102205. */
  102206. getEngine(): Engine;
  102207. private _behaviors;
  102208. /**
  102209. * Attach a behavior to the node
  102210. * @see http://doc.babylonjs.com/features/behaviour
  102211. * @param behavior defines the behavior to attach
  102212. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102213. * @returns the current Node
  102214. */
  102215. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102216. /**
  102217. * Remove an attached behavior
  102218. * @see http://doc.babylonjs.com/features/behaviour
  102219. * @param behavior defines the behavior to attach
  102220. * @returns the current Node
  102221. */
  102222. removeBehavior(behavior: Behavior<Node>): Node;
  102223. /**
  102224. * Gets the list of attached behaviors
  102225. * @see http://doc.babylonjs.com/features/behaviour
  102226. */
  102227. get behaviors(): Behavior<Node>[];
  102228. /**
  102229. * Gets an attached behavior by name
  102230. * @param name defines the name of the behavior to look for
  102231. * @see http://doc.babylonjs.com/features/behaviour
  102232. * @returns null if behavior was not found else the requested behavior
  102233. */
  102234. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102235. /**
  102236. * Returns the latest update of the World matrix
  102237. * @returns a Matrix
  102238. */
  102239. getWorldMatrix(): Matrix;
  102240. /** @hidden */
  102241. _getWorldMatrixDeterminant(): number;
  102242. /**
  102243. * Returns directly the latest state of the mesh World matrix.
  102244. * A Matrix is returned.
  102245. */
  102246. get worldMatrixFromCache(): Matrix;
  102247. /** @hidden */
  102248. _initCache(): void;
  102249. /** @hidden */
  102250. updateCache(force?: boolean): void;
  102251. /** @hidden */
  102252. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102253. /** @hidden */
  102254. _updateCache(ignoreParentClass?: boolean): void;
  102255. /** @hidden */
  102256. _isSynchronized(): boolean;
  102257. /** @hidden */
  102258. _markSyncedWithParent(): void;
  102259. /** @hidden */
  102260. isSynchronizedWithParent(): boolean;
  102261. /** @hidden */
  102262. isSynchronized(): boolean;
  102263. /**
  102264. * Is this node ready to be used/rendered
  102265. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102266. * @return true if the node is ready
  102267. */
  102268. isReady(completeCheck?: boolean): boolean;
  102269. /**
  102270. * Is this node enabled?
  102271. * 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
  102272. * @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
  102273. * @return whether this node (and its parent) is enabled
  102274. */
  102275. isEnabled(checkAncestors?: boolean): boolean;
  102276. /** @hidden */
  102277. protected _syncParentEnabledState(): void;
  102278. /**
  102279. * Set the enabled state of this node
  102280. * @param value defines the new enabled state
  102281. */
  102282. setEnabled(value: boolean): void;
  102283. /**
  102284. * Is this node a descendant of the given node?
  102285. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102286. * @param ancestor defines the parent node to inspect
  102287. * @returns a boolean indicating if this node is a descendant of the given node
  102288. */
  102289. isDescendantOf(ancestor: Node): boolean;
  102290. /** @hidden */
  102291. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102292. /**
  102293. * Will return all nodes that have this node as ascendant
  102294. * @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
  102295. * @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
  102296. * @return all children nodes of all types
  102297. */
  102298. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102299. /**
  102300. * Get all child-meshes of this node
  102301. * @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)
  102302. * @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
  102303. * @returns an array of AbstractMesh
  102304. */
  102305. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102306. /**
  102307. * Get all direct children of this node
  102308. * @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
  102309. * @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)
  102310. * @returns an array of Node
  102311. */
  102312. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102313. /** @hidden */
  102314. _setReady(state: boolean): void;
  102315. /**
  102316. * Get an animation by name
  102317. * @param name defines the name of the animation to look for
  102318. * @returns null if not found else the requested animation
  102319. */
  102320. getAnimationByName(name: string): Nullable<Animation>;
  102321. /**
  102322. * Creates an animation range for this node
  102323. * @param name defines the name of the range
  102324. * @param from defines the starting key
  102325. * @param to defines the end key
  102326. */
  102327. createAnimationRange(name: string, from: number, to: number): void;
  102328. /**
  102329. * Delete a specific animation range
  102330. * @param name defines the name of the range to delete
  102331. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102332. */
  102333. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102334. /**
  102335. * Get an animation range by name
  102336. * @param name defines the name of the animation range to look for
  102337. * @returns null if not found else the requested animation range
  102338. */
  102339. getAnimationRange(name: string): Nullable<AnimationRange>;
  102340. /**
  102341. * Gets the list of all animation ranges defined on this node
  102342. * @returns an array
  102343. */
  102344. getAnimationRanges(): Nullable<AnimationRange>[];
  102345. /**
  102346. * Will start the animation sequence
  102347. * @param name defines the range frames for animation sequence
  102348. * @param loop defines if the animation should loop (false by default)
  102349. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102350. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102351. * @returns the object created for this animation. If range does not exist, it will return null
  102352. */
  102353. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102354. /**
  102355. * Serialize animation ranges into a JSON compatible object
  102356. * @returns serialization object
  102357. */
  102358. serializeAnimationRanges(): any;
  102359. /**
  102360. * Computes the world matrix of the node
  102361. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102362. * @returns the world matrix
  102363. */
  102364. computeWorldMatrix(force?: boolean): Matrix;
  102365. /**
  102366. * Releases resources associated with this node.
  102367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102369. */
  102370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102371. /**
  102372. * Parse animation range data from a serialization object and store them into a given node
  102373. * @param node defines where to store the animation ranges
  102374. * @param parsedNode defines the serialization object to read data from
  102375. * @param scene defines the hosting scene
  102376. */
  102377. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102378. /**
  102379. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102380. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102381. * @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
  102382. * @returns the new bounding vectors
  102383. */
  102384. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102385. min: Vector3;
  102386. max: Vector3;
  102387. };
  102388. }
  102389. }
  102390. declare module BABYLON {
  102391. /**
  102392. * @hidden
  102393. */
  102394. export class _IAnimationState {
  102395. key: number;
  102396. repeatCount: number;
  102397. workValue?: any;
  102398. loopMode?: number;
  102399. offsetValue?: any;
  102400. highLimitValue?: any;
  102401. }
  102402. /**
  102403. * Class used to store any kind of animation
  102404. */
  102405. export class Animation {
  102406. /**Name of the animation */
  102407. name: string;
  102408. /**Property to animate */
  102409. targetProperty: string;
  102410. /**The frames per second of the animation */
  102411. framePerSecond: number;
  102412. /**The data type of the animation */
  102413. dataType: number;
  102414. /**The loop mode of the animation */
  102415. loopMode?: number | undefined;
  102416. /**Specifies if blending should be enabled */
  102417. enableBlending?: boolean | undefined;
  102418. /**
  102419. * Use matrix interpolation instead of using direct key value when animating matrices
  102420. */
  102421. static AllowMatricesInterpolation: boolean;
  102422. /**
  102423. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102424. */
  102425. static AllowMatrixDecomposeForInterpolation: boolean;
  102426. /**
  102427. * Stores the key frames of the animation
  102428. */
  102429. private _keys;
  102430. /**
  102431. * Stores the easing function of the animation
  102432. */
  102433. private _easingFunction;
  102434. /**
  102435. * @hidden Internal use only
  102436. */
  102437. _runtimeAnimations: RuntimeAnimation[];
  102438. /**
  102439. * The set of event that will be linked to this animation
  102440. */
  102441. private _events;
  102442. /**
  102443. * Stores an array of target property paths
  102444. */
  102445. targetPropertyPath: string[];
  102446. /**
  102447. * Stores the blending speed of the animation
  102448. */
  102449. blendingSpeed: number;
  102450. /**
  102451. * Stores the animation ranges for the animation
  102452. */
  102453. private _ranges;
  102454. /**
  102455. * @hidden Internal use
  102456. */
  102457. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102458. /**
  102459. * Sets up an animation
  102460. * @param property The property to animate
  102461. * @param animationType The animation type to apply
  102462. * @param framePerSecond The frames per second of the animation
  102463. * @param easingFunction The easing function used in the animation
  102464. * @returns The created animation
  102465. */
  102466. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102467. /**
  102468. * Create and start an animation on a node
  102469. * @param name defines the name of the global animation that will be run on all nodes
  102470. * @param node defines the root node where the animation will take place
  102471. * @param targetProperty defines property to animate
  102472. * @param framePerSecond defines the number of frame per second yo use
  102473. * @param totalFrame defines the number of frames in total
  102474. * @param from defines the initial value
  102475. * @param to defines the final value
  102476. * @param loopMode defines which loop mode you want to use (off by default)
  102477. * @param easingFunction defines the easing function to use (linear by default)
  102478. * @param onAnimationEnd defines the callback to call when animation end
  102479. * @returns the animatable created for this animation
  102480. */
  102481. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102482. /**
  102483. * Create and start an animation on a node and its descendants
  102484. * @param name defines the name of the global animation that will be run on all nodes
  102485. * @param node defines the root node where the animation will take place
  102486. * @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
  102487. * @param targetProperty defines property to animate
  102488. * @param framePerSecond defines the number of frame per second to use
  102489. * @param totalFrame defines the number of frames in total
  102490. * @param from defines the initial value
  102491. * @param to defines the final value
  102492. * @param loopMode defines which loop mode you want to use (off by default)
  102493. * @param easingFunction defines the easing function to use (linear by default)
  102494. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102495. * @returns the list of animatables created for all nodes
  102496. * @example https://www.babylonjs-playground.com/#MH0VLI
  102497. */
  102498. 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[]>;
  102499. /**
  102500. * Creates a new animation, merges it with the existing animations and starts it
  102501. * @param name Name of the animation
  102502. * @param node Node which contains the scene that begins the animations
  102503. * @param targetProperty Specifies which property to animate
  102504. * @param framePerSecond The frames per second of the animation
  102505. * @param totalFrame The total number of frames
  102506. * @param from The frame at the beginning of the animation
  102507. * @param to The frame at the end of the animation
  102508. * @param loopMode Specifies the loop mode of the animation
  102509. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102510. * @param onAnimationEnd Callback to run once the animation is complete
  102511. * @returns Nullable animation
  102512. */
  102513. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102514. /**
  102515. * Transition property of an host to the target Value
  102516. * @param property The property to transition
  102517. * @param targetValue The target Value of the property
  102518. * @param host The object where the property to animate belongs
  102519. * @param scene Scene used to run the animation
  102520. * @param frameRate Framerate (in frame/s) to use
  102521. * @param transition The transition type we want to use
  102522. * @param duration The duration of the animation, in milliseconds
  102523. * @param onAnimationEnd Callback trigger at the end of the animation
  102524. * @returns Nullable animation
  102525. */
  102526. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102527. /**
  102528. * Return the array of runtime animations currently using this animation
  102529. */
  102530. get runtimeAnimations(): RuntimeAnimation[];
  102531. /**
  102532. * Specifies if any of the runtime animations are currently running
  102533. */
  102534. get hasRunningRuntimeAnimations(): boolean;
  102535. /**
  102536. * Initializes the animation
  102537. * @param name Name of the animation
  102538. * @param targetProperty Property to animate
  102539. * @param framePerSecond The frames per second of the animation
  102540. * @param dataType The data type of the animation
  102541. * @param loopMode The loop mode of the animation
  102542. * @param enableBlending Specifies if blending should be enabled
  102543. */
  102544. constructor(
  102545. /**Name of the animation */
  102546. name: string,
  102547. /**Property to animate */
  102548. targetProperty: string,
  102549. /**The frames per second of the animation */
  102550. framePerSecond: number,
  102551. /**The data type of the animation */
  102552. dataType: number,
  102553. /**The loop mode of the animation */
  102554. loopMode?: number | undefined,
  102555. /**Specifies if blending should be enabled */
  102556. enableBlending?: boolean | undefined);
  102557. /**
  102558. * Converts the animation to a string
  102559. * @param fullDetails support for multiple levels of logging within scene loading
  102560. * @returns String form of the animation
  102561. */
  102562. toString(fullDetails?: boolean): string;
  102563. /**
  102564. * Add an event to this animation
  102565. * @param event Event to add
  102566. */
  102567. addEvent(event: AnimationEvent): void;
  102568. /**
  102569. * Remove all events found at the given frame
  102570. * @param frame The frame to remove events from
  102571. */
  102572. removeEvents(frame: number): void;
  102573. /**
  102574. * Retrieves all the events from the animation
  102575. * @returns Events from the animation
  102576. */
  102577. getEvents(): AnimationEvent[];
  102578. /**
  102579. * Creates an animation range
  102580. * @param name Name of the animation range
  102581. * @param from Starting frame of the animation range
  102582. * @param to Ending frame of the animation
  102583. */
  102584. createRange(name: string, from: number, to: number): void;
  102585. /**
  102586. * Deletes an animation range by name
  102587. * @param name Name of the animation range to delete
  102588. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102589. */
  102590. deleteRange(name: string, deleteFrames?: boolean): void;
  102591. /**
  102592. * Gets the animation range by name, or null if not defined
  102593. * @param name Name of the animation range
  102594. * @returns Nullable animation range
  102595. */
  102596. getRange(name: string): Nullable<AnimationRange>;
  102597. /**
  102598. * Gets the key frames from the animation
  102599. * @returns The key frames of the animation
  102600. */
  102601. getKeys(): Array<IAnimationKey>;
  102602. /**
  102603. * Gets the highest frame rate of the animation
  102604. * @returns Highest frame rate of the animation
  102605. */
  102606. getHighestFrame(): number;
  102607. /**
  102608. * Gets the easing function of the animation
  102609. * @returns Easing function of the animation
  102610. */
  102611. getEasingFunction(): IEasingFunction;
  102612. /**
  102613. * Sets the easing function of the animation
  102614. * @param easingFunction A custom mathematical formula for animation
  102615. */
  102616. setEasingFunction(easingFunction: EasingFunction): void;
  102617. /**
  102618. * Interpolates a scalar linearly
  102619. * @param startValue Start value of the animation curve
  102620. * @param endValue End value of the animation curve
  102621. * @param gradient Scalar amount to interpolate
  102622. * @returns Interpolated scalar value
  102623. */
  102624. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102625. /**
  102626. * Interpolates a scalar cubically
  102627. * @param startValue Start value of the animation curve
  102628. * @param outTangent End tangent of the animation
  102629. * @param endValue End value of the animation curve
  102630. * @param inTangent Start tangent of the animation curve
  102631. * @param gradient Scalar amount to interpolate
  102632. * @returns Interpolated scalar value
  102633. */
  102634. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102635. /**
  102636. * Interpolates a quaternion using a spherical linear interpolation
  102637. * @param startValue Start value of the animation curve
  102638. * @param endValue End value of the animation curve
  102639. * @param gradient Scalar amount to interpolate
  102640. * @returns Interpolated quaternion value
  102641. */
  102642. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102643. /**
  102644. * Interpolates a quaternion cubically
  102645. * @param startValue Start value of the animation curve
  102646. * @param outTangent End tangent of the animation curve
  102647. * @param endValue End value of the animation curve
  102648. * @param inTangent Start tangent of the animation curve
  102649. * @param gradient Scalar amount to interpolate
  102650. * @returns Interpolated quaternion value
  102651. */
  102652. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102653. /**
  102654. * Interpolates a Vector3 linearl
  102655. * @param startValue Start value of the animation curve
  102656. * @param endValue End value of the animation curve
  102657. * @param gradient Scalar amount to interpolate
  102658. * @returns Interpolated scalar value
  102659. */
  102660. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102661. /**
  102662. * Interpolates a Vector3 cubically
  102663. * @param startValue Start value of the animation curve
  102664. * @param outTangent End tangent of the animation
  102665. * @param endValue End value of the animation curve
  102666. * @param inTangent Start tangent of the animation curve
  102667. * @param gradient Scalar amount to interpolate
  102668. * @returns InterpolatedVector3 value
  102669. */
  102670. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102671. /**
  102672. * Interpolates a Vector2 linearly
  102673. * @param startValue Start value of the animation curve
  102674. * @param endValue End value of the animation curve
  102675. * @param gradient Scalar amount to interpolate
  102676. * @returns Interpolated Vector2 value
  102677. */
  102678. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102679. /**
  102680. * Interpolates a Vector2 cubically
  102681. * @param startValue Start value of the animation curve
  102682. * @param outTangent End tangent of the animation
  102683. * @param endValue End value of the animation curve
  102684. * @param inTangent Start tangent of the animation curve
  102685. * @param gradient Scalar amount to interpolate
  102686. * @returns Interpolated Vector2 value
  102687. */
  102688. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102689. /**
  102690. * Interpolates a size linearly
  102691. * @param startValue Start value of the animation curve
  102692. * @param endValue End value of the animation curve
  102693. * @param gradient Scalar amount to interpolate
  102694. * @returns Interpolated Size value
  102695. */
  102696. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102697. /**
  102698. * Interpolates a Color3 linearly
  102699. * @param startValue Start value of the animation curve
  102700. * @param endValue End value of the animation curve
  102701. * @param gradient Scalar amount to interpolate
  102702. * @returns Interpolated Color3 value
  102703. */
  102704. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102705. /**
  102706. * Interpolates a Color4 linearly
  102707. * @param startValue Start value of the animation curve
  102708. * @param endValue End value of the animation curve
  102709. * @param gradient Scalar amount to interpolate
  102710. * @returns Interpolated Color3 value
  102711. */
  102712. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102713. /**
  102714. * @hidden Internal use only
  102715. */
  102716. _getKeyValue(value: any): any;
  102717. /**
  102718. * @hidden Internal use only
  102719. */
  102720. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102721. /**
  102722. * Defines the function to use to interpolate matrices
  102723. * @param startValue defines the start matrix
  102724. * @param endValue defines the end matrix
  102725. * @param gradient defines the gradient between both matrices
  102726. * @param result defines an optional target matrix where to store the interpolation
  102727. * @returns the interpolated matrix
  102728. */
  102729. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102730. /**
  102731. * Makes a copy of the animation
  102732. * @returns Cloned animation
  102733. */
  102734. clone(): Animation;
  102735. /**
  102736. * Sets the key frames of the animation
  102737. * @param values The animation key frames to set
  102738. */
  102739. setKeys(values: Array<IAnimationKey>): void;
  102740. /**
  102741. * Serializes the animation to an object
  102742. * @returns Serialized object
  102743. */
  102744. serialize(): any;
  102745. /**
  102746. * Float animation type
  102747. */
  102748. static readonly ANIMATIONTYPE_FLOAT: number;
  102749. /**
  102750. * Vector3 animation type
  102751. */
  102752. static readonly ANIMATIONTYPE_VECTOR3: number;
  102753. /**
  102754. * Quaternion animation type
  102755. */
  102756. static readonly ANIMATIONTYPE_QUATERNION: number;
  102757. /**
  102758. * Matrix animation type
  102759. */
  102760. static readonly ANIMATIONTYPE_MATRIX: number;
  102761. /**
  102762. * Color3 animation type
  102763. */
  102764. static readonly ANIMATIONTYPE_COLOR3: number;
  102765. /**
  102766. * Color3 animation type
  102767. */
  102768. static readonly ANIMATIONTYPE_COLOR4: number;
  102769. /**
  102770. * Vector2 animation type
  102771. */
  102772. static readonly ANIMATIONTYPE_VECTOR2: number;
  102773. /**
  102774. * Size animation type
  102775. */
  102776. static readonly ANIMATIONTYPE_SIZE: number;
  102777. /**
  102778. * Relative Loop Mode
  102779. */
  102780. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102781. /**
  102782. * Cycle Loop Mode
  102783. */
  102784. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102785. /**
  102786. * Constant Loop Mode
  102787. */
  102788. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102789. /** @hidden */
  102790. static _UniversalLerp(left: any, right: any, amount: number): any;
  102791. /**
  102792. * Parses an animation object and creates an animation
  102793. * @param parsedAnimation Parsed animation object
  102794. * @returns Animation object
  102795. */
  102796. static Parse(parsedAnimation: any): Animation;
  102797. /**
  102798. * Appends the serialized animations from the source animations
  102799. * @param source Source containing the animations
  102800. * @param destination Target to store the animations
  102801. */
  102802. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102803. }
  102804. }
  102805. declare module BABYLON {
  102806. /**
  102807. * Interface containing an array of animations
  102808. */
  102809. export interface IAnimatable {
  102810. /**
  102811. * Array of animations
  102812. */
  102813. animations: Nullable<Array<Animation>>;
  102814. }
  102815. }
  102816. declare module BABYLON {
  102817. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102818. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102819. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102820. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102821. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102822. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102823. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102824. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102825. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102826. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102827. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102828. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102829. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102830. /**
  102831. * Decorator used to define property that can be serialized as reference to a camera
  102832. * @param sourceName defines the name of the property to decorate
  102833. */
  102834. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102835. /**
  102836. * Class used to help serialization objects
  102837. */
  102838. export class SerializationHelper {
  102839. /** @hidden */
  102840. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102841. /** @hidden */
  102842. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102843. /** @hidden */
  102844. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102845. /** @hidden */
  102846. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102847. /**
  102848. * Appends the serialized animations from the source animations
  102849. * @param source Source containing the animations
  102850. * @param destination Target to store the animations
  102851. */
  102852. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102853. /**
  102854. * Static function used to serialized a specific entity
  102855. * @param entity defines the entity to serialize
  102856. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102857. * @returns a JSON compatible object representing the serialization of the entity
  102858. */
  102859. static Serialize<T>(entity: T, serializationObject?: any): any;
  102860. /**
  102861. * Creates a new entity from a serialization data object
  102862. * @param creationFunction defines a function used to instanciated the new entity
  102863. * @param source defines the source serialization data
  102864. * @param scene defines the hosting scene
  102865. * @param rootUrl defines the root url for resources
  102866. * @returns a new entity
  102867. */
  102868. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102869. /**
  102870. * Clones an object
  102871. * @param creationFunction defines the function used to instanciate the new object
  102872. * @param source defines the source object
  102873. * @returns the cloned object
  102874. */
  102875. static Clone<T>(creationFunction: () => T, source: T): T;
  102876. /**
  102877. * Instanciates a new object based on a source one (some data will be shared between both object)
  102878. * @param creationFunction defines the function used to instanciate the new object
  102879. * @param source defines the source object
  102880. * @returns the new object
  102881. */
  102882. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102883. }
  102884. }
  102885. declare module BABYLON {
  102886. /**
  102887. * Class used to manipulate GUIDs
  102888. */
  102889. export class GUID {
  102890. /**
  102891. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102892. * Be aware Math.random() could cause collisions, but:
  102893. * "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"
  102894. * @returns a pseudo random id
  102895. */
  102896. static RandomId(): string;
  102897. }
  102898. }
  102899. declare module BABYLON {
  102900. /**
  102901. * Base class of all the textures in babylon.
  102902. * It groups all the common properties the materials, post process, lights... might need
  102903. * in order to make a correct use of the texture.
  102904. */
  102905. export class BaseTexture implements IAnimatable {
  102906. /**
  102907. * Default anisotropic filtering level for the application.
  102908. * It is set to 4 as a good tradeoff between perf and quality.
  102909. */
  102910. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102911. /**
  102912. * Gets or sets the unique id of the texture
  102913. */
  102914. uniqueId: number;
  102915. /**
  102916. * Define the name of the texture.
  102917. */
  102918. name: string;
  102919. /**
  102920. * Gets or sets an object used to store user defined information.
  102921. */
  102922. metadata: any;
  102923. /**
  102924. * For internal use only. Please do not use.
  102925. */
  102926. reservedDataStore: any;
  102927. private _hasAlpha;
  102928. /**
  102929. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102930. */
  102931. set hasAlpha(value: boolean);
  102932. get hasAlpha(): boolean;
  102933. /**
  102934. * Defines if the alpha value should be determined via the rgb values.
  102935. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102936. */
  102937. getAlphaFromRGB: boolean;
  102938. /**
  102939. * Intensity or strength of the texture.
  102940. * It is commonly used by materials to fine tune the intensity of the texture
  102941. */
  102942. level: number;
  102943. /**
  102944. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102945. * This is part of the texture as textures usually maps to one uv set.
  102946. */
  102947. coordinatesIndex: number;
  102948. private _coordinatesMode;
  102949. /**
  102950. * How a texture is mapped.
  102951. *
  102952. * | Value | Type | Description |
  102953. * | ----- | ----------------------------------- | ----------- |
  102954. * | 0 | EXPLICIT_MODE | |
  102955. * | 1 | SPHERICAL_MODE | |
  102956. * | 2 | PLANAR_MODE | |
  102957. * | 3 | CUBIC_MODE | |
  102958. * | 4 | PROJECTION_MODE | |
  102959. * | 5 | SKYBOX_MODE | |
  102960. * | 6 | INVCUBIC_MODE | |
  102961. * | 7 | EQUIRECTANGULAR_MODE | |
  102962. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102963. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102964. */
  102965. set coordinatesMode(value: number);
  102966. get coordinatesMode(): number;
  102967. /**
  102968. * | Value | Type | Description |
  102969. * | ----- | ------------------ | ----------- |
  102970. * | 0 | CLAMP_ADDRESSMODE | |
  102971. * | 1 | WRAP_ADDRESSMODE | |
  102972. * | 2 | MIRROR_ADDRESSMODE | |
  102973. */
  102974. wrapU: number;
  102975. /**
  102976. * | Value | Type | Description |
  102977. * | ----- | ------------------ | ----------- |
  102978. * | 0 | CLAMP_ADDRESSMODE | |
  102979. * | 1 | WRAP_ADDRESSMODE | |
  102980. * | 2 | MIRROR_ADDRESSMODE | |
  102981. */
  102982. wrapV: number;
  102983. /**
  102984. * | Value | Type | Description |
  102985. * | ----- | ------------------ | ----------- |
  102986. * | 0 | CLAMP_ADDRESSMODE | |
  102987. * | 1 | WRAP_ADDRESSMODE | |
  102988. * | 2 | MIRROR_ADDRESSMODE | |
  102989. */
  102990. wrapR: number;
  102991. /**
  102992. * With compliant hardware and browser (supporting anisotropic filtering)
  102993. * this defines the level of anisotropic filtering in the texture.
  102994. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102995. */
  102996. anisotropicFilteringLevel: number;
  102997. /**
  102998. * Define if the texture is a cube texture or if false a 2d texture.
  102999. */
  103000. get isCube(): boolean;
  103001. set isCube(value: boolean);
  103002. /**
  103003. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103004. */
  103005. get is3D(): boolean;
  103006. set is3D(value: boolean);
  103007. /**
  103008. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103009. */
  103010. get is2DArray(): boolean;
  103011. set is2DArray(value: boolean);
  103012. /**
  103013. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103014. * HDR texture are usually stored in linear space.
  103015. * This only impacts the PBR and Background materials
  103016. */
  103017. gammaSpace: boolean;
  103018. /**
  103019. * Gets or sets whether or not the texture contains RGBD data.
  103020. */
  103021. get isRGBD(): boolean;
  103022. set isRGBD(value: boolean);
  103023. /**
  103024. * Is Z inverted in the texture (useful in a cube texture).
  103025. */
  103026. invertZ: boolean;
  103027. /**
  103028. * Are mip maps generated for this texture or not.
  103029. */
  103030. get noMipmap(): boolean;
  103031. /**
  103032. * @hidden
  103033. */
  103034. lodLevelInAlpha: boolean;
  103035. /**
  103036. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103037. */
  103038. get lodGenerationOffset(): number;
  103039. set lodGenerationOffset(value: number);
  103040. /**
  103041. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103042. */
  103043. get lodGenerationScale(): number;
  103044. set lodGenerationScale(value: number);
  103045. /**
  103046. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103047. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103048. * average roughness values.
  103049. */
  103050. get linearSpecularLOD(): boolean;
  103051. set linearSpecularLOD(value: boolean);
  103052. /**
  103053. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103054. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103055. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103056. */
  103057. get irradianceTexture(): Nullable<BaseTexture>;
  103058. set irradianceTexture(value: Nullable<BaseTexture>);
  103059. /**
  103060. * Define if the texture is a render target.
  103061. */
  103062. isRenderTarget: boolean;
  103063. /**
  103064. * Define the unique id of the texture in the scene.
  103065. */
  103066. get uid(): string;
  103067. /**
  103068. * Return a string representation of the texture.
  103069. * @returns the texture as a string
  103070. */
  103071. toString(): string;
  103072. /**
  103073. * Get the class name of the texture.
  103074. * @returns "BaseTexture"
  103075. */
  103076. getClassName(): string;
  103077. /**
  103078. * Define the list of animation attached to the texture.
  103079. */
  103080. animations: Animation[];
  103081. /**
  103082. * An event triggered when the texture is disposed.
  103083. */
  103084. onDisposeObservable: Observable<BaseTexture>;
  103085. private _onDisposeObserver;
  103086. /**
  103087. * Callback triggered when the texture has been disposed.
  103088. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103089. */
  103090. set onDispose(callback: () => void);
  103091. /**
  103092. * Define the current state of the loading sequence when in delayed load mode.
  103093. */
  103094. delayLoadState: number;
  103095. private _scene;
  103096. /** @hidden */
  103097. _texture: Nullable<InternalTexture>;
  103098. private _uid;
  103099. /**
  103100. * Define if the texture is preventinga material to render or not.
  103101. * If not and the texture is not ready, the engine will use a default black texture instead.
  103102. */
  103103. get isBlocking(): boolean;
  103104. /**
  103105. * Instantiates a new BaseTexture.
  103106. * Base class of all the textures in babylon.
  103107. * It groups all the common properties the materials, post process, lights... might need
  103108. * in order to make a correct use of the texture.
  103109. * @param scene Define the scene the texture blongs to
  103110. */
  103111. constructor(scene: Nullable<Scene>);
  103112. /**
  103113. * Get the scene the texture belongs to.
  103114. * @returns the scene or null if undefined
  103115. */
  103116. getScene(): Nullable<Scene>;
  103117. /**
  103118. * Get the texture transform matrix used to offset tile the texture for istance.
  103119. * @returns the transformation matrix
  103120. */
  103121. getTextureMatrix(): Matrix;
  103122. /**
  103123. * Get the texture reflection matrix used to rotate/transform the reflection.
  103124. * @returns the reflection matrix
  103125. */
  103126. getReflectionTextureMatrix(): Matrix;
  103127. /**
  103128. * Get the underlying lower level texture from Babylon.
  103129. * @returns the insternal texture
  103130. */
  103131. getInternalTexture(): Nullable<InternalTexture>;
  103132. /**
  103133. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103134. * @returns true if ready or not blocking
  103135. */
  103136. isReadyOrNotBlocking(): boolean;
  103137. /**
  103138. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103139. * @returns true if fully ready
  103140. */
  103141. isReady(): boolean;
  103142. private _cachedSize;
  103143. /**
  103144. * Get the size of the texture.
  103145. * @returns the texture size.
  103146. */
  103147. getSize(): ISize;
  103148. /**
  103149. * Get the base size of the texture.
  103150. * It can be different from the size if the texture has been resized for POT for instance
  103151. * @returns the base size
  103152. */
  103153. getBaseSize(): ISize;
  103154. /**
  103155. * Update the sampling mode of the texture.
  103156. * Default is Trilinear mode.
  103157. *
  103158. * | Value | Type | Description |
  103159. * | ----- | ------------------ | ----------- |
  103160. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103161. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103162. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103163. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103164. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103165. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103166. * | 7 | NEAREST_LINEAR | |
  103167. * | 8 | NEAREST_NEAREST | |
  103168. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103169. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103170. * | 11 | LINEAR_LINEAR | |
  103171. * | 12 | LINEAR_NEAREST | |
  103172. *
  103173. * > _mag_: magnification filter (close to the viewer)
  103174. * > _min_: minification filter (far from the viewer)
  103175. * > _mip_: filter used between mip map levels
  103176. *@param samplingMode Define the new sampling mode of the texture
  103177. */
  103178. updateSamplingMode(samplingMode: number): void;
  103179. /**
  103180. * Scales the texture if is `canRescale()`
  103181. * @param ratio the resize factor we want to use to rescale
  103182. */
  103183. scale(ratio: number): void;
  103184. /**
  103185. * Get if the texture can rescale.
  103186. */
  103187. get canRescale(): boolean;
  103188. /** @hidden */
  103189. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103190. /** @hidden */
  103191. _rebuild(): void;
  103192. /**
  103193. * Triggers the load sequence in delayed load mode.
  103194. */
  103195. delayLoad(): void;
  103196. /**
  103197. * Clones the texture.
  103198. * @returns the cloned texture
  103199. */
  103200. clone(): Nullable<BaseTexture>;
  103201. /**
  103202. * Get the texture underlying type (INT, FLOAT...)
  103203. */
  103204. get textureType(): number;
  103205. /**
  103206. * Get the texture underlying format (RGB, RGBA...)
  103207. */
  103208. get textureFormat(): number;
  103209. /**
  103210. * Indicates that textures need to be re-calculated for all materials
  103211. */
  103212. protected _markAllSubMeshesAsTexturesDirty(): void;
  103213. /**
  103214. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103215. * This will returns an RGBA array buffer containing either in values (0-255) or
  103216. * float values (0-1) depending of the underlying buffer type.
  103217. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103218. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103219. * @param buffer defines a user defined buffer to fill with data (can be null)
  103220. * @returns The Array buffer containing the pixels data.
  103221. */
  103222. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103223. /**
  103224. * Release and destroy the underlying lower level texture aka internalTexture.
  103225. */
  103226. releaseInternalTexture(): void;
  103227. /** @hidden */
  103228. get _lodTextureHigh(): Nullable<BaseTexture>;
  103229. /** @hidden */
  103230. get _lodTextureMid(): Nullable<BaseTexture>;
  103231. /** @hidden */
  103232. get _lodTextureLow(): Nullable<BaseTexture>;
  103233. /**
  103234. * Dispose the texture and release its associated resources.
  103235. */
  103236. dispose(): void;
  103237. /**
  103238. * Serialize the texture into a JSON representation that can be parsed later on.
  103239. * @returns the JSON representation of the texture
  103240. */
  103241. serialize(): any;
  103242. /**
  103243. * Helper function to be called back once a list of texture contains only ready textures.
  103244. * @param textures Define the list of textures to wait for
  103245. * @param callback Define the callback triggered once the entire list will be ready
  103246. */
  103247. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103248. }
  103249. }
  103250. declare module BABYLON {
  103251. /**
  103252. * Options to be used when creating an effect.
  103253. */
  103254. export interface IEffectCreationOptions {
  103255. /**
  103256. * Atrributes that will be used in the shader.
  103257. */
  103258. attributes: string[];
  103259. /**
  103260. * Uniform varible names that will be set in the shader.
  103261. */
  103262. uniformsNames: string[];
  103263. /**
  103264. * Uniform buffer variable names that will be set in the shader.
  103265. */
  103266. uniformBuffersNames: string[];
  103267. /**
  103268. * Sampler texture variable names that will be set in the shader.
  103269. */
  103270. samplers: string[];
  103271. /**
  103272. * Define statements that will be set in the shader.
  103273. */
  103274. defines: any;
  103275. /**
  103276. * Possible fallbacks for this effect to improve performance when needed.
  103277. */
  103278. fallbacks: Nullable<IEffectFallbacks>;
  103279. /**
  103280. * Callback that will be called when the shader is compiled.
  103281. */
  103282. onCompiled: Nullable<(effect: Effect) => void>;
  103283. /**
  103284. * Callback that will be called if an error occurs during shader compilation.
  103285. */
  103286. onError: Nullable<(effect: Effect, errors: string) => void>;
  103287. /**
  103288. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103289. */
  103290. indexParameters?: any;
  103291. /**
  103292. * Max number of lights that can be used in the shader.
  103293. */
  103294. maxSimultaneousLights?: number;
  103295. /**
  103296. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103297. */
  103298. transformFeedbackVaryings?: Nullable<string[]>;
  103299. }
  103300. /**
  103301. * Effect containing vertex and fragment shader that can be executed on an object.
  103302. */
  103303. export class Effect implements IDisposable {
  103304. /**
  103305. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103306. */
  103307. static ShadersRepository: string;
  103308. /**
  103309. * Name of the effect.
  103310. */
  103311. name: any;
  103312. /**
  103313. * String container all the define statements that should be set on the shader.
  103314. */
  103315. defines: string;
  103316. /**
  103317. * Callback that will be called when the shader is compiled.
  103318. */
  103319. onCompiled: Nullable<(effect: Effect) => void>;
  103320. /**
  103321. * Callback that will be called if an error occurs during shader compilation.
  103322. */
  103323. onError: Nullable<(effect: Effect, errors: string) => void>;
  103324. /**
  103325. * Callback that will be called when effect is bound.
  103326. */
  103327. onBind: Nullable<(effect: Effect) => void>;
  103328. /**
  103329. * Unique ID of the effect.
  103330. */
  103331. uniqueId: number;
  103332. /**
  103333. * Observable that will be called when the shader is compiled.
  103334. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103335. */
  103336. onCompileObservable: Observable<Effect>;
  103337. /**
  103338. * Observable that will be called if an error occurs during shader compilation.
  103339. */
  103340. onErrorObservable: Observable<Effect>;
  103341. /** @hidden */
  103342. _onBindObservable: Nullable<Observable<Effect>>;
  103343. /**
  103344. * @hidden
  103345. * Specifies if the effect was previously ready
  103346. */
  103347. _wasPreviouslyReady: boolean;
  103348. /**
  103349. * Observable that will be called when effect is bound.
  103350. */
  103351. get onBindObservable(): Observable<Effect>;
  103352. /** @hidden */
  103353. _bonesComputationForcedToCPU: boolean;
  103354. private static _uniqueIdSeed;
  103355. private _engine;
  103356. private _uniformBuffersNames;
  103357. private _uniformsNames;
  103358. private _samplerList;
  103359. private _samplers;
  103360. private _isReady;
  103361. private _compilationError;
  103362. private _allFallbacksProcessed;
  103363. private _attributesNames;
  103364. private _attributes;
  103365. private _attributeLocationByName;
  103366. private _uniforms;
  103367. /**
  103368. * Key for the effect.
  103369. * @hidden
  103370. */
  103371. _key: string;
  103372. private _indexParameters;
  103373. private _fallbacks;
  103374. private _vertexSourceCode;
  103375. private _fragmentSourceCode;
  103376. private _vertexSourceCodeOverride;
  103377. private _fragmentSourceCodeOverride;
  103378. private _transformFeedbackVaryings;
  103379. /**
  103380. * Compiled shader to webGL program.
  103381. * @hidden
  103382. */
  103383. _pipelineContext: Nullable<IPipelineContext>;
  103384. private _valueCache;
  103385. private static _baseCache;
  103386. /**
  103387. * Instantiates an effect.
  103388. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103389. * @param baseName Name of the effect.
  103390. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103391. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103392. * @param samplers List of sampler variables that will be passed to the shader.
  103393. * @param engine Engine to be used to render the effect
  103394. * @param defines Define statements to be added to the shader.
  103395. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103396. * @param onCompiled Callback that will be called when the shader is compiled.
  103397. * @param onError Callback that will be called if an error occurs during shader compilation.
  103398. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103399. */
  103400. 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);
  103401. private _useFinalCode;
  103402. /**
  103403. * Unique key for this effect
  103404. */
  103405. get key(): string;
  103406. /**
  103407. * If the effect has been compiled and prepared.
  103408. * @returns if the effect is compiled and prepared.
  103409. */
  103410. isReady(): boolean;
  103411. private _isReadyInternal;
  103412. /**
  103413. * The engine the effect was initialized with.
  103414. * @returns the engine.
  103415. */
  103416. getEngine(): Engine;
  103417. /**
  103418. * The pipeline context for this effect
  103419. * @returns the associated pipeline context
  103420. */
  103421. getPipelineContext(): Nullable<IPipelineContext>;
  103422. /**
  103423. * The set of names of attribute variables for the shader.
  103424. * @returns An array of attribute names.
  103425. */
  103426. getAttributesNames(): string[];
  103427. /**
  103428. * Returns the attribute at the given index.
  103429. * @param index The index of the attribute.
  103430. * @returns The location of the attribute.
  103431. */
  103432. getAttributeLocation(index: number): number;
  103433. /**
  103434. * Returns the attribute based on the name of the variable.
  103435. * @param name of the attribute to look up.
  103436. * @returns the attribute location.
  103437. */
  103438. getAttributeLocationByName(name: string): number;
  103439. /**
  103440. * The number of attributes.
  103441. * @returns the numnber of attributes.
  103442. */
  103443. getAttributesCount(): number;
  103444. /**
  103445. * Gets the index of a uniform variable.
  103446. * @param uniformName of the uniform to look up.
  103447. * @returns the index.
  103448. */
  103449. getUniformIndex(uniformName: string): number;
  103450. /**
  103451. * Returns the attribute based on the name of the variable.
  103452. * @param uniformName of the uniform to look up.
  103453. * @returns the location of the uniform.
  103454. */
  103455. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103456. /**
  103457. * Returns an array of sampler variable names
  103458. * @returns The array of sampler variable neames.
  103459. */
  103460. getSamplers(): string[];
  103461. /**
  103462. * The error from the last compilation.
  103463. * @returns the error string.
  103464. */
  103465. getCompilationError(): string;
  103466. /**
  103467. * Gets a boolean indicating that all fallbacks were used during compilation
  103468. * @returns true if all fallbacks were used
  103469. */
  103470. allFallbacksProcessed(): boolean;
  103471. /**
  103472. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103473. * @param func The callback to be used.
  103474. */
  103475. executeWhenCompiled(func: (effect: Effect) => void): void;
  103476. private _checkIsReady;
  103477. private _loadShader;
  103478. /**
  103479. * Recompiles the webGL program
  103480. * @param vertexSourceCode The source code for the vertex shader.
  103481. * @param fragmentSourceCode The source code for the fragment shader.
  103482. * @param onCompiled Callback called when completed.
  103483. * @param onError Callback called on error.
  103484. * @hidden
  103485. */
  103486. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103487. /**
  103488. * Prepares the effect
  103489. * @hidden
  103490. */
  103491. _prepareEffect(): void;
  103492. private _processCompilationErrors;
  103493. /**
  103494. * Checks if the effect is supported. (Must be called after compilation)
  103495. */
  103496. get isSupported(): boolean;
  103497. /**
  103498. * Binds a texture to the engine to be used as output of the shader.
  103499. * @param channel Name of the output variable.
  103500. * @param texture Texture to bind.
  103501. * @hidden
  103502. */
  103503. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103504. /**
  103505. * Sets a texture on the engine to be used in the shader.
  103506. * @param channel Name of the sampler variable.
  103507. * @param texture Texture to set.
  103508. */
  103509. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103510. /**
  103511. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103512. * @param channel Name of the sampler variable.
  103513. * @param texture Texture to set.
  103514. */
  103515. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103516. /**
  103517. * Sets an array of textures on the engine to be used in the shader.
  103518. * @param channel Name of the variable.
  103519. * @param textures Textures to set.
  103520. */
  103521. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103522. /**
  103523. * 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)
  103524. * @param channel Name of the sampler variable.
  103525. * @param postProcess Post process to get the input texture from.
  103526. */
  103527. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103528. /**
  103529. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103530. * 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)
  103531. * @param channel Name of the sampler variable.
  103532. * @param postProcess Post process to get the output texture from.
  103533. */
  103534. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103535. /** @hidden */
  103536. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103537. /** @hidden */
  103538. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103539. /** @hidden */
  103540. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103541. /** @hidden */
  103542. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103543. /**
  103544. * Binds a buffer to a uniform.
  103545. * @param buffer Buffer to bind.
  103546. * @param name Name of the uniform variable to bind to.
  103547. */
  103548. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103549. /**
  103550. * Binds block to a uniform.
  103551. * @param blockName Name of the block to bind.
  103552. * @param index Index to bind.
  103553. */
  103554. bindUniformBlock(blockName: string, index: number): void;
  103555. /**
  103556. * Sets an interger value on a uniform variable.
  103557. * @param uniformName Name of the variable.
  103558. * @param value Value to be set.
  103559. * @returns this effect.
  103560. */
  103561. setInt(uniformName: string, value: number): Effect;
  103562. /**
  103563. * Sets an int array on a uniform variable.
  103564. * @param uniformName Name of the variable.
  103565. * @param array array to be set.
  103566. * @returns this effect.
  103567. */
  103568. setIntArray(uniformName: string, array: Int32Array): Effect;
  103569. /**
  103570. * 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)
  103571. * @param uniformName Name of the variable.
  103572. * @param array array to be set.
  103573. * @returns this effect.
  103574. */
  103575. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103576. /**
  103577. * 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)
  103578. * @param uniformName Name of the variable.
  103579. * @param array array to be set.
  103580. * @returns this effect.
  103581. */
  103582. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103583. /**
  103584. * 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)
  103585. * @param uniformName Name of the variable.
  103586. * @param array array to be set.
  103587. * @returns this effect.
  103588. */
  103589. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103590. /**
  103591. * Sets an float array on a uniform variable.
  103592. * @param uniformName Name of the variable.
  103593. * @param array array to be set.
  103594. * @returns this effect.
  103595. */
  103596. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103597. /**
  103598. * 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)
  103599. * @param uniformName Name of the variable.
  103600. * @param array array to be set.
  103601. * @returns this effect.
  103602. */
  103603. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103604. /**
  103605. * 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)
  103606. * @param uniformName Name of the variable.
  103607. * @param array array to be set.
  103608. * @returns this effect.
  103609. */
  103610. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103611. /**
  103612. * 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)
  103613. * @param uniformName Name of the variable.
  103614. * @param array array to be set.
  103615. * @returns this effect.
  103616. */
  103617. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103618. /**
  103619. * Sets an array on a uniform variable.
  103620. * @param uniformName Name of the variable.
  103621. * @param array array to be set.
  103622. * @returns this effect.
  103623. */
  103624. setArray(uniformName: string, array: number[]): Effect;
  103625. /**
  103626. * 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)
  103627. * @param uniformName Name of the variable.
  103628. * @param array array to be set.
  103629. * @returns this effect.
  103630. */
  103631. setArray2(uniformName: string, array: number[]): Effect;
  103632. /**
  103633. * 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)
  103634. * @param uniformName Name of the variable.
  103635. * @param array array to be set.
  103636. * @returns this effect.
  103637. */
  103638. setArray3(uniformName: string, array: number[]): Effect;
  103639. /**
  103640. * 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)
  103641. * @param uniformName Name of the variable.
  103642. * @param array array to be set.
  103643. * @returns this effect.
  103644. */
  103645. setArray4(uniformName: string, array: number[]): Effect;
  103646. /**
  103647. * Sets matrices on a uniform variable.
  103648. * @param uniformName Name of the variable.
  103649. * @param matrices matrices to be set.
  103650. * @returns this effect.
  103651. */
  103652. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103653. /**
  103654. * Sets matrix on a uniform variable.
  103655. * @param uniformName Name of the variable.
  103656. * @param matrix matrix to be set.
  103657. * @returns this effect.
  103658. */
  103659. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103660. /**
  103661. * 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)
  103662. * @param uniformName Name of the variable.
  103663. * @param matrix matrix to be set.
  103664. * @returns this effect.
  103665. */
  103666. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103667. /**
  103668. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103669. * @param uniformName Name of the variable.
  103670. * @param matrix matrix to be set.
  103671. * @returns this effect.
  103672. */
  103673. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103674. /**
  103675. * Sets a float on a uniform variable.
  103676. * @param uniformName Name of the variable.
  103677. * @param value value to be set.
  103678. * @returns this effect.
  103679. */
  103680. setFloat(uniformName: string, value: number): Effect;
  103681. /**
  103682. * Sets a boolean on a uniform variable.
  103683. * @param uniformName Name of the variable.
  103684. * @param bool value to be set.
  103685. * @returns this effect.
  103686. */
  103687. setBool(uniformName: string, bool: boolean): Effect;
  103688. /**
  103689. * Sets a Vector2 on a uniform variable.
  103690. * @param uniformName Name of the variable.
  103691. * @param vector2 vector2 to be set.
  103692. * @returns this effect.
  103693. */
  103694. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103695. /**
  103696. * Sets a float2 on a uniform variable.
  103697. * @param uniformName Name of the variable.
  103698. * @param x First float in float2.
  103699. * @param y Second float in float2.
  103700. * @returns this effect.
  103701. */
  103702. setFloat2(uniformName: string, x: number, y: number): Effect;
  103703. /**
  103704. * Sets a Vector3 on a uniform variable.
  103705. * @param uniformName Name of the variable.
  103706. * @param vector3 Value to be set.
  103707. * @returns this effect.
  103708. */
  103709. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103710. /**
  103711. * Sets a float3 on a uniform variable.
  103712. * @param uniformName Name of the variable.
  103713. * @param x First float in float3.
  103714. * @param y Second float in float3.
  103715. * @param z Third float in float3.
  103716. * @returns this effect.
  103717. */
  103718. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103719. /**
  103720. * Sets a Vector4 on a uniform variable.
  103721. * @param uniformName Name of the variable.
  103722. * @param vector4 Value to be set.
  103723. * @returns this effect.
  103724. */
  103725. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103726. /**
  103727. * Sets a float4 on a uniform variable.
  103728. * @param uniformName Name of the variable.
  103729. * @param x First float in float4.
  103730. * @param y Second float in float4.
  103731. * @param z Third float in float4.
  103732. * @param w Fourth float in float4.
  103733. * @returns this effect.
  103734. */
  103735. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103736. /**
  103737. * Sets a Color3 on a uniform variable.
  103738. * @param uniformName Name of the variable.
  103739. * @param color3 Value to be set.
  103740. * @returns this effect.
  103741. */
  103742. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103743. /**
  103744. * Sets a Color4 on a uniform variable.
  103745. * @param uniformName Name of the variable.
  103746. * @param color3 Value to be set.
  103747. * @param alpha Alpha value to be set.
  103748. * @returns this effect.
  103749. */
  103750. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103751. /**
  103752. * Sets a Color4 on a uniform variable
  103753. * @param uniformName defines the name of the variable
  103754. * @param color4 defines the value to be set
  103755. * @returns this effect.
  103756. */
  103757. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103758. /** Release all associated resources */
  103759. dispose(): void;
  103760. /**
  103761. * This function will add a new shader to the shader store
  103762. * @param name the name of the shader
  103763. * @param pixelShader optional pixel shader content
  103764. * @param vertexShader optional vertex shader content
  103765. */
  103766. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103767. /**
  103768. * Store of each shader (The can be looked up using effect.key)
  103769. */
  103770. static ShadersStore: {
  103771. [key: string]: string;
  103772. };
  103773. /**
  103774. * Store of each included file for a shader (The can be looked up using effect.key)
  103775. */
  103776. static IncludesShadersStore: {
  103777. [key: string]: string;
  103778. };
  103779. /**
  103780. * Resets the cache of effects.
  103781. */
  103782. static ResetCache(): void;
  103783. }
  103784. }
  103785. declare module BABYLON {
  103786. /**
  103787. * Interface used to describe the capabilities of the engine relatively to the current browser
  103788. */
  103789. export interface EngineCapabilities {
  103790. /** Maximum textures units per fragment shader */
  103791. maxTexturesImageUnits: number;
  103792. /** Maximum texture units per vertex shader */
  103793. maxVertexTextureImageUnits: number;
  103794. /** Maximum textures units in the entire pipeline */
  103795. maxCombinedTexturesImageUnits: number;
  103796. /** Maximum texture size */
  103797. maxTextureSize: number;
  103798. /** Maximum texture samples */
  103799. maxSamples?: number;
  103800. /** Maximum cube texture size */
  103801. maxCubemapTextureSize: number;
  103802. /** Maximum render texture size */
  103803. maxRenderTextureSize: number;
  103804. /** Maximum number of vertex attributes */
  103805. maxVertexAttribs: number;
  103806. /** Maximum number of varyings */
  103807. maxVaryingVectors: number;
  103808. /** Maximum number of uniforms per vertex shader */
  103809. maxVertexUniformVectors: number;
  103810. /** Maximum number of uniforms per fragment shader */
  103811. maxFragmentUniformVectors: number;
  103812. /** Defines if standard derivates (dx/dy) are supported */
  103813. standardDerivatives: boolean;
  103814. /** Defines if s3tc texture compression is supported */
  103815. s3tc?: WEBGL_compressed_texture_s3tc;
  103816. /** Defines if pvrtc texture compression is supported */
  103817. pvrtc: any;
  103818. /** Defines if etc1 texture compression is supported */
  103819. etc1: any;
  103820. /** Defines if etc2 texture compression is supported */
  103821. etc2: any;
  103822. /** Defines if astc texture compression is supported */
  103823. astc: any;
  103824. /** Defines if float textures are supported */
  103825. textureFloat: boolean;
  103826. /** Defines if vertex array objects are supported */
  103827. vertexArrayObject: boolean;
  103828. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103829. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103830. /** Gets the maximum level of anisotropy supported */
  103831. maxAnisotropy: number;
  103832. /** Defines if instancing is supported */
  103833. instancedArrays: boolean;
  103834. /** Defines if 32 bits indices are supported */
  103835. uintIndices: boolean;
  103836. /** Defines if high precision shaders are supported */
  103837. highPrecisionShaderSupported: boolean;
  103838. /** Defines if depth reading in the fragment shader is supported */
  103839. fragmentDepthSupported: boolean;
  103840. /** Defines if float texture linear filtering is supported*/
  103841. textureFloatLinearFiltering: boolean;
  103842. /** Defines if rendering to float textures is supported */
  103843. textureFloatRender: boolean;
  103844. /** Defines if half float textures are supported*/
  103845. textureHalfFloat: boolean;
  103846. /** Defines if half float texture linear filtering is supported*/
  103847. textureHalfFloatLinearFiltering: boolean;
  103848. /** Defines if rendering to half float textures is supported */
  103849. textureHalfFloatRender: boolean;
  103850. /** Defines if textureLOD shader command is supported */
  103851. textureLOD: boolean;
  103852. /** Defines if draw buffers extension is supported */
  103853. drawBuffersExtension: boolean;
  103854. /** Defines if depth textures are supported */
  103855. depthTextureExtension: boolean;
  103856. /** Defines if float color buffer are supported */
  103857. colorBufferFloat: boolean;
  103858. /** Gets disjoint timer query extension (null if not supported) */
  103859. timerQuery?: EXT_disjoint_timer_query;
  103860. /** Defines if timestamp can be used with timer query */
  103861. canUseTimestampForTimerQuery: boolean;
  103862. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103863. multiview?: any;
  103864. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103865. oculusMultiview?: any;
  103866. /** Function used to let the system compiles shaders in background */
  103867. parallelShaderCompile?: {
  103868. COMPLETION_STATUS_KHR: number;
  103869. };
  103870. /** Max number of texture samples for MSAA */
  103871. maxMSAASamples: number;
  103872. /** Defines if the blend min max extension is supported */
  103873. blendMinMax: boolean;
  103874. }
  103875. }
  103876. declare module BABYLON {
  103877. /**
  103878. * @hidden
  103879. **/
  103880. export class DepthCullingState {
  103881. private _isDepthTestDirty;
  103882. private _isDepthMaskDirty;
  103883. private _isDepthFuncDirty;
  103884. private _isCullFaceDirty;
  103885. private _isCullDirty;
  103886. private _isZOffsetDirty;
  103887. private _isFrontFaceDirty;
  103888. private _depthTest;
  103889. private _depthMask;
  103890. private _depthFunc;
  103891. private _cull;
  103892. private _cullFace;
  103893. private _zOffset;
  103894. private _frontFace;
  103895. /**
  103896. * Initializes the state.
  103897. */
  103898. constructor();
  103899. get isDirty(): boolean;
  103900. get zOffset(): number;
  103901. set zOffset(value: number);
  103902. get cullFace(): Nullable<number>;
  103903. set cullFace(value: Nullable<number>);
  103904. get cull(): Nullable<boolean>;
  103905. set cull(value: Nullable<boolean>);
  103906. get depthFunc(): Nullable<number>;
  103907. set depthFunc(value: Nullable<number>);
  103908. get depthMask(): boolean;
  103909. set depthMask(value: boolean);
  103910. get depthTest(): boolean;
  103911. set depthTest(value: boolean);
  103912. get frontFace(): Nullable<number>;
  103913. set frontFace(value: Nullable<number>);
  103914. reset(): void;
  103915. apply(gl: WebGLRenderingContext): void;
  103916. }
  103917. }
  103918. declare module BABYLON {
  103919. /**
  103920. * @hidden
  103921. **/
  103922. export class StencilState {
  103923. /** 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 */
  103924. static readonly ALWAYS: number;
  103925. /** Passed to stencilOperation to specify that stencil value must be kept */
  103926. static readonly KEEP: number;
  103927. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103928. static readonly REPLACE: number;
  103929. private _isStencilTestDirty;
  103930. private _isStencilMaskDirty;
  103931. private _isStencilFuncDirty;
  103932. private _isStencilOpDirty;
  103933. private _stencilTest;
  103934. private _stencilMask;
  103935. private _stencilFunc;
  103936. private _stencilFuncRef;
  103937. private _stencilFuncMask;
  103938. private _stencilOpStencilFail;
  103939. private _stencilOpDepthFail;
  103940. private _stencilOpStencilDepthPass;
  103941. get isDirty(): boolean;
  103942. get stencilFunc(): number;
  103943. set stencilFunc(value: number);
  103944. get stencilFuncRef(): number;
  103945. set stencilFuncRef(value: number);
  103946. get stencilFuncMask(): number;
  103947. set stencilFuncMask(value: number);
  103948. get stencilOpStencilFail(): number;
  103949. set stencilOpStencilFail(value: number);
  103950. get stencilOpDepthFail(): number;
  103951. set stencilOpDepthFail(value: number);
  103952. get stencilOpStencilDepthPass(): number;
  103953. set stencilOpStencilDepthPass(value: number);
  103954. get stencilMask(): number;
  103955. set stencilMask(value: number);
  103956. get stencilTest(): boolean;
  103957. set stencilTest(value: boolean);
  103958. constructor();
  103959. reset(): void;
  103960. apply(gl: WebGLRenderingContext): void;
  103961. }
  103962. }
  103963. declare module BABYLON {
  103964. /**
  103965. * @hidden
  103966. **/
  103967. export class AlphaState {
  103968. private _isAlphaBlendDirty;
  103969. private _isBlendFunctionParametersDirty;
  103970. private _isBlendEquationParametersDirty;
  103971. private _isBlendConstantsDirty;
  103972. private _alphaBlend;
  103973. private _blendFunctionParameters;
  103974. private _blendEquationParameters;
  103975. private _blendConstants;
  103976. /**
  103977. * Initializes the state.
  103978. */
  103979. constructor();
  103980. get isDirty(): boolean;
  103981. get alphaBlend(): boolean;
  103982. set alphaBlend(value: boolean);
  103983. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103984. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103985. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103986. reset(): void;
  103987. apply(gl: WebGLRenderingContext): void;
  103988. }
  103989. }
  103990. declare module BABYLON {
  103991. /** @hidden */
  103992. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103993. attributeProcessor(attribute: string): string;
  103994. varyingProcessor(varying: string, isFragment: boolean): string;
  103995. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103996. }
  103997. }
  103998. declare module BABYLON {
  103999. /**
  104000. * Interface for attribute information associated with buffer instanciation
  104001. */
  104002. export interface InstancingAttributeInfo {
  104003. /**
  104004. * Name of the GLSL attribute
  104005. * if attribute index is not specified, this is used to retrieve the index from the effect
  104006. */
  104007. attributeName: string;
  104008. /**
  104009. * Index/offset of the attribute in the vertex shader
  104010. * if not specified, this will be computes from the name.
  104011. */
  104012. index?: number;
  104013. /**
  104014. * size of the attribute, 1, 2, 3 or 4
  104015. */
  104016. attributeSize: number;
  104017. /**
  104018. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104019. */
  104020. offset: number;
  104021. /**
  104022. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104023. * default to 1
  104024. */
  104025. divisor?: number;
  104026. /**
  104027. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104028. * default is FLOAT
  104029. */
  104030. attributeType?: number;
  104031. /**
  104032. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104033. */
  104034. normalized?: boolean;
  104035. }
  104036. }
  104037. declare module BABYLON {
  104038. interface ThinEngine {
  104039. /**
  104040. * Update a video texture
  104041. * @param texture defines the texture to update
  104042. * @param video defines the video element to use
  104043. * @param invertY defines if data must be stored with Y axis inverted
  104044. */
  104045. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104046. }
  104047. }
  104048. declare module BABYLON {
  104049. /**
  104050. * Settings for finer control over video usage
  104051. */
  104052. export interface VideoTextureSettings {
  104053. /**
  104054. * Applies `autoplay` to video, if specified
  104055. */
  104056. autoPlay?: boolean;
  104057. /**
  104058. * Applies `loop` to video, if specified
  104059. */
  104060. loop?: boolean;
  104061. /**
  104062. * Automatically updates internal texture from video at every frame in the render loop
  104063. */
  104064. autoUpdateTexture: boolean;
  104065. /**
  104066. * Image src displayed during the video loading or until the user interacts with the video.
  104067. */
  104068. poster?: string;
  104069. }
  104070. /**
  104071. * If you want to display a video in your scene, this is the special texture for that.
  104072. * This special texture works similar to other textures, with the exception of a few parameters.
  104073. * @see https://doc.babylonjs.com/how_to/video_texture
  104074. */
  104075. export class VideoTexture extends Texture {
  104076. /**
  104077. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104078. */
  104079. readonly autoUpdateTexture: boolean;
  104080. /**
  104081. * The video instance used by the texture internally
  104082. */
  104083. readonly video: HTMLVideoElement;
  104084. private _onUserActionRequestedObservable;
  104085. /**
  104086. * Event triggerd when a dom action is required by the user to play the video.
  104087. * This happens due to recent changes in browser policies preventing video to auto start.
  104088. */
  104089. get onUserActionRequestedObservable(): Observable<Texture>;
  104090. private _generateMipMaps;
  104091. private _engine;
  104092. private _stillImageCaptured;
  104093. private _displayingPosterTexture;
  104094. private _settings;
  104095. private _createInternalTextureOnEvent;
  104096. private _frameId;
  104097. private _currentSrc;
  104098. /**
  104099. * Creates a video texture.
  104100. * If you want to display a video in your scene, this is the special texture for that.
  104101. * This special texture works similar to other textures, with the exception of a few parameters.
  104102. * @see https://doc.babylonjs.com/how_to/video_texture
  104103. * @param name optional name, will detect from video source, if not defined
  104104. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104105. * @param scene is obviously the current scene.
  104106. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104107. * @param invertY is false by default but can be used to invert video on Y axis
  104108. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104109. * @param settings allows finer control over video usage
  104110. */
  104111. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104112. private _getName;
  104113. private _getVideo;
  104114. private _createInternalTexture;
  104115. private reset;
  104116. /**
  104117. * @hidden Internal method to initiate `update`.
  104118. */
  104119. _rebuild(): void;
  104120. /**
  104121. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104122. */
  104123. update(): void;
  104124. /**
  104125. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104126. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104127. */
  104128. updateTexture(isVisible: boolean): void;
  104129. protected _updateInternalTexture: () => void;
  104130. /**
  104131. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104132. * @param url New url.
  104133. */
  104134. updateURL(url: string): void;
  104135. /**
  104136. * Clones the texture.
  104137. * @returns the cloned texture
  104138. */
  104139. clone(): VideoTexture;
  104140. /**
  104141. * Dispose the texture and release its associated resources.
  104142. */
  104143. dispose(): void;
  104144. /**
  104145. * Creates a video texture straight from a stream.
  104146. * @param scene Define the scene the texture should be created in
  104147. * @param stream Define the stream the texture should be created from
  104148. * @returns The created video texture as a promise
  104149. */
  104150. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104151. /**
  104152. * Creates a video texture straight from your WebCam video feed.
  104153. * @param scene Define the scene the texture should be created in
  104154. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104155. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104156. * @returns The created video texture as a promise
  104157. */
  104158. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104159. minWidth: number;
  104160. maxWidth: number;
  104161. minHeight: number;
  104162. maxHeight: number;
  104163. deviceId: string;
  104164. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104165. /**
  104166. * Creates a video texture straight from your WebCam video feed.
  104167. * @param scene Define the scene the texture should be created in
  104168. * @param onReady Define a callback to triggered once the texture will be ready
  104169. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104170. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104171. */
  104172. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104173. minWidth: number;
  104174. maxWidth: number;
  104175. minHeight: number;
  104176. maxHeight: number;
  104177. deviceId: string;
  104178. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104179. }
  104180. }
  104181. declare module BABYLON {
  104182. /**
  104183. * Defines the interface used by objects working like Scene
  104184. * @hidden
  104185. */
  104186. interface ISceneLike {
  104187. _addPendingData(data: any): void;
  104188. _removePendingData(data: any): void;
  104189. offlineProvider: IOfflineProvider;
  104190. }
  104191. /** Interface defining initialization parameters for Engine class */
  104192. export interface EngineOptions extends WebGLContextAttributes {
  104193. /**
  104194. * Defines if the engine should no exceed a specified device ratio
  104195. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104196. */
  104197. limitDeviceRatio?: number;
  104198. /**
  104199. * Defines if webvr should be enabled automatically
  104200. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104201. */
  104202. autoEnableWebVR?: boolean;
  104203. /**
  104204. * Defines if webgl2 should be turned off even if supported
  104205. * @see http://doc.babylonjs.com/features/webgl2
  104206. */
  104207. disableWebGL2Support?: boolean;
  104208. /**
  104209. * Defines if webaudio should be initialized as well
  104210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104211. */
  104212. audioEngine?: boolean;
  104213. /**
  104214. * Defines if animations should run using a deterministic lock step
  104215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104216. */
  104217. deterministicLockstep?: boolean;
  104218. /** Defines the maximum steps to use with deterministic lock step mode */
  104219. lockstepMaxSteps?: number;
  104220. /** Defines the seconds between each deterministic lock step */
  104221. timeStep?: number;
  104222. /**
  104223. * Defines that engine should ignore context lost events
  104224. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104225. */
  104226. doNotHandleContextLost?: boolean;
  104227. /**
  104228. * Defines that engine should ignore modifying touch action attribute and style
  104229. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104230. */
  104231. doNotHandleTouchAction?: boolean;
  104232. /**
  104233. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104234. */
  104235. useHighPrecisionFloats?: boolean;
  104236. }
  104237. /**
  104238. * The base engine class (root of all engines)
  104239. */
  104240. export class ThinEngine {
  104241. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104242. static ExceptionList: ({
  104243. key: string;
  104244. capture: string;
  104245. captureConstraint: number;
  104246. targets: string[];
  104247. } | {
  104248. key: string;
  104249. capture: null;
  104250. captureConstraint: null;
  104251. targets: string[];
  104252. })[];
  104253. /** @hidden */
  104254. static _TextureLoaders: IInternalTextureLoader[];
  104255. /**
  104256. * Returns the current npm package of the sdk
  104257. */
  104258. static get NpmPackage(): string;
  104259. /**
  104260. * Returns the current version of the framework
  104261. */
  104262. static get Version(): string;
  104263. /**
  104264. * Returns a string describing the current engine
  104265. */
  104266. get description(): string;
  104267. /**
  104268. * Gets or sets the epsilon value used by collision engine
  104269. */
  104270. static CollisionsEpsilon: number;
  104271. /**
  104272. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104273. */
  104274. static get ShadersRepository(): string;
  104275. static set ShadersRepository(value: string);
  104276. /**
  104277. * Gets or sets the textures that the engine should not attempt to load as compressed
  104278. */
  104279. protected _excludedCompressedTextures: string[];
  104280. /**
  104281. * Filters the compressed texture formats to only include
  104282. * files that are not included in the skippable list
  104283. *
  104284. * @param url the current extension
  104285. * @param textureFormatInUse the current compressed texture format
  104286. * @returns "format" string
  104287. */
  104288. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104289. /** @hidden */
  104290. _shaderProcessor: IShaderProcessor;
  104291. /**
  104292. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104293. */
  104294. forcePOTTextures: boolean;
  104295. /**
  104296. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104297. */
  104298. isFullscreen: boolean;
  104299. /**
  104300. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104301. */
  104302. cullBackFaces: boolean;
  104303. /**
  104304. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104305. */
  104306. renderEvenInBackground: boolean;
  104307. /**
  104308. * Gets or sets a boolean indicating that cache can be kept between frames
  104309. */
  104310. preventCacheWipeBetweenFrames: boolean;
  104311. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104312. validateShaderPrograms: boolean;
  104313. /**
  104314. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104315. * This can provide greater z depth for distant objects.
  104316. */
  104317. useReverseDepthBuffer: boolean;
  104318. /**
  104319. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104320. */
  104321. disableUniformBuffers: boolean;
  104322. /** @hidden */
  104323. _uniformBuffers: UniformBuffer[];
  104324. /**
  104325. * Gets a boolean indicating that the engine supports uniform buffers
  104326. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104327. */
  104328. get supportsUniformBuffers(): boolean;
  104329. /** @hidden */
  104330. _gl: WebGLRenderingContext;
  104331. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104332. protected _windowIsBackground: boolean;
  104333. protected _webGLVersion: number;
  104334. protected _creationOptions: EngineOptions;
  104335. protected _highPrecisionShadersAllowed: boolean;
  104336. /** @hidden */
  104337. get _shouldUseHighPrecisionShader(): boolean;
  104338. /**
  104339. * Gets a boolean indicating that only power of 2 textures are supported
  104340. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104341. */
  104342. get needPOTTextures(): boolean;
  104343. /** @hidden */
  104344. _badOS: boolean;
  104345. /** @hidden */
  104346. _badDesktopOS: boolean;
  104347. private _hardwareScalingLevel;
  104348. /** @hidden */
  104349. _caps: EngineCapabilities;
  104350. private _isStencilEnable;
  104351. private _glVersion;
  104352. private _glRenderer;
  104353. private _glVendor;
  104354. /** @hidden */
  104355. _videoTextureSupported: boolean;
  104356. protected _renderingQueueLaunched: boolean;
  104357. protected _activeRenderLoops: (() => void)[];
  104358. /**
  104359. * Observable signaled when a context lost event is raised
  104360. */
  104361. onContextLostObservable: Observable<ThinEngine>;
  104362. /**
  104363. * Observable signaled when a context restored event is raised
  104364. */
  104365. onContextRestoredObservable: Observable<ThinEngine>;
  104366. private _onContextLost;
  104367. private _onContextRestored;
  104368. protected _contextWasLost: boolean;
  104369. /** @hidden */
  104370. _doNotHandleContextLost: boolean;
  104371. /**
  104372. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104374. */
  104375. get doNotHandleContextLost(): boolean;
  104376. set doNotHandleContextLost(value: boolean);
  104377. /**
  104378. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104379. */
  104380. disableVertexArrayObjects: boolean;
  104381. /** @hidden */
  104382. protected _colorWrite: boolean;
  104383. /** @hidden */
  104384. protected _colorWriteChanged: boolean;
  104385. /** @hidden */
  104386. protected _depthCullingState: DepthCullingState;
  104387. /** @hidden */
  104388. protected _stencilState: StencilState;
  104389. /** @hidden */
  104390. _alphaState: AlphaState;
  104391. /** @hidden */
  104392. _alphaMode: number;
  104393. /** @hidden */
  104394. _alphaEquation: number;
  104395. /** @hidden */
  104396. _internalTexturesCache: InternalTexture[];
  104397. /** @hidden */
  104398. protected _activeChannel: number;
  104399. private _currentTextureChannel;
  104400. /** @hidden */
  104401. protected _boundTexturesCache: {
  104402. [key: string]: Nullable<InternalTexture>;
  104403. };
  104404. /** @hidden */
  104405. protected _currentEffect: Nullable<Effect>;
  104406. /** @hidden */
  104407. protected _currentProgram: Nullable<WebGLProgram>;
  104408. private _compiledEffects;
  104409. private _vertexAttribArraysEnabled;
  104410. /** @hidden */
  104411. protected _cachedViewport: Nullable<IViewportLike>;
  104412. private _cachedVertexArrayObject;
  104413. /** @hidden */
  104414. protected _cachedVertexBuffers: any;
  104415. /** @hidden */
  104416. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104417. /** @hidden */
  104418. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104419. /** @hidden */
  104420. _currentRenderTarget: Nullable<InternalTexture>;
  104421. private _uintIndicesCurrentlySet;
  104422. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104423. /** @hidden */
  104424. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104425. private _currentBufferPointers;
  104426. private _currentInstanceLocations;
  104427. private _currentInstanceBuffers;
  104428. private _textureUnits;
  104429. /** @hidden */
  104430. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104431. /** @hidden */
  104432. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104433. /** @hidden */
  104434. _boundRenderFunction: any;
  104435. private _vaoRecordInProgress;
  104436. private _mustWipeVertexAttributes;
  104437. private _emptyTexture;
  104438. private _emptyCubeTexture;
  104439. private _emptyTexture3D;
  104440. private _emptyTexture2DArray;
  104441. /** @hidden */
  104442. _frameHandler: number;
  104443. private _nextFreeTextureSlots;
  104444. private _maxSimultaneousTextures;
  104445. private _activeRequests;
  104446. protected _texturesSupported: string[];
  104447. /** @hidden */
  104448. _textureFormatInUse: Nullable<string>;
  104449. protected get _supportsHardwareTextureRescaling(): boolean;
  104450. /**
  104451. * Gets the list of texture formats supported
  104452. */
  104453. get texturesSupported(): Array<string>;
  104454. /**
  104455. * Gets the list of texture formats in use
  104456. */
  104457. get textureFormatInUse(): Nullable<string>;
  104458. /**
  104459. * Gets the current viewport
  104460. */
  104461. get currentViewport(): Nullable<IViewportLike>;
  104462. /**
  104463. * Gets the default empty texture
  104464. */
  104465. get emptyTexture(): InternalTexture;
  104466. /**
  104467. * Gets the default empty 3D texture
  104468. */
  104469. get emptyTexture3D(): InternalTexture;
  104470. /**
  104471. * Gets the default empty 2D array texture
  104472. */
  104473. get emptyTexture2DArray(): InternalTexture;
  104474. /**
  104475. * Gets the default empty cube texture
  104476. */
  104477. get emptyCubeTexture(): InternalTexture;
  104478. /**
  104479. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104480. */
  104481. readonly premultipliedAlpha: boolean;
  104482. /**
  104483. * Observable event triggered before each texture is initialized
  104484. */
  104485. onBeforeTextureInitObservable: Observable<Texture>;
  104486. /**
  104487. * Creates a new engine
  104488. * @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
  104489. * @param antialias defines enable antialiasing (default: false)
  104490. * @param options defines further options to be sent to the getContext() function
  104491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104492. */
  104493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104494. private _rebuildInternalTextures;
  104495. private _rebuildEffects;
  104496. /**
  104497. * Gets a boolean indicating if all created effects are ready
  104498. * @returns true if all effects are ready
  104499. */
  104500. areAllEffectsReady(): boolean;
  104501. protected _rebuildBuffers(): void;
  104502. private _initGLContext;
  104503. /**
  104504. * Gets version of the current webGL context
  104505. */
  104506. get webGLVersion(): number;
  104507. /**
  104508. * Gets a string idenfifying the name of the class
  104509. * @returns "Engine" string
  104510. */
  104511. getClassName(): string;
  104512. /**
  104513. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104514. */
  104515. get isStencilEnable(): boolean;
  104516. /** @hidden */
  104517. _prepareWorkingCanvas(): void;
  104518. /**
  104519. * Reset the texture cache to empty state
  104520. */
  104521. resetTextureCache(): void;
  104522. /**
  104523. * Gets an object containing information about the current webGL context
  104524. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104525. */
  104526. getGlInfo(): {
  104527. vendor: string;
  104528. renderer: string;
  104529. version: string;
  104530. };
  104531. /**
  104532. * Defines the hardware scaling level.
  104533. * By default the hardware scaling level is computed from the window device ratio.
  104534. * 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.
  104535. * @param level defines the level to use
  104536. */
  104537. setHardwareScalingLevel(level: number): void;
  104538. /**
  104539. * Gets the current hardware scaling level.
  104540. * By default the hardware scaling level is computed from the window device ratio.
  104541. * 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.
  104542. * @returns a number indicating the current hardware scaling level
  104543. */
  104544. getHardwareScalingLevel(): number;
  104545. /**
  104546. * Gets the list of loaded textures
  104547. * @returns an array containing all loaded textures
  104548. */
  104549. getLoadedTexturesCache(): InternalTexture[];
  104550. /**
  104551. * Gets the object containing all engine capabilities
  104552. * @returns the EngineCapabilities object
  104553. */
  104554. getCaps(): EngineCapabilities;
  104555. /**
  104556. * stop executing a render loop function and remove it from the execution array
  104557. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104558. */
  104559. stopRenderLoop(renderFunction?: () => void): void;
  104560. /** @hidden */
  104561. _renderLoop(): void;
  104562. /**
  104563. * Gets the HTML canvas attached with the current webGL context
  104564. * @returns a HTML canvas
  104565. */
  104566. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104567. /**
  104568. * Gets host window
  104569. * @returns the host window object
  104570. */
  104571. getHostWindow(): Nullable<Window>;
  104572. /**
  104573. * Gets the current render width
  104574. * @param useScreen defines if screen size must be used (or the current render target if any)
  104575. * @returns a number defining the current render width
  104576. */
  104577. getRenderWidth(useScreen?: boolean): number;
  104578. /**
  104579. * Gets the current render height
  104580. * @param useScreen defines if screen size must be used (or the current render target if any)
  104581. * @returns a number defining the current render height
  104582. */
  104583. getRenderHeight(useScreen?: boolean): number;
  104584. /**
  104585. * Can be used to override the current requestAnimationFrame requester.
  104586. * @hidden
  104587. */
  104588. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104589. /**
  104590. * Register and execute a render loop. The engine can have more than one render function
  104591. * @param renderFunction defines the function to continuously execute
  104592. */
  104593. runRenderLoop(renderFunction: () => void): void;
  104594. /**
  104595. * Clear the current render buffer or the current render target (if any is set up)
  104596. * @param color defines the color to use
  104597. * @param backBuffer defines if the back buffer must be cleared
  104598. * @param depth defines if the depth buffer must be cleared
  104599. * @param stencil defines if the stencil buffer must be cleared
  104600. */
  104601. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104602. private _viewportCached;
  104603. /** @hidden */
  104604. _viewport(x: number, y: number, width: number, height: number): void;
  104605. /**
  104606. * Set the WebGL's viewport
  104607. * @param viewport defines the viewport element to be used
  104608. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104609. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104610. */
  104611. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104612. /**
  104613. * Begin a new frame
  104614. */
  104615. beginFrame(): void;
  104616. /**
  104617. * Enf the current frame
  104618. */
  104619. endFrame(): void;
  104620. /**
  104621. * Resize the view according to the canvas' size
  104622. */
  104623. resize(): void;
  104624. /**
  104625. * Force a specific size of the canvas
  104626. * @param width defines the new canvas' width
  104627. * @param height defines the new canvas' height
  104628. */
  104629. setSize(width: number, height: number): void;
  104630. /**
  104631. * Binds the frame buffer to the specified texture.
  104632. * @param texture The texture to render to or null for the default canvas
  104633. * @param faceIndex The face of the texture to render to in case of cube texture
  104634. * @param requiredWidth The width of the target to render to
  104635. * @param requiredHeight The height of the target to render to
  104636. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104637. * @param lodLevel defines the lod level to bind to the frame buffer
  104638. * @param layer defines the 2d array index to bind to frame buffer to
  104639. */
  104640. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104641. /** @hidden */
  104642. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104643. /**
  104644. * Unbind the current render target texture from the webGL context
  104645. * @param texture defines the render target texture to unbind
  104646. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104647. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104648. */
  104649. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104650. /**
  104651. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104652. */
  104653. flushFramebuffer(): void;
  104654. /**
  104655. * Unbind the current render target and bind the default framebuffer
  104656. */
  104657. restoreDefaultFramebuffer(): void;
  104658. /** @hidden */
  104659. protected _resetVertexBufferBinding(): void;
  104660. /**
  104661. * Creates a vertex buffer
  104662. * @param data the data for the vertex buffer
  104663. * @returns the new WebGL static buffer
  104664. */
  104665. createVertexBuffer(data: DataArray): DataBuffer;
  104666. private _createVertexBuffer;
  104667. /**
  104668. * Creates a dynamic vertex buffer
  104669. * @param data the data for the dynamic vertex buffer
  104670. * @returns the new WebGL dynamic buffer
  104671. */
  104672. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104673. protected _resetIndexBufferBinding(): void;
  104674. /**
  104675. * Creates a new index buffer
  104676. * @param indices defines the content of the index buffer
  104677. * @param updatable defines if the index buffer must be updatable
  104678. * @returns a new webGL buffer
  104679. */
  104680. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104681. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104682. /**
  104683. * Bind a webGL buffer to the webGL context
  104684. * @param buffer defines the buffer to bind
  104685. */
  104686. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104687. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104688. private bindBuffer;
  104689. /**
  104690. * update the bound buffer with the given data
  104691. * @param data defines the data to update
  104692. */
  104693. updateArrayBuffer(data: Float32Array): void;
  104694. private _vertexAttribPointer;
  104695. /** @hidden */
  104696. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104697. private _bindVertexBuffersAttributes;
  104698. /**
  104699. * Records a vertex array object
  104700. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104701. * @param vertexBuffers defines the list of vertex buffers to store
  104702. * @param indexBuffer defines the index buffer to store
  104703. * @param effect defines the effect to store
  104704. * @returns the new vertex array object
  104705. */
  104706. recordVertexArrayObject(vertexBuffers: {
  104707. [key: string]: VertexBuffer;
  104708. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104709. /**
  104710. * Bind a specific vertex array object
  104711. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104712. * @param vertexArrayObject defines the vertex array object to bind
  104713. * @param indexBuffer defines the index buffer to bind
  104714. */
  104715. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104716. /**
  104717. * Bind webGl buffers directly to the webGL context
  104718. * @param vertexBuffer defines the vertex buffer to bind
  104719. * @param indexBuffer defines the index buffer to bind
  104720. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104721. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104722. * @param effect defines the effect associated with the vertex buffer
  104723. */
  104724. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104725. private _unbindVertexArrayObject;
  104726. /**
  104727. * Bind a list of vertex buffers to the webGL context
  104728. * @param vertexBuffers defines the list of vertex buffers to bind
  104729. * @param indexBuffer defines the index buffer to bind
  104730. * @param effect defines the effect associated with the vertex buffers
  104731. */
  104732. bindBuffers(vertexBuffers: {
  104733. [key: string]: Nullable<VertexBuffer>;
  104734. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104735. /**
  104736. * Unbind all instance attributes
  104737. */
  104738. unbindInstanceAttributes(): void;
  104739. /**
  104740. * Release and free the memory of a vertex array object
  104741. * @param vao defines the vertex array object to delete
  104742. */
  104743. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104744. /** @hidden */
  104745. _releaseBuffer(buffer: DataBuffer): boolean;
  104746. protected _deleteBuffer(buffer: DataBuffer): void;
  104747. /**
  104748. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104749. * @param instancesBuffer defines the webGL buffer to update and bind
  104750. * @param data defines the data to store in the buffer
  104751. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104752. */
  104753. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104754. /**
  104755. * Bind the content of a webGL buffer used with instantiation
  104756. * @param instancesBuffer defines the webGL buffer to bind
  104757. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104758. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104759. */
  104760. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104761. /**
  104762. * Disable the instance attribute corresponding to the name in parameter
  104763. * @param name defines the name of the attribute to disable
  104764. */
  104765. disableInstanceAttributeByName(name: string): void;
  104766. /**
  104767. * Disable the instance attribute corresponding to the location in parameter
  104768. * @param attributeLocation defines the attribute location of the attribute to disable
  104769. */
  104770. disableInstanceAttribute(attributeLocation: number): void;
  104771. /**
  104772. * Disable the attribute corresponding to the location in parameter
  104773. * @param attributeLocation defines the attribute location of the attribute to disable
  104774. */
  104775. disableAttributeByIndex(attributeLocation: number): void;
  104776. /**
  104777. * Send a draw order
  104778. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104779. * @param indexStart defines the starting index
  104780. * @param indexCount defines the number of index to draw
  104781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104782. */
  104783. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104784. /**
  104785. * Draw a list of points
  104786. * @param verticesStart defines the index of first vertex to draw
  104787. * @param verticesCount defines the count of vertices to draw
  104788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104789. */
  104790. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104791. /**
  104792. * Draw a list of unindexed primitives
  104793. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104794. * @param verticesStart defines the index of first vertex to draw
  104795. * @param verticesCount defines the count of vertices to draw
  104796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104797. */
  104798. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104799. /**
  104800. * Draw a list of indexed primitives
  104801. * @param fillMode defines the primitive to use
  104802. * @param indexStart defines the starting index
  104803. * @param indexCount defines the number of index to draw
  104804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104805. */
  104806. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104807. /**
  104808. * Draw a list of unindexed primitives
  104809. * @param fillMode defines the primitive to use
  104810. * @param verticesStart defines the index of first vertex to draw
  104811. * @param verticesCount defines the count of vertices to draw
  104812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104813. */
  104814. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104815. private _drawMode;
  104816. /** @hidden */
  104817. protected _reportDrawCall(): void;
  104818. /** @hidden */
  104819. _releaseEffect(effect: Effect): void;
  104820. /** @hidden */
  104821. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104822. /**
  104823. * Create a new effect (used to store vertex/fragment shaders)
  104824. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104825. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104826. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104827. * @param samplers defines an array of string used to represent textures
  104828. * @param defines defines the string containing the defines to use to compile the shaders
  104829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104830. * @param onCompiled defines a function to call when the effect creation is successful
  104831. * @param onError defines a function to call when the effect creation has failed
  104832. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104833. * @returns the new Effect
  104834. */
  104835. 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;
  104836. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104837. private _compileShader;
  104838. private _compileRawShader;
  104839. /**
  104840. * Directly creates a webGL program
  104841. * @param pipelineContext defines the pipeline context to attach to
  104842. * @param vertexCode defines the vertex shader code to use
  104843. * @param fragmentCode defines the fragment shader code to use
  104844. * @param context defines the webGL context to use (if not set, the current one will be used)
  104845. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104846. * @returns the new webGL program
  104847. */
  104848. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104849. /**
  104850. * Creates a webGL program
  104851. * @param pipelineContext defines the pipeline context to attach to
  104852. * @param vertexCode defines the vertex shader code to use
  104853. * @param fragmentCode defines the fragment shader code to use
  104854. * @param defines defines the string containing the defines to use to compile the shaders
  104855. * @param context defines the webGL context to use (if not set, the current one will be used)
  104856. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104857. * @returns the new webGL program
  104858. */
  104859. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104860. /**
  104861. * Creates a new pipeline context
  104862. * @returns the new pipeline
  104863. */
  104864. createPipelineContext(): IPipelineContext;
  104865. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104866. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104867. /** @hidden */
  104868. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104869. /** @hidden */
  104870. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104871. /** @hidden */
  104872. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104873. /**
  104874. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104875. * @param pipelineContext defines the pipeline context to use
  104876. * @param uniformsNames defines the list of uniform names
  104877. * @returns an array of webGL uniform locations
  104878. */
  104879. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104880. /**
  104881. * Gets the lsit of active attributes for a given webGL program
  104882. * @param pipelineContext defines the pipeline context to use
  104883. * @param attributesNames defines the list of attribute names to get
  104884. * @returns an array of indices indicating the offset of each attribute
  104885. */
  104886. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104887. /**
  104888. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104889. * @param effect defines the effect to activate
  104890. */
  104891. enableEffect(effect: Nullable<Effect>): void;
  104892. /**
  104893. * Set the value of an uniform to a number (int)
  104894. * @param uniform defines the webGL uniform location where to store the value
  104895. * @param value defines the int number to store
  104896. */
  104897. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104898. /**
  104899. * Set the value of an uniform to an array of int32
  104900. * @param uniform defines the webGL uniform location where to store the value
  104901. * @param array defines the array of int32 to store
  104902. */
  104903. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104904. /**
  104905. * Set the value of an uniform to an array of int32 (stored as vec2)
  104906. * @param uniform defines the webGL uniform location where to store the value
  104907. * @param array defines the array of int32 to store
  104908. */
  104909. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104910. /**
  104911. * Set the value of an uniform to an array of int32 (stored as vec3)
  104912. * @param uniform defines the webGL uniform location where to store the value
  104913. * @param array defines the array of int32 to store
  104914. */
  104915. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104916. /**
  104917. * Set the value of an uniform to an array of int32 (stored as vec4)
  104918. * @param uniform defines the webGL uniform location where to store the value
  104919. * @param array defines the array of int32 to store
  104920. */
  104921. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104922. /**
  104923. * Set the value of an uniform to an array of number
  104924. * @param uniform defines the webGL uniform location where to store the value
  104925. * @param array defines the array of number to store
  104926. */
  104927. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104928. /**
  104929. * Set the value of an uniform to an array of number (stored as vec2)
  104930. * @param uniform defines the webGL uniform location where to store the value
  104931. * @param array defines the array of number to store
  104932. */
  104933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104934. /**
  104935. * Set the value of an uniform to an array of number (stored as vec3)
  104936. * @param uniform defines the webGL uniform location where to store the value
  104937. * @param array defines the array of number to store
  104938. */
  104939. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104940. /**
  104941. * Set the value of an uniform to an array of number (stored as vec4)
  104942. * @param uniform defines the webGL uniform location where to store the value
  104943. * @param array defines the array of number to store
  104944. */
  104945. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104946. /**
  104947. * Set the value of an uniform to an array of float32 (stored as matrices)
  104948. * @param uniform defines the webGL uniform location where to store the value
  104949. * @param matrices defines the array of float32 to store
  104950. */
  104951. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104952. /**
  104953. * Set the value of an uniform to a matrix (3x3)
  104954. * @param uniform defines the webGL uniform location where to store the value
  104955. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104956. */
  104957. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104958. /**
  104959. * Set the value of an uniform to a matrix (2x2)
  104960. * @param uniform defines the webGL uniform location where to store the value
  104961. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104962. */
  104963. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104964. /**
  104965. * Set the value of an uniform to a number (float)
  104966. * @param uniform defines the webGL uniform location where to store the value
  104967. * @param value defines the float number to store
  104968. */
  104969. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104970. /**
  104971. * Set the value of an uniform to a vec2
  104972. * @param uniform defines the webGL uniform location where to store the value
  104973. * @param x defines the 1st component of the value
  104974. * @param y defines the 2nd component of the value
  104975. */
  104976. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104977. /**
  104978. * Set the value of an uniform to a vec3
  104979. * @param uniform defines the webGL uniform location where to store the value
  104980. * @param x defines the 1st component of the value
  104981. * @param y defines the 2nd component of the value
  104982. * @param z defines the 3rd component of the value
  104983. */
  104984. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104985. /**
  104986. * Set the value of an uniform to a vec4
  104987. * @param uniform defines the webGL uniform location where to store the value
  104988. * @param x defines the 1st component of the value
  104989. * @param y defines the 2nd component of the value
  104990. * @param z defines the 3rd component of the value
  104991. * @param w defines the 4th component of the value
  104992. */
  104993. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104994. /**
  104995. * Apply all cached states (depth, culling, stencil and alpha)
  104996. */
  104997. applyStates(): void;
  104998. /**
  104999. * Enable or disable color writing
  105000. * @param enable defines the state to set
  105001. */
  105002. setColorWrite(enable: boolean): void;
  105003. /**
  105004. * Gets a boolean indicating if color writing is enabled
  105005. * @returns the current color writing state
  105006. */
  105007. getColorWrite(): boolean;
  105008. /**
  105009. * Gets the depth culling state manager
  105010. */
  105011. get depthCullingState(): DepthCullingState;
  105012. /**
  105013. * Gets the alpha state manager
  105014. */
  105015. get alphaState(): AlphaState;
  105016. /**
  105017. * Gets the stencil state manager
  105018. */
  105019. get stencilState(): StencilState;
  105020. /**
  105021. * Clears the list of texture accessible through engine.
  105022. * This can help preventing texture load conflict due to name collision.
  105023. */
  105024. clearInternalTexturesCache(): void;
  105025. /**
  105026. * Force the entire cache to be cleared
  105027. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105028. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105029. */
  105030. wipeCaches(bruteForce?: boolean): void;
  105031. /** @hidden */
  105032. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105033. min: number;
  105034. mag: number;
  105035. };
  105036. /** @hidden */
  105037. _createTexture(): WebGLTexture;
  105038. /**
  105039. * Usually called from Texture.ts.
  105040. * Passed information to create a WebGLTexture
  105041. * @param urlArg defines a value which contains one of the following:
  105042. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105043. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105044. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105045. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105046. * @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)
  105047. * @param scene needed for loading to the correct scene
  105048. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105049. * @param onLoad optional callback to be called upon successful completion
  105050. * @param onError optional callback to be called upon failure
  105051. * @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
  105052. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105053. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105054. * @param forcedExtension defines the extension to use to pick the right loader
  105055. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  105056. * @param mimeType defines an optional mime type
  105057. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105058. */
  105059. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  105060. /**
  105061. * Loads an image as an HTMLImageElement.
  105062. * @param input url string, ArrayBuffer, or Blob to load
  105063. * @param onLoad callback called when the image successfully loads
  105064. * @param onError callback called when the image fails to load
  105065. * @param offlineProvider offline provider for caching
  105066. * @param mimeType optional mime type
  105067. * @returns the HTMLImageElement of the loaded image
  105068. * @hidden
  105069. */
  105070. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  105071. /**
  105072. * @hidden
  105073. */
  105074. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105075. /**
  105076. * Creates a raw texture
  105077. * @param data defines the data to store in the texture
  105078. * @param width defines the width of the texture
  105079. * @param height defines the height of the texture
  105080. * @param format defines the format of the data
  105081. * @param generateMipMaps defines if the engine should generate the mip levels
  105082. * @param invertY defines if data must be stored with Y axis inverted
  105083. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105084. * @param compression defines the compression used (null by default)
  105085. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105086. * @returns the raw texture inside an InternalTexture
  105087. */
  105088. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105089. /**
  105090. * Creates a new raw cube texture
  105091. * @param data defines the array of data to use to create each face
  105092. * @param size defines the size of the textures
  105093. * @param format defines the format of the data
  105094. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105095. * @param generateMipMaps defines if the engine should generate the mip levels
  105096. * @param invertY defines if data must be stored with Y axis inverted
  105097. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105098. * @param compression defines the compression used (null by default)
  105099. * @returns the cube texture as an InternalTexture
  105100. */
  105101. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105102. /**
  105103. * Creates a new raw 3D texture
  105104. * @param data defines the data used to create the texture
  105105. * @param width defines the width of the texture
  105106. * @param height defines the height of the texture
  105107. * @param depth defines the depth of the texture
  105108. * @param format defines the format of the texture
  105109. * @param generateMipMaps defines if the engine must generate mip levels
  105110. * @param invertY defines if data must be stored with Y axis inverted
  105111. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105112. * @param compression defines the compressed used (can be null)
  105113. * @param textureType defines the compressed used (can be null)
  105114. * @returns a new raw 3D texture (stored in an InternalTexture)
  105115. */
  105116. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105117. /**
  105118. * Creates a new raw 2D array texture
  105119. * @param data defines the data used to create the texture
  105120. * @param width defines the width of the texture
  105121. * @param height defines the height of the texture
  105122. * @param depth defines the number of layers of the texture
  105123. * @param format defines the format of the texture
  105124. * @param generateMipMaps defines if the engine must generate mip levels
  105125. * @param invertY defines if data must be stored with Y axis inverted
  105126. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105127. * @param compression defines the compressed used (can be null)
  105128. * @param textureType defines the compressed used (can be null)
  105129. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105130. */
  105131. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105132. private _unpackFlipYCached;
  105133. /**
  105134. * In case you are sharing the context with other applications, it might
  105135. * be interested to not cache the unpack flip y state to ensure a consistent
  105136. * value would be set.
  105137. */
  105138. enableUnpackFlipYCached: boolean;
  105139. /** @hidden */
  105140. _unpackFlipY(value: boolean): void;
  105141. /** @hidden */
  105142. _getUnpackAlignement(): number;
  105143. private _getTextureTarget;
  105144. /**
  105145. * Update the sampling mode of a given texture
  105146. * @param samplingMode defines the required sampling mode
  105147. * @param texture defines the texture to update
  105148. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105149. */
  105150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105151. /**
  105152. * Update the sampling mode of a given texture
  105153. * @param texture defines the texture to update
  105154. * @param wrapU defines the texture wrap mode of the u coordinates
  105155. * @param wrapV defines the texture wrap mode of the v coordinates
  105156. * @param wrapR defines the texture wrap mode of the r coordinates
  105157. */
  105158. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105159. /** @hidden */
  105160. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105161. width: number;
  105162. height: number;
  105163. layers?: number;
  105164. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105165. /** @hidden */
  105166. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105167. /** @hidden */
  105168. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105169. /**
  105170. * Update a portion of an internal texture
  105171. * @param texture defines the texture to update
  105172. * @param imageData defines the data to store into the texture
  105173. * @param xOffset defines the x coordinates of the update rectangle
  105174. * @param yOffset defines the y coordinates of the update rectangle
  105175. * @param width defines the width of the update rectangle
  105176. * @param height defines the height of the update rectangle
  105177. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105178. * @param lod defines the lod level to update (0 by default)
  105179. */
  105180. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105181. /** @hidden */
  105182. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105183. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105184. private _prepareWebGLTexture;
  105185. /** @hidden */
  105186. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105187. private _getDepthStencilBuffer;
  105188. /** @hidden */
  105189. _releaseFramebufferObjects(texture: InternalTexture): void;
  105190. /** @hidden */
  105191. _releaseTexture(texture: InternalTexture): void;
  105192. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105193. protected _setProgram(program: WebGLProgram): void;
  105194. protected _boundUniforms: {
  105195. [key: number]: WebGLUniformLocation;
  105196. };
  105197. /**
  105198. * Binds an effect to the webGL context
  105199. * @param effect defines the effect to bind
  105200. */
  105201. bindSamplers(effect: Effect): void;
  105202. private _activateCurrentTexture;
  105203. /** @hidden */
  105204. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105205. /** @hidden */
  105206. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105207. /**
  105208. * Unbind all textures from the webGL context
  105209. */
  105210. unbindAllTextures(): void;
  105211. /**
  105212. * Sets a texture to the according uniform.
  105213. * @param channel The texture channel
  105214. * @param uniform The uniform to set
  105215. * @param texture The texture to apply
  105216. */
  105217. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105218. private _bindSamplerUniformToChannel;
  105219. private _getTextureWrapMode;
  105220. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105221. /**
  105222. * Sets an array of texture to the webGL context
  105223. * @param channel defines the channel where the texture array must be set
  105224. * @param uniform defines the associated uniform location
  105225. * @param textures defines the array of textures to bind
  105226. */
  105227. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105228. /** @hidden */
  105229. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105230. private _setTextureParameterFloat;
  105231. private _setTextureParameterInteger;
  105232. /**
  105233. * Unbind all vertex attributes from the webGL context
  105234. */
  105235. unbindAllAttributes(): void;
  105236. /**
  105237. * 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
  105238. */
  105239. releaseEffects(): void;
  105240. /**
  105241. * Dispose and release all associated resources
  105242. */
  105243. dispose(): void;
  105244. /**
  105245. * Attach a new callback raised when context lost event is fired
  105246. * @param callback defines the callback to call
  105247. */
  105248. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105249. /**
  105250. * Attach a new callback raised when context restored event is fired
  105251. * @param callback defines the callback to call
  105252. */
  105253. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105254. /**
  105255. * Get the current error code of the webGL context
  105256. * @returns the error code
  105257. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105258. */
  105259. getError(): number;
  105260. private _canRenderToFloatFramebuffer;
  105261. private _canRenderToHalfFloatFramebuffer;
  105262. private _canRenderToFramebuffer;
  105263. /** @hidden */
  105264. _getWebGLTextureType(type: number): number;
  105265. /** @hidden */
  105266. _getInternalFormat(format: number): number;
  105267. /** @hidden */
  105268. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105269. /** @hidden */
  105270. _getRGBAMultiSampleBufferFormat(type: number): number;
  105271. /** @hidden */
  105272. _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;
  105273. /**
  105274. * Loads a file from a url
  105275. * @param url url to load
  105276. * @param onSuccess callback called when the file successfully loads
  105277. * @param onProgress callback called while file is loading (if the server supports this mode)
  105278. * @param offlineProvider defines the offline provider for caching
  105279. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105280. * @param onError callback called when the file fails to load
  105281. * @returns a file request object
  105282. * @hidden
  105283. */
  105284. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105285. /**
  105286. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105287. * @param x defines the x coordinate of the rectangle where pixels must be read
  105288. * @param y defines the y coordinate of the rectangle where pixels must be read
  105289. * @param width defines the width of the rectangle where pixels must be read
  105290. * @param height defines the height of the rectangle where pixels must be read
  105291. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105292. * @returns a Uint8Array containing RGBA colors
  105293. */
  105294. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105295. private static _isSupported;
  105296. /**
  105297. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105298. * @returns true if the engine can be created
  105299. * @ignorenaming
  105300. */
  105301. static isSupported(): boolean;
  105302. /**
  105303. * Find the next highest power of two.
  105304. * @param x Number to start search from.
  105305. * @return Next highest power of two.
  105306. */
  105307. static CeilingPOT(x: number): number;
  105308. /**
  105309. * Find the next lowest power of two.
  105310. * @param x Number to start search from.
  105311. * @return Next lowest power of two.
  105312. */
  105313. static FloorPOT(x: number): number;
  105314. /**
  105315. * Find the nearest power of two.
  105316. * @param x Number to start search from.
  105317. * @return Next nearest power of two.
  105318. */
  105319. static NearestPOT(x: number): number;
  105320. /**
  105321. * Get the closest exponent of two
  105322. * @param value defines the value to approximate
  105323. * @param max defines the maximum value to return
  105324. * @param mode defines how to define the closest value
  105325. * @returns closest exponent of two of the given value
  105326. */
  105327. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105328. /**
  105329. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105330. * @param func - the function to be called
  105331. * @param requester - the object that will request the next frame. Falls back to window.
  105332. * @returns frame number
  105333. */
  105334. static QueueNewFrame(func: () => void, requester?: any): number;
  105335. /**
  105336. * Gets host document
  105337. * @returns the host document object
  105338. */
  105339. getHostDocument(): Nullable<Document>;
  105340. }
  105341. }
  105342. declare module BABYLON {
  105343. /**
  105344. * Class representing spherical harmonics coefficients to the 3rd degree
  105345. */
  105346. export class SphericalHarmonics {
  105347. /**
  105348. * Defines whether or not the harmonics have been prescaled for rendering.
  105349. */
  105350. preScaled: boolean;
  105351. /**
  105352. * The l0,0 coefficients of the spherical harmonics
  105353. */
  105354. l00: Vector3;
  105355. /**
  105356. * The l1,-1 coefficients of the spherical harmonics
  105357. */
  105358. l1_1: Vector3;
  105359. /**
  105360. * The l1,0 coefficients of the spherical harmonics
  105361. */
  105362. l10: Vector3;
  105363. /**
  105364. * The l1,1 coefficients of the spherical harmonics
  105365. */
  105366. l11: Vector3;
  105367. /**
  105368. * The l2,-2 coefficients of the spherical harmonics
  105369. */
  105370. l2_2: Vector3;
  105371. /**
  105372. * The l2,-1 coefficients of the spherical harmonics
  105373. */
  105374. l2_1: Vector3;
  105375. /**
  105376. * The l2,0 coefficients of the spherical harmonics
  105377. */
  105378. l20: Vector3;
  105379. /**
  105380. * The l2,1 coefficients of the spherical harmonics
  105381. */
  105382. l21: Vector3;
  105383. /**
  105384. * The l2,2 coefficients of the spherical harmonics
  105385. */
  105386. l22: Vector3;
  105387. /**
  105388. * Adds a light to the spherical harmonics
  105389. * @param direction the direction of the light
  105390. * @param color the color of the light
  105391. * @param deltaSolidAngle the delta solid angle of the light
  105392. */
  105393. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105394. /**
  105395. * Scales the spherical harmonics by the given amount
  105396. * @param scale the amount to scale
  105397. */
  105398. scaleInPlace(scale: number): void;
  105399. /**
  105400. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105401. *
  105402. * ```
  105403. * E_lm = A_l * L_lm
  105404. * ```
  105405. *
  105406. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105407. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105408. * the scaling factors are given in equation 9.
  105409. */
  105410. convertIncidentRadianceToIrradiance(): void;
  105411. /**
  105412. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105413. *
  105414. * ```
  105415. * L = (1/pi) * E * rho
  105416. * ```
  105417. *
  105418. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105419. */
  105420. convertIrradianceToLambertianRadiance(): void;
  105421. /**
  105422. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105423. * required operations at run time.
  105424. *
  105425. * This is simply done by scaling back the SH with Ylm constants parameter.
  105426. * The trigonometric part being applied by the shader at run time.
  105427. */
  105428. preScaleForRendering(): void;
  105429. /**
  105430. * Constructs a spherical harmonics from an array.
  105431. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105432. * @returns the spherical harmonics
  105433. */
  105434. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105435. /**
  105436. * Gets the spherical harmonics from polynomial
  105437. * @param polynomial the spherical polynomial
  105438. * @returns the spherical harmonics
  105439. */
  105440. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105441. }
  105442. /**
  105443. * Class representing spherical polynomial coefficients to the 3rd degree
  105444. */
  105445. export class SphericalPolynomial {
  105446. private _harmonics;
  105447. /**
  105448. * The spherical harmonics used to create the polynomials.
  105449. */
  105450. get preScaledHarmonics(): SphericalHarmonics;
  105451. /**
  105452. * The x coefficients of the spherical polynomial
  105453. */
  105454. x: Vector3;
  105455. /**
  105456. * The y coefficients of the spherical polynomial
  105457. */
  105458. y: Vector3;
  105459. /**
  105460. * The z coefficients of the spherical polynomial
  105461. */
  105462. z: Vector3;
  105463. /**
  105464. * The xx coefficients of the spherical polynomial
  105465. */
  105466. xx: Vector3;
  105467. /**
  105468. * The yy coefficients of the spherical polynomial
  105469. */
  105470. yy: Vector3;
  105471. /**
  105472. * The zz coefficients of the spherical polynomial
  105473. */
  105474. zz: Vector3;
  105475. /**
  105476. * The xy coefficients of the spherical polynomial
  105477. */
  105478. xy: Vector3;
  105479. /**
  105480. * The yz coefficients of the spherical polynomial
  105481. */
  105482. yz: Vector3;
  105483. /**
  105484. * The zx coefficients of the spherical polynomial
  105485. */
  105486. zx: Vector3;
  105487. /**
  105488. * Adds an ambient color to the spherical polynomial
  105489. * @param color the color to add
  105490. */
  105491. addAmbient(color: Color3): void;
  105492. /**
  105493. * Scales the spherical polynomial by the given amount
  105494. * @param scale the amount to scale
  105495. */
  105496. scaleInPlace(scale: number): void;
  105497. /**
  105498. * Gets the spherical polynomial from harmonics
  105499. * @param harmonics the spherical harmonics
  105500. * @returns the spherical polynomial
  105501. */
  105502. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105503. /**
  105504. * Constructs a spherical polynomial from an array.
  105505. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105506. * @returns the spherical polynomial
  105507. */
  105508. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105509. }
  105510. }
  105511. declare module BABYLON {
  105512. /**
  105513. * Defines the source of the internal texture
  105514. */
  105515. export enum InternalTextureSource {
  105516. /**
  105517. * The source of the texture data is unknown
  105518. */
  105519. Unknown = 0,
  105520. /**
  105521. * Texture data comes from an URL
  105522. */
  105523. Url = 1,
  105524. /**
  105525. * Texture data is only used for temporary storage
  105526. */
  105527. Temp = 2,
  105528. /**
  105529. * Texture data comes from raw data (ArrayBuffer)
  105530. */
  105531. Raw = 3,
  105532. /**
  105533. * Texture content is dynamic (video or dynamic texture)
  105534. */
  105535. Dynamic = 4,
  105536. /**
  105537. * Texture content is generated by rendering to it
  105538. */
  105539. RenderTarget = 5,
  105540. /**
  105541. * Texture content is part of a multi render target process
  105542. */
  105543. MultiRenderTarget = 6,
  105544. /**
  105545. * Texture data comes from a cube data file
  105546. */
  105547. Cube = 7,
  105548. /**
  105549. * Texture data comes from a raw cube data
  105550. */
  105551. CubeRaw = 8,
  105552. /**
  105553. * Texture data come from a prefiltered cube data file
  105554. */
  105555. CubePrefiltered = 9,
  105556. /**
  105557. * Texture content is raw 3D data
  105558. */
  105559. Raw3D = 10,
  105560. /**
  105561. * Texture content is raw 2D array data
  105562. */
  105563. Raw2DArray = 11,
  105564. /**
  105565. * Texture content is a depth texture
  105566. */
  105567. Depth = 12,
  105568. /**
  105569. * Texture data comes from a raw cube data encoded with RGBD
  105570. */
  105571. CubeRawRGBD = 13
  105572. }
  105573. /**
  105574. * Class used to store data associated with WebGL texture data for the engine
  105575. * This class should not be used directly
  105576. */
  105577. export class InternalTexture {
  105578. /** @hidden */
  105579. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105580. /**
  105581. * Defines if the texture is ready
  105582. */
  105583. isReady: boolean;
  105584. /**
  105585. * Defines if the texture is a cube texture
  105586. */
  105587. isCube: boolean;
  105588. /**
  105589. * Defines if the texture contains 3D data
  105590. */
  105591. is3D: boolean;
  105592. /**
  105593. * Defines if the texture contains 2D array data
  105594. */
  105595. is2DArray: boolean;
  105596. /**
  105597. * Defines if the texture contains multiview data
  105598. */
  105599. isMultiview: boolean;
  105600. /**
  105601. * Gets the URL used to load this texture
  105602. */
  105603. url: string;
  105604. /**
  105605. * Gets the sampling mode of the texture
  105606. */
  105607. samplingMode: number;
  105608. /**
  105609. * Gets a boolean indicating if the texture needs mipmaps generation
  105610. */
  105611. generateMipMaps: boolean;
  105612. /**
  105613. * Gets the number of samples used by the texture (WebGL2+ only)
  105614. */
  105615. samples: number;
  105616. /**
  105617. * Gets the type of the texture (int, float...)
  105618. */
  105619. type: number;
  105620. /**
  105621. * Gets the format of the texture (RGB, RGBA...)
  105622. */
  105623. format: number;
  105624. /**
  105625. * Observable called when the texture is loaded
  105626. */
  105627. onLoadedObservable: Observable<InternalTexture>;
  105628. /**
  105629. * Gets the width of the texture
  105630. */
  105631. width: number;
  105632. /**
  105633. * Gets the height of the texture
  105634. */
  105635. height: number;
  105636. /**
  105637. * Gets the depth of the texture
  105638. */
  105639. depth: number;
  105640. /**
  105641. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105642. */
  105643. baseWidth: number;
  105644. /**
  105645. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105646. */
  105647. baseHeight: number;
  105648. /**
  105649. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105650. */
  105651. baseDepth: number;
  105652. /**
  105653. * Gets a boolean indicating if the texture is inverted on Y axis
  105654. */
  105655. invertY: boolean;
  105656. /** @hidden */
  105657. _invertVScale: boolean;
  105658. /** @hidden */
  105659. _associatedChannel: number;
  105660. /** @hidden */
  105661. _source: InternalTextureSource;
  105662. /** @hidden */
  105663. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105664. /** @hidden */
  105665. _bufferView: Nullable<ArrayBufferView>;
  105666. /** @hidden */
  105667. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105668. /** @hidden */
  105669. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105670. /** @hidden */
  105671. _size: number;
  105672. /** @hidden */
  105673. _extension: string;
  105674. /** @hidden */
  105675. _files: Nullable<string[]>;
  105676. /** @hidden */
  105677. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105678. /** @hidden */
  105679. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105680. /** @hidden */
  105681. _framebuffer: Nullable<WebGLFramebuffer>;
  105682. /** @hidden */
  105683. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105684. /** @hidden */
  105685. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105686. /** @hidden */
  105687. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105688. /** @hidden */
  105689. _attachments: Nullable<number[]>;
  105690. /** @hidden */
  105691. _cachedCoordinatesMode: Nullable<number>;
  105692. /** @hidden */
  105693. _cachedWrapU: Nullable<number>;
  105694. /** @hidden */
  105695. _cachedWrapV: Nullable<number>;
  105696. /** @hidden */
  105697. _cachedWrapR: Nullable<number>;
  105698. /** @hidden */
  105699. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105700. /** @hidden */
  105701. _isDisabled: boolean;
  105702. /** @hidden */
  105703. _compression: Nullable<string>;
  105704. /** @hidden */
  105705. _generateStencilBuffer: boolean;
  105706. /** @hidden */
  105707. _generateDepthBuffer: boolean;
  105708. /** @hidden */
  105709. _comparisonFunction: number;
  105710. /** @hidden */
  105711. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105712. /** @hidden */
  105713. _lodGenerationScale: number;
  105714. /** @hidden */
  105715. _lodGenerationOffset: number;
  105716. /** @hidden */
  105717. _depthStencilTexture: Nullable<InternalTexture>;
  105718. /** @hidden */
  105719. _colorTextureArray: Nullable<WebGLTexture>;
  105720. /** @hidden */
  105721. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105722. /** @hidden */
  105723. _lodTextureHigh: Nullable<BaseTexture>;
  105724. /** @hidden */
  105725. _lodTextureMid: Nullable<BaseTexture>;
  105726. /** @hidden */
  105727. _lodTextureLow: Nullable<BaseTexture>;
  105728. /** @hidden */
  105729. _isRGBD: boolean;
  105730. /** @hidden */
  105731. _linearSpecularLOD: boolean;
  105732. /** @hidden */
  105733. _irradianceTexture: Nullable<BaseTexture>;
  105734. /** @hidden */
  105735. _webGLTexture: Nullable<WebGLTexture>;
  105736. /** @hidden */
  105737. _references: number;
  105738. private _engine;
  105739. /**
  105740. * Gets the Engine the texture belongs to.
  105741. * @returns The babylon engine
  105742. */
  105743. getEngine(): ThinEngine;
  105744. /**
  105745. * Gets the data source type of the texture
  105746. */
  105747. get source(): InternalTextureSource;
  105748. /**
  105749. * Creates a new InternalTexture
  105750. * @param engine defines the engine to use
  105751. * @param source defines the type of data that will be used
  105752. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105753. */
  105754. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105755. /**
  105756. * Increments the number of references (ie. the number of Texture that point to it)
  105757. */
  105758. incrementReferences(): void;
  105759. /**
  105760. * Change the size of the texture (not the size of the content)
  105761. * @param width defines the new width
  105762. * @param height defines the new height
  105763. * @param depth defines the new depth (1 by default)
  105764. */
  105765. updateSize(width: int, height: int, depth?: int): void;
  105766. /** @hidden */
  105767. _rebuild(): void;
  105768. /** @hidden */
  105769. _swapAndDie(target: InternalTexture): void;
  105770. /**
  105771. * Dispose the current allocated resources
  105772. */
  105773. dispose(): void;
  105774. }
  105775. }
  105776. declare module BABYLON {
  105777. /**
  105778. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105780. */
  105781. export class Analyser {
  105782. /**
  105783. * Gets or sets the smoothing
  105784. * @ignorenaming
  105785. */
  105786. SMOOTHING: number;
  105787. /**
  105788. * Gets or sets the FFT table size
  105789. * @ignorenaming
  105790. */
  105791. FFT_SIZE: number;
  105792. /**
  105793. * Gets or sets the bar graph amplitude
  105794. * @ignorenaming
  105795. */
  105796. BARGRAPHAMPLITUDE: number;
  105797. /**
  105798. * Gets or sets the position of the debug canvas
  105799. * @ignorenaming
  105800. */
  105801. DEBUGCANVASPOS: {
  105802. x: number;
  105803. y: number;
  105804. };
  105805. /**
  105806. * Gets or sets the debug canvas size
  105807. * @ignorenaming
  105808. */
  105809. DEBUGCANVASSIZE: {
  105810. width: number;
  105811. height: number;
  105812. };
  105813. private _byteFreqs;
  105814. private _byteTime;
  105815. private _floatFreqs;
  105816. private _webAudioAnalyser;
  105817. private _debugCanvas;
  105818. private _debugCanvasContext;
  105819. private _scene;
  105820. private _registerFunc;
  105821. private _audioEngine;
  105822. /**
  105823. * Creates a new analyser
  105824. * @param scene defines hosting scene
  105825. */
  105826. constructor(scene: Scene);
  105827. /**
  105828. * Get the number of data values you will have to play with for the visualization
  105829. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105830. * @returns a number
  105831. */
  105832. getFrequencyBinCount(): number;
  105833. /**
  105834. * Gets the current frequency data as a byte array
  105835. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105836. * @returns a Uint8Array
  105837. */
  105838. getByteFrequencyData(): Uint8Array;
  105839. /**
  105840. * Gets the current waveform as a byte array
  105841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105842. * @returns a Uint8Array
  105843. */
  105844. getByteTimeDomainData(): Uint8Array;
  105845. /**
  105846. * Gets the current frequency data as a float array
  105847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105848. * @returns a Float32Array
  105849. */
  105850. getFloatFrequencyData(): Float32Array;
  105851. /**
  105852. * Renders the debug canvas
  105853. */
  105854. drawDebugCanvas(): void;
  105855. /**
  105856. * Stops rendering the debug canvas and removes it
  105857. */
  105858. stopDebugCanvas(): void;
  105859. /**
  105860. * Connects two audio nodes
  105861. * @param inputAudioNode defines first node to connect
  105862. * @param outputAudioNode defines second node to connect
  105863. */
  105864. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105865. /**
  105866. * Releases all associated resources
  105867. */
  105868. dispose(): void;
  105869. }
  105870. }
  105871. declare module BABYLON {
  105872. /**
  105873. * This represents an audio engine and it is responsible
  105874. * to play, synchronize and analyse sounds throughout the application.
  105875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105876. */
  105877. export interface IAudioEngine extends IDisposable {
  105878. /**
  105879. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105880. */
  105881. readonly canUseWebAudio: boolean;
  105882. /**
  105883. * Gets the current AudioContext if available.
  105884. */
  105885. readonly audioContext: Nullable<AudioContext>;
  105886. /**
  105887. * The master gain node defines the global audio volume of your audio engine.
  105888. */
  105889. readonly masterGain: GainNode;
  105890. /**
  105891. * Gets whether or not mp3 are supported by your browser.
  105892. */
  105893. readonly isMP3supported: boolean;
  105894. /**
  105895. * Gets whether or not ogg are supported by your browser.
  105896. */
  105897. readonly isOGGsupported: boolean;
  105898. /**
  105899. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105900. * @ignoreNaming
  105901. */
  105902. WarnedWebAudioUnsupported: boolean;
  105903. /**
  105904. * Defines if the audio engine relies on a custom unlocked button.
  105905. * In this case, the embedded button will not be displayed.
  105906. */
  105907. useCustomUnlockedButton: boolean;
  105908. /**
  105909. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105910. */
  105911. readonly unlocked: boolean;
  105912. /**
  105913. * Event raised when audio has been unlocked on the browser.
  105914. */
  105915. onAudioUnlockedObservable: Observable<AudioEngine>;
  105916. /**
  105917. * Event raised when audio has been locked on the browser.
  105918. */
  105919. onAudioLockedObservable: Observable<AudioEngine>;
  105920. /**
  105921. * Flags the audio engine in Locked state.
  105922. * This happens due to new browser policies preventing audio to autoplay.
  105923. */
  105924. lock(): void;
  105925. /**
  105926. * Unlocks the audio engine once a user action has been done on the dom.
  105927. * This is helpful to resume play once browser policies have been satisfied.
  105928. */
  105929. unlock(): void;
  105930. }
  105931. /**
  105932. * This represents the default audio engine used in babylon.
  105933. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105935. */
  105936. export class AudioEngine implements IAudioEngine {
  105937. private _audioContext;
  105938. private _audioContextInitialized;
  105939. private _muteButton;
  105940. private _hostElement;
  105941. /**
  105942. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105943. */
  105944. canUseWebAudio: boolean;
  105945. /**
  105946. * The master gain node defines the global audio volume of your audio engine.
  105947. */
  105948. masterGain: GainNode;
  105949. /**
  105950. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105951. * @ignoreNaming
  105952. */
  105953. WarnedWebAudioUnsupported: boolean;
  105954. /**
  105955. * Gets whether or not mp3 are supported by your browser.
  105956. */
  105957. isMP3supported: boolean;
  105958. /**
  105959. * Gets whether or not ogg are supported by your browser.
  105960. */
  105961. isOGGsupported: boolean;
  105962. /**
  105963. * Gets whether audio has been unlocked on the device.
  105964. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105965. * a user interaction has happened.
  105966. */
  105967. unlocked: boolean;
  105968. /**
  105969. * Defines if the audio engine relies on a custom unlocked button.
  105970. * In this case, the embedded button will not be displayed.
  105971. */
  105972. useCustomUnlockedButton: boolean;
  105973. /**
  105974. * Event raised when audio has been unlocked on the browser.
  105975. */
  105976. onAudioUnlockedObservable: Observable<AudioEngine>;
  105977. /**
  105978. * Event raised when audio has been locked on the browser.
  105979. */
  105980. onAudioLockedObservable: Observable<AudioEngine>;
  105981. /**
  105982. * Gets the current AudioContext if available.
  105983. */
  105984. get audioContext(): Nullable<AudioContext>;
  105985. private _connectedAnalyser;
  105986. /**
  105987. * Instantiates a new audio engine.
  105988. *
  105989. * There should be only one per page as some browsers restrict the number
  105990. * of audio contexts you can create.
  105991. * @param hostElement defines the host element where to display the mute icon if necessary
  105992. */
  105993. constructor(hostElement?: Nullable<HTMLElement>);
  105994. /**
  105995. * Flags the audio engine in Locked state.
  105996. * This happens due to new browser policies preventing audio to autoplay.
  105997. */
  105998. lock(): void;
  105999. /**
  106000. * Unlocks the audio engine once a user action has been done on the dom.
  106001. * This is helpful to resume play once browser policies have been satisfied.
  106002. */
  106003. unlock(): void;
  106004. private _resumeAudioContext;
  106005. private _initializeAudioContext;
  106006. private _tryToRun;
  106007. private _triggerRunningState;
  106008. private _triggerSuspendedState;
  106009. private _displayMuteButton;
  106010. private _moveButtonToTopLeft;
  106011. private _onResize;
  106012. private _hideMuteButton;
  106013. /**
  106014. * Destroy and release the resources associated with the audio ccontext.
  106015. */
  106016. dispose(): void;
  106017. /**
  106018. * Gets the global volume sets on the master gain.
  106019. * @returns the global volume if set or -1 otherwise
  106020. */
  106021. getGlobalVolume(): number;
  106022. /**
  106023. * Sets the global volume of your experience (sets on the master gain).
  106024. * @param newVolume Defines the new global volume of the application
  106025. */
  106026. setGlobalVolume(newVolume: number): void;
  106027. /**
  106028. * Connect the audio engine to an audio analyser allowing some amazing
  106029. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106031. * @param analyser The analyser to connect to the engine
  106032. */
  106033. connectToAnalyser(analyser: Analyser): void;
  106034. }
  106035. }
  106036. declare module BABYLON {
  106037. /**
  106038. * Interface used to present a loading screen while loading a scene
  106039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106040. */
  106041. export interface ILoadingScreen {
  106042. /**
  106043. * Function called to display the loading screen
  106044. */
  106045. displayLoadingUI: () => void;
  106046. /**
  106047. * Function called to hide the loading screen
  106048. */
  106049. hideLoadingUI: () => void;
  106050. /**
  106051. * Gets or sets the color to use for the background
  106052. */
  106053. loadingUIBackgroundColor: string;
  106054. /**
  106055. * Gets or sets the text to display while loading
  106056. */
  106057. loadingUIText: string;
  106058. }
  106059. /**
  106060. * Class used for the default loading screen
  106061. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106062. */
  106063. export class DefaultLoadingScreen implements ILoadingScreen {
  106064. private _renderingCanvas;
  106065. private _loadingText;
  106066. private _loadingDivBackgroundColor;
  106067. private _loadingDiv;
  106068. private _loadingTextDiv;
  106069. /** Gets or sets the logo url to use for the default loading screen */
  106070. static DefaultLogoUrl: string;
  106071. /** Gets or sets the spinner url to use for the default loading screen */
  106072. static DefaultSpinnerUrl: string;
  106073. /**
  106074. * Creates a new default loading screen
  106075. * @param _renderingCanvas defines the canvas used to render the scene
  106076. * @param _loadingText defines the default text to display
  106077. * @param _loadingDivBackgroundColor defines the default background color
  106078. */
  106079. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106080. /**
  106081. * Function called to display the loading screen
  106082. */
  106083. displayLoadingUI(): void;
  106084. /**
  106085. * Function called to hide the loading screen
  106086. */
  106087. hideLoadingUI(): void;
  106088. /**
  106089. * Gets or sets the text to display while loading
  106090. */
  106091. set loadingUIText(text: string);
  106092. get loadingUIText(): string;
  106093. /**
  106094. * Gets or sets the color to use for the background
  106095. */
  106096. get loadingUIBackgroundColor(): string;
  106097. set loadingUIBackgroundColor(color: string);
  106098. private _resizeLoadingUI;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. /**
  106103. * Interface for any object that can request an animation frame
  106104. */
  106105. export interface ICustomAnimationFrameRequester {
  106106. /**
  106107. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106108. */
  106109. renderFunction?: Function;
  106110. /**
  106111. * Called to request the next frame to render to
  106112. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106113. */
  106114. requestAnimationFrame: Function;
  106115. /**
  106116. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106117. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106118. */
  106119. requestID?: number;
  106120. }
  106121. }
  106122. declare module BABYLON {
  106123. /**
  106124. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106125. */
  106126. export class PerformanceMonitor {
  106127. private _enabled;
  106128. private _rollingFrameTime;
  106129. private _lastFrameTimeMs;
  106130. /**
  106131. * constructor
  106132. * @param frameSampleSize The number of samples required to saturate the sliding window
  106133. */
  106134. constructor(frameSampleSize?: number);
  106135. /**
  106136. * Samples current frame
  106137. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106138. */
  106139. sampleFrame(timeMs?: number): void;
  106140. /**
  106141. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106142. */
  106143. get averageFrameTime(): number;
  106144. /**
  106145. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106146. */
  106147. get averageFrameTimeVariance(): number;
  106148. /**
  106149. * Returns the frame time of the most recent frame
  106150. */
  106151. get instantaneousFrameTime(): number;
  106152. /**
  106153. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106154. */
  106155. get averageFPS(): number;
  106156. /**
  106157. * Returns the average framerate in frames per second using the most recent frame time
  106158. */
  106159. get instantaneousFPS(): number;
  106160. /**
  106161. * Returns true if enough samples have been taken to completely fill the sliding window
  106162. */
  106163. get isSaturated(): boolean;
  106164. /**
  106165. * Enables contributions to the sliding window sample set
  106166. */
  106167. enable(): void;
  106168. /**
  106169. * Disables contributions to the sliding window sample set
  106170. * Samples will not be interpolated over the disabled period
  106171. */
  106172. disable(): void;
  106173. /**
  106174. * Returns true if sampling is enabled
  106175. */
  106176. get isEnabled(): boolean;
  106177. /**
  106178. * Resets performance monitor
  106179. */
  106180. reset(): void;
  106181. }
  106182. /**
  106183. * RollingAverage
  106184. *
  106185. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106186. */
  106187. export class RollingAverage {
  106188. /**
  106189. * Current average
  106190. */
  106191. average: number;
  106192. /**
  106193. * Current variance
  106194. */
  106195. variance: number;
  106196. protected _samples: Array<number>;
  106197. protected _sampleCount: number;
  106198. protected _pos: number;
  106199. protected _m2: number;
  106200. /**
  106201. * constructor
  106202. * @param length The number of samples required to saturate the sliding window
  106203. */
  106204. constructor(length: number);
  106205. /**
  106206. * Adds a sample to the sample set
  106207. * @param v The sample value
  106208. */
  106209. add(v: number): void;
  106210. /**
  106211. * Returns previously added values or null if outside of history or outside the sliding window domain
  106212. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106213. * @return Value previously recorded with add() or null if outside of range
  106214. */
  106215. history(i: number): number;
  106216. /**
  106217. * Returns true if enough samples have been taken to completely fill the sliding window
  106218. * @return true if sample-set saturated
  106219. */
  106220. isSaturated(): boolean;
  106221. /**
  106222. * Resets the rolling average (equivalent to 0 samples taken so far)
  106223. */
  106224. reset(): void;
  106225. /**
  106226. * Wraps a value around the sample range boundaries
  106227. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106228. * @return Wrapped position in sample range
  106229. */
  106230. protected _wrapPosition(i: number): number;
  106231. }
  106232. }
  106233. declare module BABYLON {
  106234. /**
  106235. * This class is used to track a performance counter which is number based.
  106236. * The user has access to many properties which give statistics of different nature.
  106237. *
  106238. * The implementer can track two kinds of Performance Counter: time and count.
  106239. * 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.
  106240. * 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.
  106241. */
  106242. export class PerfCounter {
  106243. /**
  106244. * Gets or sets a global boolean to turn on and off all the counters
  106245. */
  106246. static Enabled: boolean;
  106247. /**
  106248. * Returns the smallest value ever
  106249. */
  106250. get min(): number;
  106251. /**
  106252. * Returns the biggest value ever
  106253. */
  106254. get max(): number;
  106255. /**
  106256. * Returns the average value since the performance counter is running
  106257. */
  106258. get average(): number;
  106259. /**
  106260. * Returns the average value of the last second the counter was monitored
  106261. */
  106262. get lastSecAverage(): number;
  106263. /**
  106264. * Returns the current value
  106265. */
  106266. get current(): number;
  106267. /**
  106268. * Gets the accumulated total
  106269. */
  106270. get total(): number;
  106271. /**
  106272. * Gets the total value count
  106273. */
  106274. get count(): number;
  106275. /**
  106276. * Creates a new counter
  106277. */
  106278. constructor();
  106279. /**
  106280. * Call this method to start monitoring a new frame.
  106281. * 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.
  106282. */
  106283. fetchNewFrame(): void;
  106284. /**
  106285. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106286. * @param newCount the count value to add to the monitored count
  106287. * @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.
  106288. */
  106289. addCount(newCount: number, fetchResult: boolean): void;
  106290. /**
  106291. * Start monitoring this performance counter
  106292. */
  106293. beginMonitoring(): void;
  106294. /**
  106295. * Compute the time lapsed since the previous beginMonitoring() call.
  106296. * @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
  106297. */
  106298. endMonitoring(newFrame?: boolean): void;
  106299. private _fetchResult;
  106300. private _startMonitoringTime;
  106301. private _min;
  106302. private _max;
  106303. private _average;
  106304. private _current;
  106305. private _totalValueCount;
  106306. private _totalAccumulated;
  106307. private _lastSecAverage;
  106308. private _lastSecAccumulated;
  106309. private _lastSecTime;
  106310. private _lastSecValueCount;
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. interface ThinEngine {
  106315. /**
  106316. * Sets alpha constants used by some alpha blending modes
  106317. * @param r defines the red component
  106318. * @param g defines the green component
  106319. * @param b defines the blue component
  106320. * @param a defines the alpha component
  106321. */
  106322. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106323. /**
  106324. * Sets the current alpha mode
  106325. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106326. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106327. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106328. */
  106329. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106330. /**
  106331. * Gets the current alpha mode
  106332. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106333. * @returns the current alpha mode
  106334. */
  106335. getAlphaMode(): number;
  106336. /**
  106337. * Sets the current alpha equation
  106338. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106339. */
  106340. setAlphaEquation(equation: number): void;
  106341. /**
  106342. * Gets the current alpha equation.
  106343. * @returns the current alpha equation
  106344. */
  106345. getAlphaEquation(): number;
  106346. }
  106347. }
  106348. declare module BABYLON {
  106349. /**
  106350. * Defines the interface used by display changed events
  106351. */
  106352. export interface IDisplayChangedEventArgs {
  106353. /** Gets the vrDisplay object (if any) */
  106354. vrDisplay: Nullable<any>;
  106355. /** Gets a boolean indicating if webVR is supported */
  106356. vrSupported: boolean;
  106357. }
  106358. /**
  106359. * Defines the interface used by objects containing a viewport (like a camera)
  106360. */
  106361. interface IViewportOwnerLike {
  106362. /**
  106363. * Gets or sets the viewport
  106364. */
  106365. viewport: IViewportLike;
  106366. }
  106367. /**
  106368. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106369. */
  106370. export class Engine extends ThinEngine {
  106371. /** Defines that alpha blending is disabled */
  106372. static readonly ALPHA_DISABLE: number;
  106373. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106374. static readonly ALPHA_ADD: number;
  106375. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106376. static readonly ALPHA_COMBINE: number;
  106377. /** Defines that alpha blending to DEST - SRC * DEST */
  106378. static readonly ALPHA_SUBTRACT: number;
  106379. /** Defines that alpha blending to SRC * DEST */
  106380. static readonly ALPHA_MULTIPLY: number;
  106381. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106382. static readonly ALPHA_MAXIMIZED: number;
  106383. /** Defines that alpha blending to SRC + DEST */
  106384. static readonly ALPHA_ONEONE: number;
  106385. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106386. static readonly ALPHA_PREMULTIPLIED: number;
  106387. /**
  106388. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106389. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106390. */
  106391. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106392. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106393. static readonly ALPHA_INTERPOLATE: number;
  106394. /**
  106395. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106396. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106397. */
  106398. static readonly ALPHA_SCREENMODE: number;
  106399. /** Defines that the ressource is not delayed*/
  106400. static readonly DELAYLOADSTATE_NONE: number;
  106401. /** Defines that the ressource was successfully delay loaded */
  106402. static readonly DELAYLOADSTATE_LOADED: number;
  106403. /** Defines that the ressource is currently delay loading */
  106404. static readonly DELAYLOADSTATE_LOADING: number;
  106405. /** Defines that the ressource is delayed and has not started loading */
  106406. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106408. static readonly NEVER: number;
  106409. /** 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 */
  106410. static readonly ALWAYS: number;
  106411. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106412. static readonly LESS: number;
  106413. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106414. static readonly EQUAL: number;
  106415. /** 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 */
  106416. static readonly LEQUAL: number;
  106417. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106418. static readonly GREATER: number;
  106419. /** 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 */
  106420. static readonly GEQUAL: number;
  106421. /** 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 */
  106422. static readonly NOTEQUAL: number;
  106423. /** Passed to stencilOperation to specify that stencil value must be kept */
  106424. static readonly KEEP: number;
  106425. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106426. static readonly REPLACE: number;
  106427. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106428. static readonly INCR: number;
  106429. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106430. static readonly DECR: number;
  106431. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106432. static readonly INVERT: number;
  106433. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106434. static readonly INCR_WRAP: number;
  106435. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106436. static readonly DECR_WRAP: number;
  106437. /** Texture is not repeating outside of 0..1 UVs */
  106438. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106439. /** Texture is repeating outside of 0..1 UVs */
  106440. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106441. /** Texture is repeating and mirrored */
  106442. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106443. /** ALPHA */
  106444. static readonly TEXTUREFORMAT_ALPHA: number;
  106445. /** LUMINANCE */
  106446. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106447. /** LUMINANCE_ALPHA */
  106448. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106449. /** RGB */
  106450. static readonly TEXTUREFORMAT_RGB: number;
  106451. /** RGBA */
  106452. static readonly TEXTUREFORMAT_RGBA: number;
  106453. /** RED */
  106454. static readonly TEXTUREFORMAT_RED: number;
  106455. /** RED (2nd reference) */
  106456. static readonly TEXTUREFORMAT_R: number;
  106457. /** RG */
  106458. static readonly TEXTUREFORMAT_RG: number;
  106459. /** RED_INTEGER */
  106460. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106461. /** RED_INTEGER (2nd reference) */
  106462. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106463. /** RG_INTEGER */
  106464. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106465. /** RGB_INTEGER */
  106466. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106467. /** RGBA_INTEGER */
  106468. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106469. /** UNSIGNED_BYTE */
  106470. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106471. /** UNSIGNED_BYTE (2nd reference) */
  106472. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106473. /** FLOAT */
  106474. static readonly TEXTURETYPE_FLOAT: number;
  106475. /** HALF_FLOAT */
  106476. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106477. /** BYTE */
  106478. static readonly TEXTURETYPE_BYTE: number;
  106479. /** SHORT */
  106480. static readonly TEXTURETYPE_SHORT: number;
  106481. /** UNSIGNED_SHORT */
  106482. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106483. /** INT */
  106484. static readonly TEXTURETYPE_INT: number;
  106485. /** UNSIGNED_INT */
  106486. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106487. /** UNSIGNED_SHORT_4_4_4_4 */
  106488. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106489. /** UNSIGNED_SHORT_5_5_5_1 */
  106490. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106491. /** UNSIGNED_SHORT_5_6_5 */
  106492. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106493. /** UNSIGNED_INT_2_10_10_10_REV */
  106494. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106495. /** UNSIGNED_INT_24_8 */
  106496. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106497. /** UNSIGNED_INT_10F_11F_11F_REV */
  106498. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106499. /** UNSIGNED_INT_5_9_9_9_REV */
  106500. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106501. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106502. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106503. /** nearest is mag = nearest and min = nearest and mip = linear */
  106504. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106505. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106506. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106507. /** Trilinear is mag = linear and min = linear and mip = linear */
  106508. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106509. /** nearest is mag = nearest and min = nearest and mip = linear */
  106510. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106511. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106512. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106513. /** Trilinear is mag = linear and min = linear and mip = linear */
  106514. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106515. /** mag = nearest and min = nearest and mip = nearest */
  106516. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106517. /** mag = nearest and min = linear and mip = nearest */
  106518. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106519. /** mag = nearest and min = linear and mip = linear */
  106520. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106521. /** mag = nearest and min = linear and mip = none */
  106522. static readonly TEXTURE_NEAREST_LINEAR: number;
  106523. /** mag = nearest and min = nearest and mip = none */
  106524. static readonly TEXTURE_NEAREST_NEAREST: number;
  106525. /** mag = linear and min = nearest and mip = nearest */
  106526. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106527. /** mag = linear and min = nearest and mip = linear */
  106528. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106529. /** mag = linear and min = linear and mip = none */
  106530. static readonly TEXTURE_LINEAR_LINEAR: number;
  106531. /** mag = linear and min = nearest and mip = none */
  106532. static readonly TEXTURE_LINEAR_NEAREST: number;
  106533. /** Explicit coordinates mode */
  106534. static readonly TEXTURE_EXPLICIT_MODE: number;
  106535. /** Spherical coordinates mode */
  106536. static readonly TEXTURE_SPHERICAL_MODE: number;
  106537. /** Planar coordinates mode */
  106538. static readonly TEXTURE_PLANAR_MODE: number;
  106539. /** Cubic coordinates mode */
  106540. static readonly TEXTURE_CUBIC_MODE: number;
  106541. /** Projection coordinates mode */
  106542. static readonly TEXTURE_PROJECTION_MODE: number;
  106543. /** Skybox coordinates mode */
  106544. static readonly TEXTURE_SKYBOX_MODE: number;
  106545. /** Inverse Cubic coordinates mode */
  106546. static readonly TEXTURE_INVCUBIC_MODE: number;
  106547. /** Equirectangular coordinates mode */
  106548. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106549. /** Equirectangular Fixed coordinates mode */
  106550. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106551. /** Equirectangular Fixed Mirrored coordinates mode */
  106552. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106553. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106554. static readonly SCALEMODE_FLOOR: number;
  106555. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106556. static readonly SCALEMODE_NEAREST: number;
  106557. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106558. static readonly SCALEMODE_CEILING: number;
  106559. /**
  106560. * Returns the current npm package of the sdk
  106561. */
  106562. static get NpmPackage(): string;
  106563. /**
  106564. * Returns the current version of the framework
  106565. */
  106566. static get Version(): string;
  106567. /** Gets the list of created engines */
  106568. static get Instances(): Engine[];
  106569. /**
  106570. * Gets the latest created engine
  106571. */
  106572. static get LastCreatedEngine(): Nullable<Engine>;
  106573. /**
  106574. * Gets the latest created scene
  106575. */
  106576. static get LastCreatedScene(): Nullable<Scene>;
  106577. /**
  106578. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106579. * @param flag defines which part of the materials must be marked as dirty
  106580. * @param predicate defines a predicate used to filter which materials should be affected
  106581. */
  106582. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106583. /**
  106584. * Method called to create the default loading screen.
  106585. * This can be overriden in your own app.
  106586. * @param canvas The rendering canvas element
  106587. * @returns The loading screen
  106588. */
  106589. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106590. /**
  106591. * Method called to create the default rescale post process on each engine.
  106592. */
  106593. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106594. /**
  106595. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106596. **/
  106597. enableOfflineSupport: boolean;
  106598. /**
  106599. * 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)
  106600. **/
  106601. disableManifestCheck: boolean;
  106602. /**
  106603. * Gets the list of created scenes
  106604. */
  106605. scenes: Scene[];
  106606. /**
  106607. * Event raised when a new scene is created
  106608. */
  106609. onNewSceneAddedObservable: Observable<Scene>;
  106610. /**
  106611. * Gets the list of created postprocesses
  106612. */
  106613. postProcesses: PostProcess[];
  106614. /**
  106615. * Gets a boolean indicating if the pointer is currently locked
  106616. */
  106617. isPointerLock: boolean;
  106618. /**
  106619. * Observable event triggered each time the rendering canvas is resized
  106620. */
  106621. onResizeObservable: Observable<Engine>;
  106622. /**
  106623. * Observable event triggered each time the canvas loses focus
  106624. */
  106625. onCanvasBlurObservable: Observable<Engine>;
  106626. /**
  106627. * Observable event triggered each time the canvas gains focus
  106628. */
  106629. onCanvasFocusObservable: Observable<Engine>;
  106630. /**
  106631. * Observable event triggered each time the canvas receives pointerout event
  106632. */
  106633. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106634. /**
  106635. * Observable raised when the engine begins a new frame
  106636. */
  106637. onBeginFrameObservable: Observable<Engine>;
  106638. /**
  106639. * If set, will be used to request the next animation frame for the render loop
  106640. */
  106641. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106642. /**
  106643. * Observable raised when the engine ends the current frame
  106644. */
  106645. onEndFrameObservable: Observable<Engine>;
  106646. /**
  106647. * Observable raised when the engine is about to compile a shader
  106648. */
  106649. onBeforeShaderCompilationObservable: Observable<Engine>;
  106650. /**
  106651. * Observable raised when the engine has jsut compiled a shader
  106652. */
  106653. onAfterShaderCompilationObservable: Observable<Engine>;
  106654. /**
  106655. * Gets the audio engine
  106656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106657. * @ignorenaming
  106658. */
  106659. static audioEngine: IAudioEngine;
  106660. /**
  106661. * Default AudioEngine factory responsible of creating the Audio Engine.
  106662. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106663. */
  106664. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106665. /**
  106666. * Default offline support factory responsible of creating a tool used to store data locally.
  106667. * By default, this will create a Database object if the workload has been embedded.
  106668. */
  106669. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106670. private _loadingScreen;
  106671. private _pointerLockRequested;
  106672. private _dummyFramebuffer;
  106673. private _rescalePostProcess;
  106674. private _deterministicLockstep;
  106675. private _lockstepMaxSteps;
  106676. private _timeStep;
  106677. protected get _supportsHardwareTextureRescaling(): boolean;
  106678. private _fps;
  106679. private _deltaTime;
  106680. /** @hidden */
  106681. _drawCalls: PerfCounter;
  106682. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  106683. canvasTabIndex: number;
  106684. /**
  106685. * Turn this value on if you want to pause FPS computation when in background
  106686. */
  106687. disablePerformanceMonitorInBackground: boolean;
  106688. private _performanceMonitor;
  106689. /**
  106690. * Gets the performance monitor attached to this engine
  106691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106692. */
  106693. get performanceMonitor(): PerformanceMonitor;
  106694. private _onFocus;
  106695. private _onBlur;
  106696. private _onCanvasPointerOut;
  106697. private _onCanvasBlur;
  106698. private _onCanvasFocus;
  106699. private _onFullscreenChange;
  106700. private _onPointerLockChange;
  106701. /**
  106702. * Gets the HTML element used to attach event listeners
  106703. * @returns a HTML element
  106704. */
  106705. getInputElement(): Nullable<HTMLElement>;
  106706. /**
  106707. * Creates a new engine
  106708. * @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
  106709. * @param antialias defines enable antialiasing (default: false)
  106710. * @param options defines further options to be sent to the getContext() function
  106711. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106712. */
  106713. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106714. /**
  106715. * Gets current aspect ratio
  106716. * @param viewportOwner defines the camera to use to get the aspect ratio
  106717. * @param useScreen defines if screen size must be used (or the current render target if any)
  106718. * @returns a number defining the aspect ratio
  106719. */
  106720. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106721. /**
  106722. * Gets current screen aspect ratio
  106723. * @returns a number defining the aspect ratio
  106724. */
  106725. getScreenAspectRatio(): number;
  106726. /**
  106727. * Gets the client rect of the HTML canvas attached with the current webGL context
  106728. * @returns a client rectanglee
  106729. */
  106730. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106731. /**
  106732. * Gets the client rect of the HTML element used for events
  106733. * @returns a client rectanglee
  106734. */
  106735. getInputElementClientRect(): Nullable<ClientRect>;
  106736. /**
  106737. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106739. * @returns true if engine is in deterministic lock step mode
  106740. */
  106741. isDeterministicLockStep(): boolean;
  106742. /**
  106743. * Gets the max steps when engine is running in deterministic lock step
  106744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106745. * @returns the max steps
  106746. */
  106747. getLockstepMaxSteps(): number;
  106748. /**
  106749. * Returns the time in ms between steps when using deterministic lock step.
  106750. * @returns time step in (ms)
  106751. */
  106752. getTimeStep(): number;
  106753. /**
  106754. * Force the mipmap generation for the given render target texture
  106755. * @param texture defines the render target texture to use
  106756. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106757. */
  106758. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106759. /** States */
  106760. /**
  106761. * Set various states to the webGL context
  106762. * @param culling defines backface culling state
  106763. * @param zOffset defines the value to apply to zOffset (0 by default)
  106764. * @param force defines if states must be applied even if cache is up to date
  106765. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106766. */
  106767. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106768. /**
  106769. * Set the z offset to apply to current rendering
  106770. * @param value defines the offset to apply
  106771. */
  106772. setZOffset(value: number): void;
  106773. /**
  106774. * Gets the current value of the zOffset
  106775. * @returns the current zOffset state
  106776. */
  106777. getZOffset(): number;
  106778. /**
  106779. * Enable or disable depth buffering
  106780. * @param enable defines the state to set
  106781. */
  106782. setDepthBuffer(enable: boolean): void;
  106783. /**
  106784. * Gets a boolean indicating if depth writing is enabled
  106785. * @returns the current depth writing state
  106786. */
  106787. getDepthWrite(): boolean;
  106788. /**
  106789. * Enable or disable depth writing
  106790. * @param enable defines the state to set
  106791. */
  106792. setDepthWrite(enable: boolean): void;
  106793. /**
  106794. * Gets a boolean indicating if stencil buffer is enabled
  106795. * @returns the current stencil buffer state
  106796. */
  106797. getStencilBuffer(): boolean;
  106798. /**
  106799. * Enable or disable the stencil buffer
  106800. * @param enable defines if the stencil buffer must be enabled or disabled
  106801. */
  106802. setStencilBuffer(enable: boolean): void;
  106803. /**
  106804. * Gets the current stencil mask
  106805. * @returns a number defining the new stencil mask to use
  106806. */
  106807. getStencilMask(): number;
  106808. /**
  106809. * Sets the current stencil mask
  106810. * @param mask defines the new stencil mask to use
  106811. */
  106812. setStencilMask(mask: number): void;
  106813. /**
  106814. * Gets the current stencil function
  106815. * @returns a number defining the stencil function to use
  106816. */
  106817. getStencilFunction(): number;
  106818. /**
  106819. * Gets the current stencil reference value
  106820. * @returns a number defining the stencil reference value to use
  106821. */
  106822. getStencilFunctionReference(): number;
  106823. /**
  106824. * Gets the current stencil mask
  106825. * @returns a number defining the stencil mask to use
  106826. */
  106827. getStencilFunctionMask(): number;
  106828. /**
  106829. * Sets the current stencil function
  106830. * @param stencilFunc defines the new stencil function to use
  106831. */
  106832. setStencilFunction(stencilFunc: number): void;
  106833. /**
  106834. * Sets the current stencil reference
  106835. * @param reference defines the new stencil reference to use
  106836. */
  106837. setStencilFunctionReference(reference: number): void;
  106838. /**
  106839. * Sets the current stencil mask
  106840. * @param mask defines the new stencil mask to use
  106841. */
  106842. setStencilFunctionMask(mask: number): void;
  106843. /**
  106844. * Gets the current stencil operation when stencil fails
  106845. * @returns a number defining stencil operation to use when stencil fails
  106846. */
  106847. getStencilOperationFail(): number;
  106848. /**
  106849. * Gets the current stencil operation when depth fails
  106850. * @returns a number defining stencil operation to use when depth fails
  106851. */
  106852. getStencilOperationDepthFail(): number;
  106853. /**
  106854. * Gets the current stencil operation when stencil passes
  106855. * @returns a number defining stencil operation to use when stencil passes
  106856. */
  106857. getStencilOperationPass(): number;
  106858. /**
  106859. * Sets the stencil operation to use when stencil fails
  106860. * @param operation defines the stencil operation to use when stencil fails
  106861. */
  106862. setStencilOperationFail(operation: number): void;
  106863. /**
  106864. * Sets the stencil operation to use when depth fails
  106865. * @param operation defines the stencil operation to use when depth fails
  106866. */
  106867. setStencilOperationDepthFail(operation: number): void;
  106868. /**
  106869. * Sets the stencil operation to use when stencil passes
  106870. * @param operation defines the stencil operation to use when stencil passes
  106871. */
  106872. setStencilOperationPass(operation: number): void;
  106873. /**
  106874. * Sets a boolean indicating if the dithering state is enabled or disabled
  106875. * @param value defines the dithering state
  106876. */
  106877. setDitheringState(value: boolean): void;
  106878. /**
  106879. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106880. * @param value defines the rasterizer state
  106881. */
  106882. setRasterizerState(value: boolean): void;
  106883. /**
  106884. * Gets the current depth function
  106885. * @returns a number defining the depth function
  106886. */
  106887. getDepthFunction(): Nullable<number>;
  106888. /**
  106889. * Sets the current depth function
  106890. * @param depthFunc defines the function to use
  106891. */
  106892. setDepthFunction(depthFunc: number): void;
  106893. /**
  106894. * Sets the current depth function to GREATER
  106895. */
  106896. setDepthFunctionToGreater(): void;
  106897. /**
  106898. * Sets the current depth function to GEQUAL
  106899. */
  106900. setDepthFunctionToGreaterOrEqual(): void;
  106901. /**
  106902. * Sets the current depth function to LESS
  106903. */
  106904. setDepthFunctionToLess(): void;
  106905. /**
  106906. * Sets the current depth function to LEQUAL
  106907. */
  106908. setDepthFunctionToLessOrEqual(): void;
  106909. private _cachedStencilBuffer;
  106910. private _cachedStencilFunction;
  106911. private _cachedStencilMask;
  106912. private _cachedStencilOperationPass;
  106913. private _cachedStencilOperationFail;
  106914. private _cachedStencilOperationDepthFail;
  106915. private _cachedStencilReference;
  106916. /**
  106917. * Caches the the state of the stencil buffer
  106918. */
  106919. cacheStencilState(): void;
  106920. /**
  106921. * Restores the state of the stencil buffer
  106922. */
  106923. restoreStencilState(): void;
  106924. /**
  106925. * Directly set the WebGL Viewport
  106926. * @param x defines the x coordinate of the viewport (in screen space)
  106927. * @param y defines the y coordinate of the viewport (in screen space)
  106928. * @param width defines the width of the viewport (in screen space)
  106929. * @param height defines the height of the viewport (in screen space)
  106930. * @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
  106931. */
  106932. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106933. /**
  106934. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106935. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106936. * @param y defines the y-coordinate of the corner of the clear rectangle
  106937. * @param width defines the width of the clear rectangle
  106938. * @param height defines the height of the clear rectangle
  106939. * @param clearColor defines the clear color
  106940. */
  106941. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106942. /**
  106943. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106944. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106945. * @param y defines the y-coordinate of the corner of the clear rectangle
  106946. * @param width defines the width of the clear rectangle
  106947. * @param height defines the height of the clear rectangle
  106948. */
  106949. enableScissor(x: number, y: number, width: number, height: number): void;
  106950. /**
  106951. * Disable previously set scissor test rectangle
  106952. */
  106953. disableScissor(): void;
  106954. protected _reportDrawCall(): void;
  106955. /**
  106956. * Initializes a webVR display and starts listening to display change events
  106957. * The onVRDisplayChangedObservable will be notified upon these changes
  106958. * @returns The onVRDisplayChangedObservable
  106959. */
  106960. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106961. /** @hidden */
  106962. _prepareVRComponent(): void;
  106963. /** @hidden */
  106964. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106965. /** @hidden */
  106966. _submitVRFrame(): void;
  106967. /**
  106968. * Call this function to leave webVR mode
  106969. * Will do nothing if webVR is not supported or if there is no webVR device
  106970. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106971. */
  106972. disableVR(): void;
  106973. /**
  106974. * Gets a boolean indicating that the system is in VR mode and is presenting
  106975. * @returns true if VR mode is engaged
  106976. */
  106977. isVRPresenting(): boolean;
  106978. /** @hidden */
  106979. _requestVRFrame(): void;
  106980. /** @hidden */
  106981. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106982. /**
  106983. * Gets the source code of the vertex shader associated with a specific webGL program
  106984. * @param program defines the program to use
  106985. * @returns a string containing the source code of the vertex shader associated with the program
  106986. */
  106987. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106988. /**
  106989. * Gets the source code of the fragment shader associated with a specific webGL program
  106990. * @param program defines the program to use
  106991. * @returns a string containing the source code of the fragment shader associated with the program
  106992. */
  106993. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106994. /**
  106995. * Sets a depth stencil texture from a render target to the according uniform.
  106996. * @param channel The texture channel
  106997. * @param uniform The uniform to set
  106998. * @param texture The render target texture containing the depth stencil texture to apply
  106999. */
  107000. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107001. /**
  107002. * Sets a texture to the webGL context from a postprocess
  107003. * @param channel defines the channel to use
  107004. * @param postProcess defines the source postprocess
  107005. */
  107006. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107007. /**
  107008. * Binds the output of the passed in post process to the texture channel specified
  107009. * @param channel The channel the texture should be bound to
  107010. * @param postProcess The post process which's output should be bound
  107011. */
  107012. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107013. /** @hidden */
  107014. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107015. protected _rebuildBuffers(): void;
  107016. /** @hidden */
  107017. _renderFrame(): void;
  107018. _renderLoop(): void;
  107019. /** @hidden */
  107020. _renderViews(): boolean;
  107021. /**
  107022. * Toggle full screen mode
  107023. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107024. */
  107025. switchFullscreen(requestPointerLock: boolean): void;
  107026. /**
  107027. * Enters full screen mode
  107028. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107029. */
  107030. enterFullscreen(requestPointerLock: boolean): void;
  107031. /**
  107032. * Exits full screen mode
  107033. */
  107034. exitFullscreen(): void;
  107035. /**
  107036. * Enters Pointerlock mode
  107037. */
  107038. enterPointerlock(): void;
  107039. /**
  107040. * Exits Pointerlock mode
  107041. */
  107042. exitPointerlock(): void;
  107043. /**
  107044. * Begin a new frame
  107045. */
  107046. beginFrame(): void;
  107047. /**
  107048. * Enf the current frame
  107049. */
  107050. endFrame(): void;
  107051. resize(): void;
  107052. /**
  107053. * Set the compressed texture format to use, based on the formats you have, and the formats
  107054. * supported by the hardware / browser.
  107055. *
  107056. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  107057. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  107058. * to API arguments needed to compressed textures. This puts the burden on the container
  107059. * generator to house the arcane code for determining these for current & future formats.
  107060. *
  107061. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  107062. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  107063. *
  107064. * Note: The result of this call is not taken into account when a texture is base64.
  107065. *
  107066. * @param formatsAvailable defines the list of those format families you have created
  107067. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  107068. *
  107069. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  107070. * @returns The extension selected.
  107071. */
  107072. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  107073. /**
  107074. * Set the compressed texture extensions or file names to skip.
  107075. *
  107076. * @param skippedFiles defines the list of those texture files you want to skip
  107077. * Example: [".dds", ".env", "myfile.png"]
  107078. */
  107079. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  107080. /**
  107081. * Force a specific size of the canvas
  107082. * @param width defines the new canvas' width
  107083. * @param height defines the new canvas' height
  107084. */
  107085. setSize(width: number, height: number): void;
  107086. /**
  107087. * Updates a dynamic vertex buffer.
  107088. * @param vertexBuffer the vertex buffer to update
  107089. * @param data the data used to update the vertex buffer
  107090. * @param byteOffset the byte offset of the data
  107091. * @param byteLength the byte length of the data
  107092. */
  107093. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107094. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107096. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107097. _releaseTexture(texture: InternalTexture): void;
  107098. /**
  107099. * @hidden
  107100. * Rescales a texture
  107101. * @param source input texutre
  107102. * @param destination destination texture
  107103. * @param scene scene to use to render the resize
  107104. * @param internalFormat format to use when resizing
  107105. * @param onComplete callback to be called when resize has completed
  107106. */
  107107. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107108. /**
  107109. * Gets the current framerate
  107110. * @returns a number representing the framerate
  107111. */
  107112. getFps(): number;
  107113. /**
  107114. * Gets the time spent between current and previous frame
  107115. * @returns a number representing the delta time in ms
  107116. */
  107117. getDeltaTime(): number;
  107118. private _measureFps;
  107119. /** @hidden */
  107120. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107121. /**
  107122. * Update a dynamic index buffer
  107123. * @param indexBuffer defines the target index buffer
  107124. * @param indices defines the data to update
  107125. * @param offset defines the offset in the target index buffer where update should start
  107126. */
  107127. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107128. /**
  107129. * Updates the sample count of a render target texture
  107130. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107131. * @param texture defines the texture to update
  107132. * @param samples defines the sample count to set
  107133. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107134. */
  107135. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107136. /**
  107137. * Updates a depth texture Comparison Mode and Function.
  107138. * If the comparison Function is equal to 0, the mode will be set to none.
  107139. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107140. * @param texture The texture to set the comparison function for
  107141. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107142. */
  107143. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107144. /**
  107145. * Creates a webGL buffer to use with instanciation
  107146. * @param capacity defines the size of the buffer
  107147. * @returns the webGL buffer
  107148. */
  107149. createInstancesBuffer(capacity: number): DataBuffer;
  107150. /**
  107151. * Delete a webGL buffer used with instanciation
  107152. * @param buffer defines the webGL buffer to delete
  107153. */
  107154. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107155. /** @hidden */
  107156. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107157. dispose(): void;
  107158. private _disableTouchAction;
  107159. /**
  107160. * Display the loading screen
  107161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107162. */
  107163. displayLoadingUI(): void;
  107164. /**
  107165. * Hide the loading screen
  107166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107167. */
  107168. hideLoadingUI(): void;
  107169. /**
  107170. * Gets the current loading screen object
  107171. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107172. */
  107173. get loadingScreen(): ILoadingScreen;
  107174. /**
  107175. * Sets the current loading screen object
  107176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107177. */
  107178. set loadingScreen(loadingScreen: ILoadingScreen);
  107179. /**
  107180. * Sets the current loading screen text
  107181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107182. */
  107183. set loadingUIText(text: string);
  107184. /**
  107185. * Sets the current loading screen background color
  107186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107187. */
  107188. set loadingUIBackgroundColor(color: string);
  107189. /** Pointerlock and fullscreen */
  107190. /**
  107191. * Ask the browser to promote the current element to pointerlock mode
  107192. * @param element defines the DOM element to promote
  107193. */
  107194. static _RequestPointerlock(element: HTMLElement): void;
  107195. /**
  107196. * Asks the browser to exit pointerlock mode
  107197. */
  107198. static _ExitPointerlock(): void;
  107199. /**
  107200. * Ask the browser to promote the current element to fullscreen rendering mode
  107201. * @param element defines the DOM element to promote
  107202. */
  107203. static _RequestFullscreen(element: HTMLElement): void;
  107204. /**
  107205. * Asks the browser to exit fullscreen mode
  107206. */
  107207. static _ExitFullscreen(): void;
  107208. }
  107209. }
  107210. declare module BABYLON {
  107211. /**
  107212. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107213. * during the life time of the application.
  107214. */
  107215. export class EngineStore {
  107216. /** Gets the list of created engines */
  107217. static Instances: Engine[];
  107218. /** @hidden */
  107219. static _LastCreatedScene: Nullable<Scene>;
  107220. /**
  107221. * Gets the latest created engine
  107222. */
  107223. static get LastCreatedEngine(): Nullable<Engine>;
  107224. /**
  107225. * Gets the latest created scene
  107226. */
  107227. static get LastCreatedScene(): Nullable<Scene>;
  107228. /**
  107229. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107230. * @ignorenaming
  107231. */
  107232. static UseFallbackTexture: boolean;
  107233. /**
  107234. * Texture content used if a texture cannot loaded
  107235. * @ignorenaming
  107236. */
  107237. static FallbackTexture: string;
  107238. }
  107239. }
  107240. declare module BABYLON {
  107241. /**
  107242. * Helper class that provides a small promise polyfill
  107243. */
  107244. export class PromisePolyfill {
  107245. /**
  107246. * Static function used to check if the polyfill is required
  107247. * If this is the case then the function will inject the polyfill to window.Promise
  107248. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107249. */
  107250. static Apply(force?: boolean): void;
  107251. }
  107252. }
  107253. declare module BABYLON {
  107254. /**
  107255. * Interface for screenshot methods with describe argument called `size` as object with options
  107256. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107257. */
  107258. export interface IScreenshotSize {
  107259. /**
  107260. * number in pixels for canvas height
  107261. */
  107262. height?: number;
  107263. /**
  107264. * multiplier allowing render at a higher or lower resolution
  107265. * If value is defined then height and width will be ignored and taken from camera
  107266. */
  107267. precision?: number;
  107268. /**
  107269. * number in pixels for canvas width
  107270. */
  107271. width?: number;
  107272. }
  107273. }
  107274. declare module BABYLON {
  107275. interface IColor4Like {
  107276. r: float;
  107277. g: float;
  107278. b: float;
  107279. a: float;
  107280. }
  107281. /**
  107282. * Class containing a set of static utilities functions
  107283. */
  107284. export class Tools {
  107285. /**
  107286. * Gets or sets the base URL to use to load assets
  107287. */
  107288. static get BaseUrl(): string;
  107289. static set BaseUrl(value: string);
  107290. /**
  107291. * Enable/Disable Custom HTTP Request Headers globally.
  107292. * default = false
  107293. * @see CustomRequestHeaders
  107294. */
  107295. static UseCustomRequestHeaders: boolean;
  107296. /**
  107297. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107298. * i.e. when loading files, where the server/service expects an Authorization header
  107299. */
  107300. static CustomRequestHeaders: {
  107301. [key: string]: string;
  107302. };
  107303. /**
  107304. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107305. */
  107306. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107307. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107308. /**
  107309. * Default behaviour for cors in the application.
  107310. * It can be a string if the expected behavior is identical in the entire app.
  107311. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107312. */
  107313. static CorsBehavior: string | ((url: string | string[]) => string);
  107314. /**
  107315. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107316. * @ignorenaming
  107317. */
  107318. static get UseFallbackTexture(): boolean;
  107319. static set UseFallbackTexture(value: boolean);
  107320. /**
  107321. * Use this object to register external classes like custom textures or material
  107322. * to allow the laoders to instantiate them
  107323. */
  107324. static get RegisteredExternalClasses(): {
  107325. [key: string]: Object;
  107326. };
  107327. static set RegisteredExternalClasses(classes: {
  107328. [key: string]: Object;
  107329. });
  107330. /**
  107331. * Texture content used if a texture cannot loaded
  107332. * @ignorenaming
  107333. */
  107334. static get fallbackTexture(): string;
  107335. static set fallbackTexture(value: string);
  107336. /**
  107337. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107338. * @param u defines the coordinate on X axis
  107339. * @param v defines the coordinate on Y axis
  107340. * @param width defines the width of the source data
  107341. * @param height defines the height of the source data
  107342. * @param pixels defines the source byte array
  107343. * @param color defines the output color
  107344. */
  107345. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107346. /**
  107347. * Interpolates between a and b via alpha
  107348. * @param a The lower value (returned when alpha = 0)
  107349. * @param b The upper value (returned when alpha = 1)
  107350. * @param alpha The interpolation-factor
  107351. * @return The mixed value
  107352. */
  107353. static Mix(a: number, b: number, alpha: number): number;
  107354. /**
  107355. * Tries to instantiate a new object from a given class name
  107356. * @param className defines the class name to instantiate
  107357. * @returns the new object or null if the system was not able to do the instantiation
  107358. */
  107359. static Instantiate(className: string): any;
  107360. /**
  107361. * Provides a slice function that will work even on IE
  107362. * @param data defines the array to slice
  107363. * @param start defines the start of the data (optional)
  107364. * @param end defines the end of the data (optional)
  107365. * @returns the new sliced array
  107366. */
  107367. static Slice<T>(data: T, start?: number, end?: number): T;
  107368. /**
  107369. * Polyfill for setImmediate
  107370. * @param action defines the action to execute after the current execution block
  107371. */
  107372. static SetImmediate(action: () => void): void;
  107373. /**
  107374. * Function indicating if a number is an exponent of 2
  107375. * @param value defines the value to test
  107376. * @returns true if the value is an exponent of 2
  107377. */
  107378. static IsExponentOfTwo(value: number): boolean;
  107379. private static _tmpFloatArray;
  107380. /**
  107381. * Returns the nearest 32-bit single precision float representation of a Number
  107382. * @param value A Number. If the parameter is of a different type, it will get converted
  107383. * to a number or to NaN if it cannot be converted
  107384. * @returns number
  107385. */
  107386. static FloatRound(value: number): number;
  107387. /**
  107388. * Extracts the filename from a path
  107389. * @param path defines the path to use
  107390. * @returns the filename
  107391. */
  107392. static GetFilename(path: string): string;
  107393. /**
  107394. * Extracts the "folder" part of a path (everything before the filename).
  107395. * @param uri The URI to extract the info from
  107396. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107397. * @returns The "folder" part of the path
  107398. */
  107399. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107400. /**
  107401. * Extracts text content from a DOM element hierarchy
  107402. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107403. */
  107404. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107405. /**
  107406. * Convert an angle in radians to degrees
  107407. * @param angle defines the angle to convert
  107408. * @returns the angle in degrees
  107409. */
  107410. static ToDegrees(angle: number): number;
  107411. /**
  107412. * Convert an angle in degrees to radians
  107413. * @param angle defines the angle to convert
  107414. * @returns the angle in radians
  107415. */
  107416. static ToRadians(angle: number): number;
  107417. /**
  107418. * Returns an array if obj is not an array
  107419. * @param obj defines the object to evaluate as an array
  107420. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107421. * @returns either obj directly if obj is an array or a new array containing obj
  107422. */
  107423. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107424. /**
  107425. * Gets the pointer prefix to use
  107426. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107427. */
  107428. static GetPointerPrefix(): string;
  107429. /**
  107430. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107431. * @param url define the url we are trying
  107432. * @param element define the dom element where to configure the cors policy
  107433. */
  107434. static SetCorsBehavior(url: string | string[], element: {
  107435. crossOrigin: string | null;
  107436. }): void;
  107437. /**
  107438. * Removes unwanted characters from an url
  107439. * @param url defines the url to clean
  107440. * @returns the cleaned url
  107441. */
  107442. static CleanUrl(url: string): string;
  107443. /**
  107444. * Gets or sets a function used to pre-process url before using them to load assets
  107445. */
  107446. static get PreprocessUrl(): (url: string) => string;
  107447. static set PreprocessUrl(processor: (url: string) => string);
  107448. /**
  107449. * Loads an image as an HTMLImageElement.
  107450. * @param input url string, ArrayBuffer, or Blob to load
  107451. * @param onLoad callback called when the image successfully loads
  107452. * @param onError callback called when the image fails to load
  107453. * @param offlineProvider offline provider for caching
  107454. * @param mimeType optional mime type
  107455. * @returns the HTMLImageElement of the loaded image
  107456. */
  107457. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107458. /**
  107459. * Loads a file from a url
  107460. * @param url url string, ArrayBuffer, or Blob to load
  107461. * @param onSuccess callback called when the file successfully loads
  107462. * @param onProgress callback called while file is loading (if the server supports this mode)
  107463. * @param offlineProvider defines the offline provider for caching
  107464. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107465. * @param onError callback called when the file fails to load
  107466. * @returns a file request object
  107467. */
  107468. 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;
  107469. /**
  107470. * Loads a file from a url
  107471. * @param url the file url to load
  107472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107473. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107474. */
  107475. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107476. /**
  107477. * Load a script (identified by an url). When the url returns, the
  107478. * content of this file is added into a new script element, attached to the DOM (body element)
  107479. * @param scriptUrl defines the url of the script to laod
  107480. * @param onSuccess defines the callback called when the script is loaded
  107481. * @param onError defines the callback to call if an error occurs
  107482. * @param scriptId defines the id of the script element
  107483. */
  107484. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107485. /**
  107486. * Load an asynchronous script (identified by an url). When the url returns, the
  107487. * content of this file is added into a new script element, attached to the DOM (body element)
  107488. * @param scriptUrl defines the url of the script to laod
  107489. * @param scriptId defines the id of the script element
  107490. * @returns a promise request object
  107491. */
  107492. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107493. /**
  107494. * Loads a file from a blob
  107495. * @param fileToLoad defines the blob to use
  107496. * @param callback defines the callback to call when data is loaded
  107497. * @param progressCallback defines the callback to call during loading process
  107498. * @returns a file request object
  107499. */
  107500. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107501. /**
  107502. * Reads a file from a File object
  107503. * @param file defines the file to load
  107504. * @param onSuccess defines the callback to call when data is loaded
  107505. * @param onProgress defines the callback to call during loading process
  107506. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107507. * @param onError defines the callback to call when an error occurs
  107508. * @returns a file request object
  107509. */
  107510. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107511. /**
  107512. * Creates a data url from a given string content
  107513. * @param content defines the content to convert
  107514. * @returns the new data url link
  107515. */
  107516. static FileAsURL(content: string): string;
  107517. /**
  107518. * Format the given number to a specific decimal format
  107519. * @param value defines the number to format
  107520. * @param decimals defines the number of decimals to use
  107521. * @returns the formatted string
  107522. */
  107523. static Format(value: number, decimals?: number): string;
  107524. /**
  107525. * Tries to copy an object by duplicating every property
  107526. * @param source defines the source object
  107527. * @param destination defines the target object
  107528. * @param doNotCopyList defines a list of properties to avoid
  107529. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107530. */
  107531. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107532. /**
  107533. * Gets a boolean indicating if the given object has no own property
  107534. * @param obj defines the object to test
  107535. * @returns true if object has no own property
  107536. */
  107537. static IsEmpty(obj: any): boolean;
  107538. /**
  107539. * Function used to register events at window level
  107540. * @param windowElement defines the Window object to use
  107541. * @param events defines the events to register
  107542. */
  107543. static RegisterTopRootEvents(windowElement: Window, events: {
  107544. name: string;
  107545. handler: Nullable<(e: FocusEvent) => any>;
  107546. }[]): void;
  107547. /**
  107548. * Function used to unregister events from window level
  107549. * @param windowElement defines the Window object to use
  107550. * @param events defines the events to unregister
  107551. */
  107552. static UnregisterTopRootEvents(windowElement: Window, events: {
  107553. name: string;
  107554. handler: Nullable<(e: FocusEvent) => any>;
  107555. }[]): void;
  107556. /**
  107557. * @ignore
  107558. */
  107559. static _ScreenshotCanvas: HTMLCanvasElement;
  107560. /**
  107561. * Dumps the current bound framebuffer
  107562. * @param width defines the rendering width
  107563. * @param height defines the rendering height
  107564. * @param engine defines the hosting engine
  107565. * @param successCallback defines the callback triggered once the data are available
  107566. * @param mimeType defines the mime type of the result
  107567. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107568. */
  107569. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107570. /**
  107571. * Converts the canvas data to blob.
  107572. * This acts as a polyfill for browsers not supporting the to blob function.
  107573. * @param canvas Defines the canvas to extract the data from
  107574. * @param successCallback Defines the callback triggered once the data are available
  107575. * @param mimeType Defines the mime type of the result
  107576. */
  107577. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107578. /**
  107579. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107580. * @param successCallback defines the callback triggered once the data are available
  107581. * @param mimeType defines the mime type of the result
  107582. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107583. */
  107584. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107585. /**
  107586. * Downloads a blob in the browser
  107587. * @param blob defines the blob to download
  107588. * @param fileName defines the name of the downloaded file
  107589. */
  107590. static Download(blob: Blob, fileName: string): void;
  107591. /**
  107592. * Captures a screenshot of the current rendering
  107593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107594. * @param engine defines the rendering engine
  107595. * @param camera defines the source camera
  107596. * @param size This parameter can be set to a single number or to an object with the
  107597. * following (optional) properties: precision, width, height. If a single number is passed,
  107598. * it will be used for both width and height. If an object is passed, the screenshot size
  107599. * will be derived from the parameters. The precision property is a multiplier allowing
  107600. * rendering at a higher or lower resolution
  107601. * @param successCallback defines the callback receives a single parameter which contains the
  107602. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107603. * src parameter of an <img> to display it
  107604. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107605. * Check your browser for supported MIME types
  107606. */
  107607. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107608. /**
  107609. * Captures a screenshot of the current rendering
  107610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107611. * @param engine defines the rendering engine
  107612. * @param camera defines the source camera
  107613. * @param size This parameter can be set to a single number or to an object with the
  107614. * following (optional) properties: precision, width, height. If a single number is passed,
  107615. * it will be used for both width and height. If an object is passed, the screenshot size
  107616. * will be derived from the parameters. The precision property is a multiplier allowing
  107617. * rendering at a higher or lower resolution
  107618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107619. * Check your browser for supported MIME types
  107620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107621. * to the src parameter of an <img> to display it
  107622. */
  107623. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107624. /**
  107625. * Generates an image screenshot from the specified camera.
  107626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107627. * @param engine The engine to use for rendering
  107628. * @param camera The camera to use for rendering
  107629. * @param size This parameter can be set to a single number or to an object with the
  107630. * following (optional) properties: precision, width, height. If a single number is passed,
  107631. * it will be used for both width and height. If an object is passed, the screenshot size
  107632. * will be derived from the parameters. The precision property is a multiplier allowing
  107633. * rendering at a higher or lower resolution
  107634. * @param successCallback The callback receives a single parameter which contains the
  107635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107636. * src parameter of an <img> to display it
  107637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107638. * Check your browser for supported MIME types
  107639. * @param samples Texture samples (default: 1)
  107640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107641. * @param fileName A name for for the downloaded file.
  107642. */
  107643. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107644. /**
  107645. * Generates an image screenshot from the specified camera.
  107646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107647. * @param engine The engine to use for rendering
  107648. * @param camera The camera to use for rendering
  107649. * @param size This parameter can be set to a single number or to an object with the
  107650. * following (optional) properties: precision, width, height. If a single number is passed,
  107651. * it will be used for both width and height. If an object is passed, the screenshot size
  107652. * will be derived from the parameters. The precision property is a multiplier allowing
  107653. * rendering at a higher or lower resolution
  107654. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107655. * Check your browser for supported MIME types
  107656. * @param samples Texture samples (default: 1)
  107657. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107658. * @param fileName A name for for the downloaded file.
  107659. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107660. * to the src parameter of an <img> to display it
  107661. */
  107662. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107663. /**
  107664. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107665. * Be aware Math.random() could cause collisions, but:
  107666. * "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"
  107667. * @returns a pseudo random id
  107668. */
  107669. static RandomId(): string;
  107670. /**
  107671. * Test if the given uri is a base64 string
  107672. * @param uri The uri to test
  107673. * @return True if the uri is a base64 string or false otherwise
  107674. */
  107675. static IsBase64(uri: string): boolean;
  107676. /**
  107677. * Decode the given base64 uri.
  107678. * @param uri The uri to decode
  107679. * @return The decoded base64 data.
  107680. */
  107681. static DecodeBase64(uri: string): ArrayBuffer;
  107682. /**
  107683. * Gets the absolute url.
  107684. * @param url the input url
  107685. * @return the absolute url
  107686. */
  107687. static GetAbsoluteUrl(url: string): string;
  107688. /**
  107689. * No log
  107690. */
  107691. static readonly NoneLogLevel: number;
  107692. /**
  107693. * Only message logs
  107694. */
  107695. static readonly MessageLogLevel: number;
  107696. /**
  107697. * Only warning logs
  107698. */
  107699. static readonly WarningLogLevel: number;
  107700. /**
  107701. * Only error logs
  107702. */
  107703. static readonly ErrorLogLevel: number;
  107704. /**
  107705. * All logs
  107706. */
  107707. static readonly AllLogLevel: number;
  107708. /**
  107709. * Gets a value indicating the number of loading errors
  107710. * @ignorenaming
  107711. */
  107712. static get errorsCount(): number;
  107713. /**
  107714. * Callback called when a new log is added
  107715. */
  107716. static OnNewCacheEntry: (entry: string) => void;
  107717. /**
  107718. * Log a message to the console
  107719. * @param message defines the message to log
  107720. */
  107721. static Log(message: string): void;
  107722. /**
  107723. * Write a warning message to the console
  107724. * @param message defines the message to log
  107725. */
  107726. static Warn(message: string): void;
  107727. /**
  107728. * Write an error message to the console
  107729. * @param message defines the message to log
  107730. */
  107731. static Error(message: string): void;
  107732. /**
  107733. * Gets current log cache (list of logs)
  107734. */
  107735. static get LogCache(): string;
  107736. /**
  107737. * Clears the log cache
  107738. */
  107739. static ClearLogCache(): void;
  107740. /**
  107741. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107742. */
  107743. static set LogLevels(level: number);
  107744. /**
  107745. * Checks if the window object exists
  107746. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107747. */
  107748. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107749. /**
  107750. * No performance log
  107751. */
  107752. static readonly PerformanceNoneLogLevel: number;
  107753. /**
  107754. * Use user marks to log performance
  107755. */
  107756. static readonly PerformanceUserMarkLogLevel: number;
  107757. /**
  107758. * Log performance to the console
  107759. */
  107760. static readonly PerformanceConsoleLogLevel: number;
  107761. private static _performance;
  107762. /**
  107763. * Sets the current performance log level
  107764. */
  107765. static set PerformanceLogLevel(level: number);
  107766. private static _StartPerformanceCounterDisabled;
  107767. private static _EndPerformanceCounterDisabled;
  107768. private static _StartUserMark;
  107769. private static _EndUserMark;
  107770. private static _StartPerformanceConsole;
  107771. private static _EndPerformanceConsole;
  107772. /**
  107773. * Starts a performance counter
  107774. */
  107775. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107776. /**
  107777. * Ends a specific performance coutner
  107778. */
  107779. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107780. /**
  107781. * Gets either window.performance.now() if supported or Date.now() else
  107782. */
  107783. static get Now(): number;
  107784. /**
  107785. * This method will return the name of the class used to create the instance of the given object.
  107786. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107787. * @param object the object to get the class name from
  107788. * @param isType defines if the object is actually a type
  107789. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107790. */
  107791. static GetClassName(object: any, isType?: boolean): string;
  107792. /**
  107793. * Gets the first element of an array satisfying a given predicate
  107794. * @param array defines the array to browse
  107795. * @param predicate defines the predicate to use
  107796. * @returns null if not found or the element
  107797. */
  107798. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107799. /**
  107800. * This method will return the name of the full name of the class, including its owning module (if any).
  107801. * 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).
  107802. * @param object the object to get the class name from
  107803. * @param isType defines if the object is actually a type
  107804. * @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.
  107805. * @ignorenaming
  107806. */
  107807. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107808. /**
  107809. * Returns a promise that resolves after the given amount of time.
  107810. * @param delay Number of milliseconds to delay
  107811. * @returns Promise that resolves after the given amount of time
  107812. */
  107813. static DelayAsync(delay: number): Promise<void>;
  107814. /**
  107815. * Utility function to detect if the current user agent is Safari
  107816. * @returns whether or not the current user agent is safari
  107817. */
  107818. static IsSafari(): boolean;
  107819. }
  107820. /**
  107821. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107822. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107823. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107824. * @param name The name of the class, case should be preserved
  107825. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107826. */
  107827. export function className(name: string, module?: string): (target: Object) => void;
  107828. /**
  107829. * An implementation of a loop for asynchronous functions.
  107830. */
  107831. export class AsyncLoop {
  107832. /**
  107833. * Defines the number of iterations for the loop
  107834. */
  107835. iterations: number;
  107836. /**
  107837. * Defines the current index of the loop.
  107838. */
  107839. index: number;
  107840. private _done;
  107841. private _fn;
  107842. private _successCallback;
  107843. /**
  107844. * Constructor.
  107845. * @param iterations the number of iterations.
  107846. * @param func the function to run each iteration
  107847. * @param successCallback the callback that will be called upon succesful execution
  107848. * @param offset starting offset.
  107849. */
  107850. constructor(
  107851. /**
  107852. * Defines the number of iterations for the loop
  107853. */
  107854. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107855. /**
  107856. * Execute the next iteration. Must be called after the last iteration was finished.
  107857. */
  107858. executeNext(): void;
  107859. /**
  107860. * Break the loop and run the success callback.
  107861. */
  107862. breakLoop(): void;
  107863. /**
  107864. * Create and run an async loop.
  107865. * @param iterations the number of iterations.
  107866. * @param fn the function to run each iteration
  107867. * @param successCallback the callback that will be called upon succesful execution
  107868. * @param offset starting offset.
  107869. * @returns the created async loop object
  107870. */
  107871. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107872. /**
  107873. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107874. * @param iterations total number of iterations
  107875. * @param syncedIterations number of synchronous iterations in each async iteration.
  107876. * @param fn the function to call each iteration.
  107877. * @param callback a success call back that will be called when iterating stops.
  107878. * @param breakFunction a break condition (optional)
  107879. * @param timeout timeout settings for the setTimeout function. default - 0.
  107880. * @returns the created async loop object
  107881. */
  107882. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107883. }
  107884. }
  107885. declare module BABYLON {
  107886. /**
  107887. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107888. * The underlying implementation relies on an associative array to ensure the best performances.
  107889. * The value can be anything including 'null' but except 'undefined'
  107890. */
  107891. export class StringDictionary<T> {
  107892. /**
  107893. * This will clear this dictionary and copy the content from the 'source' one.
  107894. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107895. * @param source the dictionary to take the content from and copy to this dictionary
  107896. */
  107897. copyFrom(source: StringDictionary<T>): void;
  107898. /**
  107899. * Get a value based from its key
  107900. * @param key the given key to get the matching value from
  107901. * @return the value if found, otherwise undefined is returned
  107902. */
  107903. get(key: string): T | undefined;
  107904. /**
  107905. * Get a value from its key or add it if it doesn't exist.
  107906. * This method will ensure you that a given key/data will be present in the dictionary.
  107907. * @param key the given key to get the matching value from
  107908. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107909. * The factory will only be invoked if there's no data for the given key.
  107910. * @return the value corresponding to the key.
  107911. */
  107912. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107913. /**
  107914. * Get a value from its key if present in the dictionary otherwise add it
  107915. * @param key the key to get the value from
  107916. * @param val if there's no such key/value pair in the dictionary add it with this value
  107917. * @return the value corresponding to the key
  107918. */
  107919. getOrAdd(key: string, val: T): T;
  107920. /**
  107921. * Check if there's a given key in the dictionary
  107922. * @param key the key to check for
  107923. * @return true if the key is present, false otherwise
  107924. */
  107925. contains(key: string): boolean;
  107926. /**
  107927. * Add a new key and its corresponding value
  107928. * @param key the key to add
  107929. * @param value the value corresponding to the key
  107930. * @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
  107931. */
  107932. add(key: string, value: T): boolean;
  107933. /**
  107934. * Update a specific value associated to a key
  107935. * @param key defines the key to use
  107936. * @param value defines the value to store
  107937. * @returns true if the value was updated (or false if the key was not found)
  107938. */
  107939. set(key: string, value: T): boolean;
  107940. /**
  107941. * Get the element of the given key and remove it from the dictionary
  107942. * @param key defines the key to search
  107943. * @returns the value associated with the key or null if not found
  107944. */
  107945. getAndRemove(key: string): Nullable<T>;
  107946. /**
  107947. * Remove a key/value from the dictionary.
  107948. * @param key the key to remove
  107949. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107950. */
  107951. remove(key: string): boolean;
  107952. /**
  107953. * Clear the whole content of the dictionary
  107954. */
  107955. clear(): void;
  107956. /**
  107957. * Gets the current count
  107958. */
  107959. get count(): number;
  107960. /**
  107961. * Execute a callback on each key/val of the dictionary.
  107962. * Note that you can remove any element in this dictionary in the callback implementation
  107963. * @param callback the callback to execute on a given key/value pair
  107964. */
  107965. forEach(callback: (key: string, val: T) => void): void;
  107966. /**
  107967. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107968. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107969. * Note that you can remove any element in this dictionary in the callback implementation
  107970. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107971. * @returns the first item
  107972. */
  107973. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107974. private _count;
  107975. private _data;
  107976. }
  107977. }
  107978. declare module BABYLON {
  107979. /** @hidden */
  107980. export interface ICollisionCoordinator {
  107981. createCollider(): Collider;
  107982. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107983. init(scene: Scene): void;
  107984. }
  107985. /** @hidden */
  107986. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107987. private _scene;
  107988. private _scaledPosition;
  107989. private _scaledVelocity;
  107990. private _finalPosition;
  107991. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107992. createCollider(): Collider;
  107993. init(scene: Scene): void;
  107994. private _collideWithWorld;
  107995. }
  107996. }
  107997. declare module BABYLON {
  107998. /**
  107999. * Class used to manage all inputs for the scene.
  108000. */
  108001. export class InputManager {
  108002. /** The distance in pixel that you have to move to prevent some events */
  108003. static DragMovementThreshold: number;
  108004. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108005. static LongPressDelay: number;
  108006. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108007. static DoubleClickDelay: number;
  108008. /** If you need to check double click without raising a single click at first click, enable this flag */
  108009. static ExclusiveDoubleClickMode: boolean;
  108010. private _wheelEventName;
  108011. private _onPointerMove;
  108012. private _onPointerDown;
  108013. private _onPointerUp;
  108014. private _initClickEvent;
  108015. private _initActionManager;
  108016. private _delayedSimpleClick;
  108017. private _delayedSimpleClickTimeout;
  108018. private _previousDelayedSimpleClickTimeout;
  108019. private _meshPickProceed;
  108020. private _previousButtonPressed;
  108021. private _currentPickResult;
  108022. private _previousPickResult;
  108023. private _totalPointersPressed;
  108024. private _doubleClickOccured;
  108025. private _pointerOverMesh;
  108026. private _pickedDownMesh;
  108027. private _pickedUpMesh;
  108028. private _pointerX;
  108029. private _pointerY;
  108030. private _unTranslatedPointerX;
  108031. private _unTranslatedPointerY;
  108032. private _startingPointerPosition;
  108033. private _previousStartingPointerPosition;
  108034. private _startingPointerTime;
  108035. private _previousStartingPointerTime;
  108036. private _pointerCaptures;
  108037. private _onKeyDown;
  108038. private _onKeyUp;
  108039. private _onCanvasFocusObserver;
  108040. private _onCanvasBlurObserver;
  108041. private _scene;
  108042. /**
  108043. * Creates a new InputManager
  108044. * @param scene defines the hosting scene
  108045. */
  108046. constructor(scene: Scene);
  108047. /**
  108048. * Gets the mesh that is currently under the pointer
  108049. */
  108050. get meshUnderPointer(): Nullable<AbstractMesh>;
  108051. /**
  108052. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108053. */
  108054. get unTranslatedPointer(): Vector2;
  108055. /**
  108056. * Gets or sets the current on-screen X position of the pointer
  108057. */
  108058. get pointerX(): number;
  108059. set pointerX(value: number);
  108060. /**
  108061. * Gets or sets the current on-screen Y position of the pointer
  108062. */
  108063. get pointerY(): number;
  108064. set pointerY(value: number);
  108065. private _updatePointerPosition;
  108066. private _processPointerMove;
  108067. private _setRayOnPointerInfo;
  108068. private _checkPrePointerObservable;
  108069. /**
  108070. * Use this method to simulate a pointer move on a mesh
  108071. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108072. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108073. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108074. */
  108075. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108076. /**
  108077. * Use this method to simulate a pointer down on a mesh
  108078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108081. */
  108082. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108083. private _processPointerDown;
  108084. /** @hidden */
  108085. _isPointerSwiping(): boolean;
  108086. /**
  108087. * Use this method to simulate a pointer up on a mesh
  108088. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108089. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108090. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108091. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108092. */
  108093. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108094. private _processPointerUp;
  108095. /**
  108096. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108097. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108098. * @returns true if the pointer was captured
  108099. */
  108100. isPointerCaptured(pointerId?: number): boolean;
  108101. /**
  108102. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108103. * @param attachUp defines if you want to attach events to pointerup
  108104. * @param attachDown defines if you want to attach events to pointerdown
  108105. * @param attachMove defines if you want to attach events to pointermove
  108106. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108107. */
  108108. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108109. /**
  108110. * Detaches all event handlers
  108111. */
  108112. detachControl(): void;
  108113. /**
  108114. * Force the value of meshUnderPointer
  108115. * @param mesh defines the mesh to use
  108116. */
  108117. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108118. /**
  108119. * Gets the mesh under the pointer
  108120. * @returns a Mesh or null if no mesh is under the pointer
  108121. */
  108122. getPointerOverMesh(): Nullable<AbstractMesh>;
  108123. }
  108124. }
  108125. declare module BABYLON {
  108126. /**
  108127. * Helper class used to generate session unique ID
  108128. */
  108129. export class UniqueIdGenerator {
  108130. private static _UniqueIdCounter;
  108131. /**
  108132. * Gets an unique (relatively to the current scene) Id
  108133. */
  108134. static get UniqueId(): number;
  108135. }
  108136. }
  108137. declare module BABYLON {
  108138. /**
  108139. * This class defines the direct association between an animation and a target
  108140. */
  108141. export class TargetedAnimation {
  108142. /**
  108143. * Animation to perform
  108144. */
  108145. animation: Animation;
  108146. /**
  108147. * Target to animate
  108148. */
  108149. target: any;
  108150. /**
  108151. * Serialize the object
  108152. * @returns the JSON object representing the current entity
  108153. */
  108154. serialize(): any;
  108155. }
  108156. /**
  108157. * Use this class to create coordinated animations on multiple targets
  108158. */
  108159. export class AnimationGroup implements IDisposable {
  108160. /** The name of the animation group */
  108161. name: string;
  108162. private _scene;
  108163. private _targetedAnimations;
  108164. private _animatables;
  108165. private _from;
  108166. private _to;
  108167. private _isStarted;
  108168. private _isPaused;
  108169. private _speedRatio;
  108170. private _loopAnimation;
  108171. /**
  108172. * Gets or sets the unique id of the node
  108173. */
  108174. uniqueId: number;
  108175. /**
  108176. * This observable will notify when one animation have ended
  108177. */
  108178. onAnimationEndObservable: Observable<TargetedAnimation>;
  108179. /**
  108180. * Observer raised when one animation loops
  108181. */
  108182. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108183. /**
  108184. * Observer raised when all animations have looped
  108185. */
  108186. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108187. /**
  108188. * This observable will notify when all animations have ended.
  108189. */
  108190. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108191. /**
  108192. * This observable will notify when all animations have paused.
  108193. */
  108194. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108195. /**
  108196. * This observable will notify when all animations are playing.
  108197. */
  108198. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108199. /**
  108200. * Gets the first frame
  108201. */
  108202. get from(): number;
  108203. /**
  108204. * Gets the last frame
  108205. */
  108206. get to(): number;
  108207. /**
  108208. * Define if the animations are started
  108209. */
  108210. get isStarted(): boolean;
  108211. /**
  108212. * Gets a value indicating that the current group is playing
  108213. */
  108214. get isPlaying(): boolean;
  108215. /**
  108216. * Gets or sets the speed ratio to use for all animations
  108217. */
  108218. get speedRatio(): number;
  108219. /**
  108220. * Gets or sets the speed ratio to use for all animations
  108221. */
  108222. set speedRatio(value: number);
  108223. /**
  108224. * Gets or sets if all animations should loop or not
  108225. */
  108226. get loopAnimation(): boolean;
  108227. set loopAnimation(value: boolean);
  108228. /**
  108229. * Gets the targeted animations for this animation group
  108230. */
  108231. get targetedAnimations(): Array<TargetedAnimation>;
  108232. /**
  108233. * returning the list of animatables controlled by this animation group.
  108234. */
  108235. get animatables(): Array<Animatable>;
  108236. /**
  108237. * Instantiates a new Animation Group.
  108238. * This helps managing several animations at once.
  108239. * @see http://doc.babylonjs.com/how_to/group
  108240. * @param name Defines the name of the group
  108241. * @param scene Defines the scene the group belongs to
  108242. */
  108243. constructor(
  108244. /** The name of the animation group */
  108245. name: string, scene?: Nullable<Scene>);
  108246. /**
  108247. * Add an animation (with its target) in the group
  108248. * @param animation defines the animation we want to add
  108249. * @param target defines the target of the animation
  108250. * @returns the TargetedAnimation object
  108251. */
  108252. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108253. /**
  108254. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108255. * It can add constant keys at begin or end
  108256. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108257. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108258. * @returns the animation group
  108259. */
  108260. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108261. private _animationLoopCount;
  108262. private _animationLoopFlags;
  108263. private _processLoop;
  108264. /**
  108265. * Start all animations on given targets
  108266. * @param loop defines if animations must loop
  108267. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108268. * @param from defines the from key (optional)
  108269. * @param to defines the to key (optional)
  108270. * @returns the current animation group
  108271. */
  108272. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108273. /**
  108274. * Pause all animations
  108275. * @returns the animation group
  108276. */
  108277. pause(): AnimationGroup;
  108278. /**
  108279. * Play all animations to initial state
  108280. * This function will start() the animations if they were not started or will restart() them if they were paused
  108281. * @param loop defines if animations must loop
  108282. * @returns the animation group
  108283. */
  108284. play(loop?: boolean): AnimationGroup;
  108285. /**
  108286. * Reset all animations to initial state
  108287. * @returns the animation group
  108288. */
  108289. reset(): AnimationGroup;
  108290. /**
  108291. * Restart animations from key 0
  108292. * @returns the animation group
  108293. */
  108294. restart(): AnimationGroup;
  108295. /**
  108296. * Stop all animations
  108297. * @returns the animation group
  108298. */
  108299. stop(): AnimationGroup;
  108300. /**
  108301. * Set animation weight for all animatables
  108302. * @param weight defines the weight to use
  108303. * @return the animationGroup
  108304. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108305. */
  108306. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108307. /**
  108308. * Synchronize and normalize all animatables with a source animatable
  108309. * @param root defines the root animatable to synchronize with
  108310. * @return the animationGroup
  108311. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108312. */
  108313. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108314. /**
  108315. * Goes to a specific frame in this animation group
  108316. * @param frame the frame number to go to
  108317. * @return the animationGroup
  108318. */
  108319. goToFrame(frame: number): AnimationGroup;
  108320. /**
  108321. * Dispose all associated resources
  108322. */
  108323. dispose(): void;
  108324. private _checkAnimationGroupEnded;
  108325. /**
  108326. * Clone the current animation group and returns a copy
  108327. * @param newName defines the name of the new group
  108328. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108329. * @returns the new aniamtion group
  108330. */
  108331. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108332. /**
  108333. * Serializes the animationGroup to an object
  108334. * @returns Serialized object
  108335. */
  108336. serialize(): any;
  108337. /**
  108338. * Returns a new AnimationGroup object parsed from the source provided.
  108339. * @param parsedAnimationGroup defines the source
  108340. * @param scene defines the scene that will receive the animationGroup
  108341. * @returns a new AnimationGroup
  108342. */
  108343. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108344. /**
  108345. * Returns the string "AnimationGroup"
  108346. * @returns "AnimationGroup"
  108347. */
  108348. getClassName(): string;
  108349. /**
  108350. * Creates a detailled string about the object
  108351. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108352. * @returns a string representing the object
  108353. */
  108354. toString(fullDetails?: boolean): string;
  108355. }
  108356. }
  108357. declare module BABYLON {
  108358. /**
  108359. * Define an interface for all classes that will hold resources
  108360. */
  108361. export interface IDisposable {
  108362. /**
  108363. * Releases all held resources
  108364. */
  108365. dispose(): void;
  108366. }
  108367. /** Interface defining initialization parameters for Scene class */
  108368. export interface SceneOptions {
  108369. /**
  108370. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108371. * It will improve performance when the number of geometries becomes important.
  108372. */
  108373. useGeometryUniqueIdsMap?: boolean;
  108374. /**
  108375. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108376. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108377. */
  108378. useMaterialMeshMap?: boolean;
  108379. /**
  108380. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108381. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108382. */
  108383. useClonedMeshMap?: boolean;
  108384. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108385. virtual?: boolean;
  108386. }
  108387. /**
  108388. * Represents a scene to be rendered by the engine.
  108389. * @see http://doc.babylonjs.com/features/scene
  108390. */
  108391. export class Scene extends AbstractScene implements IAnimatable {
  108392. /** The fog is deactivated */
  108393. static readonly FOGMODE_NONE: number;
  108394. /** The fog density is following an exponential function */
  108395. static readonly FOGMODE_EXP: number;
  108396. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108397. static readonly FOGMODE_EXP2: number;
  108398. /** The fog density is following a linear function. */
  108399. static readonly FOGMODE_LINEAR: number;
  108400. /**
  108401. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108402. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108403. */
  108404. static MinDeltaTime: number;
  108405. /**
  108406. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108407. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108408. */
  108409. static MaxDeltaTime: number;
  108410. /**
  108411. * Factory used to create the default material.
  108412. * @param name The name of the material to create
  108413. * @param scene The scene to create the material for
  108414. * @returns The default material
  108415. */
  108416. static DefaultMaterialFactory(scene: Scene): Material;
  108417. /**
  108418. * Factory used to create the a collision coordinator.
  108419. * @returns The collision coordinator
  108420. */
  108421. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108422. /** @hidden */
  108423. _inputManager: InputManager;
  108424. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108425. cameraToUseForPointers: Nullable<Camera>;
  108426. /** @hidden */
  108427. readonly _isScene: boolean;
  108428. /** @hidden */
  108429. _blockEntityCollection: boolean;
  108430. /**
  108431. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108432. */
  108433. autoClear: boolean;
  108434. /**
  108435. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108436. */
  108437. autoClearDepthAndStencil: boolean;
  108438. /**
  108439. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108440. */
  108441. clearColor: Color4;
  108442. /**
  108443. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108444. */
  108445. ambientColor: Color3;
  108446. /**
  108447. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108448. * It should only be one of the following (if not the default embedded one):
  108449. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108450. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108451. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108452. * The material properties need to be setup according to the type of texture in use.
  108453. */
  108454. environmentBRDFTexture: BaseTexture;
  108455. /** @hidden */
  108456. protected _environmentTexture: Nullable<BaseTexture>;
  108457. /**
  108458. * Texture used in all pbr material as the reflection texture.
  108459. * As in the majority of the scene they are the same (exception for multi room and so on),
  108460. * this is easier to reference from here than from all the materials.
  108461. */
  108462. get environmentTexture(): Nullable<BaseTexture>;
  108463. /**
  108464. * Texture used in all pbr material as the reflection texture.
  108465. * As in the majority of the scene they are the same (exception for multi room and so on),
  108466. * this is easier to set here than in all the materials.
  108467. */
  108468. set environmentTexture(value: Nullable<BaseTexture>);
  108469. /** @hidden */
  108470. protected _environmentIntensity: number;
  108471. /**
  108472. * Intensity of the environment in all pbr material.
  108473. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108474. * As in the majority of the scene they are the same (exception for multi room and so on),
  108475. * this is easier to reference from here than from all the materials.
  108476. */
  108477. get environmentIntensity(): number;
  108478. /**
  108479. * Intensity of the environment in all pbr material.
  108480. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108481. * As in the majority of the scene they are the same (exception for multi room and so on),
  108482. * this is easier to set here than in all the materials.
  108483. */
  108484. set environmentIntensity(value: number);
  108485. /** @hidden */
  108486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108487. /**
  108488. * Default image processing configuration used either in the rendering
  108489. * Forward main pass or through the imageProcessingPostProcess if present.
  108490. * As in the majority of the scene they are the same (exception for multi camera),
  108491. * this is easier to reference from here than from all the materials and post process.
  108492. *
  108493. * No setter as we it is a shared configuration, you can set the values instead.
  108494. */
  108495. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108496. private _forceWireframe;
  108497. /**
  108498. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108499. */
  108500. set forceWireframe(value: boolean);
  108501. get forceWireframe(): boolean;
  108502. private _skipFrustumClipping;
  108503. /**
  108504. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108505. */
  108506. set skipFrustumClipping(value: boolean);
  108507. get skipFrustumClipping(): boolean;
  108508. private _forcePointsCloud;
  108509. /**
  108510. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108511. */
  108512. set forcePointsCloud(value: boolean);
  108513. get forcePointsCloud(): boolean;
  108514. /**
  108515. * Gets or sets the active clipplane 1
  108516. */
  108517. clipPlane: Nullable<Plane>;
  108518. /**
  108519. * Gets or sets the active clipplane 2
  108520. */
  108521. clipPlane2: Nullable<Plane>;
  108522. /**
  108523. * Gets or sets the active clipplane 3
  108524. */
  108525. clipPlane3: Nullable<Plane>;
  108526. /**
  108527. * Gets or sets the active clipplane 4
  108528. */
  108529. clipPlane4: Nullable<Plane>;
  108530. /**
  108531. * Gets or sets the active clipplane 5
  108532. */
  108533. clipPlane5: Nullable<Plane>;
  108534. /**
  108535. * Gets or sets the active clipplane 6
  108536. */
  108537. clipPlane6: Nullable<Plane>;
  108538. /**
  108539. * Gets or sets a boolean indicating if animations are enabled
  108540. */
  108541. animationsEnabled: boolean;
  108542. private _animationPropertiesOverride;
  108543. /**
  108544. * Gets or sets the animation properties override
  108545. */
  108546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108547. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108548. /**
  108549. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108550. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108551. */
  108552. useConstantAnimationDeltaTime: boolean;
  108553. /**
  108554. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108555. * Please note that it requires to run a ray cast through the scene on every frame
  108556. */
  108557. constantlyUpdateMeshUnderPointer: boolean;
  108558. /**
  108559. * Defines the HTML cursor to use when hovering over interactive elements
  108560. */
  108561. hoverCursor: string;
  108562. /**
  108563. * Defines the HTML default cursor to use (empty by default)
  108564. */
  108565. defaultCursor: string;
  108566. /**
  108567. * Defines whether cursors are handled by the scene.
  108568. */
  108569. doNotHandleCursors: boolean;
  108570. /**
  108571. * This is used to call preventDefault() on pointer down
  108572. * in order to block unwanted artifacts like system double clicks
  108573. */
  108574. preventDefaultOnPointerDown: boolean;
  108575. /**
  108576. * This is used to call preventDefault() on pointer up
  108577. * in order to block unwanted artifacts like system double clicks
  108578. */
  108579. preventDefaultOnPointerUp: boolean;
  108580. /**
  108581. * Gets or sets user defined metadata
  108582. */
  108583. metadata: any;
  108584. /**
  108585. * For internal use only. Please do not use.
  108586. */
  108587. reservedDataStore: any;
  108588. /**
  108589. * Gets the name of the plugin used to load this scene (null by default)
  108590. */
  108591. loadingPluginName: string;
  108592. /**
  108593. * Use this array to add regular expressions used to disable offline support for specific urls
  108594. */
  108595. disableOfflineSupportExceptionRules: RegExp[];
  108596. /**
  108597. * An event triggered when the scene is disposed.
  108598. */
  108599. onDisposeObservable: Observable<Scene>;
  108600. private _onDisposeObserver;
  108601. /** Sets a function to be executed when this scene is disposed. */
  108602. set onDispose(callback: () => void);
  108603. /**
  108604. * An event triggered before rendering the scene (right after animations and physics)
  108605. */
  108606. onBeforeRenderObservable: Observable<Scene>;
  108607. private _onBeforeRenderObserver;
  108608. /** Sets a function to be executed before rendering this scene */
  108609. set beforeRender(callback: Nullable<() => void>);
  108610. /**
  108611. * An event triggered after rendering the scene
  108612. */
  108613. onAfterRenderObservable: Observable<Scene>;
  108614. /**
  108615. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108616. */
  108617. onAfterRenderCameraObservable: Observable<Camera>;
  108618. private _onAfterRenderObserver;
  108619. /** Sets a function to be executed after rendering this scene */
  108620. set afterRender(callback: Nullable<() => void>);
  108621. /**
  108622. * An event triggered before animating the scene
  108623. */
  108624. onBeforeAnimationsObservable: Observable<Scene>;
  108625. /**
  108626. * An event triggered after animations processing
  108627. */
  108628. onAfterAnimationsObservable: Observable<Scene>;
  108629. /**
  108630. * An event triggered before draw calls are ready to be sent
  108631. */
  108632. onBeforeDrawPhaseObservable: Observable<Scene>;
  108633. /**
  108634. * An event triggered after draw calls have been sent
  108635. */
  108636. onAfterDrawPhaseObservable: Observable<Scene>;
  108637. /**
  108638. * An event triggered when the scene is ready
  108639. */
  108640. onReadyObservable: Observable<Scene>;
  108641. /**
  108642. * An event triggered before rendering a camera
  108643. */
  108644. onBeforeCameraRenderObservable: Observable<Camera>;
  108645. private _onBeforeCameraRenderObserver;
  108646. /** Sets a function to be executed before rendering a camera*/
  108647. set beforeCameraRender(callback: () => void);
  108648. /**
  108649. * An event triggered after rendering a camera
  108650. */
  108651. onAfterCameraRenderObservable: Observable<Camera>;
  108652. private _onAfterCameraRenderObserver;
  108653. /** Sets a function to be executed after rendering a camera*/
  108654. set afterCameraRender(callback: () => void);
  108655. /**
  108656. * An event triggered when active meshes evaluation is about to start
  108657. */
  108658. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108659. /**
  108660. * An event triggered when active meshes evaluation is done
  108661. */
  108662. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108663. /**
  108664. * An event triggered when particles rendering is about to start
  108665. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108666. */
  108667. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108668. /**
  108669. * An event triggered when particles rendering is done
  108670. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108671. */
  108672. onAfterParticlesRenderingObservable: Observable<Scene>;
  108673. /**
  108674. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108675. */
  108676. onDataLoadedObservable: Observable<Scene>;
  108677. /**
  108678. * An event triggered when a camera is created
  108679. */
  108680. onNewCameraAddedObservable: Observable<Camera>;
  108681. /**
  108682. * An event triggered when a camera is removed
  108683. */
  108684. onCameraRemovedObservable: Observable<Camera>;
  108685. /**
  108686. * An event triggered when a light is created
  108687. */
  108688. onNewLightAddedObservable: Observable<Light>;
  108689. /**
  108690. * An event triggered when a light is removed
  108691. */
  108692. onLightRemovedObservable: Observable<Light>;
  108693. /**
  108694. * An event triggered when a geometry is created
  108695. */
  108696. onNewGeometryAddedObservable: Observable<Geometry>;
  108697. /**
  108698. * An event triggered when a geometry is removed
  108699. */
  108700. onGeometryRemovedObservable: Observable<Geometry>;
  108701. /**
  108702. * An event triggered when a transform node is created
  108703. */
  108704. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108705. /**
  108706. * An event triggered when a transform node is removed
  108707. */
  108708. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108709. /**
  108710. * An event triggered when a mesh is created
  108711. */
  108712. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108713. /**
  108714. * An event triggered when a mesh is removed
  108715. */
  108716. onMeshRemovedObservable: Observable<AbstractMesh>;
  108717. /**
  108718. * An event triggered when a skeleton is created
  108719. */
  108720. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108721. /**
  108722. * An event triggered when a skeleton is removed
  108723. */
  108724. onSkeletonRemovedObservable: Observable<Skeleton>;
  108725. /**
  108726. * An event triggered when a material is created
  108727. */
  108728. onNewMaterialAddedObservable: Observable<Material>;
  108729. /**
  108730. * An event triggered when a material is removed
  108731. */
  108732. onMaterialRemovedObservable: Observable<Material>;
  108733. /**
  108734. * An event triggered when a texture is created
  108735. */
  108736. onNewTextureAddedObservable: Observable<BaseTexture>;
  108737. /**
  108738. * An event triggered when a texture is removed
  108739. */
  108740. onTextureRemovedObservable: Observable<BaseTexture>;
  108741. /**
  108742. * An event triggered when render targets are about to be rendered
  108743. * Can happen multiple times per frame.
  108744. */
  108745. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108746. /**
  108747. * An event triggered when render targets were rendered.
  108748. * Can happen multiple times per frame.
  108749. */
  108750. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108751. /**
  108752. * An event triggered before calculating deterministic simulation step
  108753. */
  108754. onBeforeStepObservable: Observable<Scene>;
  108755. /**
  108756. * An event triggered after calculating deterministic simulation step
  108757. */
  108758. onAfterStepObservable: Observable<Scene>;
  108759. /**
  108760. * An event triggered when the activeCamera property is updated
  108761. */
  108762. onActiveCameraChanged: Observable<Scene>;
  108763. /**
  108764. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108765. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108766. * 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)
  108767. */
  108768. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108769. /**
  108770. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108771. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108772. * 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)
  108773. */
  108774. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108775. /**
  108776. * This Observable will when a mesh has been imported into the scene.
  108777. */
  108778. onMeshImportedObservable: Observable<AbstractMesh>;
  108779. /**
  108780. * This Observable will when an animation file has been imported into the scene.
  108781. */
  108782. onAnimationFileImportedObservable: Observable<Scene>;
  108783. /**
  108784. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108785. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108786. */
  108787. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108788. /** @hidden */
  108789. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108790. /**
  108791. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108792. */
  108793. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108794. /**
  108795. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108796. */
  108797. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108798. /**
  108799. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108800. */
  108801. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108802. /** Callback called when a pointer move is detected */
  108803. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108804. /** Callback called when a pointer down is detected */
  108805. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108806. /** Callback called when a pointer up is detected */
  108807. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108808. /** Callback called when a pointer pick is detected */
  108809. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108810. /**
  108811. * 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).
  108812. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108813. */
  108814. onPrePointerObservable: Observable<PointerInfoPre>;
  108815. /**
  108816. * Observable event triggered each time an input event is received from the rendering canvas
  108817. */
  108818. onPointerObservable: Observable<PointerInfo>;
  108819. /**
  108820. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108821. */
  108822. get unTranslatedPointer(): Vector2;
  108823. /**
  108824. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108825. */
  108826. static get DragMovementThreshold(): number;
  108827. static set DragMovementThreshold(value: number);
  108828. /**
  108829. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108830. */
  108831. static get LongPressDelay(): number;
  108832. static set LongPressDelay(value: number);
  108833. /**
  108834. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108835. */
  108836. static get DoubleClickDelay(): number;
  108837. static set DoubleClickDelay(value: number);
  108838. /** If you need to check double click without raising a single click at first click, enable this flag */
  108839. static get ExclusiveDoubleClickMode(): boolean;
  108840. static set ExclusiveDoubleClickMode(value: boolean);
  108841. /** @hidden */
  108842. _mirroredCameraPosition: Nullable<Vector3>;
  108843. /**
  108844. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108845. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108846. */
  108847. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108848. /**
  108849. * Observable event triggered each time an keyboard event is received from the hosting window
  108850. */
  108851. onKeyboardObservable: Observable<KeyboardInfo>;
  108852. private _useRightHandedSystem;
  108853. /**
  108854. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108855. */
  108856. set useRightHandedSystem(value: boolean);
  108857. get useRightHandedSystem(): boolean;
  108858. private _timeAccumulator;
  108859. private _currentStepId;
  108860. private _currentInternalStep;
  108861. /**
  108862. * Sets the step Id used by deterministic lock step
  108863. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108864. * @param newStepId defines the step Id
  108865. */
  108866. setStepId(newStepId: number): void;
  108867. /**
  108868. * Gets the step Id used by deterministic lock step
  108869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108870. * @returns the step Id
  108871. */
  108872. getStepId(): number;
  108873. /**
  108874. * Gets the internal step used by deterministic lock step
  108875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108876. * @returns the internal step
  108877. */
  108878. getInternalStep(): number;
  108879. private _fogEnabled;
  108880. /**
  108881. * Gets or sets a boolean indicating if fog is enabled on this scene
  108882. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108883. * (Default is true)
  108884. */
  108885. set fogEnabled(value: boolean);
  108886. get fogEnabled(): boolean;
  108887. private _fogMode;
  108888. /**
  108889. * Gets or sets the fog mode to use
  108890. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108891. * | mode | value |
  108892. * | --- | --- |
  108893. * | FOGMODE_NONE | 0 |
  108894. * | FOGMODE_EXP | 1 |
  108895. * | FOGMODE_EXP2 | 2 |
  108896. * | FOGMODE_LINEAR | 3 |
  108897. */
  108898. set fogMode(value: number);
  108899. get fogMode(): number;
  108900. /**
  108901. * Gets or sets the fog color to use
  108902. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108903. * (Default is Color3(0.2, 0.2, 0.3))
  108904. */
  108905. fogColor: Color3;
  108906. /**
  108907. * Gets or sets the fog density to use
  108908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108909. * (Default is 0.1)
  108910. */
  108911. fogDensity: number;
  108912. /**
  108913. * Gets or sets the fog start distance to use
  108914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108915. * (Default is 0)
  108916. */
  108917. fogStart: number;
  108918. /**
  108919. * Gets or sets the fog end distance to use
  108920. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108921. * (Default is 1000)
  108922. */
  108923. fogEnd: number;
  108924. private _shadowsEnabled;
  108925. /**
  108926. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108927. */
  108928. set shadowsEnabled(value: boolean);
  108929. get shadowsEnabled(): boolean;
  108930. private _lightsEnabled;
  108931. /**
  108932. * Gets or sets a boolean indicating if lights are enabled on this scene
  108933. */
  108934. set lightsEnabled(value: boolean);
  108935. get lightsEnabled(): boolean;
  108936. /** All of the active cameras added to this scene. */
  108937. activeCameras: Camera[];
  108938. /** @hidden */
  108939. _activeCamera: Nullable<Camera>;
  108940. /** Gets or sets the current active camera */
  108941. get activeCamera(): Nullable<Camera>;
  108942. set activeCamera(value: Nullable<Camera>);
  108943. private _defaultMaterial;
  108944. /** The default material used on meshes when no material is affected */
  108945. get defaultMaterial(): Material;
  108946. /** The default material used on meshes when no material is affected */
  108947. set defaultMaterial(value: Material);
  108948. private _texturesEnabled;
  108949. /**
  108950. * Gets or sets a boolean indicating if textures are enabled on this scene
  108951. */
  108952. set texturesEnabled(value: boolean);
  108953. get texturesEnabled(): boolean;
  108954. /**
  108955. * Gets or sets a boolean indicating if particles are enabled on this scene
  108956. */
  108957. particlesEnabled: boolean;
  108958. /**
  108959. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108960. */
  108961. spritesEnabled: boolean;
  108962. private _skeletonsEnabled;
  108963. /**
  108964. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108965. */
  108966. set skeletonsEnabled(value: boolean);
  108967. get skeletonsEnabled(): boolean;
  108968. /**
  108969. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108970. */
  108971. lensFlaresEnabled: boolean;
  108972. /**
  108973. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108974. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108975. */
  108976. collisionsEnabled: boolean;
  108977. private _collisionCoordinator;
  108978. /** @hidden */
  108979. get collisionCoordinator(): ICollisionCoordinator;
  108980. /**
  108981. * Defines the gravity applied to this scene (used only for collisions)
  108982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108983. */
  108984. gravity: Vector3;
  108985. /**
  108986. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108987. */
  108988. postProcessesEnabled: boolean;
  108989. /**
  108990. * The list of postprocesses added to the scene
  108991. */
  108992. postProcesses: PostProcess[];
  108993. /**
  108994. * Gets the current postprocess manager
  108995. */
  108996. postProcessManager: PostProcessManager;
  108997. /**
  108998. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108999. */
  109000. renderTargetsEnabled: boolean;
  109001. /**
  109002. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109003. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109004. */
  109005. dumpNextRenderTargets: boolean;
  109006. /**
  109007. * The list of user defined render targets added to the scene
  109008. */
  109009. customRenderTargets: RenderTargetTexture[];
  109010. /**
  109011. * Defines if texture loading must be delayed
  109012. * If true, textures will only be loaded when they need to be rendered
  109013. */
  109014. useDelayedTextureLoading: boolean;
  109015. /**
  109016. * Gets the list of meshes imported to the scene through SceneLoader
  109017. */
  109018. importedMeshesFiles: String[];
  109019. /**
  109020. * Gets or sets a boolean indicating if probes are enabled on this scene
  109021. */
  109022. probesEnabled: boolean;
  109023. /**
  109024. * Gets or sets the current offline provider to use to store scene data
  109025. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109026. */
  109027. offlineProvider: IOfflineProvider;
  109028. /**
  109029. * Gets or sets the action manager associated with the scene
  109030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109031. */
  109032. actionManager: AbstractActionManager;
  109033. private _meshesForIntersections;
  109034. /**
  109035. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109036. */
  109037. proceduralTexturesEnabled: boolean;
  109038. private _engine;
  109039. private _totalVertices;
  109040. /** @hidden */
  109041. _activeIndices: PerfCounter;
  109042. /** @hidden */
  109043. _activeParticles: PerfCounter;
  109044. /** @hidden */
  109045. _activeBones: PerfCounter;
  109046. private _animationRatio;
  109047. /** @hidden */
  109048. _animationTimeLast: number;
  109049. /** @hidden */
  109050. _animationTime: number;
  109051. /**
  109052. * Gets or sets a general scale for animation speed
  109053. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109054. */
  109055. animationTimeScale: number;
  109056. /** @hidden */
  109057. _cachedMaterial: Nullable<Material>;
  109058. /** @hidden */
  109059. _cachedEffect: Nullable<Effect>;
  109060. /** @hidden */
  109061. _cachedVisibility: Nullable<number>;
  109062. private _renderId;
  109063. private _frameId;
  109064. private _executeWhenReadyTimeoutId;
  109065. private _intermediateRendering;
  109066. private _viewUpdateFlag;
  109067. private _projectionUpdateFlag;
  109068. /** @hidden */
  109069. _toBeDisposed: Nullable<IDisposable>[];
  109070. private _activeRequests;
  109071. /** @hidden */
  109072. _pendingData: any[];
  109073. private _isDisposed;
  109074. /**
  109075. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109076. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109077. */
  109078. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109079. private _activeMeshes;
  109080. private _processedMaterials;
  109081. private _renderTargets;
  109082. /** @hidden */
  109083. _activeParticleSystems: SmartArray<IParticleSystem>;
  109084. private _activeSkeletons;
  109085. private _softwareSkinnedMeshes;
  109086. private _renderingManager;
  109087. /** @hidden */
  109088. _activeAnimatables: Animatable[];
  109089. private _transformMatrix;
  109090. private _sceneUbo;
  109091. /** @hidden */
  109092. _viewMatrix: Matrix;
  109093. private _projectionMatrix;
  109094. /** @hidden */
  109095. _forcedViewPosition: Nullable<Vector3>;
  109096. /** @hidden */
  109097. _frustumPlanes: Plane[];
  109098. /**
  109099. * Gets the list of frustum planes (built from the active camera)
  109100. */
  109101. get frustumPlanes(): Plane[];
  109102. /**
  109103. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109104. * This is useful if there are more lights that the maximum simulteanous authorized
  109105. */
  109106. requireLightSorting: boolean;
  109107. /** @hidden */
  109108. readonly useMaterialMeshMap: boolean;
  109109. /** @hidden */
  109110. readonly useClonedMeshMap: boolean;
  109111. private _externalData;
  109112. private _uid;
  109113. /**
  109114. * @hidden
  109115. * Backing store of defined scene components.
  109116. */
  109117. _components: ISceneComponent[];
  109118. /**
  109119. * @hidden
  109120. * Backing store of defined scene components.
  109121. */
  109122. _serializableComponents: ISceneSerializableComponent[];
  109123. /**
  109124. * List of components to register on the next registration step.
  109125. */
  109126. private _transientComponents;
  109127. /**
  109128. * Registers the transient components if needed.
  109129. */
  109130. private _registerTransientComponents;
  109131. /**
  109132. * @hidden
  109133. * Add a component to the scene.
  109134. * Note that the ccomponent could be registered on th next frame if this is called after
  109135. * the register component stage.
  109136. * @param component Defines the component to add to the scene
  109137. */
  109138. _addComponent(component: ISceneComponent): void;
  109139. /**
  109140. * @hidden
  109141. * Gets a component from the scene.
  109142. * @param name defines the name of the component to retrieve
  109143. * @returns the component or null if not present
  109144. */
  109145. _getComponent(name: string): Nullable<ISceneComponent>;
  109146. /**
  109147. * @hidden
  109148. * Defines the actions happening before camera updates.
  109149. */
  109150. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109151. /**
  109152. * @hidden
  109153. * Defines the actions happening before clear the canvas.
  109154. */
  109155. _beforeClearStage: Stage<SimpleStageAction>;
  109156. /**
  109157. * @hidden
  109158. * Defines the actions when collecting render targets for the frame.
  109159. */
  109160. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109161. /**
  109162. * @hidden
  109163. * Defines the actions happening for one camera in the frame.
  109164. */
  109165. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109166. /**
  109167. * @hidden
  109168. * Defines the actions happening during the per mesh ready checks.
  109169. */
  109170. _isReadyForMeshStage: Stage<MeshStageAction>;
  109171. /**
  109172. * @hidden
  109173. * Defines the actions happening before evaluate active mesh checks.
  109174. */
  109175. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109176. /**
  109177. * @hidden
  109178. * Defines the actions happening during the evaluate sub mesh checks.
  109179. */
  109180. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109181. /**
  109182. * @hidden
  109183. * Defines the actions happening during the active mesh stage.
  109184. */
  109185. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109186. /**
  109187. * @hidden
  109188. * Defines the actions happening during the per camera render target step.
  109189. */
  109190. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109191. /**
  109192. * @hidden
  109193. * Defines the actions happening just before the active camera is drawing.
  109194. */
  109195. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109196. /**
  109197. * @hidden
  109198. * Defines the actions happening just before a render target is drawing.
  109199. */
  109200. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109201. /**
  109202. * @hidden
  109203. * Defines the actions happening just before a rendering group is drawing.
  109204. */
  109205. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109206. /**
  109207. * @hidden
  109208. * Defines the actions happening just before a mesh is drawing.
  109209. */
  109210. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109211. /**
  109212. * @hidden
  109213. * Defines the actions happening just after a mesh has been drawn.
  109214. */
  109215. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109216. /**
  109217. * @hidden
  109218. * Defines the actions happening just after a rendering group has been drawn.
  109219. */
  109220. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109221. /**
  109222. * @hidden
  109223. * Defines the actions happening just after the active camera has been drawn.
  109224. */
  109225. _afterCameraDrawStage: Stage<CameraStageAction>;
  109226. /**
  109227. * @hidden
  109228. * Defines the actions happening just after a render target has been drawn.
  109229. */
  109230. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109231. /**
  109232. * @hidden
  109233. * Defines the actions happening just after rendering all cameras and computing intersections.
  109234. */
  109235. _afterRenderStage: Stage<SimpleStageAction>;
  109236. /**
  109237. * @hidden
  109238. * Defines the actions happening when a pointer move event happens.
  109239. */
  109240. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109241. /**
  109242. * @hidden
  109243. * Defines the actions happening when a pointer down event happens.
  109244. */
  109245. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109246. /**
  109247. * @hidden
  109248. * Defines the actions happening when a pointer up event happens.
  109249. */
  109250. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109251. /**
  109252. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109253. */
  109254. private geometriesByUniqueId;
  109255. /**
  109256. * Creates a new Scene
  109257. * @param engine defines the engine to use to render this scene
  109258. * @param options defines the scene options
  109259. */
  109260. constructor(engine: Engine, options?: SceneOptions);
  109261. /**
  109262. * Gets a string idenfifying the name of the class
  109263. * @returns "Scene" string
  109264. */
  109265. getClassName(): string;
  109266. private _defaultMeshCandidates;
  109267. /**
  109268. * @hidden
  109269. */
  109270. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109271. private _defaultSubMeshCandidates;
  109272. /**
  109273. * @hidden
  109274. */
  109275. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109276. /**
  109277. * Sets the default candidate providers for the scene.
  109278. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109279. * and getCollidingSubMeshCandidates to their default function
  109280. */
  109281. setDefaultCandidateProviders(): void;
  109282. /**
  109283. * Gets the mesh that is currently under the pointer
  109284. */
  109285. get meshUnderPointer(): Nullable<AbstractMesh>;
  109286. /**
  109287. * Gets or sets the current on-screen X position of the pointer
  109288. */
  109289. get pointerX(): number;
  109290. set pointerX(value: number);
  109291. /**
  109292. * Gets or sets the current on-screen Y position of the pointer
  109293. */
  109294. get pointerY(): number;
  109295. set pointerY(value: number);
  109296. /**
  109297. * Gets the cached material (ie. the latest rendered one)
  109298. * @returns the cached material
  109299. */
  109300. getCachedMaterial(): Nullable<Material>;
  109301. /**
  109302. * Gets the cached effect (ie. the latest rendered one)
  109303. * @returns the cached effect
  109304. */
  109305. getCachedEffect(): Nullable<Effect>;
  109306. /**
  109307. * Gets the cached visibility state (ie. the latest rendered one)
  109308. * @returns the cached visibility state
  109309. */
  109310. getCachedVisibility(): Nullable<number>;
  109311. /**
  109312. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109313. * @param material defines the current material
  109314. * @param effect defines the current effect
  109315. * @param visibility defines the current visibility state
  109316. * @returns true if one parameter is not cached
  109317. */
  109318. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109319. /**
  109320. * Gets the engine associated with the scene
  109321. * @returns an Engine
  109322. */
  109323. getEngine(): Engine;
  109324. /**
  109325. * Gets the total number of vertices rendered per frame
  109326. * @returns the total number of vertices rendered per frame
  109327. */
  109328. getTotalVertices(): number;
  109329. /**
  109330. * Gets the performance counter for total vertices
  109331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109332. */
  109333. get totalVerticesPerfCounter(): PerfCounter;
  109334. /**
  109335. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109336. * @returns the total number of active indices rendered per frame
  109337. */
  109338. getActiveIndices(): number;
  109339. /**
  109340. * Gets the performance counter for active indices
  109341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109342. */
  109343. get totalActiveIndicesPerfCounter(): PerfCounter;
  109344. /**
  109345. * Gets the total number of active particles rendered per frame
  109346. * @returns the total number of active particles rendered per frame
  109347. */
  109348. getActiveParticles(): number;
  109349. /**
  109350. * Gets the performance counter for active particles
  109351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109352. */
  109353. get activeParticlesPerfCounter(): PerfCounter;
  109354. /**
  109355. * Gets the total number of active bones rendered per frame
  109356. * @returns the total number of active bones rendered per frame
  109357. */
  109358. getActiveBones(): number;
  109359. /**
  109360. * Gets the performance counter for active bones
  109361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109362. */
  109363. get activeBonesPerfCounter(): PerfCounter;
  109364. /**
  109365. * Gets the array of active meshes
  109366. * @returns an array of AbstractMesh
  109367. */
  109368. getActiveMeshes(): SmartArray<AbstractMesh>;
  109369. /**
  109370. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109371. * @returns a number
  109372. */
  109373. getAnimationRatio(): number;
  109374. /**
  109375. * Gets an unique Id for the current render phase
  109376. * @returns a number
  109377. */
  109378. getRenderId(): number;
  109379. /**
  109380. * Gets an unique Id for the current frame
  109381. * @returns a number
  109382. */
  109383. getFrameId(): number;
  109384. /** Call this function if you want to manually increment the render Id*/
  109385. incrementRenderId(): void;
  109386. private _createUbo;
  109387. /**
  109388. * Use this method to simulate a pointer move on a mesh
  109389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109392. * @returns the current scene
  109393. */
  109394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109395. /**
  109396. * Use this method to simulate a pointer down on a mesh
  109397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109400. * @returns the current scene
  109401. */
  109402. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109403. /**
  109404. * Use this method to simulate a pointer up on a mesh
  109405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109408. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109409. * @returns the current scene
  109410. */
  109411. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109412. /**
  109413. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109414. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109415. * @returns true if the pointer was captured
  109416. */
  109417. isPointerCaptured(pointerId?: number): boolean;
  109418. /**
  109419. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109420. * @param attachUp defines if you want to attach events to pointerup
  109421. * @param attachDown defines if you want to attach events to pointerdown
  109422. * @param attachMove defines if you want to attach events to pointermove
  109423. */
  109424. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109425. /** Detaches all event handlers*/
  109426. detachControl(): void;
  109427. /**
  109428. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109429. * Delay loaded resources are not taking in account
  109430. * @return true if all required resources are ready
  109431. */
  109432. isReady(): boolean;
  109433. /** Resets all cached information relative to material (including effect and visibility) */
  109434. resetCachedMaterial(): void;
  109435. /**
  109436. * Registers a function to be called before every frame render
  109437. * @param func defines the function to register
  109438. */
  109439. registerBeforeRender(func: () => void): void;
  109440. /**
  109441. * Unregisters a function called before every frame render
  109442. * @param func defines the function to unregister
  109443. */
  109444. unregisterBeforeRender(func: () => void): void;
  109445. /**
  109446. * Registers a function to be called after every frame render
  109447. * @param func defines the function to register
  109448. */
  109449. registerAfterRender(func: () => void): void;
  109450. /**
  109451. * Unregisters a function called after every frame render
  109452. * @param func defines the function to unregister
  109453. */
  109454. unregisterAfterRender(func: () => void): void;
  109455. private _executeOnceBeforeRender;
  109456. /**
  109457. * The provided function will run before render once and will be disposed afterwards.
  109458. * A timeout delay can be provided so that the function will be executed in N ms.
  109459. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109460. * @param func The function to be executed.
  109461. * @param timeout optional delay in ms
  109462. */
  109463. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109464. /** @hidden */
  109465. _addPendingData(data: any): void;
  109466. /** @hidden */
  109467. _removePendingData(data: any): void;
  109468. /**
  109469. * Returns the number of items waiting to be loaded
  109470. * @returns the number of items waiting to be loaded
  109471. */
  109472. getWaitingItemsCount(): number;
  109473. /**
  109474. * Returns a boolean indicating if the scene is still loading data
  109475. */
  109476. get isLoading(): boolean;
  109477. /**
  109478. * Registers a function to be executed when the scene is ready
  109479. * @param {Function} func - the function to be executed
  109480. */
  109481. executeWhenReady(func: () => void): void;
  109482. /**
  109483. * Returns a promise that resolves when the scene is ready
  109484. * @returns A promise that resolves when the scene is ready
  109485. */
  109486. whenReadyAsync(): Promise<void>;
  109487. /** @hidden */
  109488. _checkIsReady(): void;
  109489. /**
  109490. * Gets all animatable attached to the scene
  109491. */
  109492. get animatables(): Animatable[];
  109493. /**
  109494. * Resets the last animation time frame.
  109495. * Useful to override when animations start running when loading a scene for the first time.
  109496. */
  109497. resetLastAnimationTimeFrame(): void;
  109498. /**
  109499. * Gets the current view matrix
  109500. * @returns a Matrix
  109501. */
  109502. getViewMatrix(): Matrix;
  109503. /**
  109504. * Gets the current projection matrix
  109505. * @returns a Matrix
  109506. */
  109507. getProjectionMatrix(): Matrix;
  109508. /**
  109509. * Gets the current transform matrix
  109510. * @returns a Matrix made of View * Projection
  109511. */
  109512. getTransformMatrix(): Matrix;
  109513. /**
  109514. * Sets the current transform matrix
  109515. * @param viewL defines the View matrix to use
  109516. * @param projectionL defines the Projection matrix to use
  109517. * @param viewR defines the right View matrix to use (if provided)
  109518. * @param projectionR defines the right Projection matrix to use (if provided)
  109519. */
  109520. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109521. /**
  109522. * Gets the uniform buffer used to store scene data
  109523. * @returns a UniformBuffer
  109524. */
  109525. getSceneUniformBuffer(): UniformBuffer;
  109526. /**
  109527. * Gets an unique (relatively to the current scene) Id
  109528. * @returns an unique number for the scene
  109529. */
  109530. getUniqueId(): number;
  109531. /**
  109532. * Add a mesh to the list of scene's meshes
  109533. * @param newMesh defines the mesh to add
  109534. * @param recursive if all child meshes should also be added to the scene
  109535. */
  109536. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109537. /**
  109538. * Remove a mesh for the list of scene's meshes
  109539. * @param toRemove defines the mesh to remove
  109540. * @param recursive if all child meshes should also be removed from the scene
  109541. * @returns the index where the mesh was in the mesh list
  109542. */
  109543. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109544. /**
  109545. * Add a transform node to the list of scene's transform nodes
  109546. * @param newTransformNode defines the transform node to add
  109547. */
  109548. addTransformNode(newTransformNode: TransformNode): void;
  109549. /**
  109550. * Remove a transform node for the list of scene's transform nodes
  109551. * @param toRemove defines the transform node to remove
  109552. * @returns the index where the transform node was in the transform node list
  109553. */
  109554. removeTransformNode(toRemove: TransformNode): number;
  109555. /**
  109556. * Remove a skeleton for the list of scene's skeletons
  109557. * @param toRemove defines the skeleton to remove
  109558. * @returns the index where the skeleton was in the skeleton list
  109559. */
  109560. removeSkeleton(toRemove: Skeleton): number;
  109561. /**
  109562. * Remove a morph target for the list of scene's morph targets
  109563. * @param toRemove defines the morph target to remove
  109564. * @returns the index where the morph target was in the morph target list
  109565. */
  109566. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109567. /**
  109568. * Remove a light for the list of scene's lights
  109569. * @param toRemove defines the light to remove
  109570. * @returns the index where the light was in the light list
  109571. */
  109572. removeLight(toRemove: Light): number;
  109573. /**
  109574. * Remove a camera for the list of scene's cameras
  109575. * @param toRemove defines the camera to remove
  109576. * @returns the index where the camera was in the camera list
  109577. */
  109578. removeCamera(toRemove: Camera): number;
  109579. /**
  109580. * Remove a particle system for the list of scene's particle systems
  109581. * @param toRemove defines the particle system to remove
  109582. * @returns the index where the particle system was in the particle system list
  109583. */
  109584. removeParticleSystem(toRemove: IParticleSystem): number;
  109585. /**
  109586. * Remove a animation for the list of scene's animations
  109587. * @param toRemove defines the animation to remove
  109588. * @returns the index where the animation was in the animation list
  109589. */
  109590. removeAnimation(toRemove: Animation): number;
  109591. /**
  109592. * Will stop the animation of the given target
  109593. * @param target - the target
  109594. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109595. * @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)
  109596. */
  109597. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109598. /**
  109599. * Removes the given animation group from this scene.
  109600. * @param toRemove The animation group to remove
  109601. * @returns The index of the removed animation group
  109602. */
  109603. removeAnimationGroup(toRemove: AnimationGroup): number;
  109604. /**
  109605. * Removes the given multi-material from this scene.
  109606. * @param toRemove The multi-material to remove
  109607. * @returns The index of the removed multi-material
  109608. */
  109609. removeMultiMaterial(toRemove: MultiMaterial): number;
  109610. /**
  109611. * Removes the given material from this scene.
  109612. * @param toRemove The material to remove
  109613. * @returns The index of the removed material
  109614. */
  109615. removeMaterial(toRemove: Material): number;
  109616. /**
  109617. * Removes the given action manager from this scene.
  109618. * @param toRemove The action manager to remove
  109619. * @returns The index of the removed action manager
  109620. */
  109621. removeActionManager(toRemove: AbstractActionManager): number;
  109622. /**
  109623. * Removes the given texture from this scene.
  109624. * @param toRemove The texture to remove
  109625. * @returns The index of the removed texture
  109626. */
  109627. removeTexture(toRemove: BaseTexture): number;
  109628. /**
  109629. * Adds the given light to this scene
  109630. * @param newLight The light to add
  109631. */
  109632. addLight(newLight: Light): void;
  109633. /**
  109634. * Sorts the list list based on light priorities
  109635. */
  109636. sortLightsByPriority(): void;
  109637. /**
  109638. * Adds the given camera to this scene
  109639. * @param newCamera The camera to add
  109640. */
  109641. addCamera(newCamera: Camera): void;
  109642. /**
  109643. * Adds the given skeleton to this scene
  109644. * @param newSkeleton The skeleton to add
  109645. */
  109646. addSkeleton(newSkeleton: Skeleton): void;
  109647. /**
  109648. * Adds the given particle system to this scene
  109649. * @param newParticleSystem The particle system to add
  109650. */
  109651. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109652. /**
  109653. * Adds the given animation to this scene
  109654. * @param newAnimation The animation to add
  109655. */
  109656. addAnimation(newAnimation: Animation): void;
  109657. /**
  109658. * Adds the given animation group to this scene.
  109659. * @param newAnimationGroup The animation group to add
  109660. */
  109661. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109662. /**
  109663. * Adds the given multi-material to this scene
  109664. * @param newMultiMaterial The multi-material to add
  109665. */
  109666. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109667. /**
  109668. * Adds the given material to this scene
  109669. * @param newMaterial The material to add
  109670. */
  109671. addMaterial(newMaterial: Material): void;
  109672. /**
  109673. * Adds the given morph target to this scene
  109674. * @param newMorphTargetManager The morph target to add
  109675. */
  109676. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109677. /**
  109678. * Adds the given geometry to this scene
  109679. * @param newGeometry The geometry to add
  109680. */
  109681. addGeometry(newGeometry: Geometry): void;
  109682. /**
  109683. * Adds the given action manager to this scene
  109684. * @param newActionManager The action manager to add
  109685. */
  109686. addActionManager(newActionManager: AbstractActionManager): void;
  109687. /**
  109688. * Adds the given texture to this scene.
  109689. * @param newTexture The texture to add
  109690. */
  109691. addTexture(newTexture: BaseTexture): void;
  109692. /**
  109693. * Switch active camera
  109694. * @param newCamera defines the new active camera
  109695. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109696. */
  109697. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109698. /**
  109699. * sets the active camera of the scene using its ID
  109700. * @param id defines the camera's ID
  109701. * @return the new active camera or null if none found.
  109702. */
  109703. setActiveCameraByID(id: string): Nullable<Camera>;
  109704. /**
  109705. * sets the active camera of the scene using its name
  109706. * @param name defines the camera's name
  109707. * @returns the new active camera or null if none found.
  109708. */
  109709. setActiveCameraByName(name: string): Nullable<Camera>;
  109710. /**
  109711. * get an animation group using its name
  109712. * @param name defines the material's name
  109713. * @return the animation group or null if none found.
  109714. */
  109715. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109716. /**
  109717. * Get a material using its unique id
  109718. * @param uniqueId defines the material's unique id
  109719. * @return the material or null if none found.
  109720. */
  109721. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109722. /**
  109723. * get a material using its id
  109724. * @param id defines the material's ID
  109725. * @return the material or null if none found.
  109726. */
  109727. getMaterialByID(id: string): Nullable<Material>;
  109728. /**
  109729. * Gets a the last added material using a given id
  109730. * @param id defines the material's ID
  109731. * @return the last material with the given id or null if none found.
  109732. */
  109733. getLastMaterialByID(id: string): Nullable<Material>;
  109734. /**
  109735. * Gets a material using its name
  109736. * @param name defines the material's name
  109737. * @return the material or null if none found.
  109738. */
  109739. getMaterialByName(name: string): Nullable<Material>;
  109740. /**
  109741. * Get a texture using its unique id
  109742. * @param uniqueId defines the texture's unique id
  109743. * @return the texture or null if none found.
  109744. */
  109745. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109746. /**
  109747. * Gets a camera using its id
  109748. * @param id defines the id to look for
  109749. * @returns the camera or null if not found
  109750. */
  109751. getCameraByID(id: string): Nullable<Camera>;
  109752. /**
  109753. * Gets a camera using its unique id
  109754. * @param uniqueId defines the unique id to look for
  109755. * @returns the camera or null if not found
  109756. */
  109757. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109758. /**
  109759. * Gets a camera using its name
  109760. * @param name defines the camera's name
  109761. * @return the camera or null if none found.
  109762. */
  109763. getCameraByName(name: string): Nullable<Camera>;
  109764. /**
  109765. * Gets a bone using its id
  109766. * @param id defines the bone's id
  109767. * @return the bone or null if not found
  109768. */
  109769. getBoneByID(id: string): Nullable<Bone>;
  109770. /**
  109771. * Gets a bone using its id
  109772. * @param name defines the bone's name
  109773. * @return the bone or null if not found
  109774. */
  109775. getBoneByName(name: string): Nullable<Bone>;
  109776. /**
  109777. * Gets a light node using its name
  109778. * @param name defines the the light's name
  109779. * @return the light or null if none found.
  109780. */
  109781. getLightByName(name: string): Nullable<Light>;
  109782. /**
  109783. * Gets a light node using its id
  109784. * @param id defines the light's id
  109785. * @return the light or null if none found.
  109786. */
  109787. getLightByID(id: string): Nullable<Light>;
  109788. /**
  109789. * Gets a light node using its scene-generated unique ID
  109790. * @param uniqueId defines the light's unique id
  109791. * @return the light or null if none found.
  109792. */
  109793. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109794. /**
  109795. * Gets a particle system by id
  109796. * @param id defines the particle system id
  109797. * @return the corresponding system or null if none found
  109798. */
  109799. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109800. /**
  109801. * Gets a geometry using its ID
  109802. * @param id defines the geometry's id
  109803. * @return the geometry or null if none found.
  109804. */
  109805. getGeometryByID(id: string): Nullable<Geometry>;
  109806. private _getGeometryByUniqueID;
  109807. /**
  109808. * Add a new geometry to this scene
  109809. * @param geometry defines the geometry to be added to the scene.
  109810. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109811. * @return a boolean defining if the geometry was added or not
  109812. */
  109813. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109814. /**
  109815. * Removes an existing geometry
  109816. * @param geometry defines the geometry to be removed from the scene
  109817. * @return a boolean defining if the geometry was removed or not
  109818. */
  109819. removeGeometry(geometry: Geometry): boolean;
  109820. /**
  109821. * Gets the list of geometries attached to the scene
  109822. * @returns an array of Geometry
  109823. */
  109824. getGeometries(): Geometry[];
  109825. /**
  109826. * Gets the first added mesh found of a given ID
  109827. * @param id defines the id to search for
  109828. * @return the mesh found or null if not found at all
  109829. */
  109830. getMeshByID(id: string): Nullable<AbstractMesh>;
  109831. /**
  109832. * Gets a list of meshes using their id
  109833. * @param id defines the id to search for
  109834. * @returns a list of meshes
  109835. */
  109836. getMeshesByID(id: string): Array<AbstractMesh>;
  109837. /**
  109838. * Gets the first added transform node found of a given ID
  109839. * @param id defines the id to search for
  109840. * @return the found transform node or null if not found at all.
  109841. */
  109842. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109843. /**
  109844. * Gets a transform node with its auto-generated unique id
  109845. * @param uniqueId efines the unique id to search for
  109846. * @return the found transform node or null if not found at all.
  109847. */
  109848. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109849. /**
  109850. * Gets a list of transform nodes using their id
  109851. * @param id defines the id to search for
  109852. * @returns a list of transform nodes
  109853. */
  109854. getTransformNodesByID(id: string): Array<TransformNode>;
  109855. /**
  109856. * Gets a mesh with its auto-generated unique id
  109857. * @param uniqueId defines the unique id to search for
  109858. * @return the found mesh or null if not found at all.
  109859. */
  109860. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109861. /**
  109862. * Gets a the last added mesh using a given id
  109863. * @param id defines the id to search for
  109864. * @return the found mesh or null if not found at all.
  109865. */
  109866. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109867. /**
  109868. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109869. * @param id defines the id to search for
  109870. * @return the found node or null if not found at all
  109871. */
  109872. getLastEntryByID(id: string): Nullable<Node>;
  109873. /**
  109874. * Gets a node (Mesh, Camera, Light) using a given id
  109875. * @param id defines the id to search for
  109876. * @return the found node or null if not found at all
  109877. */
  109878. getNodeByID(id: string): Nullable<Node>;
  109879. /**
  109880. * Gets a node (Mesh, Camera, Light) using a given name
  109881. * @param name defines the name to search for
  109882. * @return the found node or null if not found at all.
  109883. */
  109884. getNodeByName(name: string): Nullable<Node>;
  109885. /**
  109886. * Gets a mesh using a given name
  109887. * @param name defines the name to search for
  109888. * @return the found mesh or null if not found at all.
  109889. */
  109890. getMeshByName(name: string): Nullable<AbstractMesh>;
  109891. /**
  109892. * Gets a transform node using a given name
  109893. * @param name defines the name to search for
  109894. * @return the found transform node or null if not found at all.
  109895. */
  109896. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109897. /**
  109898. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109899. * @param id defines the id to search for
  109900. * @return the found skeleton or null if not found at all.
  109901. */
  109902. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109903. /**
  109904. * Gets a skeleton using a given auto generated unique id
  109905. * @param uniqueId defines the unique id to search for
  109906. * @return the found skeleton or null if not found at all.
  109907. */
  109908. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109909. /**
  109910. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109911. * @param id defines the id to search for
  109912. * @return the found skeleton or null if not found at all.
  109913. */
  109914. getSkeletonById(id: string): Nullable<Skeleton>;
  109915. /**
  109916. * Gets a skeleton using a given name
  109917. * @param name defines the name to search for
  109918. * @return the found skeleton or null if not found at all.
  109919. */
  109920. getSkeletonByName(name: string): Nullable<Skeleton>;
  109921. /**
  109922. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109923. * @param id defines the id to search for
  109924. * @return the found morph target manager or null if not found at all.
  109925. */
  109926. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109927. /**
  109928. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109929. * @param id defines the id to search for
  109930. * @return the found morph target or null if not found at all.
  109931. */
  109932. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109933. /**
  109934. * Gets a boolean indicating if the given mesh is active
  109935. * @param mesh defines the mesh to look for
  109936. * @returns true if the mesh is in the active list
  109937. */
  109938. isActiveMesh(mesh: AbstractMesh): boolean;
  109939. /**
  109940. * Return a unique id as a string which can serve as an identifier for the scene
  109941. */
  109942. get uid(): string;
  109943. /**
  109944. * Add an externaly attached data from its key.
  109945. * This method call will fail and return false, if such key already exists.
  109946. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109947. * @param key the unique key that identifies the data
  109948. * @param data the data object to associate to the key for this Engine instance
  109949. * @return true if no such key were already present and the data was added successfully, false otherwise
  109950. */
  109951. addExternalData<T>(key: string, data: T): boolean;
  109952. /**
  109953. * Get an externaly attached data from its key
  109954. * @param key the unique key that identifies the data
  109955. * @return the associated data, if present (can be null), or undefined if not present
  109956. */
  109957. getExternalData<T>(key: string): Nullable<T>;
  109958. /**
  109959. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109960. * @param key the unique key that identifies the data
  109961. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109962. * @return the associated data, can be null if the factory returned null.
  109963. */
  109964. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109965. /**
  109966. * Remove an externaly attached data from the Engine instance
  109967. * @param key the unique key that identifies the data
  109968. * @return true if the data was successfully removed, false if it doesn't exist
  109969. */
  109970. removeExternalData(key: string): boolean;
  109971. private _evaluateSubMesh;
  109972. /**
  109973. * Clear the processed materials smart array preventing retention point in material dispose.
  109974. */
  109975. freeProcessedMaterials(): void;
  109976. private _preventFreeActiveMeshesAndRenderingGroups;
  109977. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109978. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109979. * when disposing several meshes in a row or a hierarchy of meshes.
  109980. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109981. */
  109982. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109983. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109984. /**
  109985. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109986. */
  109987. freeActiveMeshes(): void;
  109988. /**
  109989. * Clear the info related to rendering groups preventing retention points during dispose.
  109990. */
  109991. freeRenderingGroups(): void;
  109992. /** @hidden */
  109993. _isInIntermediateRendering(): boolean;
  109994. /**
  109995. * Lambda returning the list of potentially active meshes.
  109996. */
  109997. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109998. /**
  109999. * Lambda returning the list of potentially active sub meshes.
  110000. */
  110001. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110002. /**
  110003. * Lambda returning the list of potentially intersecting sub meshes.
  110004. */
  110005. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110006. /**
  110007. * Lambda returning the list of potentially colliding sub meshes.
  110008. */
  110009. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110010. private _activeMeshesFrozen;
  110011. private _skipEvaluateActiveMeshesCompletely;
  110012. /**
  110013. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110014. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110015. * @returns the current scene
  110016. */
  110017. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110018. /**
  110019. * Use this function to restart evaluating active meshes on every frame
  110020. * @returns the current scene
  110021. */
  110022. unfreezeActiveMeshes(): Scene;
  110023. private _evaluateActiveMeshes;
  110024. private _activeMesh;
  110025. /**
  110026. * Update the transform matrix to update from the current active camera
  110027. * @param force defines a boolean used to force the update even if cache is up to date
  110028. */
  110029. updateTransformMatrix(force?: boolean): void;
  110030. private _bindFrameBuffer;
  110031. /** @hidden */
  110032. _allowPostProcessClearColor: boolean;
  110033. /** @hidden */
  110034. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110035. private _processSubCameras;
  110036. private _checkIntersections;
  110037. /** @hidden */
  110038. _advancePhysicsEngineStep(step: number): void;
  110039. /**
  110040. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110041. */
  110042. getDeterministicFrameTime: () => number;
  110043. /** @hidden */
  110044. _animate(): void;
  110045. /** Execute all animations (for a frame) */
  110046. animate(): void;
  110047. /**
  110048. * Render the scene
  110049. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110050. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110051. */
  110052. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110053. /**
  110054. * Freeze all materials
  110055. * A frozen material will not be updatable but should be faster to render
  110056. */
  110057. freezeMaterials(): void;
  110058. /**
  110059. * Unfreeze all materials
  110060. * A frozen material will not be updatable but should be faster to render
  110061. */
  110062. unfreezeMaterials(): void;
  110063. /**
  110064. * Releases all held ressources
  110065. */
  110066. dispose(): void;
  110067. /**
  110068. * Gets if the scene is already disposed
  110069. */
  110070. get isDisposed(): boolean;
  110071. /**
  110072. * Call this function to reduce memory footprint of the scene.
  110073. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110074. */
  110075. clearCachedVertexData(): void;
  110076. /**
  110077. * This function will remove the local cached buffer data from texture.
  110078. * It will save memory but will prevent the texture from being rebuilt
  110079. */
  110080. cleanCachedTextureBuffer(): void;
  110081. /**
  110082. * Get the world extend vectors with an optional filter
  110083. *
  110084. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110085. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110086. */
  110087. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110088. min: Vector3;
  110089. max: Vector3;
  110090. };
  110091. /**
  110092. * Creates a ray that can be used to pick in the scene
  110093. * @param x defines the x coordinate of the origin (on-screen)
  110094. * @param y defines the y coordinate of the origin (on-screen)
  110095. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110096. * @param camera defines the camera to use for the picking
  110097. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110098. * @returns a Ray
  110099. */
  110100. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110101. /**
  110102. * Creates a ray that can be used to pick in the scene
  110103. * @param x defines the x coordinate of the origin (on-screen)
  110104. * @param y defines the y coordinate of the origin (on-screen)
  110105. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110106. * @param result defines the ray where to store the picking ray
  110107. * @param camera defines the camera to use for the picking
  110108. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110109. * @returns the current scene
  110110. */
  110111. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110112. /**
  110113. * Creates a ray that can be used to pick in the scene
  110114. * @param x defines the x coordinate of the origin (on-screen)
  110115. * @param y defines the y coordinate of the origin (on-screen)
  110116. * @param camera defines the camera to use for the picking
  110117. * @returns a Ray
  110118. */
  110119. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110120. /**
  110121. * Creates a ray that can be used to pick in the scene
  110122. * @param x defines the x coordinate of the origin (on-screen)
  110123. * @param y defines the y coordinate of the origin (on-screen)
  110124. * @param result defines the ray where to store the picking ray
  110125. * @param camera defines the camera to use for the picking
  110126. * @returns the current scene
  110127. */
  110128. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110129. /** Launch a ray to try to pick a mesh in the scene
  110130. * @param x position on screen
  110131. * @param y position on screen
  110132. * @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
  110133. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110134. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110135. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110136. * @returns a PickingInfo
  110137. */
  110138. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110139. /** Use the given ray to pick a mesh in the scene
  110140. * @param ray The ray to use to pick meshes
  110141. * @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
  110142. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110144. * @returns a PickingInfo
  110145. */
  110146. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110147. /**
  110148. * Launch a ray to try to pick a mesh in the scene
  110149. * @param x X position on screen
  110150. * @param y Y position on screen
  110151. * @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
  110152. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110153. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110154. * @returns an array of PickingInfo
  110155. */
  110156. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110157. /**
  110158. * Launch a ray to try to pick a mesh in the scene
  110159. * @param ray Ray to use
  110160. * @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
  110161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110162. * @returns an array of PickingInfo
  110163. */
  110164. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110165. /**
  110166. * Force the value of meshUnderPointer
  110167. * @param mesh defines the mesh to use
  110168. */
  110169. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110170. /**
  110171. * Gets the mesh under the pointer
  110172. * @returns a Mesh or null if no mesh is under the pointer
  110173. */
  110174. getPointerOverMesh(): Nullable<AbstractMesh>;
  110175. /** @hidden */
  110176. _rebuildGeometries(): void;
  110177. /** @hidden */
  110178. _rebuildTextures(): void;
  110179. private _getByTags;
  110180. /**
  110181. * Get a list of meshes by tags
  110182. * @param tagsQuery defines the tags query to use
  110183. * @param forEach defines a predicate used to filter results
  110184. * @returns an array of Mesh
  110185. */
  110186. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110187. /**
  110188. * Get a list of cameras by tags
  110189. * @param tagsQuery defines the tags query to use
  110190. * @param forEach defines a predicate used to filter results
  110191. * @returns an array of Camera
  110192. */
  110193. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110194. /**
  110195. * Get a list of lights by tags
  110196. * @param tagsQuery defines the tags query to use
  110197. * @param forEach defines a predicate used to filter results
  110198. * @returns an array of Light
  110199. */
  110200. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110201. /**
  110202. * Get a list of materials by tags
  110203. * @param tagsQuery defines the tags query to use
  110204. * @param forEach defines a predicate used to filter results
  110205. * @returns an array of Material
  110206. */
  110207. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110208. /**
  110209. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110210. * This allowed control for front to back rendering or reversly depending of the special needs.
  110211. *
  110212. * @param renderingGroupId The rendering group id corresponding to its index
  110213. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110214. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110215. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110216. */
  110217. 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;
  110218. /**
  110219. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110220. *
  110221. * @param renderingGroupId The rendering group id corresponding to its index
  110222. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110223. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110224. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110225. */
  110226. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110227. /**
  110228. * Gets the current auto clear configuration for one rendering group of the rendering
  110229. * manager.
  110230. * @param index the rendering group index to get the information for
  110231. * @returns The auto clear setup for the requested rendering group
  110232. */
  110233. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110234. private _blockMaterialDirtyMechanism;
  110235. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110236. get blockMaterialDirtyMechanism(): boolean;
  110237. set blockMaterialDirtyMechanism(value: boolean);
  110238. /**
  110239. * Will flag all materials as dirty to trigger new shader compilation
  110240. * @param flag defines the flag used to specify which material part must be marked as dirty
  110241. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110242. */
  110243. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110244. /** @hidden */
  110245. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  110246. /** @hidden */
  110247. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110248. /** @hidden */
  110249. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  110250. /** @hidden */
  110251. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110252. /** @hidden */
  110253. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110254. /** @hidden */
  110255. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110256. }
  110257. }
  110258. declare module BABYLON {
  110259. /**
  110260. * Set of assets to keep when moving a scene into an asset container.
  110261. */
  110262. export class KeepAssets extends AbstractScene {
  110263. }
  110264. /**
  110265. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110266. */
  110267. export class InstantiatedEntries {
  110268. /**
  110269. * List of new root nodes (eg. nodes with no parent)
  110270. */
  110271. rootNodes: TransformNode[];
  110272. /**
  110273. * List of new skeletons
  110274. */
  110275. skeletons: Skeleton[];
  110276. /**
  110277. * List of new animation groups
  110278. */
  110279. animationGroups: AnimationGroup[];
  110280. }
  110281. /**
  110282. * Container with a set of assets that can be added or removed from a scene.
  110283. */
  110284. export class AssetContainer extends AbstractScene {
  110285. private _wasAddedToScene;
  110286. /**
  110287. * The scene the AssetContainer belongs to.
  110288. */
  110289. scene: Scene;
  110290. /**
  110291. * Instantiates an AssetContainer.
  110292. * @param scene The scene the AssetContainer belongs to.
  110293. */
  110294. constructor(scene: Scene);
  110295. /**
  110296. * Instantiate or clone all meshes and add the new ones to the scene.
  110297. * Skeletons and animation groups will all be cloned
  110298. * @param nameFunction defines an optional function used to get new names for clones
  110299. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110300. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110301. */
  110302. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110303. /**
  110304. * Adds all the assets from the container to the scene.
  110305. */
  110306. addAllToScene(): void;
  110307. /**
  110308. * Removes all the assets in the container from the scene
  110309. */
  110310. removeAllFromScene(): void;
  110311. /**
  110312. * Disposes all the assets in the container
  110313. */
  110314. dispose(): void;
  110315. private _moveAssets;
  110316. /**
  110317. * Removes all the assets contained in the scene and adds them to the container.
  110318. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110319. */
  110320. moveAllFromScene(keepAssets?: KeepAssets): void;
  110321. /**
  110322. * 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.
  110323. * @returns the root mesh
  110324. */
  110325. createRootMesh(): Mesh;
  110326. /**
  110327. * Merge animations from this asset container into a scene
  110328. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110329. * @param animatables set of animatables to retarget to a node from the scene
  110330. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110331. */
  110332. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110333. }
  110334. }
  110335. declare module BABYLON {
  110336. /**
  110337. * Defines how the parser contract is defined.
  110338. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110339. */
  110340. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110341. /**
  110342. * Defines how the individual parser contract is defined.
  110343. * These parser can parse an individual asset
  110344. */
  110345. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110346. /**
  110347. * Base class of the scene acting as a container for the different elements composing a scene.
  110348. * This class is dynamically extended by the different components of the scene increasing
  110349. * flexibility and reducing coupling
  110350. */
  110351. export abstract class AbstractScene {
  110352. /**
  110353. * Stores the list of available parsers in the application.
  110354. */
  110355. private static _BabylonFileParsers;
  110356. /**
  110357. * Stores the list of available individual parsers in the application.
  110358. */
  110359. private static _IndividualBabylonFileParsers;
  110360. /**
  110361. * Adds a parser in the list of available ones
  110362. * @param name Defines the name of the parser
  110363. * @param parser Defines the parser to add
  110364. */
  110365. static AddParser(name: string, parser: BabylonFileParser): void;
  110366. /**
  110367. * Gets a general parser from the list of avaialble ones
  110368. * @param name Defines the name of the parser
  110369. * @returns the requested parser or null
  110370. */
  110371. static GetParser(name: string): Nullable<BabylonFileParser>;
  110372. /**
  110373. * Adds n individual parser in the list of available ones
  110374. * @param name Defines the name of the parser
  110375. * @param parser Defines the parser to add
  110376. */
  110377. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110378. /**
  110379. * Gets an individual parser from the list of avaialble ones
  110380. * @param name Defines the name of the parser
  110381. * @returns the requested parser or null
  110382. */
  110383. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110384. /**
  110385. * Parser json data and populate both a scene and its associated container object
  110386. * @param jsonData Defines the data to parse
  110387. * @param scene Defines the scene to parse the data for
  110388. * @param container Defines the container attached to the parsing sequence
  110389. * @param rootUrl Defines the root url of the data
  110390. */
  110391. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110392. /**
  110393. * Gets the list of root nodes (ie. nodes with no parent)
  110394. */
  110395. rootNodes: Node[];
  110396. /** All of the cameras added to this scene
  110397. * @see http://doc.babylonjs.com/babylon101/cameras
  110398. */
  110399. cameras: Camera[];
  110400. /**
  110401. * All of the lights added to this scene
  110402. * @see http://doc.babylonjs.com/babylon101/lights
  110403. */
  110404. lights: Light[];
  110405. /**
  110406. * All of the (abstract) meshes added to this scene
  110407. */
  110408. meshes: AbstractMesh[];
  110409. /**
  110410. * The list of skeletons added to the scene
  110411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110412. */
  110413. skeletons: Skeleton[];
  110414. /**
  110415. * All of the particle systems added to this scene
  110416. * @see http://doc.babylonjs.com/babylon101/particles
  110417. */
  110418. particleSystems: IParticleSystem[];
  110419. /**
  110420. * Gets a list of Animations associated with the scene
  110421. */
  110422. animations: Animation[];
  110423. /**
  110424. * All of the animation groups added to this scene
  110425. * @see http://doc.babylonjs.com/how_to/group
  110426. */
  110427. animationGroups: AnimationGroup[];
  110428. /**
  110429. * All of the multi-materials added to this scene
  110430. * @see http://doc.babylonjs.com/how_to/multi_materials
  110431. */
  110432. multiMaterials: MultiMaterial[];
  110433. /**
  110434. * All of the materials added to this scene
  110435. * In the context of a Scene, it is not supposed to be modified manually.
  110436. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110437. * Note also that the order of the Material within the array is not significant and might change.
  110438. * @see http://doc.babylonjs.com/babylon101/materials
  110439. */
  110440. materials: Material[];
  110441. /**
  110442. * The list of morph target managers added to the scene
  110443. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110444. */
  110445. morphTargetManagers: MorphTargetManager[];
  110446. /**
  110447. * The list of geometries used in the scene.
  110448. */
  110449. geometries: Geometry[];
  110450. /**
  110451. * All of the tranform nodes added to this scene
  110452. * In the context of a Scene, it is not supposed to be modified manually.
  110453. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110454. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110455. * @see http://doc.babylonjs.com/how_to/transformnode
  110456. */
  110457. transformNodes: TransformNode[];
  110458. /**
  110459. * ActionManagers available on the scene.
  110460. */
  110461. actionManagers: AbstractActionManager[];
  110462. /**
  110463. * Textures to keep.
  110464. */
  110465. textures: BaseTexture[];
  110466. /**
  110467. * Environment texture for the scene
  110468. */
  110469. environmentTexture: Nullable<BaseTexture>;
  110470. /**
  110471. * @returns all meshes, lights, cameras, transformNodes and bones
  110472. */
  110473. getNodes(): Array<Node>;
  110474. }
  110475. }
  110476. declare module BABYLON {
  110477. /**
  110478. * Interface used to define options for Sound class
  110479. */
  110480. export interface ISoundOptions {
  110481. /**
  110482. * Does the sound autoplay once loaded.
  110483. */
  110484. autoplay?: boolean;
  110485. /**
  110486. * Does the sound loop after it finishes playing once.
  110487. */
  110488. loop?: boolean;
  110489. /**
  110490. * Sound's volume
  110491. */
  110492. volume?: number;
  110493. /**
  110494. * Is it a spatial sound?
  110495. */
  110496. spatialSound?: boolean;
  110497. /**
  110498. * Maximum distance to hear that sound
  110499. */
  110500. maxDistance?: number;
  110501. /**
  110502. * Uses user defined attenuation function
  110503. */
  110504. useCustomAttenuation?: boolean;
  110505. /**
  110506. * Define the roll off factor of spatial sounds.
  110507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110508. */
  110509. rolloffFactor?: number;
  110510. /**
  110511. * Define the reference distance the sound should be heard perfectly.
  110512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110513. */
  110514. refDistance?: number;
  110515. /**
  110516. * Define the distance attenuation model the sound will follow.
  110517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110518. */
  110519. distanceModel?: string;
  110520. /**
  110521. * Defines the playback speed (1 by default)
  110522. */
  110523. playbackRate?: number;
  110524. /**
  110525. * Defines if the sound is from a streaming source
  110526. */
  110527. streaming?: boolean;
  110528. /**
  110529. * Defines an optional length (in seconds) inside the sound file
  110530. */
  110531. length?: number;
  110532. /**
  110533. * Defines an optional offset (in seconds) inside the sound file
  110534. */
  110535. offset?: number;
  110536. /**
  110537. * If true, URLs will not be required to state the audio file codec to use.
  110538. */
  110539. skipCodecCheck?: boolean;
  110540. }
  110541. /**
  110542. * Defines a sound that can be played in the application.
  110543. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110545. */
  110546. export class Sound {
  110547. /**
  110548. * The name of the sound in the scene.
  110549. */
  110550. name: string;
  110551. /**
  110552. * Does the sound autoplay once loaded.
  110553. */
  110554. autoplay: boolean;
  110555. /**
  110556. * Does the sound loop after it finishes playing once.
  110557. */
  110558. loop: boolean;
  110559. /**
  110560. * Does the sound use a custom attenuation curve to simulate the falloff
  110561. * happening when the source gets further away from the camera.
  110562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110563. */
  110564. useCustomAttenuation: boolean;
  110565. /**
  110566. * The sound track id this sound belongs to.
  110567. */
  110568. soundTrackId: number;
  110569. /**
  110570. * Is this sound currently played.
  110571. */
  110572. isPlaying: boolean;
  110573. /**
  110574. * Is this sound currently paused.
  110575. */
  110576. isPaused: boolean;
  110577. /**
  110578. * Does this sound enables spatial sound.
  110579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110580. */
  110581. spatialSound: boolean;
  110582. /**
  110583. * Define the reference distance the sound should be heard perfectly.
  110584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110585. */
  110586. refDistance: number;
  110587. /**
  110588. * Define the roll off factor of spatial sounds.
  110589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110590. */
  110591. rolloffFactor: number;
  110592. /**
  110593. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110595. */
  110596. maxDistance: number;
  110597. /**
  110598. * Define the distance attenuation model the sound will follow.
  110599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110600. */
  110601. distanceModel: string;
  110602. /**
  110603. * @hidden
  110604. * Back Compat
  110605. **/
  110606. onended: () => any;
  110607. /**
  110608. * Observable event when the current playing sound finishes.
  110609. */
  110610. onEndedObservable: Observable<Sound>;
  110611. private _panningModel;
  110612. private _playbackRate;
  110613. private _streaming;
  110614. private _startTime;
  110615. private _startOffset;
  110616. private _position;
  110617. /** @hidden */
  110618. _positionInEmitterSpace: boolean;
  110619. private _localDirection;
  110620. private _volume;
  110621. private _isReadyToPlay;
  110622. private _isDirectional;
  110623. private _readyToPlayCallback;
  110624. private _audioBuffer;
  110625. private _soundSource;
  110626. private _streamingSource;
  110627. private _soundPanner;
  110628. private _soundGain;
  110629. private _inputAudioNode;
  110630. private _outputAudioNode;
  110631. private _coneInnerAngle;
  110632. private _coneOuterAngle;
  110633. private _coneOuterGain;
  110634. private _scene;
  110635. private _connectedTransformNode;
  110636. private _customAttenuationFunction;
  110637. private _registerFunc;
  110638. private _isOutputConnected;
  110639. private _htmlAudioElement;
  110640. private _urlType;
  110641. private _length?;
  110642. private _offset?;
  110643. /** @hidden */
  110644. static _SceneComponentInitialization: (scene: Scene) => void;
  110645. /**
  110646. * Create a sound and attach it to a scene
  110647. * @param name Name of your sound
  110648. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110649. * @param scene defines the scene the sound belongs to
  110650. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110651. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110652. */
  110653. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110654. /**
  110655. * Release the sound and its associated resources
  110656. */
  110657. dispose(): void;
  110658. /**
  110659. * Gets if the sounds is ready to be played or not.
  110660. * @returns true if ready, otherwise false
  110661. */
  110662. isReady(): boolean;
  110663. private _soundLoaded;
  110664. /**
  110665. * Sets the data of the sound from an audiobuffer
  110666. * @param audioBuffer The audioBuffer containing the data
  110667. */
  110668. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110669. /**
  110670. * Updates the current sounds options such as maxdistance, loop...
  110671. * @param options A JSON object containing values named as the object properties
  110672. */
  110673. updateOptions(options: ISoundOptions): void;
  110674. private _createSpatialParameters;
  110675. private _updateSpatialParameters;
  110676. /**
  110677. * Switch the panning model to HRTF:
  110678. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110680. */
  110681. switchPanningModelToHRTF(): void;
  110682. /**
  110683. * Switch the panning model to Equal Power:
  110684. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110686. */
  110687. switchPanningModelToEqualPower(): void;
  110688. private _switchPanningModel;
  110689. /**
  110690. * Connect this sound to a sound track audio node like gain...
  110691. * @param soundTrackAudioNode the sound track audio node to connect to
  110692. */
  110693. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110694. /**
  110695. * Transform this sound into a directional source
  110696. * @param coneInnerAngle Size of the inner cone in degree
  110697. * @param coneOuterAngle Size of the outer cone in degree
  110698. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110699. */
  110700. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110701. /**
  110702. * Gets or sets the inner angle for the directional cone.
  110703. */
  110704. get directionalConeInnerAngle(): number;
  110705. /**
  110706. * Gets or sets the inner angle for the directional cone.
  110707. */
  110708. set directionalConeInnerAngle(value: number);
  110709. /**
  110710. * Gets or sets the outer angle for the directional cone.
  110711. */
  110712. get directionalConeOuterAngle(): number;
  110713. /**
  110714. * Gets or sets the outer angle for the directional cone.
  110715. */
  110716. set directionalConeOuterAngle(value: number);
  110717. /**
  110718. * Sets the position of the emitter if spatial sound is enabled
  110719. * @param newPosition Defines the new posisiton
  110720. */
  110721. setPosition(newPosition: Vector3): void;
  110722. /**
  110723. * Sets the local direction of the emitter if spatial sound is enabled
  110724. * @param newLocalDirection Defines the new local direction
  110725. */
  110726. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110727. private _updateDirection;
  110728. /** @hidden */
  110729. updateDistanceFromListener(): void;
  110730. /**
  110731. * Sets a new custom attenuation function for the sound.
  110732. * @param callback Defines the function used for the attenuation
  110733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110734. */
  110735. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110736. /**
  110737. * Play the sound
  110738. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110739. * @param offset (optional) Start the sound at a specific time in seconds
  110740. * @param length (optional) Sound duration (in seconds)
  110741. */
  110742. play(time?: number, offset?: number, length?: number): void;
  110743. private _onended;
  110744. /**
  110745. * Stop the sound
  110746. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110747. */
  110748. stop(time?: number): void;
  110749. /**
  110750. * Put the sound in pause
  110751. */
  110752. pause(): void;
  110753. /**
  110754. * Sets a dedicated volume for this sounds
  110755. * @param newVolume Define the new volume of the sound
  110756. * @param time Define time for gradual change to new volume
  110757. */
  110758. setVolume(newVolume: number, time?: number): void;
  110759. /**
  110760. * Set the sound play back rate
  110761. * @param newPlaybackRate Define the playback rate the sound should be played at
  110762. */
  110763. setPlaybackRate(newPlaybackRate: number): void;
  110764. /**
  110765. * Gets the volume of the sound.
  110766. * @returns the volume of the sound
  110767. */
  110768. getVolume(): number;
  110769. /**
  110770. * Attach the sound to a dedicated mesh
  110771. * @param transformNode The transform node to connect the sound with
  110772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110773. */
  110774. attachToMesh(transformNode: TransformNode): void;
  110775. /**
  110776. * Detach the sound from the previously attached mesh
  110777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110778. */
  110779. detachFromMesh(): void;
  110780. private _onRegisterAfterWorldMatrixUpdate;
  110781. /**
  110782. * Clone the current sound in the scene.
  110783. * @returns the new sound clone
  110784. */
  110785. clone(): Nullable<Sound>;
  110786. /**
  110787. * Gets the current underlying audio buffer containing the data
  110788. * @returns the audio buffer
  110789. */
  110790. getAudioBuffer(): Nullable<AudioBuffer>;
  110791. /**
  110792. * Serializes the Sound in a JSON representation
  110793. * @returns the JSON representation of the sound
  110794. */
  110795. serialize(): any;
  110796. /**
  110797. * Parse a JSON representation of a sound to innstantiate in a given scene
  110798. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110799. * @param scene Define the scene the new parsed sound should be created in
  110800. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110801. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110802. * @returns the newly parsed sound
  110803. */
  110804. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110805. }
  110806. }
  110807. declare module BABYLON {
  110808. /**
  110809. * This defines an action helpful to play a defined sound on a triggered action.
  110810. */
  110811. export class PlaySoundAction extends Action {
  110812. private _sound;
  110813. /**
  110814. * Instantiate the action
  110815. * @param triggerOptions defines the trigger options
  110816. * @param sound defines the sound to play
  110817. * @param condition defines the trigger related conditions
  110818. */
  110819. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110820. /** @hidden */
  110821. _prepare(): void;
  110822. /**
  110823. * Execute the action and play the sound.
  110824. */
  110825. execute(): void;
  110826. /**
  110827. * Serializes the actions and its related information.
  110828. * @param parent defines the object to serialize in
  110829. * @returns the serialized object
  110830. */
  110831. serialize(parent: any): any;
  110832. }
  110833. /**
  110834. * This defines an action helpful to stop a defined sound on a triggered action.
  110835. */
  110836. export class StopSoundAction extends Action {
  110837. private _sound;
  110838. /**
  110839. * Instantiate the action
  110840. * @param triggerOptions defines the trigger options
  110841. * @param sound defines the sound to stop
  110842. * @param condition defines the trigger related conditions
  110843. */
  110844. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110845. /** @hidden */
  110846. _prepare(): void;
  110847. /**
  110848. * Execute the action and stop the sound.
  110849. */
  110850. execute(): void;
  110851. /**
  110852. * Serializes the actions and its related information.
  110853. * @param parent defines the object to serialize in
  110854. * @returns the serialized object
  110855. */
  110856. serialize(parent: any): any;
  110857. }
  110858. }
  110859. declare module BABYLON {
  110860. /**
  110861. * This defines an action responsible to change the value of a property
  110862. * by interpolating between its current value and the newly set one once triggered.
  110863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110864. */
  110865. export class InterpolateValueAction extends Action {
  110866. /**
  110867. * Defines the path of the property where the value should be interpolated
  110868. */
  110869. propertyPath: string;
  110870. /**
  110871. * Defines the target value at the end of the interpolation.
  110872. */
  110873. value: any;
  110874. /**
  110875. * Defines the time it will take for the property to interpolate to the value.
  110876. */
  110877. duration: number;
  110878. /**
  110879. * Defines if the other scene animations should be stopped when the action has been triggered
  110880. */
  110881. stopOtherAnimations?: boolean;
  110882. /**
  110883. * Defines a callback raised once the interpolation animation has been done.
  110884. */
  110885. onInterpolationDone?: () => void;
  110886. /**
  110887. * Observable triggered once the interpolation animation has been done.
  110888. */
  110889. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110890. private _target;
  110891. private _effectiveTarget;
  110892. private _property;
  110893. /**
  110894. * Instantiate the action
  110895. * @param triggerOptions defines the trigger options
  110896. * @param target defines the object containing the value to interpolate
  110897. * @param propertyPath defines the path to the property in the target object
  110898. * @param value defines the target value at the end of the interpolation
  110899. * @param duration deines the time it will take for the property to interpolate to the value.
  110900. * @param condition defines the trigger related conditions
  110901. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110902. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110903. */
  110904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110905. /** @hidden */
  110906. _prepare(): void;
  110907. /**
  110908. * Execute the action starts the value interpolation.
  110909. */
  110910. execute(): void;
  110911. /**
  110912. * Serializes the actions and its related information.
  110913. * @param parent defines the object to serialize in
  110914. * @returns the serialized object
  110915. */
  110916. serialize(parent: any): any;
  110917. }
  110918. }
  110919. declare module BABYLON {
  110920. /**
  110921. * Options allowed during the creation of a sound track.
  110922. */
  110923. export interface ISoundTrackOptions {
  110924. /**
  110925. * The volume the sound track should take during creation
  110926. */
  110927. volume?: number;
  110928. /**
  110929. * Define if the sound track is the main sound track of the scene
  110930. */
  110931. mainTrack?: boolean;
  110932. }
  110933. /**
  110934. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110935. * It will be also used in a future release to apply effects on a specific track.
  110936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110937. */
  110938. export class SoundTrack {
  110939. /**
  110940. * The unique identifier of the sound track in the scene.
  110941. */
  110942. id: number;
  110943. /**
  110944. * The list of sounds included in the sound track.
  110945. */
  110946. soundCollection: Array<Sound>;
  110947. private _outputAudioNode;
  110948. private _scene;
  110949. private _connectedAnalyser;
  110950. private _options;
  110951. private _isInitialized;
  110952. /**
  110953. * Creates a new sound track.
  110954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110955. * @param scene Define the scene the sound track belongs to
  110956. * @param options
  110957. */
  110958. constructor(scene: Scene, options?: ISoundTrackOptions);
  110959. private _initializeSoundTrackAudioGraph;
  110960. /**
  110961. * Release the sound track and its associated resources
  110962. */
  110963. dispose(): void;
  110964. /**
  110965. * Adds a sound to this sound track
  110966. * @param sound define the cound to add
  110967. * @ignoreNaming
  110968. */
  110969. AddSound(sound: Sound): void;
  110970. /**
  110971. * Removes a sound to this sound track
  110972. * @param sound define the cound to remove
  110973. * @ignoreNaming
  110974. */
  110975. RemoveSound(sound: Sound): void;
  110976. /**
  110977. * Set a global volume for the full sound track.
  110978. * @param newVolume Define the new volume of the sound track
  110979. */
  110980. setVolume(newVolume: number): void;
  110981. /**
  110982. * Switch the panning model to HRTF:
  110983. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110985. */
  110986. switchPanningModelToHRTF(): void;
  110987. /**
  110988. * Switch the panning model to Equal Power:
  110989. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110991. */
  110992. switchPanningModelToEqualPower(): void;
  110993. /**
  110994. * Connect the sound track to an audio analyser allowing some amazing
  110995. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110997. * @param analyser The analyser to connect to the engine
  110998. */
  110999. connectToAnalyser(analyser: Analyser): void;
  111000. }
  111001. }
  111002. declare module BABYLON {
  111003. interface AbstractScene {
  111004. /**
  111005. * The list of sounds used in the scene.
  111006. */
  111007. sounds: Nullable<Array<Sound>>;
  111008. }
  111009. interface Scene {
  111010. /**
  111011. * @hidden
  111012. * Backing field
  111013. */
  111014. _mainSoundTrack: SoundTrack;
  111015. /**
  111016. * The main sound track played by the scene.
  111017. * It cotains your primary collection of sounds.
  111018. */
  111019. mainSoundTrack: SoundTrack;
  111020. /**
  111021. * The list of sound tracks added to the scene
  111022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111023. */
  111024. soundTracks: Nullable<Array<SoundTrack>>;
  111025. /**
  111026. * Gets a sound using a given name
  111027. * @param name defines the name to search for
  111028. * @return the found sound or null if not found at all.
  111029. */
  111030. getSoundByName(name: string): Nullable<Sound>;
  111031. /**
  111032. * Gets or sets if audio support is enabled
  111033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111034. */
  111035. audioEnabled: boolean;
  111036. /**
  111037. * Gets or sets if audio will be output to headphones
  111038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111039. */
  111040. headphone: boolean;
  111041. /**
  111042. * Gets or sets custom audio listener position provider
  111043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111044. */
  111045. audioListenerPositionProvider: Nullable<() => Vector3>;
  111046. /**
  111047. * Gets or sets a refresh rate when using 3D audio positioning
  111048. */
  111049. audioPositioningRefreshRate: number;
  111050. }
  111051. /**
  111052. * Defines the sound scene component responsible to manage any sounds
  111053. * in a given scene.
  111054. */
  111055. export class AudioSceneComponent implements ISceneSerializableComponent {
  111056. /**
  111057. * The component name helpfull to identify the component in the list of scene components.
  111058. */
  111059. readonly name: string;
  111060. /**
  111061. * The scene the component belongs to.
  111062. */
  111063. scene: Scene;
  111064. private _audioEnabled;
  111065. /**
  111066. * Gets whether audio is enabled or not.
  111067. * Please use related enable/disable method to switch state.
  111068. */
  111069. get audioEnabled(): boolean;
  111070. private _headphone;
  111071. /**
  111072. * Gets whether audio is outputing to headphone or not.
  111073. * Please use the according Switch methods to change output.
  111074. */
  111075. get headphone(): boolean;
  111076. /**
  111077. * Gets or sets a refresh rate when using 3D audio positioning
  111078. */
  111079. audioPositioningRefreshRate: number;
  111080. private _audioListenerPositionProvider;
  111081. /**
  111082. * Gets the current audio listener position provider
  111083. */
  111084. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111085. /**
  111086. * Sets a custom listener position for all sounds in the scene
  111087. * By default, this is the position of the first active camera
  111088. */
  111089. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111090. /**
  111091. * Creates a new instance of the component for the given scene
  111092. * @param scene Defines the scene to register the component in
  111093. */
  111094. constructor(scene: Scene);
  111095. /**
  111096. * Registers the component in a given scene
  111097. */
  111098. register(): void;
  111099. /**
  111100. * Rebuilds the elements related to this component in case of
  111101. * context lost for instance.
  111102. */
  111103. rebuild(): void;
  111104. /**
  111105. * Serializes the component data to the specified json object
  111106. * @param serializationObject The object to serialize to
  111107. */
  111108. serialize(serializationObject: any): void;
  111109. /**
  111110. * Adds all the elements from the container to the scene
  111111. * @param container the container holding the elements
  111112. */
  111113. addFromContainer(container: AbstractScene): void;
  111114. /**
  111115. * Removes all the elements in the container from the scene
  111116. * @param container contains the elements to remove
  111117. * @param dispose if the removed element should be disposed (default: false)
  111118. */
  111119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111120. /**
  111121. * Disposes the component and the associated ressources.
  111122. */
  111123. dispose(): void;
  111124. /**
  111125. * Disables audio in the associated scene.
  111126. */
  111127. disableAudio(): void;
  111128. /**
  111129. * Enables audio in the associated scene.
  111130. */
  111131. enableAudio(): void;
  111132. /**
  111133. * Switch audio to headphone output.
  111134. */
  111135. switchAudioModeForHeadphones(): void;
  111136. /**
  111137. * Switch audio to normal speakers.
  111138. */
  111139. switchAudioModeForNormalSpeakers(): void;
  111140. private _cachedCameraDirection;
  111141. private _cachedCameraPosition;
  111142. private _lastCheck;
  111143. private _afterRender;
  111144. }
  111145. }
  111146. declare module BABYLON {
  111147. /**
  111148. * Wraps one or more Sound objects and selects one with random weight for playback.
  111149. */
  111150. export class WeightedSound {
  111151. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111152. loop: boolean;
  111153. private _coneInnerAngle;
  111154. private _coneOuterAngle;
  111155. private _volume;
  111156. /** A Sound is currently playing. */
  111157. isPlaying: boolean;
  111158. /** A Sound is currently paused. */
  111159. isPaused: boolean;
  111160. private _sounds;
  111161. private _weights;
  111162. private _currentIndex?;
  111163. /**
  111164. * Creates a new WeightedSound from the list of sounds given.
  111165. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111166. * @param sounds Array of Sounds that will be selected from.
  111167. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111168. */
  111169. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111170. /**
  111171. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111172. */
  111173. get directionalConeInnerAngle(): number;
  111174. /**
  111175. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111176. */
  111177. set directionalConeInnerAngle(value: number);
  111178. /**
  111179. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111180. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111181. */
  111182. get directionalConeOuterAngle(): number;
  111183. /**
  111184. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111185. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111186. */
  111187. set directionalConeOuterAngle(value: number);
  111188. /**
  111189. * Playback volume.
  111190. */
  111191. get volume(): number;
  111192. /**
  111193. * Playback volume.
  111194. */
  111195. set volume(value: number);
  111196. private _onended;
  111197. /**
  111198. * Suspend playback
  111199. */
  111200. pause(): void;
  111201. /**
  111202. * Stop playback
  111203. */
  111204. stop(): void;
  111205. /**
  111206. * Start playback.
  111207. * @param startOffset Position the clip head at a specific time in seconds.
  111208. */
  111209. play(startOffset?: number): void;
  111210. }
  111211. }
  111212. declare module BABYLON {
  111213. /**
  111214. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111216. */
  111217. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111218. /**
  111219. * Gets the name of the behavior.
  111220. */
  111221. get name(): string;
  111222. /**
  111223. * The easing function used by animations
  111224. */
  111225. static EasingFunction: BackEase;
  111226. /**
  111227. * The easing mode used by animations
  111228. */
  111229. static EasingMode: number;
  111230. /**
  111231. * The duration of the animation, in milliseconds
  111232. */
  111233. transitionDuration: number;
  111234. /**
  111235. * Length of the distance animated by the transition when lower radius is reached
  111236. */
  111237. lowerRadiusTransitionRange: number;
  111238. /**
  111239. * Length of the distance animated by the transition when upper radius is reached
  111240. */
  111241. upperRadiusTransitionRange: number;
  111242. private _autoTransitionRange;
  111243. /**
  111244. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111245. */
  111246. get autoTransitionRange(): boolean;
  111247. /**
  111248. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111249. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111250. */
  111251. set autoTransitionRange(value: boolean);
  111252. private _attachedCamera;
  111253. private _onAfterCheckInputsObserver;
  111254. private _onMeshTargetChangedObserver;
  111255. /**
  111256. * Initializes the behavior.
  111257. */
  111258. init(): void;
  111259. /**
  111260. * Attaches the behavior to its arc rotate camera.
  111261. * @param camera Defines the camera to attach the behavior to
  111262. */
  111263. attach(camera: ArcRotateCamera): void;
  111264. /**
  111265. * Detaches the behavior from its current arc rotate camera.
  111266. */
  111267. detach(): void;
  111268. private _radiusIsAnimating;
  111269. private _radiusBounceTransition;
  111270. private _animatables;
  111271. private _cachedWheelPrecision;
  111272. /**
  111273. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111274. * @param radiusLimit The limit to check against.
  111275. * @return Bool to indicate if at limit.
  111276. */
  111277. private _isRadiusAtLimit;
  111278. /**
  111279. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111280. * @param radiusDelta The delta by which to animate to. Can be negative.
  111281. */
  111282. private _applyBoundRadiusAnimation;
  111283. /**
  111284. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111285. */
  111286. protected _clearAnimationLocks(): void;
  111287. /**
  111288. * Stops and removes all animations that have been applied to the camera
  111289. */
  111290. stopAllAnimations(): void;
  111291. }
  111292. }
  111293. declare module BABYLON {
  111294. /**
  111295. * 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.
  111296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111297. */
  111298. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111299. /**
  111300. * Gets the name of the behavior.
  111301. */
  111302. get name(): string;
  111303. private _mode;
  111304. private _radiusScale;
  111305. private _positionScale;
  111306. private _defaultElevation;
  111307. private _elevationReturnTime;
  111308. private _elevationReturnWaitTime;
  111309. private _zoomStopsAnimation;
  111310. private _framingTime;
  111311. /**
  111312. * The easing function used by animations
  111313. */
  111314. static EasingFunction: ExponentialEase;
  111315. /**
  111316. * The easing mode used by animations
  111317. */
  111318. static EasingMode: number;
  111319. /**
  111320. * Sets the current mode used by the behavior
  111321. */
  111322. set mode(mode: number);
  111323. /**
  111324. * Gets current mode used by the behavior.
  111325. */
  111326. get mode(): number;
  111327. /**
  111328. * Sets the scale applied to the radius (1 by default)
  111329. */
  111330. set radiusScale(radius: number);
  111331. /**
  111332. * Gets the scale applied to the radius
  111333. */
  111334. get radiusScale(): number;
  111335. /**
  111336. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111337. */
  111338. set positionScale(scale: number);
  111339. /**
  111340. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111341. */
  111342. get positionScale(): number;
  111343. /**
  111344. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111345. * behaviour is triggered, in radians.
  111346. */
  111347. set defaultElevation(elevation: number);
  111348. /**
  111349. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111350. * behaviour is triggered, in radians.
  111351. */
  111352. get defaultElevation(): number;
  111353. /**
  111354. * Sets the time (in milliseconds) taken to return to the default beta position.
  111355. * Negative value indicates camera should not return to default.
  111356. */
  111357. set elevationReturnTime(speed: number);
  111358. /**
  111359. * Gets the time (in milliseconds) taken to return to the default beta position.
  111360. * Negative value indicates camera should not return to default.
  111361. */
  111362. get elevationReturnTime(): number;
  111363. /**
  111364. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111365. */
  111366. set elevationReturnWaitTime(time: number);
  111367. /**
  111368. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111369. */
  111370. get elevationReturnWaitTime(): number;
  111371. /**
  111372. * Sets the flag that indicates if user zooming should stop animation.
  111373. */
  111374. set zoomStopsAnimation(flag: boolean);
  111375. /**
  111376. * Gets the flag that indicates if user zooming should stop animation.
  111377. */
  111378. get zoomStopsAnimation(): boolean;
  111379. /**
  111380. * Sets the transition time when framing the mesh, in milliseconds
  111381. */
  111382. set framingTime(time: number);
  111383. /**
  111384. * Gets the transition time when framing the mesh, in milliseconds
  111385. */
  111386. get framingTime(): number;
  111387. /**
  111388. * Define if the behavior should automatically change the configured
  111389. * camera limits and sensibilities.
  111390. */
  111391. autoCorrectCameraLimitsAndSensibility: boolean;
  111392. private _onPrePointerObservableObserver;
  111393. private _onAfterCheckInputsObserver;
  111394. private _onMeshTargetChangedObserver;
  111395. private _attachedCamera;
  111396. private _isPointerDown;
  111397. private _lastInteractionTime;
  111398. /**
  111399. * Initializes the behavior.
  111400. */
  111401. init(): void;
  111402. /**
  111403. * Attaches the behavior to its arc rotate camera.
  111404. * @param camera Defines the camera to attach the behavior to
  111405. */
  111406. attach(camera: ArcRotateCamera): void;
  111407. /**
  111408. * Detaches the behavior from its current arc rotate camera.
  111409. */
  111410. detach(): void;
  111411. private _animatables;
  111412. private _betaIsAnimating;
  111413. private _betaTransition;
  111414. private _radiusTransition;
  111415. private _vectorTransition;
  111416. /**
  111417. * Targets the given mesh and updates zoom level accordingly.
  111418. * @param mesh The mesh to target.
  111419. * @param radius Optional. If a cached radius position already exists, overrides default.
  111420. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111421. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111422. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111423. */
  111424. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111425. /**
  111426. * Targets the given mesh with its children and updates zoom level accordingly.
  111427. * @param mesh The mesh to target.
  111428. * @param radius Optional. If a cached radius position already exists, overrides default.
  111429. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111430. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111431. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111432. */
  111433. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111434. /**
  111435. * Targets the given meshes with their children and updates zoom level accordingly.
  111436. * @param meshes The mesh to target.
  111437. * @param radius Optional. If a cached radius position already exists, overrides default.
  111438. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111439. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111440. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111441. */
  111442. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111443. /**
  111444. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111445. * @param minimumWorld Determines the smaller position of the bounding box extend
  111446. * @param maximumWorld Determines the bigger position of the bounding box extend
  111447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111449. */
  111450. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111451. /**
  111452. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111453. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111454. * frustum width.
  111455. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111456. * to fully enclose the mesh in the viewing frustum.
  111457. */
  111458. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111459. /**
  111460. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111461. * is automatically returned to its default position (expected to be above ground plane).
  111462. */
  111463. private _maintainCameraAboveGround;
  111464. /**
  111465. * Returns the frustum slope based on the canvas ratio and camera FOV
  111466. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111467. */
  111468. private _getFrustumSlope;
  111469. /**
  111470. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111471. */
  111472. private _clearAnimationLocks;
  111473. /**
  111474. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111475. */
  111476. private _applyUserInteraction;
  111477. /**
  111478. * Stops and removes all animations that have been applied to the camera
  111479. */
  111480. stopAllAnimations(): void;
  111481. /**
  111482. * Gets a value indicating if the user is moving the camera
  111483. */
  111484. get isUserIsMoving(): boolean;
  111485. /**
  111486. * The camera can move all the way towards the mesh.
  111487. */
  111488. static IgnoreBoundsSizeMode: number;
  111489. /**
  111490. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111491. */
  111492. static FitFrustumSidesMode: number;
  111493. }
  111494. }
  111495. declare module BABYLON {
  111496. /**
  111497. * Base class for Camera Pointer Inputs.
  111498. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111499. * for example usage.
  111500. */
  111501. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111502. /**
  111503. * Defines the camera the input is attached to.
  111504. */
  111505. abstract camera: Camera;
  111506. /**
  111507. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111508. */
  111509. protected _altKey: boolean;
  111510. protected _ctrlKey: boolean;
  111511. protected _metaKey: boolean;
  111512. protected _shiftKey: boolean;
  111513. /**
  111514. * Which mouse buttons were pressed at time of last mouse event.
  111515. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111516. */
  111517. protected _buttonsPressed: number;
  111518. /**
  111519. * Defines the buttons associated with the input to handle camera move.
  111520. */
  111521. buttons: number[];
  111522. /**
  111523. * Attach the input controls to a specific dom element to get the input from.
  111524. * @param element Defines the element the controls should be listened from
  111525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111526. */
  111527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111528. /**
  111529. * Detach the current controls from the specified dom element.
  111530. * @param element Defines the element to stop listening the inputs from
  111531. */
  111532. detachControl(element: Nullable<HTMLElement>): void;
  111533. /**
  111534. * Gets the class name of the current input.
  111535. * @returns the class name
  111536. */
  111537. getClassName(): string;
  111538. /**
  111539. * Get the friendly name associated with the input class.
  111540. * @returns the input friendly name
  111541. */
  111542. getSimpleName(): string;
  111543. /**
  111544. * Called on pointer POINTERDOUBLETAP event.
  111545. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111546. */
  111547. protected onDoubleTap(type: string): void;
  111548. /**
  111549. * Called on pointer POINTERMOVE event if only a single touch is active.
  111550. * Override this method to provide functionality.
  111551. */
  111552. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111553. /**
  111554. * Called on pointer POINTERMOVE event if multiple touches are active.
  111555. * Override this method to provide functionality.
  111556. */
  111557. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111558. /**
  111559. * Called on JS contextmenu event.
  111560. * Override this method to provide functionality.
  111561. */
  111562. protected onContextMenu(evt: PointerEvent): void;
  111563. /**
  111564. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111565. * press.
  111566. * Override this method to provide functionality.
  111567. */
  111568. protected onButtonDown(evt: PointerEvent): void;
  111569. /**
  111570. * Called each time a new POINTERUP event occurs. Ie, for each button
  111571. * release.
  111572. * Override this method to provide functionality.
  111573. */
  111574. protected onButtonUp(evt: PointerEvent): void;
  111575. /**
  111576. * Called when window becomes inactive.
  111577. * Override this method to provide functionality.
  111578. */
  111579. protected onLostFocus(): void;
  111580. private _pointerInput;
  111581. private _observer;
  111582. private _onLostFocus;
  111583. private pointA;
  111584. private pointB;
  111585. }
  111586. }
  111587. declare module BABYLON {
  111588. /**
  111589. * Manage the pointers inputs to control an arc rotate camera.
  111590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111591. */
  111592. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111593. /**
  111594. * Defines the camera the input is attached to.
  111595. */
  111596. camera: ArcRotateCamera;
  111597. /**
  111598. * Gets the class name of the current input.
  111599. * @returns the class name
  111600. */
  111601. getClassName(): string;
  111602. /**
  111603. * Defines the buttons associated with the input to handle camera move.
  111604. */
  111605. buttons: number[];
  111606. /**
  111607. * Defines the pointer angular sensibility along the X axis or how fast is
  111608. * the camera rotating.
  111609. */
  111610. angularSensibilityX: number;
  111611. /**
  111612. * Defines the pointer angular sensibility along the Y axis or how fast is
  111613. * the camera rotating.
  111614. */
  111615. angularSensibilityY: number;
  111616. /**
  111617. * Defines the pointer pinch precision or how fast is the camera zooming.
  111618. */
  111619. pinchPrecision: number;
  111620. /**
  111621. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111622. * from 0.
  111623. * It defines the percentage of current camera.radius to use as delta when
  111624. * pinch zoom is used.
  111625. */
  111626. pinchDeltaPercentage: number;
  111627. /**
  111628. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111629. * that any object in the plane at the camera's target point will scale
  111630. * perfectly with finger motion.
  111631. * Overrides pinchDeltaPercentage and pinchPrecision.
  111632. */
  111633. useNaturalPinchZoom: boolean;
  111634. /**
  111635. * Defines the pointer panning sensibility or how fast is the camera moving.
  111636. */
  111637. panningSensibility: number;
  111638. /**
  111639. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111640. */
  111641. multiTouchPanning: boolean;
  111642. /**
  111643. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111644. * zoom (pinch) through multitouch.
  111645. */
  111646. multiTouchPanAndZoom: boolean;
  111647. /**
  111648. * Revers pinch action direction.
  111649. */
  111650. pinchInwards: boolean;
  111651. private _isPanClick;
  111652. private _twoFingerActivityCount;
  111653. private _isPinching;
  111654. /**
  111655. * Called on pointer POINTERMOVE event if only a single touch is active.
  111656. */
  111657. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111658. /**
  111659. * Called on pointer POINTERDOUBLETAP event.
  111660. */
  111661. protected onDoubleTap(type: string): void;
  111662. /**
  111663. * Called on pointer POINTERMOVE event if multiple touches are active.
  111664. */
  111665. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111666. /**
  111667. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111668. * press.
  111669. */
  111670. protected onButtonDown(evt: PointerEvent): void;
  111671. /**
  111672. * Called each time a new POINTERUP event occurs. Ie, for each button
  111673. * release.
  111674. */
  111675. protected onButtonUp(evt: PointerEvent): void;
  111676. /**
  111677. * Called when window becomes inactive.
  111678. */
  111679. protected onLostFocus(): void;
  111680. }
  111681. }
  111682. declare module BABYLON {
  111683. /**
  111684. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111686. */
  111687. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111688. /**
  111689. * Defines the camera the input is attached to.
  111690. */
  111691. camera: ArcRotateCamera;
  111692. /**
  111693. * Defines the list of key codes associated with the up action (increase alpha)
  111694. */
  111695. keysUp: number[];
  111696. /**
  111697. * Defines the list of key codes associated with the down action (decrease alpha)
  111698. */
  111699. keysDown: number[];
  111700. /**
  111701. * Defines the list of key codes associated with the left action (increase beta)
  111702. */
  111703. keysLeft: number[];
  111704. /**
  111705. * Defines the list of key codes associated with the right action (decrease beta)
  111706. */
  111707. keysRight: number[];
  111708. /**
  111709. * Defines the list of key codes associated with the reset action.
  111710. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111711. */
  111712. keysReset: number[];
  111713. /**
  111714. * Defines the panning sensibility of the inputs.
  111715. * (How fast is the camera panning)
  111716. */
  111717. panningSensibility: number;
  111718. /**
  111719. * Defines the zooming sensibility of the inputs.
  111720. * (How fast is the camera zooming)
  111721. */
  111722. zoomingSensibility: number;
  111723. /**
  111724. * Defines whether maintaining the alt key down switch the movement mode from
  111725. * orientation to zoom.
  111726. */
  111727. useAltToZoom: boolean;
  111728. /**
  111729. * Rotation speed of the camera
  111730. */
  111731. angularSpeed: number;
  111732. private _keys;
  111733. private _ctrlPressed;
  111734. private _altPressed;
  111735. private _onCanvasBlurObserver;
  111736. private _onKeyboardObserver;
  111737. private _engine;
  111738. private _scene;
  111739. /**
  111740. * Attach the input controls to a specific dom element to get the input from.
  111741. * @param element Defines the element the controls should be listened from
  111742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111743. */
  111744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111745. /**
  111746. * Detach the current controls from the specified dom element.
  111747. * @param element Defines the element to stop listening the inputs from
  111748. */
  111749. detachControl(element: Nullable<HTMLElement>): void;
  111750. /**
  111751. * Update the current camera state depending on the inputs that have been used this frame.
  111752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111753. */
  111754. checkInputs(): void;
  111755. /**
  111756. * Gets the class name of the current intput.
  111757. * @returns the class name
  111758. */
  111759. getClassName(): string;
  111760. /**
  111761. * Get the friendly name associated with the input class.
  111762. * @returns the input friendly name
  111763. */
  111764. getSimpleName(): string;
  111765. }
  111766. }
  111767. declare module BABYLON {
  111768. /**
  111769. * Manage the mouse wheel inputs to control an arc rotate camera.
  111770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111771. */
  111772. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111773. /**
  111774. * Defines the camera the input is attached to.
  111775. */
  111776. camera: ArcRotateCamera;
  111777. /**
  111778. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111779. */
  111780. wheelPrecision: number;
  111781. /**
  111782. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111783. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111784. */
  111785. wheelDeltaPercentage: number;
  111786. private _wheel;
  111787. private _observer;
  111788. private computeDeltaFromMouseWheelLegacyEvent;
  111789. /**
  111790. * Attach the input controls to a specific dom element to get the input from.
  111791. * @param element Defines the element the controls should be listened from
  111792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111793. */
  111794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111795. /**
  111796. * Detach the current controls from the specified dom element.
  111797. * @param element Defines the element to stop listening the inputs from
  111798. */
  111799. detachControl(element: Nullable<HTMLElement>): void;
  111800. /**
  111801. * Gets the class name of the current intput.
  111802. * @returns the class name
  111803. */
  111804. getClassName(): string;
  111805. /**
  111806. * Get the friendly name associated with the input class.
  111807. * @returns the input friendly name
  111808. */
  111809. getSimpleName(): string;
  111810. }
  111811. }
  111812. declare module BABYLON {
  111813. /**
  111814. * Default Inputs manager for the ArcRotateCamera.
  111815. * It groups all the default supported inputs for ease of use.
  111816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111817. */
  111818. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111819. /**
  111820. * Instantiates a new ArcRotateCameraInputsManager.
  111821. * @param camera Defines the camera the inputs belong to
  111822. */
  111823. constructor(camera: ArcRotateCamera);
  111824. /**
  111825. * Add mouse wheel input support to the input manager.
  111826. * @returns the current input manager
  111827. */
  111828. addMouseWheel(): ArcRotateCameraInputsManager;
  111829. /**
  111830. * Add pointers input support to the input manager.
  111831. * @returns the current input manager
  111832. */
  111833. addPointers(): ArcRotateCameraInputsManager;
  111834. /**
  111835. * Add keyboard input support to the input manager.
  111836. * @returns the current input manager
  111837. */
  111838. addKeyboard(): ArcRotateCameraInputsManager;
  111839. }
  111840. }
  111841. declare module BABYLON {
  111842. /**
  111843. * This represents an orbital type of camera.
  111844. *
  111845. * 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.
  111846. * 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.
  111847. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111848. */
  111849. export class ArcRotateCamera extends TargetCamera {
  111850. /**
  111851. * Defines the rotation angle of the camera along the longitudinal axis.
  111852. */
  111853. alpha: number;
  111854. /**
  111855. * Defines the rotation angle of the camera along the latitudinal axis.
  111856. */
  111857. beta: number;
  111858. /**
  111859. * Defines the radius of the camera from it s target point.
  111860. */
  111861. radius: number;
  111862. protected _target: Vector3;
  111863. protected _targetHost: Nullable<AbstractMesh>;
  111864. /**
  111865. * Defines the target point of the camera.
  111866. * The camera looks towards it form the radius distance.
  111867. */
  111868. get target(): Vector3;
  111869. set target(value: Vector3);
  111870. /**
  111871. * Define the current local position of the camera in the scene
  111872. */
  111873. get position(): Vector3;
  111874. set position(newPosition: Vector3);
  111875. protected _upVector: Vector3;
  111876. protected _upToYMatrix: Matrix;
  111877. protected _YToUpMatrix: Matrix;
  111878. /**
  111879. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111880. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111881. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111882. */
  111883. set upVector(vec: Vector3);
  111884. get upVector(): Vector3;
  111885. /**
  111886. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111887. */
  111888. setMatUp(): void;
  111889. /**
  111890. * Current inertia value on the longitudinal axis.
  111891. * The bigger this number the longer it will take for the camera to stop.
  111892. */
  111893. inertialAlphaOffset: number;
  111894. /**
  111895. * Current inertia value on the latitudinal axis.
  111896. * The bigger this number the longer it will take for the camera to stop.
  111897. */
  111898. inertialBetaOffset: number;
  111899. /**
  111900. * Current inertia value on the radius axis.
  111901. * The bigger this number the longer it will take for the camera to stop.
  111902. */
  111903. inertialRadiusOffset: number;
  111904. /**
  111905. * Minimum allowed angle on the longitudinal axis.
  111906. * This can help limiting how the Camera is able to move in the scene.
  111907. */
  111908. lowerAlphaLimit: Nullable<number>;
  111909. /**
  111910. * Maximum allowed angle on the longitudinal axis.
  111911. * This can help limiting how the Camera is able to move in the scene.
  111912. */
  111913. upperAlphaLimit: Nullable<number>;
  111914. /**
  111915. * Minimum allowed angle on the latitudinal axis.
  111916. * This can help limiting how the Camera is able to move in the scene.
  111917. */
  111918. lowerBetaLimit: number;
  111919. /**
  111920. * Maximum allowed angle on the latitudinal axis.
  111921. * This can help limiting how the Camera is able to move in the scene.
  111922. */
  111923. upperBetaLimit: number;
  111924. /**
  111925. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111926. * This can help limiting how the Camera is able to move in the scene.
  111927. */
  111928. lowerRadiusLimit: Nullable<number>;
  111929. /**
  111930. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111931. * This can help limiting how the Camera is able to move in the scene.
  111932. */
  111933. upperRadiusLimit: Nullable<number>;
  111934. /**
  111935. * Defines the current inertia value used during panning of the camera along the X axis.
  111936. */
  111937. inertialPanningX: number;
  111938. /**
  111939. * Defines the current inertia value used during panning of the camera along the Y axis.
  111940. */
  111941. inertialPanningY: number;
  111942. /**
  111943. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111944. * Basically if your fingers moves away from more than this distance you will be considered
  111945. * in pinch mode.
  111946. */
  111947. pinchToPanMaxDistance: number;
  111948. /**
  111949. * Defines the maximum distance the camera can pan.
  111950. * This could help keeping the cammera always in your scene.
  111951. */
  111952. panningDistanceLimit: Nullable<number>;
  111953. /**
  111954. * Defines the target of the camera before paning.
  111955. */
  111956. panningOriginTarget: Vector3;
  111957. /**
  111958. * Defines the value of the inertia used during panning.
  111959. * 0 would mean stop inertia and one would mean no decelleration at all.
  111960. */
  111961. panningInertia: number;
  111962. /**
  111963. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111964. */
  111965. get angularSensibilityX(): number;
  111966. set angularSensibilityX(value: number);
  111967. /**
  111968. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111969. */
  111970. get angularSensibilityY(): number;
  111971. set angularSensibilityY(value: number);
  111972. /**
  111973. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111974. */
  111975. get pinchPrecision(): number;
  111976. set pinchPrecision(value: number);
  111977. /**
  111978. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111979. * It will be used instead of pinchDeltaPrecision if different from 0.
  111980. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111981. */
  111982. get pinchDeltaPercentage(): number;
  111983. set pinchDeltaPercentage(value: number);
  111984. /**
  111985. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111986. * and pinch delta percentage.
  111987. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111988. * that any object in the plane at the camera's target point will scale
  111989. * perfectly with finger motion.
  111990. */
  111991. get useNaturalPinchZoom(): boolean;
  111992. set useNaturalPinchZoom(value: boolean);
  111993. /**
  111994. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111995. */
  111996. get panningSensibility(): number;
  111997. set panningSensibility(value: number);
  111998. /**
  111999. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112000. */
  112001. get keysUp(): number[];
  112002. set keysUp(value: number[]);
  112003. /**
  112004. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112005. */
  112006. get keysDown(): number[];
  112007. set keysDown(value: number[]);
  112008. /**
  112009. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112010. */
  112011. get keysLeft(): number[];
  112012. set keysLeft(value: number[]);
  112013. /**
  112014. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112015. */
  112016. get keysRight(): number[];
  112017. set keysRight(value: number[]);
  112018. /**
  112019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112020. */
  112021. get wheelPrecision(): number;
  112022. set wheelPrecision(value: number);
  112023. /**
  112024. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112025. * It will be used instead of pinchDeltaPrecision if different from 0.
  112026. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112027. */
  112028. get wheelDeltaPercentage(): number;
  112029. set wheelDeltaPercentage(value: number);
  112030. /**
  112031. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112032. */
  112033. zoomOnFactor: number;
  112034. /**
  112035. * Defines a screen offset for the camera position.
  112036. */
  112037. targetScreenOffset: Vector2;
  112038. /**
  112039. * Allows the camera to be completely reversed.
  112040. * If false the camera can not arrive upside down.
  112041. */
  112042. allowUpsideDown: boolean;
  112043. /**
  112044. * Define if double tap/click is used to restore the previously saved state of the camera.
  112045. */
  112046. useInputToRestoreState: boolean;
  112047. /** @hidden */
  112048. _viewMatrix: Matrix;
  112049. /** @hidden */
  112050. _useCtrlForPanning: boolean;
  112051. /** @hidden */
  112052. _panningMouseButton: number;
  112053. /**
  112054. * Defines the input associated to the camera.
  112055. */
  112056. inputs: ArcRotateCameraInputsManager;
  112057. /** @hidden */
  112058. _reset: () => void;
  112059. /**
  112060. * Defines the allowed panning axis.
  112061. */
  112062. panningAxis: Vector3;
  112063. protected _localDirection: Vector3;
  112064. protected _transformedDirection: Vector3;
  112065. private _bouncingBehavior;
  112066. /**
  112067. * Gets the bouncing behavior of the camera if it has been enabled.
  112068. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112069. */
  112070. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112071. /**
  112072. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112074. */
  112075. get useBouncingBehavior(): boolean;
  112076. set useBouncingBehavior(value: boolean);
  112077. private _framingBehavior;
  112078. /**
  112079. * Gets the framing behavior of the camera if it has been enabled.
  112080. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112081. */
  112082. get framingBehavior(): Nullable<FramingBehavior>;
  112083. /**
  112084. * Defines if the framing behavior of the camera is enabled on the camera.
  112085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112086. */
  112087. get useFramingBehavior(): boolean;
  112088. set useFramingBehavior(value: boolean);
  112089. private _autoRotationBehavior;
  112090. /**
  112091. * Gets the auto rotation behavior of the camera if it has been enabled.
  112092. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112093. */
  112094. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112095. /**
  112096. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112097. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112098. */
  112099. get useAutoRotationBehavior(): boolean;
  112100. set useAutoRotationBehavior(value: boolean);
  112101. /**
  112102. * Observable triggered when the mesh target has been changed on the camera.
  112103. */
  112104. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112105. /**
  112106. * Event raised when the camera is colliding with a mesh.
  112107. */
  112108. onCollide: (collidedMesh: AbstractMesh) => void;
  112109. /**
  112110. * Defines whether the camera should check collision with the objects oh the scene.
  112111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112112. */
  112113. checkCollisions: boolean;
  112114. /**
  112115. * Defines the collision radius of the camera.
  112116. * This simulates a sphere around the camera.
  112117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112118. */
  112119. collisionRadius: Vector3;
  112120. protected _collider: Collider;
  112121. protected _previousPosition: Vector3;
  112122. protected _collisionVelocity: Vector3;
  112123. protected _newPosition: Vector3;
  112124. protected _previousAlpha: number;
  112125. protected _previousBeta: number;
  112126. protected _previousRadius: number;
  112127. protected _collisionTriggered: boolean;
  112128. protected _targetBoundingCenter: Nullable<Vector3>;
  112129. private _computationVector;
  112130. /**
  112131. * Instantiates a new ArcRotateCamera in a given scene
  112132. * @param name Defines the name of the camera
  112133. * @param alpha Defines the camera rotation along the logitudinal axis
  112134. * @param beta Defines the camera rotation along the latitudinal axis
  112135. * @param radius Defines the camera distance from its target
  112136. * @param target Defines the camera target
  112137. * @param scene Defines the scene the camera belongs to
  112138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112139. */
  112140. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112141. /** @hidden */
  112142. _initCache(): void;
  112143. /** @hidden */
  112144. _updateCache(ignoreParentClass?: boolean): void;
  112145. protected _getTargetPosition(): Vector3;
  112146. private _storedAlpha;
  112147. private _storedBeta;
  112148. private _storedRadius;
  112149. private _storedTarget;
  112150. private _storedTargetScreenOffset;
  112151. /**
  112152. * Stores the current state of the camera (alpha, beta, radius and target)
  112153. * @returns the camera itself
  112154. */
  112155. storeState(): Camera;
  112156. /**
  112157. * @hidden
  112158. * Restored camera state. You must call storeState() first
  112159. */
  112160. _restoreStateValues(): boolean;
  112161. /** @hidden */
  112162. _isSynchronizedViewMatrix(): boolean;
  112163. /**
  112164. * Attached controls to the current camera.
  112165. * @param element Defines the element the controls should be listened from
  112166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112167. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112168. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112169. */
  112170. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112171. /**
  112172. * Detach the current controls from the camera.
  112173. * The camera will stop reacting to inputs.
  112174. * @param element Defines the element to stop listening the inputs from
  112175. */
  112176. detachControl(element: HTMLElement): void;
  112177. /** @hidden */
  112178. _checkInputs(): void;
  112179. protected _checkLimits(): void;
  112180. /**
  112181. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112182. */
  112183. rebuildAnglesAndRadius(): void;
  112184. /**
  112185. * Use a position to define the current camera related information like alpha, beta and radius
  112186. * @param position Defines the position to set the camera at
  112187. */
  112188. setPosition(position: Vector3): void;
  112189. /**
  112190. * Defines the target the camera should look at.
  112191. * This will automatically adapt alpha beta and radius to fit within the new target.
  112192. * @param target Defines the new target as a Vector or a mesh
  112193. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112194. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112195. */
  112196. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112197. /** @hidden */
  112198. _getViewMatrix(): Matrix;
  112199. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112200. /**
  112201. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112202. * @param meshes Defines the mesh to zoom on
  112203. * @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)
  112204. */
  112205. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112206. /**
  112207. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112208. * The target will be changed but the radius
  112209. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112210. * @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)
  112211. */
  112212. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112213. min: Vector3;
  112214. max: Vector3;
  112215. distance: number;
  112216. }, doNotUpdateMaxZ?: boolean): void;
  112217. /**
  112218. * @override
  112219. * Override Camera.createRigCamera
  112220. */
  112221. createRigCamera(name: string, cameraIndex: number): Camera;
  112222. /**
  112223. * @hidden
  112224. * @override
  112225. * Override Camera._updateRigCameras
  112226. */
  112227. _updateRigCameras(): void;
  112228. /**
  112229. * Destroy the camera and release the current resources hold by it.
  112230. */
  112231. dispose(): void;
  112232. /**
  112233. * Gets the current object class name.
  112234. * @return the class name
  112235. */
  112236. getClassName(): string;
  112237. }
  112238. }
  112239. declare module BABYLON {
  112240. /**
  112241. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112243. */
  112244. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112245. /**
  112246. * Gets the name of the behavior.
  112247. */
  112248. get name(): string;
  112249. private _zoomStopsAnimation;
  112250. private _idleRotationSpeed;
  112251. private _idleRotationWaitTime;
  112252. private _idleRotationSpinupTime;
  112253. /**
  112254. * Sets the flag that indicates if user zooming should stop animation.
  112255. */
  112256. set zoomStopsAnimation(flag: boolean);
  112257. /**
  112258. * Gets the flag that indicates if user zooming should stop animation.
  112259. */
  112260. get zoomStopsAnimation(): boolean;
  112261. /**
  112262. * Sets the default speed at which the camera rotates around the model.
  112263. */
  112264. set idleRotationSpeed(speed: number);
  112265. /**
  112266. * Gets the default speed at which the camera rotates around the model.
  112267. */
  112268. get idleRotationSpeed(): number;
  112269. /**
  112270. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112271. */
  112272. set idleRotationWaitTime(time: number);
  112273. /**
  112274. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112275. */
  112276. get idleRotationWaitTime(): number;
  112277. /**
  112278. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112279. */
  112280. set idleRotationSpinupTime(time: number);
  112281. /**
  112282. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112283. */
  112284. get idleRotationSpinupTime(): number;
  112285. /**
  112286. * Gets a value indicating if the camera is currently rotating because of this behavior
  112287. */
  112288. get rotationInProgress(): boolean;
  112289. private _onPrePointerObservableObserver;
  112290. private _onAfterCheckInputsObserver;
  112291. private _attachedCamera;
  112292. private _isPointerDown;
  112293. private _lastFrameTime;
  112294. private _lastInteractionTime;
  112295. private _cameraRotationSpeed;
  112296. /**
  112297. * Initializes the behavior.
  112298. */
  112299. init(): void;
  112300. /**
  112301. * Attaches the behavior to its arc rotate camera.
  112302. * @param camera Defines the camera to attach the behavior to
  112303. */
  112304. attach(camera: ArcRotateCamera): void;
  112305. /**
  112306. * Detaches the behavior from its current arc rotate camera.
  112307. */
  112308. detach(): void;
  112309. /**
  112310. * Returns true if user is scrolling.
  112311. * @return true if user is scrolling.
  112312. */
  112313. private _userIsZooming;
  112314. private _lastFrameRadius;
  112315. private _shouldAnimationStopForInteraction;
  112316. /**
  112317. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112318. */
  112319. private _applyUserInteraction;
  112320. private _userIsMoving;
  112321. }
  112322. }
  112323. declare module BABYLON {
  112324. /**
  112325. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112326. */
  112327. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112328. private ui;
  112329. /**
  112330. * The name of the behavior
  112331. */
  112332. name: string;
  112333. /**
  112334. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112335. */
  112336. distanceAwayFromFace: number;
  112337. /**
  112338. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112339. */
  112340. distanceAwayFromBottomOfFace: number;
  112341. private _faceVectors;
  112342. private _target;
  112343. private _scene;
  112344. private _onRenderObserver;
  112345. private _tmpMatrix;
  112346. private _tmpVector;
  112347. /**
  112348. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112349. * @param ui The transform node that should be attched to the mesh
  112350. */
  112351. constructor(ui: TransformNode);
  112352. /**
  112353. * Initializes the behavior
  112354. */
  112355. init(): void;
  112356. private _closestFace;
  112357. private _zeroVector;
  112358. private _lookAtTmpMatrix;
  112359. private _lookAtToRef;
  112360. /**
  112361. * Attaches the AttachToBoxBehavior to the passed in mesh
  112362. * @param target The mesh that the specified node will be attached to
  112363. */
  112364. attach(target: Mesh): void;
  112365. /**
  112366. * Detaches the behavior from the mesh
  112367. */
  112368. detach(): void;
  112369. }
  112370. }
  112371. declare module BABYLON {
  112372. /**
  112373. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112374. */
  112375. export class FadeInOutBehavior implements Behavior<Mesh> {
  112376. /**
  112377. * Time in milliseconds to delay before fading in (Default: 0)
  112378. */
  112379. delay: number;
  112380. /**
  112381. * Time in milliseconds for the mesh to fade in (Default: 300)
  112382. */
  112383. fadeInTime: number;
  112384. private _millisecondsPerFrame;
  112385. private _hovered;
  112386. private _hoverValue;
  112387. private _ownerNode;
  112388. /**
  112389. * Instatiates the FadeInOutBehavior
  112390. */
  112391. constructor();
  112392. /**
  112393. * The name of the behavior
  112394. */
  112395. get name(): string;
  112396. /**
  112397. * Initializes the behavior
  112398. */
  112399. init(): void;
  112400. /**
  112401. * Attaches the fade behavior on the passed in mesh
  112402. * @param ownerNode The mesh that will be faded in/out once attached
  112403. */
  112404. attach(ownerNode: Mesh): void;
  112405. /**
  112406. * Detaches the behavior from the mesh
  112407. */
  112408. detach(): void;
  112409. /**
  112410. * Triggers the mesh to begin fading in or out
  112411. * @param value if the object should fade in or out (true to fade in)
  112412. */
  112413. fadeIn(value: boolean): void;
  112414. private _update;
  112415. private _setAllVisibility;
  112416. }
  112417. }
  112418. declare module BABYLON {
  112419. /**
  112420. * Class containing a set of static utilities functions for managing Pivots
  112421. * @hidden
  112422. */
  112423. export class PivotTools {
  112424. private static _PivotCached;
  112425. private static _OldPivotPoint;
  112426. private static _PivotTranslation;
  112427. private static _PivotTmpVector;
  112428. /** @hidden */
  112429. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112430. /** @hidden */
  112431. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112432. }
  112433. }
  112434. declare module BABYLON {
  112435. /**
  112436. * Class containing static functions to help procedurally build meshes
  112437. */
  112438. export class PlaneBuilder {
  112439. /**
  112440. * Creates a plane mesh
  112441. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112442. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112443. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112447. * @param name defines the name of the mesh
  112448. * @param options defines the options used to create the mesh
  112449. * @param scene defines the hosting scene
  112450. * @returns the plane mesh
  112451. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112452. */
  112453. static CreatePlane(name: string, options: {
  112454. size?: number;
  112455. width?: number;
  112456. height?: number;
  112457. sideOrientation?: number;
  112458. frontUVs?: Vector4;
  112459. backUVs?: Vector4;
  112460. updatable?: boolean;
  112461. sourcePlane?: Plane;
  112462. }, scene?: Nullable<Scene>): Mesh;
  112463. }
  112464. }
  112465. declare module BABYLON {
  112466. /**
  112467. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112468. */
  112469. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112470. private static _AnyMouseID;
  112471. /**
  112472. * Abstract mesh the behavior is set on
  112473. */
  112474. attachedNode: AbstractMesh;
  112475. private _dragPlane;
  112476. private _scene;
  112477. private _pointerObserver;
  112478. private _beforeRenderObserver;
  112479. private static _planeScene;
  112480. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112481. /**
  112482. * 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)
  112483. */
  112484. maxDragAngle: number;
  112485. /**
  112486. * @hidden
  112487. */
  112488. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112489. /**
  112490. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112491. */
  112492. currentDraggingPointerID: number;
  112493. /**
  112494. * The last position where the pointer hit the drag plane in world space
  112495. */
  112496. lastDragPosition: Vector3;
  112497. /**
  112498. * If the behavior is currently in a dragging state
  112499. */
  112500. dragging: boolean;
  112501. /**
  112502. * 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)
  112503. */
  112504. dragDeltaRatio: number;
  112505. /**
  112506. * If the drag plane orientation should be updated during the dragging (Default: true)
  112507. */
  112508. updateDragPlane: boolean;
  112509. private _debugMode;
  112510. private _moving;
  112511. /**
  112512. * Fires each time the attached mesh is dragged with the pointer
  112513. * * delta between last drag position and current drag position in world space
  112514. * * dragDistance along the drag axis
  112515. * * dragPlaneNormal normal of the current drag plane used during the drag
  112516. * * dragPlanePoint in world space where the drag intersects the drag plane
  112517. */
  112518. onDragObservable: Observable<{
  112519. delta: Vector3;
  112520. dragPlanePoint: Vector3;
  112521. dragPlaneNormal: Vector3;
  112522. dragDistance: number;
  112523. pointerId: number;
  112524. }>;
  112525. /**
  112526. * Fires each time a drag begins (eg. mouse down on mesh)
  112527. */
  112528. onDragStartObservable: Observable<{
  112529. dragPlanePoint: Vector3;
  112530. pointerId: number;
  112531. }>;
  112532. /**
  112533. * Fires each time a drag ends (eg. mouse release after drag)
  112534. */
  112535. onDragEndObservable: Observable<{
  112536. dragPlanePoint: Vector3;
  112537. pointerId: number;
  112538. }>;
  112539. /**
  112540. * If the attached mesh should be moved when dragged
  112541. */
  112542. moveAttached: boolean;
  112543. /**
  112544. * If the drag behavior will react to drag events (Default: true)
  112545. */
  112546. enabled: boolean;
  112547. /**
  112548. * If pointer events should start and release the drag (Default: true)
  112549. */
  112550. startAndReleaseDragOnPointerEvents: boolean;
  112551. /**
  112552. * If camera controls should be detached during the drag
  112553. */
  112554. detachCameraControls: boolean;
  112555. /**
  112556. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112557. */
  112558. useObjectOrientationForDragging: boolean;
  112559. private _options;
  112560. /**
  112561. * Gets the options used by the behavior
  112562. */
  112563. get options(): {
  112564. dragAxis?: Vector3;
  112565. dragPlaneNormal?: Vector3;
  112566. };
  112567. /**
  112568. * Sets the options used by the behavior
  112569. */
  112570. set options(options: {
  112571. dragAxis?: Vector3;
  112572. dragPlaneNormal?: Vector3;
  112573. });
  112574. /**
  112575. * Creates a pointer drag behavior that can be attached to a mesh
  112576. * @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)
  112577. */
  112578. constructor(options?: {
  112579. dragAxis?: Vector3;
  112580. dragPlaneNormal?: Vector3;
  112581. });
  112582. /**
  112583. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112584. */
  112585. validateDrag: (targetPosition: Vector3) => boolean;
  112586. /**
  112587. * The name of the behavior
  112588. */
  112589. get name(): string;
  112590. /**
  112591. * Initializes the behavior
  112592. */
  112593. init(): void;
  112594. private _tmpVector;
  112595. private _alternatePickedPoint;
  112596. private _worldDragAxis;
  112597. private _targetPosition;
  112598. private _attachedElement;
  112599. /**
  112600. * Attaches the drag behavior the passed in mesh
  112601. * @param ownerNode The mesh that will be dragged around once attached
  112602. * @param predicate Predicate to use for pick filtering
  112603. */
  112604. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112605. /**
  112606. * Force relase the drag action by code.
  112607. */
  112608. releaseDrag(): void;
  112609. private _startDragRay;
  112610. private _lastPointerRay;
  112611. /**
  112612. * Simulates the start of a pointer drag event on the behavior
  112613. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112614. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112615. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112616. */
  112617. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112618. private _startDrag;
  112619. private _dragDelta;
  112620. private _moveDrag;
  112621. private _pickWithRayOnDragPlane;
  112622. private _pointA;
  112623. private _pointB;
  112624. private _pointC;
  112625. private _lineA;
  112626. private _lineB;
  112627. private _localAxis;
  112628. private _lookAt;
  112629. private _updateDragPlanePosition;
  112630. /**
  112631. * Detaches the behavior from the mesh
  112632. */
  112633. detach(): void;
  112634. }
  112635. }
  112636. declare module BABYLON {
  112637. /**
  112638. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112639. */
  112640. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112641. private _dragBehaviorA;
  112642. private _dragBehaviorB;
  112643. private _startDistance;
  112644. private _initialScale;
  112645. private _targetScale;
  112646. private _ownerNode;
  112647. private _sceneRenderObserver;
  112648. /**
  112649. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112650. */
  112651. constructor();
  112652. /**
  112653. * The name of the behavior
  112654. */
  112655. get name(): string;
  112656. /**
  112657. * Initializes the behavior
  112658. */
  112659. init(): void;
  112660. private _getCurrentDistance;
  112661. /**
  112662. * Attaches the scale behavior the passed in mesh
  112663. * @param ownerNode The mesh that will be scaled around once attached
  112664. */
  112665. attach(ownerNode: Mesh): void;
  112666. /**
  112667. * Detaches the behavior from the mesh
  112668. */
  112669. detach(): void;
  112670. }
  112671. }
  112672. declare module BABYLON {
  112673. /**
  112674. * 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
  112675. */
  112676. export class SixDofDragBehavior implements Behavior<Mesh> {
  112677. private static _virtualScene;
  112678. private _ownerNode;
  112679. private _sceneRenderObserver;
  112680. private _scene;
  112681. private _targetPosition;
  112682. private _virtualOriginMesh;
  112683. private _virtualDragMesh;
  112684. private _pointerObserver;
  112685. private _moving;
  112686. private _startingOrientation;
  112687. /**
  112688. * 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)
  112689. */
  112690. private zDragFactor;
  112691. /**
  112692. * If the object should rotate to face the drag origin
  112693. */
  112694. rotateDraggedObject: boolean;
  112695. /**
  112696. * If the behavior is currently in a dragging state
  112697. */
  112698. dragging: boolean;
  112699. /**
  112700. * 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)
  112701. */
  112702. dragDeltaRatio: number;
  112703. /**
  112704. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112705. */
  112706. currentDraggingPointerID: number;
  112707. /**
  112708. * If camera controls should be detached during the drag
  112709. */
  112710. detachCameraControls: boolean;
  112711. /**
  112712. * Fires each time a drag starts
  112713. */
  112714. onDragStartObservable: Observable<{}>;
  112715. /**
  112716. * Fires each time a drag ends (eg. mouse release after drag)
  112717. */
  112718. onDragEndObservable: Observable<{}>;
  112719. /**
  112720. * 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
  112721. */
  112722. constructor();
  112723. /**
  112724. * The name of the behavior
  112725. */
  112726. get name(): string;
  112727. /**
  112728. * Initializes the behavior
  112729. */
  112730. init(): void;
  112731. /**
  112732. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112733. */
  112734. private get _pointerCamera();
  112735. /**
  112736. * Attaches the scale behavior the passed in mesh
  112737. * @param ownerNode The mesh that will be scaled around once attached
  112738. */
  112739. attach(ownerNode: Mesh): void;
  112740. /**
  112741. * Detaches the behavior from the mesh
  112742. */
  112743. detach(): void;
  112744. }
  112745. }
  112746. declare module BABYLON {
  112747. /**
  112748. * Class used to apply inverse kinematics to bones
  112749. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112750. */
  112751. export class BoneIKController {
  112752. private static _tmpVecs;
  112753. private static _tmpQuat;
  112754. private static _tmpMats;
  112755. /**
  112756. * Gets or sets the target mesh
  112757. */
  112758. targetMesh: AbstractMesh;
  112759. /** Gets or sets the mesh used as pole */
  112760. poleTargetMesh: AbstractMesh;
  112761. /**
  112762. * Gets or sets the bone used as pole
  112763. */
  112764. poleTargetBone: Nullable<Bone>;
  112765. /**
  112766. * Gets or sets the target position
  112767. */
  112768. targetPosition: Vector3;
  112769. /**
  112770. * Gets or sets the pole target position
  112771. */
  112772. poleTargetPosition: Vector3;
  112773. /**
  112774. * Gets or sets the pole target local offset
  112775. */
  112776. poleTargetLocalOffset: Vector3;
  112777. /**
  112778. * Gets or sets the pole angle
  112779. */
  112780. poleAngle: number;
  112781. /**
  112782. * Gets or sets the mesh associated with the controller
  112783. */
  112784. mesh: AbstractMesh;
  112785. /**
  112786. * 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)
  112787. */
  112788. slerpAmount: number;
  112789. private _bone1Quat;
  112790. private _bone1Mat;
  112791. private _bone2Ang;
  112792. private _bone1;
  112793. private _bone2;
  112794. private _bone1Length;
  112795. private _bone2Length;
  112796. private _maxAngle;
  112797. private _maxReach;
  112798. private _rightHandedSystem;
  112799. private _bendAxis;
  112800. private _slerping;
  112801. private _adjustRoll;
  112802. /**
  112803. * Gets or sets maximum allowed angle
  112804. */
  112805. get maxAngle(): number;
  112806. set maxAngle(value: number);
  112807. /**
  112808. * Creates a new BoneIKController
  112809. * @param mesh defines the mesh to control
  112810. * @param bone defines the bone to control
  112811. * @param options defines options to set up the controller
  112812. */
  112813. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112814. targetMesh?: AbstractMesh;
  112815. poleTargetMesh?: AbstractMesh;
  112816. poleTargetBone?: Bone;
  112817. poleTargetLocalOffset?: Vector3;
  112818. poleAngle?: number;
  112819. bendAxis?: Vector3;
  112820. maxAngle?: number;
  112821. slerpAmount?: number;
  112822. });
  112823. private _setMaxAngle;
  112824. /**
  112825. * Force the controller to update the bones
  112826. */
  112827. update(): void;
  112828. }
  112829. }
  112830. declare module BABYLON {
  112831. /**
  112832. * Class used to make a bone look toward a point in space
  112833. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112834. */
  112835. export class BoneLookController {
  112836. private static _tmpVecs;
  112837. private static _tmpQuat;
  112838. private static _tmpMats;
  112839. /**
  112840. * The target Vector3 that the bone will look at
  112841. */
  112842. target: Vector3;
  112843. /**
  112844. * The mesh that the bone is attached to
  112845. */
  112846. mesh: AbstractMesh;
  112847. /**
  112848. * The bone that will be looking to the target
  112849. */
  112850. bone: Bone;
  112851. /**
  112852. * The up axis of the coordinate system that is used when the bone is rotated
  112853. */
  112854. upAxis: Vector3;
  112855. /**
  112856. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112857. */
  112858. upAxisSpace: Space;
  112859. /**
  112860. * Used to make an adjustment to the yaw of the bone
  112861. */
  112862. adjustYaw: number;
  112863. /**
  112864. * Used to make an adjustment to the pitch of the bone
  112865. */
  112866. adjustPitch: number;
  112867. /**
  112868. * Used to make an adjustment to the roll of the bone
  112869. */
  112870. adjustRoll: number;
  112871. /**
  112872. * 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)
  112873. */
  112874. slerpAmount: number;
  112875. private _minYaw;
  112876. private _maxYaw;
  112877. private _minPitch;
  112878. private _maxPitch;
  112879. private _minYawSin;
  112880. private _minYawCos;
  112881. private _maxYawSin;
  112882. private _maxYawCos;
  112883. private _midYawConstraint;
  112884. private _minPitchTan;
  112885. private _maxPitchTan;
  112886. private _boneQuat;
  112887. private _slerping;
  112888. private _transformYawPitch;
  112889. private _transformYawPitchInv;
  112890. private _firstFrameSkipped;
  112891. private _yawRange;
  112892. private _fowardAxis;
  112893. /**
  112894. * Gets or sets the minimum yaw angle that the bone can look to
  112895. */
  112896. get minYaw(): number;
  112897. set minYaw(value: number);
  112898. /**
  112899. * Gets or sets the maximum yaw angle that the bone can look to
  112900. */
  112901. get maxYaw(): number;
  112902. set maxYaw(value: number);
  112903. /**
  112904. * Gets or sets the minimum pitch angle that the bone can look to
  112905. */
  112906. get minPitch(): number;
  112907. set minPitch(value: number);
  112908. /**
  112909. * Gets or sets the maximum pitch angle that the bone can look to
  112910. */
  112911. get maxPitch(): number;
  112912. set maxPitch(value: number);
  112913. /**
  112914. * Create a BoneLookController
  112915. * @param mesh the mesh that the bone belongs to
  112916. * @param bone the bone that will be looking to the target
  112917. * @param target the target Vector3 to look at
  112918. * @param options optional settings:
  112919. * * maxYaw: the maximum angle the bone will yaw to
  112920. * * minYaw: the minimum angle the bone will yaw to
  112921. * * maxPitch: the maximum angle the bone will pitch to
  112922. * * minPitch: the minimum angle the bone will yaw to
  112923. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112924. * * upAxis: the up axis of the coordinate system
  112925. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112926. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112927. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112928. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112929. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112930. * * adjustRoll: used to make an adjustment to the roll of the bone
  112931. **/
  112932. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112933. maxYaw?: number;
  112934. minYaw?: number;
  112935. maxPitch?: number;
  112936. minPitch?: number;
  112937. slerpAmount?: number;
  112938. upAxis?: Vector3;
  112939. upAxisSpace?: Space;
  112940. yawAxis?: Vector3;
  112941. pitchAxis?: Vector3;
  112942. adjustYaw?: number;
  112943. adjustPitch?: number;
  112944. adjustRoll?: number;
  112945. });
  112946. /**
  112947. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112948. */
  112949. update(): void;
  112950. private _getAngleDiff;
  112951. private _getAngleBetween;
  112952. private _isAngleBetween;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /**
  112957. * Manage the gamepad inputs to control an arc rotate camera.
  112958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112959. */
  112960. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112961. /**
  112962. * Defines the camera the input is attached to.
  112963. */
  112964. camera: ArcRotateCamera;
  112965. /**
  112966. * Defines the gamepad the input is gathering event from.
  112967. */
  112968. gamepad: Nullable<Gamepad>;
  112969. /**
  112970. * Defines the gamepad rotation sensiblity.
  112971. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112972. */
  112973. gamepadRotationSensibility: number;
  112974. /**
  112975. * Defines the gamepad move sensiblity.
  112976. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112977. */
  112978. gamepadMoveSensibility: number;
  112979. private _yAxisScale;
  112980. /**
  112981. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112982. */
  112983. get invertYAxis(): boolean;
  112984. set invertYAxis(value: boolean);
  112985. private _onGamepadConnectedObserver;
  112986. private _onGamepadDisconnectedObserver;
  112987. /**
  112988. * Attach the input controls to a specific dom element to get the input from.
  112989. * @param element Defines the element the controls should be listened from
  112990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112991. */
  112992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112993. /**
  112994. * Detach the current controls from the specified dom element.
  112995. * @param element Defines the element to stop listening the inputs from
  112996. */
  112997. detachControl(element: Nullable<HTMLElement>): void;
  112998. /**
  112999. * Update the current camera state depending on the inputs that have been used this frame.
  113000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113001. */
  113002. checkInputs(): void;
  113003. /**
  113004. * Gets the class name of the current intput.
  113005. * @returns the class name
  113006. */
  113007. getClassName(): string;
  113008. /**
  113009. * Get the friendly name associated with the input class.
  113010. * @returns the input friendly name
  113011. */
  113012. getSimpleName(): string;
  113013. }
  113014. }
  113015. declare module BABYLON {
  113016. interface ArcRotateCameraInputsManager {
  113017. /**
  113018. * Add orientation input support to the input manager.
  113019. * @returns the current input manager
  113020. */
  113021. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113022. }
  113023. /**
  113024. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113026. */
  113027. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113028. /**
  113029. * Defines the camera the input is attached to.
  113030. */
  113031. camera: ArcRotateCamera;
  113032. /**
  113033. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113034. */
  113035. alphaCorrection: number;
  113036. /**
  113037. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113038. */
  113039. gammaCorrection: number;
  113040. private _alpha;
  113041. private _gamma;
  113042. private _dirty;
  113043. private _deviceOrientationHandler;
  113044. /**
  113045. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113046. */
  113047. constructor();
  113048. /**
  113049. * Attach the input controls to a specific dom element to get the input from.
  113050. * @param element Defines the element the controls should be listened from
  113051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113052. */
  113053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113054. /** @hidden */
  113055. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113056. /**
  113057. * Update the current camera state depending on the inputs that have been used this frame.
  113058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113059. */
  113060. checkInputs(): void;
  113061. /**
  113062. * Detach the current controls from the specified dom element.
  113063. * @param element Defines the element to stop listening the inputs from
  113064. */
  113065. detachControl(element: Nullable<HTMLElement>): void;
  113066. /**
  113067. * Gets the class name of the current intput.
  113068. * @returns the class name
  113069. */
  113070. getClassName(): string;
  113071. /**
  113072. * Get the friendly name associated with the input class.
  113073. * @returns the input friendly name
  113074. */
  113075. getSimpleName(): string;
  113076. }
  113077. }
  113078. declare module BABYLON {
  113079. /**
  113080. * Listen to mouse events to control the camera.
  113081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113082. */
  113083. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113084. /**
  113085. * Defines the camera the input is attached to.
  113086. */
  113087. camera: FlyCamera;
  113088. /**
  113089. * Defines if touch is enabled. (Default is true.)
  113090. */
  113091. touchEnabled: boolean;
  113092. /**
  113093. * Defines the buttons associated with the input to handle camera rotation.
  113094. */
  113095. buttons: number[];
  113096. /**
  113097. * Assign buttons for Yaw control.
  113098. */
  113099. buttonsYaw: number[];
  113100. /**
  113101. * Assign buttons for Pitch control.
  113102. */
  113103. buttonsPitch: number[];
  113104. /**
  113105. * Assign buttons for Roll control.
  113106. */
  113107. buttonsRoll: number[];
  113108. /**
  113109. * Detect if any button is being pressed while mouse is moved.
  113110. * -1 = Mouse locked.
  113111. * 0 = Left button.
  113112. * 1 = Middle Button.
  113113. * 2 = Right Button.
  113114. */
  113115. activeButton: number;
  113116. /**
  113117. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113118. * Higher values reduce its sensitivity.
  113119. */
  113120. angularSensibility: number;
  113121. private _mousemoveCallback;
  113122. private _observer;
  113123. private _rollObserver;
  113124. private previousPosition;
  113125. private noPreventDefault;
  113126. private element;
  113127. /**
  113128. * Listen to mouse events to control the camera.
  113129. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113131. */
  113132. constructor(touchEnabled?: boolean);
  113133. /**
  113134. * Attach the mouse control to the HTML DOM element.
  113135. * @param element Defines the element that listens to the input events.
  113136. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113137. */
  113138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113139. /**
  113140. * Detach the current controls from the specified dom element.
  113141. * @param element Defines the element to stop listening the inputs from
  113142. */
  113143. detachControl(element: Nullable<HTMLElement>): void;
  113144. /**
  113145. * Gets the class name of the current input.
  113146. * @returns the class name.
  113147. */
  113148. getClassName(): string;
  113149. /**
  113150. * Get the friendly name associated with the input class.
  113151. * @returns the input's friendly name.
  113152. */
  113153. getSimpleName(): string;
  113154. private _pointerInput;
  113155. private _onMouseMove;
  113156. /**
  113157. * Rotate camera by mouse offset.
  113158. */
  113159. private rotateCamera;
  113160. }
  113161. }
  113162. declare module BABYLON {
  113163. /**
  113164. * Default Inputs manager for the FlyCamera.
  113165. * It groups all the default supported inputs for ease of use.
  113166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113167. */
  113168. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113169. /**
  113170. * Instantiates a new FlyCameraInputsManager.
  113171. * @param camera Defines the camera the inputs belong to.
  113172. */
  113173. constructor(camera: FlyCamera);
  113174. /**
  113175. * Add keyboard input support to the input manager.
  113176. * @returns the new FlyCameraKeyboardMoveInput().
  113177. */
  113178. addKeyboard(): FlyCameraInputsManager;
  113179. /**
  113180. * Add mouse input support to the input manager.
  113181. * @param touchEnabled Enable touch screen support.
  113182. * @returns the new FlyCameraMouseInput().
  113183. */
  113184. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113185. }
  113186. }
  113187. declare module BABYLON {
  113188. /**
  113189. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113190. * such as in a 3D Space Shooter or a Flight Simulator.
  113191. */
  113192. export class FlyCamera extends TargetCamera {
  113193. /**
  113194. * Define the collision ellipsoid of the camera.
  113195. * This is helpful for simulating a camera body, like a player's body.
  113196. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113197. */
  113198. ellipsoid: Vector3;
  113199. /**
  113200. * Define an offset for the position of the ellipsoid around the camera.
  113201. * This can be helpful if the camera is attached away from the player's body center,
  113202. * such as at its head.
  113203. */
  113204. ellipsoidOffset: Vector3;
  113205. /**
  113206. * Enable or disable collisions of the camera with the rest of the scene objects.
  113207. */
  113208. checkCollisions: boolean;
  113209. /**
  113210. * Enable or disable gravity on the camera.
  113211. */
  113212. applyGravity: boolean;
  113213. /**
  113214. * Define the current direction the camera is moving to.
  113215. */
  113216. cameraDirection: Vector3;
  113217. /**
  113218. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113219. * This overrides and empties cameraRotation.
  113220. */
  113221. rotationQuaternion: Quaternion;
  113222. /**
  113223. * Track Roll to maintain the wanted Rolling when looking around.
  113224. */
  113225. _trackRoll: number;
  113226. /**
  113227. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113228. */
  113229. rollCorrect: number;
  113230. /**
  113231. * Mimic a banked turn, Rolling the camera when Yawing.
  113232. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113233. */
  113234. bankedTurn: boolean;
  113235. /**
  113236. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113237. */
  113238. bankedTurnLimit: number;
  113239. /**
  113240. * Value of 0 disables the banked Roll.
  113241. * Value of 1 is equal to the Yaw angle in radians.
  113242. */
  113243. bankedTurnMultiplier: number;
  113244. /**
  113245. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113246. */
  113247. inputs: FlyCameraInputsManager;
  113248. /**
  113249. * Gets the input sensibility for mouse input.
  113250. * Higher values reduce sensitivity.
  113251. */
  113252. get angularSensibility(): number;
  113253. /**
  113254. * Sets the input sensibility for a mouse input.
  113255. * Higher values reduce sensitivity.
  113256. */
  113257. set angularSensibility(value: number);
  113258. /**
  113259. * Get the keys for camera movement forward.
  113260. */
  113261. get keysForward(): number[];
  113262. /**
  113263. * Set the keys for camera movement forward.
  113264. */
  113265. set keysForward(value: number[]);
  113266. /**
  113267. * Get the keys for camera movement backward.
  113268. */
  113269. get keysBackward(): number[];
  113270. set keysBackward(value: number[]);
  113271. /**
  113272. * Get the keys for camera movement up.
  113273. */
  113274. get keysUp(): number[];
  113275. /**
  113276. * Set the keys for camera movement up.
  113277. */
  113278. set keysUp(value: number[]);
  113279. /**
  113280. * Get the keys for camera movement down.
  113281. */
  113282. get keysDown(): number[];
  113283. /**
  113284. * Set the keys for camera movement down.
  113285. */
  113286. set keysDown(value: number[]);
  113287. /**
  113288. * Get the keys for camera movement left.
  113289. */
  113290. get keysLeft(): number[];
  113291. /**
  113292. * Set the keys for camera movement left.
  113293. */
  113294. set keysLeft(value: number[]);
  113295. /**
  113296. * Set the keys for camera movement right.
  113297. */
  113298. get keysRight(): number[];
  113299. /**
  113300. * Set the keys for camera movement right.
  113301. */
  113302. set keysRight(value: number[]);
  113303. /**
  113304. * Event raised when the camera collides with a mesh in the scene.
  113305. */
  113306. onCollide: (collidedMesh: AbstractMesh) => void;
  113307. private _collider;
  113308. private _needMoveForGravity;
  113309. private _oldPosition;
  113310. private _diffPosition;
  113311. private _newPosition;
  113312. /** @hidden */
  113313. _localDirection: Vector3;
  113314. /** @hidden */
  113315. _transformedDirection: Vector3;
  113316. /**
  113317. * Instantiates a FlyCamera.
  113318. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113319. * such as in a 3D Space Shooter or a Flight Simulator.
  113320. * @param name Define the name of the camera in the scene.
  113321. * @param position Define the starting position of the camera in the scene.
  113322. * @param scene Define the scene the camera belongs to.
  113323. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113324. */
  113325. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113326. /**
  113327. * Attach a control to the HTML DOM element.
  113328. * @param element Defines the element that listens to the input events.
  113329. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113330. */
  113331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113332. /**
  113333. * Detach a control from the HTML DOM element.
  113334. * The camera will stop reacting to that input.
  113335. * @param element Defines the element that listens to the input events.
  113336. */
  113337. detachControl(element: HTMLElement): void;
  113338. private _collisionMask;
  113339. /**
  113340. * Get the mask that the camera ignores in collision events.
  113341. */
  113342. get collisionMask(): number;
  113343. /**
  113344. * Set the mask that the camera ignores in collision events.
  113345. */
  113346. set collisionMask(mask: number);
  113347. /** @hidden */
  113348. _collideWithWorld(displacement: Vector3): void;
  113349. /** @hidden */
  113350. private _onCollisionPositionChange;
  113351. /** @hidden */
  113352. _checkInputs(): void;
  113353. /** @hidden */
  113354. _decideIfNeedsToMove(): boolean;
  113355. /** @hidden */
  113356. _updatePosition(): void;
  113357. /**
  113358. * Restore the Roll to its target value at the rate specified.
  113359. * @param rate - Higher means slower restoring.
  113360. * @hidden
  113361. */
  113362. restoreRoll(rate: number): void;
  113363. /**
  113364. * Destroy the camera and release the current resources held by it.
  113365. */
  113366. dispose(): void;
  113367. /**
  113368. * Get the current object class name.
  113369. * @returns the class name.
  113370. */
  113371. getClassName(): string;
  113372. }
  113373. }
  113374. declare module BABYLON {
  113375. /**
  113376. * Listen to keyboard events to control the camera.
  113377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113378. */
  113379. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113380. /**
  113381. * Defines the camera the input is attached to.
  113382. */
  113383. camera: FlyCamera;
  113384. /**
  113385. * The list of keyboard keys used to control the forward move of the camera.
  113386. */
  113387. keysForward: number[];
  113388. /**
  113389. * The list of keyboard keys used to control the backward move of the camera.
  113390. */
  113391. keysBackward: number[];
  113392. /**
  113393. * The list of keyboard keys used to control the forward move of the camera.
  113394. */
  113395. keysUp: number[];
  113396. /**
  113397. * The list of keyboard keys used to control the backward move of the camera.
  113398. */
  113399. keysDown: number[];
  113400. /**
  113401. * The list of keyboard keys used to control the right strafe move of the camera.
  113402. */
  113403. keysRight: number[];
  113404. /**
  113405. * The list of keyboard keys used to control the left strafe move of the camera.
  113406. */
  113407. keysLeft: number[];
  113408. private _keys;
  113409. private _onCanvasBlurObserver;
  113410. private _onKeyboardObserver;
  113411. private _engine;
  113412. private _scene;
  113413. /**
  113414. * Attach the input controls to a specific dom element to get the input from.
  113415. * @param element Defines the element the controls should be listened from
  113416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113417. */
  113418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113419. /**
  113420. * Detach the current controls from the specified dom element.
  113421. * @param element Defines the element to stop listening the inputs from
  113422. */
  113423. detachControl(element: Nullable<HTMLElement>): void;
  113424. /**
  113425. * Gets the class name of the current intput.
  113426. * @returns the class name
  113427. */
  113428. getClassName(): string;
  113429. /** @hidden */
  113430. _onLostFocus(e: FocusEvent): void;
  113431. /**
  113432. * Get the friendly name associated with the input class.
  113433. * @returns the input friendly name
  113434. */
  113435. getSimpleName(): string;
  113436. /**
  113437. * Update the current camera state depending on the inputs that have been used this frame.
  113438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113439. */
  113440. checkInputs(): void;
  113441. }
  113442. }
  113443. declare module BABYLON {
  113444. /**
  113445. * Manage the mouse wheel inputs to control a follow camera.
  113446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113447. */
  113448. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113449. /**
  113450. * Defines the camera the input is attached to.
  113451. */
  113452. camera: FollowCamera;
  113453. /**
  113454. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113455. */
  113456. axisControlRadius: boolean;
  113457. /**
  113458. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113459. */
  113460. axisControlHeight: boolean;
  113461. /**
  113462. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113463. */
  113464. axisControlRotation: boolean;
  113465. /**
  113466. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113467. * relation to mouseWheel events.
  113468. */
  113469. wheelPrecision: number;
  113470. /**
  113471. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113472. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113473. */
  113474. wheelDeltaPercentage: number;
  113475. private _wheel;
  113476. private _observer;
  113477. /**
  113478. * Attach the input controls to a specific dom element to get the input from.
  113479. * @param element Defines the element the controls should be listened from
  113480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113481. */
  113482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113483. /**
  113484. * Detach the current controls from the specified dom element.
  113485. * @param element Defines the element to stop listening the inputs from
  113486. */
  113487. detachControl(element: Nullable<HTMLElement>): void;
  113488. /**
  113489. * Gets the class name of the current intput.
  113490. * @returns the class name
  113491. */
  113492. getClassName(): string;
  113493. /**
  113494. * Get the friendly name associated with the input class.
  113495. * @returns the input friendly name
  113496. */
  113497. getSimpleName(): string;
  113498. }
  113499. }
  113500. declare module BABYLON {
  113501. /**
  113502. * Manage the pointers inputs to control an follow camera.
  113503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113504. */
  113505. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113506. /**
  113507. * Defines the camera the input is attached to.
  113508. */
  113509. camera: FollowCamera;
  113510. /**
  113511. * Gets the class name of the current input.
  113512. * @returns the class name
  113513. */
  113514. getClassName(): string;
  113515. /**
  113516. * Defines the pointer angular sensibility along the X axis or how fast is
  113517. * the camera rotating.
  113518. * A negative number will reverse the axis direction.
  113519. */
  113520. angularSensibilityX: number;
  113521. /**
  113522. * Defines the pointer angular sensibility along the Y axis or how fast is
  113523. * the camera rotating.
  113524. * A negative number will reverse the axis direction.
  113525. */
  113526. angularSensibilityY: number;
  113527. /**
  113528. * Defines the pointer pinch precision or how fast is the camera zooming.
  113529. * A negative number will reverse the axis direction.
  113530. */
  113531. pinchPrecision: number;
  113532. /**
  113533. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113534. * from 0.
  113535. * It defines the percentage of current camera.radius to use as delta when
  113536. * pinch zoom is used.
  113537. */
  113538. pinchDeltaPercentage: number;
  113539. /**
  113540. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113541. */
  113542. axisXControlRadius: boolean;
  113543. /**
  113544. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113545. */
  113546. axisXControlHeight: boolean;
  113547. /**
  113548. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113549. */
  113550. axisXControlRotation: boolean;
  113551. /**
  113552. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113553. */
  113554. axisYControlRadius: boolean;
  113555. /**
  113556. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113557. */
  113558. axisYControlHeight: boolean;
  113559. /**
  113560. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113561. */
  113562. axisYControlRotation: boolean;
  113563. /**
  113564. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113565. */
  113566. axisPinchControlRadius: boolean;
  113567. /**
  113568. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113569. */
  113570. axisPinchControlHeight: boolean;
  113571. /**
  113572. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113573. */
  113574. axisPinchControlRotation: boolean;
  113575. /**
  113576. * Log error messages if basic misconfiguration has occurred.
  113577. */
  113578. warningEnable: boolean;
  113579. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113580. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113581. private _warningCounter;
  113582. private _warning;
  113583. }
  113584. }
  113585. declare module BABYLON {
  113586. /**
  113587. * Default Inputs manager for the FollowCamera.
  113588. * It groups all the default supported inputs for ease of use.
  113589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113590. */
  113591. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113592. /**
  113593. * Instantiates a new FollowCameraInputsManager.
  113594. * @param camera Defines the camera the inputs belong to
  113595. */
  113596. constructor(camera: FollowCamera);
  113597. /**
  113598. * Add keyboard input support to the input manager.
  113599. * @returns the current input manager
  113600. */
  113601. addKeyboard(): FollowCameraInputsManager;
  113602. /**
  113603. * Add mouse wheel input support to the input manager.
  113604. * @returns the current input manager
  113605. */
  113606. addMouseWheel(): FollowCameraInputsManager;
  113607. /**
  113608. * Add pointers input support to the input manager.
  113609. * @returns the current input manager
  113610. */
  113611. addPointers(): FollowCameraInputsManager;
  113612. /**
  113613. * Add orientation input support to the input manager.
  113614. * @returns the current input manager
  113615. */
  113616. addVRDeviceOrientation(): FollowCameraInputsManager;
  113617. }
  113618. }
  113619. declare module BABYLON {
  113620. /**
  113621. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113622. * an arc rotate version arcFollowCamera are available.
  113623. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113624. */
  113625. export class FollowCamera extends TargetCamera {
  113626. /**
  113627. * Distance the follow camera should follow an object at
  113628. */
  113629. radius: number;
  113630. /**
  113631. * Minimum allowed distance of the camera to the axis of rotation
  113632. * (The camera can not get closer).
  113633. * This can help limiting how the Camera is able to move in the scene.
  113634. */
  113635. lowerRadiusLimit: Nullable<number>;
  113636. /**
  113637. * Maximum allowed distance of the camera to the axis of rotation
  113638. * (The camera can not get further).
  113639. * This can help limiting how the Camera is able to move in the scene.
  113640. */
  113641. upperRadiusLimit: Nullable<number>;
  113642. /**
  113643. * Define a rotation offset between the camera and the object it follows
  113644. */
  113645. rotationOffset: number;
  113646. /**
  113647. * Minimum allowed angle to camera position relative to target object.
  113648. * This can help limiting how the Camera is able to move in the scene.
  113649. */
  113650. lowerRotationOffsetLimit: Nullable<number>;
  113651. /**
  113652. * Maximum allowed angle to camera position relative to target object.
  113653. * This can help limiting how the Camera is able to move in the scene.
  113654. */
  113655. upperRotationOffsetLimit: Nullable<number>;
  113656. /**
  113657. * Define a height offset between the camera and the object it follows.
  113658. * It can help following an object from the top (like a car chaing a plane)
  113659. */
  113660. heightOffset: number;
  113661. /**
  113662. * Minimum allowed height of camera position relative to target object.
  113663. * This can help limiting how the Camera is able to move in the scene.
  113664. */
  113665. lowerHeightOffsetLimit: Nullable<number>;
  113666. /**
  113667. * Maximum allowed height of camera position relative to target object.
  113668. * This can help limiting how the Camera is able to move in the scene.
  113669. */
  113670. upperHeightOffsetLimit: Nullable<number>;
  113671. /**
  113672. * Define how fast the camera can accelerate to follow it s target.
  113673. */
  113674. cameraAcceleration: number;
  113675. /**
  113676. * Define the speed limit of the camera following an object.
  113677. */
  113678. maxCameraSpeed: number;
  113679. /**
  113680. * Define the target of the camera.
  113681. */
  113682. lockedTarget: Nullable<AbstractMesh>;
  113683. /**
  113684. * Defines the input associated with the camera.
  113685. */
  113686. inputs: FollowCameraInputsManager;
  113687. /**
  113688. * Instantiates the follow camera.
  113689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113690. * @param name Define the name of the camera in the scene
  113691. * @param position Define the position of the camera
  113692. * @param scene Define the scene the camera belong to
  113693. * @param lockedTarget Define the target of the camera
  113694. */
  113695. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113696. private _follow;
  113697. /**
  113698. * Attached controls to the current camera.
  113699. * @param element Defines the element the controls should be listened from
  113700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113701. */
  113702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113703. /**
  113704. * Detach the current controls from the camera.
  113705. * The camera will stop reacting to inputs.
  113706. * @param element Defines the element to stop listening the inputs from
  113707. */
  113708. detachControl(element: HTMLElement): void;
  113709. /** @hidden */
  113710. _checkInputs(): void;
  113711. private _checkLimits;
  113712. /**
  113713. * Gets the camera class name.
  113714. * @returns the class name
  113715. */
  113716. getClassName(): string;
  113717. }
  113718. /**
  113719. * Arc Rotate version of the follow camera.
  113720. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113722. */
  113723. export class ArcFollowCamera extends TargetCamera {
  113724. /** The longitudinal angle of the camera */
  113725. alpha: number;
  113726. /** The latitudinal angle of the camera */
  113727. beta: number;
  113728. /** The radius of the camera from its target */
  113729. radius: number;
  113730. /** Define the camera target (the messh it should follow) */
  113731. target: Nullable<AbstractMesh>;
  113732. private _cartesianCoordinates;
  113733. /**
  113734. * Instantiates a new ArcFollowCamera
  113735. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113736. * @param name Define the name of the camera
  113737. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113738. * @param beta Define the rotation angle of the camera around the elevation axis
  113739. * @param radius Define the radius of the camera from its target point
  113740. * @param target Define the target of the camera
  113741. * @param scene Define the scene the camera belongs to
  113742. */
  113743. constructor(name: string,
  113744. /** The longitudinal angle of the camera */
  113745. alpha: number,
  113746. /** The latitudinal angle of the camera */
  113747. beta: number,
  113748. /** The radius of the camera from its target */
  113749. radius: number,
  113750. /** Define the camera target (the messh it should follow) */
  113751. target: Nullable<AbstractMesh>, scene: Scene);
  113752. private _follow;
  113753. /** @hidden */
  113754. _checkInputs(): void;
  113755. /**
  113756. * Returns the class name of the object.
  113757. * It is mostly used internally for serialization purposes.
  113758. */
  113759. getClassName(): string;
  113760. }
  113761. }
  113762. declare module BABYLON {
  113763. /**
  113764. * Manage the keyboard inputs to control the movement of a follow camera.
  113765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113766. */
  113767. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113768. /**
  113769. * Defines the camera the input is attached to.
  113770. */
  113771. camera: FollowCamera;
  113772. /**
  113773. * Defines the list of key codes associated with the up action (increase heightOffset)
  113774. */
  113775. keysHeightOffsetIncr: number[];
  113776. /**
  113777. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113778. */
  113779. keysHeightOffsetDecr: number[];
  113780. /**
  113781. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113782. */
  113783. keysHeightOffsetModifierAlt: boolean;
  113784. /**
  113785. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113786. */
  113787. keysHeightOffsetModifierCtrl: boolean;
  113788. /**
  113789. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113790. */
  113791. keysHeightOffsetModifierShift: boolean;
  113792. /**
  113793. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113794. */
  113795. keysRotationOffsetIncr: number[];
  113796. /**
  113797. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113798. */
  113799. keysRotationOffsetDecr: number[];
  113800. /**
  113801. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113802. */
  113803. keysRotationOffsetModifierAlt: boolean;
  113804. /**
  113805. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113806. */
  113807. keysRotationOffsetModifierCtrl: boolean;
  113808. /**
  113809. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113810. */
  113811. keysRotationOffsetModifierShift: boolean;
  113812. /**
  113813. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113814. */
  113815. keysRadiusIncr: number[];
  113816. /**
  113817. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113818. */
  113819. keysRadiusDecr: number[];
  113820. /**
  113821. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113822. */
  113823. keysRadiusModifierAlt: boolean;
  113824. /**
  113825. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113826. */
  113827. keysRadiusModifierCtrl: boolean;
  113828. /**
  113829. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113830. */
  113831. keysRadiusModifierShift: boolean;
  113832. /**
  113833. * Defines the rate of change of heightOffset.
  113834. */
  113835. heightSensibility: number;
  113836. /**
  113837. * Defines the rate of change of rotationOffset.
  113838. */
  113839. rotationSensibility: number;
  113840. /**
  113841. * Defines the rate of change of radius.
  113842. */
  113843. radiusSensibility: number;
  113844. private _keys;
  113845. private _ctrlPressed;
  113846. private _altPressed;
  113847. private _shiftPressed;
  113848. private _onCanvasBlurObserver;
  113849. private _onKeyboardObserver;
  113850. private _engine;
  113851. private _scene;
  113852. /**
  113853. * Attach the input controls to a specific dom element to get the input from.
  113854. * @param element Defines the element the controls should be listened from
  113855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113856. */
  113857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113858. /**
  113859. * Detach the current controls from the specified dom element.
  113860. * @param element Defines the element to stop listening the inputs from
  113861. */
  113862. detachControl(element: Nullable<HTMLElement>): void;
  113863. /**
  113864. * Update the current camera state depending on the inputs that have been used this frame.
  113865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113866. */
  113867. checkInputs(): void;
  113868. /**
  113869. * Gets the class name of the current input.
  113870. * @returns the class name
  113871. */
  113872. getClassName(): string;
  113873. /**
  113874. * Get the friendly name associated with the input class.
  113875. * @returns the input friendly name
  113876. */
  113877. getSimpleName(): string;
  113878. /**
  113879. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113880. * allow modification of the heightOffset value.
  113881. */
  113882. private _modifierHeightOffset;
  113883. /**
  113884. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113885. * allow modification of the rotationOffset value.
  113886. */
  113887. private _modifierRotationOffset;
  113888. /**
  113889. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113890. * allow modification of the radius value.
  113891. */
  113892. private _modifierRadius;
  113893. }
  113894. }
  113895. declare module BABYLON {
  113896. interface FreeCameraInputsManager {
  113897. /**
  113898. * @hidden
  113899. */
  113900. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113901. /**
  113902. * Add orientation input support to the input manager.
  113903. * @returns the current input manager
  113904. */
  113905. addDeviceOrientation(): FreeCameraInputsManager;
  113906. }
  113907. /**
  113908. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113909. * Screen rotation is taken into account.
  113910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113911. */
  113912. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113913. private _camera;
  113914. private _screenOrientationAngle;
  113915. private _constantTranform;
  113916. private _screenQuaternion;
  113917. private _alpha;
  113918. private _beta;
  113919. private _gamma;
  113920. /**
  113921. * Can be used to detect if a device orientation sensor is available on a device
  113922. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113923. * @returns a promise that will resolve on orientation change
  113924. */
  113925. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113926. /**
  113927. * @hidden
  113928. */
  113929. _onDeviceOrientationChangedObservable: Observable<void>;
  113930. /**
  113931. * Instantiates a new input
  113932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113933. */
  113934. constructor();
  113935. /**
  113936. * Define the camera controlled by the input.
  113937. */
  113938. get camera(): FreeCamera;
  113939. set camera(camera: FreeCamera);
  113940. /**
  113941. * Attach the input controls to a specific dom element to get the input from.
  113942. * @param element Defines the element the controls should be listened from
  113943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113944. */
  113945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113946. private _orientationChanged;
  113947. private _deviceOrientation;
  113948. /**
  113949. * Detach the current controls from the specified dom element.
  113950. * @param element Defines the element to stop listening the inputs from
  113951. */
  113952. detachControl(element: Nullable<HTMLElement>): void;
  113953. /**
  113954. * Update the current camera state depending on the inputs that have been used this frame.
  113955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113956. */
  113957. checkInputs(): void;
  113958. /**
  113959. * Gets the class name of the current intput.
  113960. * @returns the class name
  113961. */
  113962. getClassName(): string;
  113963. /**
  113964. * Get the friendly name associated with the input class.
  113965. * @returns the input friendly name
  113966. */
  113967. getSimpleName(): string;
  113968. }
  113969. }
  113970. declare module BABYLON {
  113971. /**
  113972. * Manage the gamepad inputs to control a free camera.
  113973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113974. */
  113975. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113976. /**
  113977. * Define the camera the input is attached to.
  113978. */
  113979. camera: FreeCamera;
  113980. /**
  113981. * Define the Gamepad controlling the input
  113982. */
  113983. gamepad: Nullable<Gamepad>;
  113984. /**
  113985. * Defines the gamepad rotation sensiblity.
  113986. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113987. */
  113988. gamepadAngularSensibility: number;
  113989. /**
  113990. * Defines the gamepad move sensiblity.
  113991. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113992. */
  113993. gamepadMoveSensibility: number;
  113994. private _yAxisScale;
  113995. /**
  113996. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113997. */
  113998. get invertYAxis(): boolean;
  113999. set invertYAxis(value: boolean);
  114000. private _onGamepadConnectedObserver;
  114001. private _onGamepadDisconnectedObserver;
  114002. private _cameraTransform;
  114003. private _deltaTransform;
  114004. private _vector3;
  114005. private _vector2;
  114006. /**
  114007. * Attach the input controls to a specific dom element to get the input from.
  114008. * @param element Defines the element the controls should be listened from
  114009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114010. */
  114011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114012. /**
  114013. * Detach the current controls from the specified dom element.
  114014. * @param element Defines the element to stop listening the inputs from
  114015. */
  114016. detachControl(element: Nullable<HTMLElement>): void;
  114017. /**
  114018. * Update the current camera state depending on the inputs that have been used this frame.
  114019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114020. */
  114021. checkInputs(): void;
  114022. /**
  114023. * Gets the class name of the current intput.
  114024. * @returns the class name
  114025. */
  114026. getClassName(): string;
  114027. /**
  114028. * Get the friendly name associated with the input class.
  114029. * @returns the input friendly name
  114030. */
  114031. getSimpleName(): string;
  114032. }
  114033. }
  114034. declare module BABYLON {
  114035. /**
  114036. * Defines the potential axis of a Joystick
  114037. */
  114038. export enum JoystickAxis {
  114039. /** X axis */
  114040. X = 0,
  114041. /** Y axis */
  114042. Y = 1,
  114043. /** Z axis */
  114044. Z = 2
  114045. }
  114046. /**
  114047. * Class used to define virtual joystick (used in touch mode)
  114048. */
  114049. export class VirtualJoystick {
  114050. /**
  114051. * Gets or sets a boolean indicating that left and right values must be inverted
  114052. */
  114053. reverseLeftRight: boolean;
  114054. /**
  114055. * Gets or sets a boolean indicating that up and down values must be inverted
  114056. */
  114057. reverseUpDown: boolean;
  114058. /**
  114059. * Gets the offset value for the position (ie. the change of the position value)
  114060. */
  114061. deltaPosition: Vector3;
  114062. /**
  114063. * Gets a boolean indicating if the virtual joystick was pressed
  114064. */
  114065. pressed: boolean;
  114066. /**
  114067. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114068. */
  114069. static Canvas: Nullable<HTMLCanvasElement>;
  114070. private static _globalJoystickIndex;
  114071. private static vjCanvasContext;
  114072. private static vjCanvasWidth;
  114073. private static vjCanvasHeight;
  114074. private static halfWidth;
  114075. private _action;
  114076. private _axisTargetedByLeftAndRight;
  114077. private _axisTargetedByUpAndDown;
  114078. private _joystickSensibility;
  114079. private _inversedSensibility;
  114080. private _joystickPointerID;
  114081. private _joystickColor;
  114082. private _joystickPointerPos;
  114083. private _joystickPreviousPointerPos;
  114084. private _joystickPointerStartPos;
  114085. private _deltaJoystickVector;
  114086. private _leftJoystick;
  114087. private _touches;
  114088. private _onPointerDownHandlerRef;
  114089. private _onPointerMoveHandlerRef;
  114090. private _onPointerUpHandlerRef;
  114091. private _onResize;
  114092. /**
  114093. * Creates a new virtual joystick
  114094. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114095. */
  114096. constructor(leftJoystick?: boolean);
  114097. /**
  114098. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114099. * @param newJoystickSensibility defines the new sensibility
  114100. */
  114101. setJoystickSensibility(newJoystickSensibility: number): void;
  114102. private _onPointerDown;
  114103. private _onPointerMove;
  114104. private _onPointerUp;
  114105. /**
  114106. * Change the color of the virtual joystick
  114107. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114108. */
  114109. setJoystickColor(newColor: string): void;
  114110. /**
  114111. * Defines a callback to call when the joystick is touched
  114112. * @param action defines the callback
  114113. */
  114114. setActionOnTouch(action: () => any): void;
  114115. /**
  114116. * Defines which axis you'd like to control for left & right
  114117. * @param axis defines the axis to use
  114118. */
  114119. setAxisForLeftRight(axis: JoystickAxis): void;
  114120. /**
  114121. * Defines which axis you'd like to control for up & down
  114122. * @param axis defines the axis to use
  114123. */
  114124. setAxisForUpDown(axis: JoystickAxis): void;
  114125. private _drawVirtualJoystick;
  114126. /**
  114127. * Release internal HTML canvas
  114128. */
  114129. releaseCanvas(): void;
  114130. }
  114131. }
  114132. declare module BABYLON {
  114133. interface FreeCameraInputsManager {
  114134. /**
  114135. * Add virtual joystick input support to the input manager.
  114136. * @returns the current input manager
  114137. */
  114138. addVirtualJoystick(): FreeCameraInputsManager;
  114139. }
  114140. /**
  114141. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114143. */
  114144. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114145. /**
  114146. * Defines the camera the input is attached to.
  114147. */
  114148. camera: FreeCamera;
  114149. private _leftjoystick;
  114150. private _rightjoystick;
  114151. /**
  114152. * Gets the left stick of the virtual joystick.
  114153. * @returns The virtual Joystick
  114154. */
  114155. getLeftJoystick(): VirtualJoystick;
  114156. /**
  114157. * Gets the right stick of the virtual joystick.
  114158. * @returns The virtual Joystick
  114159. */
  114160. getRightJoystick(): VirtualJoystick;
  114161. /**
  114162. * Update the current camera state depending on the inputs that have been used this frame.
  114163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114164. */
  114165. checkInputs(): void;
  114166. /**
  114167. * Attach the input controls to a specific dom element to get the input from.
  114168. * @param element Defines the element the controls should be listened from
  114169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114170. */
  114171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114172. /**
  114173. * Detach the current controls from the specified dom element.
  114174. * @param element Defines the element to stop listening the inputs from
  114175. */
  114176. detachControl(element: Nullable<HTMLElement>): void;
  114177. /**
  114178. * Gets the class name of the current intput.
  114179. * @returns the class name
  114180. */
  114181. getClassName(): string;
  114182. /**
  114183. * Get the friendly name associated with the input class.
  114184. * @returns the input friendly name
  114185. */
  114186. getSimpleName(): string;
  114187. }
  114188. }
  114189. declare module BABYLON {
  114190. /**
  114191. * This represents a FPS type of camera controlled by touch.
  114192. * This is like a universal camera minus the Gamepad controls.
  114193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114194. */
  114195. export class TouchCamera extends FreeCamera {
  114196. /**
  114197. * Defines the touch sensibility for rotation.
  114198. * The higher the faster.
  114199. */
  114200. get touchAngularSensibility(): number;
  114201. set touchAngularSensibility(value: number);
  114202. /**
  114203. * Defines the touch sensibility for move.
  114204. * The higher the faster.
  114205. */
  114206. get touchMoveSensibility(): number;
  114207. set touchMoveSensibility(value: number);
  114208. /**
  114209. * Instantiates a new touch camera.
  114210. * This represents a FPS type of camera controlled by touch.
  114211. * This is like a universal camera minus the Gamepad controls.
  114212. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114213. * @param name Define the name of the camera in the scene
  114214. * @param position Define the start position of the camera in the scene
  114215. * @param scene Define the scene the camera belongs to
  114216. */
  114217. constructor(name: string, position: Vector3, scene: Scene);
  114218. /**
  114219. * Gets the current object class name.
  114220. * @return the class name
  114221. */
  114222. getClassName(): string;
  114223. /** @hidden */
  114224. _setupInputs(): void;
  114225. }
  114226. }
  114227. declare module BABYLON {
  114228. /**
  114229. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114230. * being tilted forward or back and left or right.
  114231. */
  114232. export class DeviceOrientationCamera extends FreeCamera {
  114233. private _initialQuaternion;
  114234. private _quaternionCache;
  114235. private _tmpDragQuaternion;
  114236. private _disablePointerInputWhenUsingDeviceOrientation;
  114237. /**
  114238. * Creates a new device orientation camera
  114239. * @param name The name of the camera
  114240. * @param position The start position camera
  114241. * @param scene The scene the camera belongs to
  114242. */
  114243. constructor(name: string, position: Vector3, scene: Scene);
  114244. /**
  114245. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114246. */
  114247. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114248. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114249. private _dragFactor;
  114250. /**
  114251. * Enabled turning on the y axis when the orientation sensor is active
  114252. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114253. */
  114254. enableHorizontalDragging(dragFactor?: number): void;
  114255. /**
  114256. * Gets the current instance class name ("DeviceOrientationCamera").
  114257. * This helps avoiding instanceof at run time.
  114258. * @returns the class name
  114259. */
  114260. getClassName(): string;
  114261. /**
  114262. * @hidden
  114263. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114264. */
  114265. _checkInputs(): void;
  114266. /**
  114267. * Reset the camera to its default orientation on the specified axis only.
  114268. * @param axis The axis to reset
  114269. */
  114270. resetToCurrentRotation(axis?: Axis): void;
  114271. }
  114272. }
  114273. declare module BABYLON {
  114274. /**
  114275. * Defines supported buttons for XBox360 compatible gamepads
  114276. */
  114277. export enum Xbox360Button {
  114278. /** A */
  114279. A = 0,
  114280. /** B */
  114281. B = 1,
  114282. /** X */
  114283. X = 2,
  114284. /** Y */
  114285. Y = 3,
  114286. /** Start */
  114287. Start = 4,
  114288. /** Back */
  114289. Back = 5,
  114290. /** Left button */
  114291. LB = 6,
  114292. /** Right button */
  114293. RB = 7,
  114294. /** Left stick */
  114295. LeftStick = 8,
  114296. /** Right stick */
  114297. RightStick = 9
  114298. }
  114299. /** Defines values for XBox360 DPad */
  114300. export enum Xbox360Dpad {
  114301. /** Up */
  114302. Up = 0,
  114303. /** Down */
  114304. Down = 1,
  114305. /** Left */
  114306. Left = 2,
  114307. /** Right */
  114308. Right = 3
  114309. }
  114310. /**
  114311. * Defines a XBox360 gamepad
  114312. */
  114313. export class Xbox360Pad extends Gamepad {
  114314. private _leftTrigger;
  114315. private _rightTrigger;
  114316. private _onlefttriggerchanged;
  114317. private _onrighttriggerchanged;
  114318. private _onbuttondown;
  114319. private _onbuttonup;
  114320. private _ondpaddown;
  114321. private _ondpadup;
  114322. /** Observable raised when a button is pressed */
  114323. onButtonDownObservable: Observable<Xbox360Button>;
  114324. /** Observable raised when a button is released */
  114325. onButtonUpObservable: Observable<Xbox360Button>;
  114326. /** Observable raised when a pad is pressed */
  114327. onPadDownObservable: Observable<Xbox360Dpad>;
  114328. /** Observable raised when a pad is released */
  114329. onPadUpObservable: Observable<Xbox360Dpad>;
  114330. private _buttonA;
  114331. private _buttonB;
  114332. private _buttonX;
  114333. private _buttonY;
  114334. private _buttonBack;
  114335. private _buttonStart;
  114336. private _buttonLB;
  114337. private _buttonRB;
  114338. private _buttonLeftStick;
  114339. private _buttonRightStick;
  114340. private _dPadUp;
  114341. private _dPadDown;
  114342. private _dPadLeft;
  114343. private _dPadRight;
  114344. private _isXboxOnePad;
  114345. /**
  114346. * Creates a new XBox360 gamepad object
  114347. * @param id defines the id of this gamepad
  114348. * @param index defines its index
  114349. * @param gamepad defines the internal HTML gamepad object
  114350. * @param xboxOne defines if it is a XBox One gamepad
  114351. */
  114352. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114353. /**
  114354. * Defines the callback to call when left trigger is pressed
  114355. * @param callback defines the callback to use
  114356. */
  114357. onlefttriggerchanged(callback: (value: number) => void): void;
  114358. /**
  114359. * Defines the callback to call when right trigger is pressed
  114360. * @param callback defines the callback to use
  114361. */
  114362. onrighttriggerchanged(callback: (value: number) => void): void;
  114363. /**
  114364. * Gets the left trigger value
  114365. */
  114366. get leftTrigger(): number;
  114367. /**
  114368. * Sets the left trigger value
  114369. */
  114370. set leftTrigger(newValue: number);
  114371. /**
  114372. * Gets the right trigger value
  114373. */
  114374. get rightTrigger(): number;
  114375. /**
  114376. * Sets the right trigger value
  114377. */
  114378. set rightTrigger(newValue: number);
  114379. /**
  114380. * Defines the callback to call when a button is pressed
  114381. * @param callback defines the callback to use
  114382. */
  114383. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114384. /**
  114385. * Defines the callback to call when a button is released
  114386. * @param callback defines the callback to use
  114387. */
  114388. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114389. /**
  114390. * Defines the callback to call when a pad is pressed
  114391. * @param callback defines the callback to use
  114392. */
  114393. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114394. /**
  114395. * Defines the callback to call when a pad is released
  114396. * @param callback defines the callback to use
  114397. */
  114398. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114399. private _setButtonValue;
  114400. private _setDPadValue;
  114401. /**
  114402. * Gets the value of the `A` button
  114403. */
  114404. get buttonA(): number;
  114405. /**
  114406. * Sets the value of the `A` button
  114407. */
  114408. set buttonA(value: number);
  114409. /**
  114410. * Gets the value of the `B` button
  114411. */
  114412. get buttonB(): number;
  114413. /**
  114414. * Sets the value of the `B` button
  114415. */
  114416. set buttonB(value: number);
  114417. /**
  114418. * Gets the value of the `X` button
  114419. */
  114420. get buttonX(): number;
  114421. /**
  114422. * Sets the value of the `X` button
  114423. */
  114424. set buttonX(value: number);
  114425. /**
  114426. * Gets the value of the `Y` button
  114427. */
  114428. get buttonY(): number;
  114429. /**
  114430. * Sets the value of the `Y` button
  114431. */
  114432. set buttonY(value: number);
  114433. /**
  114434. * Gets the value of the `Start` button
  114435. */
  114436. get buttonStart(): number;
  114437. /**
  114438. * Sets the value of the `Start` button
  114439. */
  114440. set buttonStart(value: number);
  114441. /**
  114442. * Gets the value of the `Back` button
  114443. */
  114444. get buttonBack(): number;
  114445. /**
  114446. * Sets the value of the `Back` button
  114447. */
  114448. set buttonBack(value: number);
  114449. /**
  114450. * Gets the value of the `Left` button
  114451. */
  114452. get buttonLB(): number;
  114453. /**
  114454. * Sets the value of the `Left` button
  114455. */
  114456. set buttonLB(value: number);
  114457. /**
  114458. * Gets the value of the `Right` button
  114459. */
  114460. get buttonRB(): number;
  114461. /**
  114462. * Sets the value of the `Right` button
  114463. */
  114464. set buttonRB(value: number);
  114465. /**
  114466. * Gets the value of the Left joystick
  114467. */
  114468. get buttonLeftStick(): number;
  114469. /**
  114470. * Sets the value of the Left joystick
  114471. */
  114472. set buttonLeftStick(value: number);
  114473. /**
  114474. * Gets the value of the Right joystick
  114475. */
  114476. get buttonRightStick(): number;
  114477. /**
  114478. * Sets the value of the Right joystick
  114479. */
  114480. set buttonRightStick(value: number);
  114481. /**
  114482. * Gets the value of D-pad up
  114483. */
  114484. get dPadUp(): number;
  114485. /**
  114486. * Sets the value of D-pad up
  114487. */
  114488. set dPadUp(value: number);
  114489. /**
  114490. * Gets the value of D-pad down
  114491. */
  114492. get dPadDown(): number;
  114493. /**
  114494. * Sets the value of D-pad down
  114495. */
  114496. set dPadDown(value: number);
  114497. /**
  114498. * Gets the value of D-pad left
  114499. */
  114500. get dPadLeft(): number;
  114501. /**
  114502. * Sets the value of D-pad left
  114503. */
  114504. set dPadLeft(value: number);
  114505. /**
  114506. * Gets the value of D-pad right
  114507. */
  114508. get dPadRight(): number;
  114509. /**
  114510. * Sets the value of D-pad right
  114511. */
  114512. set dPadRight(value: number);
  114513. /**
  114514. * Force the gamepad to synchronize with device values
  114515. */
  114516. update(): void;
  114517. /**
  114518. * Disposes the gamepad
  114519. */
  114520. dispose(): void;
  114521. }
  114522. }
  114523. declare module BABYLON {
  114524. /**
  114525. * Defines supported buttons for DualShock compatible gamepads
  114526. */
  114527. export enum DualShockButton {
  114528. /** Cross */
  114529. Cross = 0,
  114530. /** Circle */
  114531. Circle = 1,
  114532. /** Square */
  114533. Square = 2,
  114534. /** Triangle */
  114535. Triangle = 3,
  114536. /** Options */
  114537. Options = 4,
  114538. /** Share */
  114539. Share = 5,
  114540. /** L1 */
  114541. L1 = 6,
  114542. /** R1 */
  114543. R1 = 7,
  114544. /** Left stick */
  114545. LeftStick = 8,
  114546. /** Right stick */
  114547. RightStick = 9
  114548. }
  114549. /** Defines values for DualShock DPad */
  114550. export enum DualShockDpad {
  114551. /** Up */
  114552. Up = 0,
  114553. /** Down */
  114554. Down = 1,
  114555. /** Left */
  114556. Left = 2,
  114557. /** Right */
  114558. Right = 3
  114559. }
  114560. /**
  114561. * Defines a DualShock gamepad
  114562. */
  114563. export class DualShockPad extends Gamepad {
  114564. private _leftTrigger;
  114565. private _rightTrigger;
  114566. private _onlefttriggerchanged;
  114567. private _onrighttriggerchanged;
  114568. private _onbuttondown;
  114569. private _onbuttonup;
  114570. private _ondpaddown;
  114571. private _ondpadup;
  114572. /** Observable raised when a button is pressed */
  114573. onButtonDownObservable: Observable<DualShockButton>;
  114574. /** Observable raised when a button is released */
  114575. onButtonUpObservable: Observable<DualShockButton>;
  114576. /** Observable raised when a pad is pressed */
  114577. onPadDownObservable: Observable<DualShockDpad>;
  114578. /** Observable raised when a pad is released */
  114579. onPadUpObservable: Observable<DualShockDpad>;
  114580. private _buttonCross;
  114581. private _buttonCircle;
  114582. private _buttonSquare;
  114583. private _buttonTriangle;
  114584. private _buttonShare;
  114585. private _buttonOptions;
  114586. private _buttonL1;
  114587. private _buttonR1;
  114588. private _buttonLeftStick;
  114589. private _buttonRightStick;
  114590. private _dPadUp;
  114591. private _dPadDown;
  114592. private _dPadLeft;
  114593. private _dPadRight;
  114594. /**
  114595. * Creates a new DualShock gamepad object
  114596. * @param id defines the id of this gamepad
  114597. * @param index defines its index
  114598. * @param gamepad defines the internal HTML gamepad object
  114599. */
  114600. constructor(id: string, index: number, gamepad: any);
  114601. /**
  114602. * Defines the callback to call when left trigger is pressed
  114603. * @param callback defines the callback to use
  114604. */
  114605. onlefttriggerchanged(callback: (value: number) => void): void;
  114606. /**
  114607. * Defines the callback to call when right trigger is pressed
  114608. * @param callback defines the callback to use
  114609. */
  114610. onrighttriggerchanged(callback: (value: number) => void): void;
  114611. /**
  114612. * Gets the left trigger value
  114613. */
  114614. get leftTrigger(): number;
  114615. /**
  114616. * Sets the left trigger value
  114617. */
  114618. set leftTrigger(newValue: number);
  114619. /**
  114620. * Gets the right trigger value
  114621. */
  114622. get rightTrigger(): number;
  114623. /**
  114624. * Sets the right trigger value
  114625. */
  114626. set rightTrigger(newValue: number);
  114627. /**
  114628. * Defines the callback to call when a button is pressed
  114629. * @param callback defines the callback to use
  114630. */
  114631. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114632. /**
  114633. * Defines the callback to call when a button is released
  114634. * @param callback defines the callback to use
  114635. */
  114636. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114637. /**
  114638. * Defines the callback to call when a pad is pressed
  114639. * @param callback defines the callback to use
  114640. */
  114641. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114642. /**
  114643. * Defines the callback to call when a pad is released
  114644. * @param callback defines the callback to use
  114645. */
  114646. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114647. private _setButtonValue;
  114648. private _setDPadValue;
  114649. /**
  114650. * Gets the value of the `Cross` button
  114651. */
  114652. get buttonCross(): number;
  114653. /**
  114654. * Sets the value of the `Cross` button
  114655. */
  114656. set buttonCross(value: number);
  114657. /**
  114658. * Gets the value of the `Circle` button
  114659. */
  114660. get buttonCircle(): number;
  114661. /**
  114662. * Sets the value of the `Circle` button
  114663. */
  114664. set buttonCircle(value: number);
  114665. /**
  114666. * Gets the value of the `Square` button
  114667. */
  114668. get buttonSquare(): number;
  114669. /**
  114670. * Sets the value of the `Square` button
  114671. */
  114672. set buttonSquare(value: number);
  114673. /**
  114674. * Gets the value of the `Triangle` button
  114675. */
  114676. get buttonTriangle(): number;
  114677. /**
  114678. * Sets the value of the `Triangle` button
  114679. */
  114680. set buttonTriangle(value: number);
  114681. /**
  114682. * Gets the value of the `Options` button
  114683. */
  114684. get buttonOptions(): number;
  114685. /**
  114686. * Sets the value of the `Options` button
  114687. */
  114688. set buttonOptions(value: number);
  114689. /**
  114690. * Gets the value of the `Share` button
  114691. */
  114692. get buttonShare(): number;
  114693. /**
  114694. * Sets the value of the `Share` button
  114695. */
  114696. set buttonShare(value: number);
  114697. /**
  114698. * Gets the value of the `L1` button
  114699. */
  114700. get buttonL1(): number;
  114701. /**
  114702. * Sets the value of the `L1` button
  114703. */
  114704. set buttonL1(value: number);
  114705. /**
  114706. * Gets the value of the `R1` button
  114707. */
  114708. get buttonR1(): number;
  114709. /**
  114710. * Sets the value of the `R1` button
  114711. */
  114712. set buttonR1(value: number);
  114713. /**
  114714. * Gets the value of the Left joystick
  114715. */
  114716. get buttonLeftStick(): number;
  114717. /**
  114718. * Sets the value of the Left joystick
  114719. */
  114720. set buttonLeftStick(value: number);
  114721. /**
  114722. * Gets the value of the Right joystick
  114723. */
  114724. get buttonRightStick(): number;
  114725. /**
  114726. * Sets the value of the Right joystick
  114727. */
  114728. set buttonRightStick(value: number);
  114729. /**
  114730. * Gets the value of D-pad up
  114731. */
  114732. get dPadUp(): number;
  114733. /**
  114734. * Sets the value of D-pad up
  114735. */
  114736. set dPadUp(value: number);
  114737. /**
  114738. * Gets the value of D-pad down
  114739. */
  114740. get dPadDown(): number;
  114741. /**
  114742. * Sets the value of D-pad down
  114743. */
  114744. set dPadDown(value: number);
  114745. /**
  114746. * Gets the value of D-pad left
  114747. */
  114748. get dPadLeft(): number;
  114749. /**
  114750. * Sets the value of D-pad left
  114751. */
  114752. set dPadLeft(value: number);
  114753. /**
  114754. * Gets the value of D-pad right
  114755. */
  114756. get dPadRight(): number;
  114757. /**
  114758. * Sets the value of D-pad right
  114759. */
  114760. set dPadRight(value: number);
  114761. /**
  114762. * Force the gamepad to synchronize with device values
  114763. */
  114764. update(): void;
  114765. /**
  114766. * Disposes the gamepad
  114767. */
  114768. dispose(): void;
  114769. }
  114770. }
  114771. declare module BABYLON {
  114772. /**
  114773. * Manager for handling gamepads
  114774. */
  114775. export class GamepadManager {
  114776. private _scene?;
  114777. private _babylonGamepads;
  114778. private _oneGamepadConnected;
  114779. /** @hidden */
  114780. _isMonitoring: boolean;
  114781. private _gamepadEventSupported;
  114782. private _gamepadSupport?;
  114783. /**
  114784. * observable to be triggered when the gamepad controller has been connected
  114785. */
  114786. onGamepadConnectedObservable: Observable<Gamepad>;
  114787. /**
  114788. * observable to be triggered when the gamepad controller has been disconnected
  114789. */
  114790. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114791. private _onGamepadConnectedEvent;
  114792. private _onGamepadDisconnectedEvent;
  114793. /**
  114794. * Initializes the gamepad manager
  114795. * @param _scene BabylonJS scene
  114796. */
  114797. constructor(_scene?: Scene | undefined);
  114798. /**
  114799. * The gamepads in the game pad manager
  114800. */
  114801. get gamepads(): Gamepad[];
  114802. /**
  114803. * Get the gamepad controllers based on type
  114804. * @param type The type of gamepad controller
  114805. * @returns Nullable gamepad
  114806. */
  114807. getGamepadByType(type?: number): Nullable<Gamepad>;
  114808. /**
  114809. * Disposes the gamepad manager
  114810. */
  114811. dispose(): void;
  114812. private _addNewGamepad;
  114813. private _startMonitoringGamepads;
  114814. private _stopMonitoringGamepads;
  114815. /** @hidden */
  114816. _checkGamepadsStatus(): void;
  114817. private _updateGamepadObjects;
  114818. }
  114819. }
  114820. declare module BABYLON {
  114821. interface Scene {
  114822. /** @hidden */
  114823. _gamepadManager: Nullable<GamepadManager>;
  114824. /**
  114825. * Gets the gamepad manager associated with the scene
  114826. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114827. */
  114828. gamepadManager: GamepadManager;
  114829. }
  114830. /**
  114831. * Interface representing a free camera inputs manager
  114832. */
  114833. interface FreeCameraInputsManager {
  114834. /**
  114835. * Adds gamepad input support to the FreeCameraInputsManager.
  114836. * @returns the FreeCameraInputsManager
  114837. */
  114838. addGamepad(): FreeCameraInputsManager;
  114839. }
  114840. /**
  114841. * Interface representing an arc rotate camera inputs manager
  114842. */
  114843. interface ArcRotateCameraInputsManager {
  114844. /**
  114845. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114846. * @returns the camera inputs manager
  114847. */
  114848. addGamepad(): ArcRotateCameraInputsManager;
  114849. }
  114850. /**
  114851. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114852. */
  114853. export class GamepadSystemSceneComponent implements ISceneComponent {
  114854. /**
  114855. * The component name helpfull to identify the component in the list of scene components.
  114856. */
  114857. readonly name: string;
  114858. /**
  114859. * The scene the component belongs to.
  114860. */
  114861. scene: Scene;
  114862. /**
  114863. * Creates a new instance of the component for the given scene
  114864. * @param scene Defines the scene to register the component in
  114865. */
  114866. constructor(scene: Scene);
  114867. /**
  114868. * Registers the component in a given scene
  114869. */
  114870. register(): void;
  114871. /**
  114872. * Rebuilds the elements related to this component in case of
  114873. * context lost for instance.
  114874. */
  114875. rebuild(): void;
  114876. /**
  114877. * Disposes the component and the associated ressources
  114878. */
  114879. dispose(): void;
  114880. private _beforeCameraUpdate;
  114881. }
  114882. }
  114883. declare module BABYLON {
  114884. /**
  114885. * 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,
  114886. * which still works and will still be found in many Playgrounds.
  114887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114888. */
  114889. export class UniversalCamera extends TouchCamera {
  114890. /**
  114891. * Defines the gamepad rotation sensiblity.
  114892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114893. */
  114894. get gamepadAngularSensibility(): number;
  114895. set gamepadAngularSensibility(value: number);
  114896. /**
  114897. * Defines the gamepad move sensiblity.
  114898. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114899. */
  114900. get gamepadMoveSensibility(): number;
  114901. set gamepadMoveSensibility(value: number);
  114902. /**
  114903. * 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,
  114904. * which still works and will still be found in many Playgrounds.
  114905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114906. * @param name Define the name of the camera in the scene
  114907. * @param position Define the start position of the camera in the scene
  114908. * @param scene Define the scene the camera belongs to
  114909. */
  114910. constructor(name: string, position: Vector3, scene: Scene);
  114911. /**
  114912. * Gets the current object class name.
  114913. * @return the class name
  114914. */
  114915. getClassName(): string;
  114916. }
  114917. }
  114918. declare module BABYLON {
  114919. /**
  114920. * This represents a FPS type of camera. This is only here for back compat purpose.
  114921. * Please use the UniversalCamera instead as both are identical.
  114922. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114923. */
  114924. export class GamepadCamera extends UniversalCamera {
  114925. /**
  114926. * Instantiates a new Gamepad Camera
  114927. * This represents a FPS type of camera. This is only here for back compat purpose.
  114928. * Please use the UniversalCamera instead as both are identical.
  114929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114930. * @param name Define the name of the camera in the scene
  114931. * @param position Define the start position of the camera in the scene
  114932. * @param scene Define the scene the camera belongs to
  114933. */
  114934. constructor(name: string, position: Vector3, scene: Scene);
  114935. /**
  114936. * Gets the current object class name.
  114937. * @return the class name
  114938. */
  114939. getClassName(): string;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /** @hidden */
  114944. export var passPixelShader: {
  114945. name: string;
  114946. shader: string;
  114947. };
  114948. }
  114949. declare module BABYLON {
  114950. /** @hidden */
  114951. export var passCubePixelShader: {
  114952. name: string;
  114953. shader: string;
  114954. };
  114955. }
  114956. declare module BABYLON {
  114957. /**
  114958. * PassPostProcess which produces an output the same as it's input
  114959. */
  114960. export class PassPostProcess extends PostProcess {
  114961. /**
  114962. * Creates the PassPostProcess
  114963. * @param name The name of the effect.
  114964. * @param options The required width/height ratio to downsize to before computing the render pass.
  114965. * @param camera The camera to apply the render pass to.
  114966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114967. * @param engine The engine which the post process will be applied. (default: current engine)
  114968. * @param reusable If the post process can be reused on the same frame. (default: false)
  114969. * @param textureType The type of texture to be used when performing the post processing.
  114970. * @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)
  114971. */
  114972. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114973. }
  114974. /**
  114975. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114976. */
  114977. export class PassCubePostProcess extends PostProcess {
  114978. private _face;
  114979. /**
  114980. * Gets or sets the cube face to display.
  114981. * * 0 is +X
  114982. * * 1 is -X
  114983. * * 2 is +Y
  114984. * * 3 is -Y
  114985. * * 4 is +Z
  114986. * * 5 is -Z
  114987. */
  114988. get face(): number;
  114989. set face(value: number);
  114990. /**
  114991. * Creates the PassCubePostProcess
  114992. * @param name The name of the effect.
  114993. * @param options The required width/height ratio to downsize to before computing the render pass.
  114994. * @param camera The camera to apply the render pass to.
  114995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114996. * @param engine The engine which the post process will be applied. (default: current engine)
  114997. * @param reusable If the post process can be reused on the same frame. (default: false)
  114998. * @param textureType The type of texture to be used when performing the post processing.
  114999. * @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)
  115000. */
  115001. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115002. }
  115003. }
  115004. declare module BABYLON {
  115005. /** @hidden */
  115006. export var anaglyphPixelShader: {
  115007. name: string;
  115008. shader: string;
  115009. };
  115010. }
  115011. declare module BABYLON {
  115012. /**
  115013. * Postprocess used to generate anaglyphic rendering
  115014. */
  115015. export class AnaglyphPostProcess extends PostProcess {
  115016. private _passedProcess;
  115017. /**
  115018. * Creates a new AnaglyphPostProcess
  115019. * @param name defines postprocess name
  115020. * @param options defines creation options or target ratio scale
  115021. * @param rigCameras defines cameras using this postprocess
  115022. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115023. * @param engine defines hosting engine
  115024. * @param reusable defines if the postprocess will be reused multiple times per frame
  115025. */
  115026. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115027. }
  115028. }
  115029. declare module BABYLON {
  115030. /**
  115031. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115032. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115033. */
  115034. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115035. /**
  115036. * Creates a new AnaglyphArcRotateCamera
  115037. * @param name defines camera name
  115038. * @param alpha defines alpha angle (in radians)
  115039. * @param beta defines beta angle (in radians)
  115040. * @param radius defines radius
  115041. * @param target defines camera target
  115042. * @param interaxialDistance defines distance between each color axis
  115043. * @param scene defines the hosting scene
  115044. */
  115045. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115046. /**
  115047. * Gets camera class name
  115048. * @returns AnaglyphArcRotateCamera
  115049. */
  115050. getClassName(): string;
  115051. }
  115052. }
  115053. declare module BABYLON {
  115054. /**
  115055. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115056. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115057. */
  115058. export class AnaglyphFreeCamera extends FreeCamera {
  115059. /**
  115060. * Creates a new AnaglyphFreeCamera
  115061. * @param name defines camera name
  115062. * @param position defines initial position
  115063. * @param interaxialDistance defines distance between each color axis
  115064. * @param scene defines the hosting scene
  115065. */
  115066. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115067. /**
  115068. * Gets camera class name
  115069. * @returns AnaglyphFreeCamera
  115070. */
  115071. getClassName(): string;
  115072. }
  115073. }
  115074. declare module BABYLON {
  115075. /**
  115076. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115077. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115078. */
  115079. export class AnaglyphGamepadCamera extends GamepadCamera {
  115080. /**
  115081. * Creates a new AnaglyphGamepadCamera
  115082. * @param name defines camera name
  115083. * @param position defines initial position
  115084. * @param interaxialDistance defines distance between each color axis
  115085. * @param scene defines the hosting scene
  115086. */
  115087. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115088. /**
  115089. * Gets camera class name
  115090. * @returns AnaglyphGamepadCamera
  115091. */
  115092. getClassName(): string;
  115093. }
  115094. }
  115095. declare module BABYLON {
  115096. /**
  115097. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115099. */
  115100. export class AnaglyphUniversalCamera extends UniversalCamera {
  115101. /**
  115102. * Creates a new AnaglyphUniversalCamera
  115103. * @param name defines camera name
  115104. * @param position defines initial position
  115105. * @param interaxialDistance defines distance between each color axis
  115106. * @param scene defines the hosting scene
  115107. */
  115108. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115109. /**
  115110. * Gets camera class name
  115111. * @returns AnaglyphUniversalCamera
  115112. */
  115113. getClassName(): string;
  115114. }
  115115. }
  115116. declare module BABYLON {
  115117. /** @hidden */
  115118. export var stereoscopicInterlacePixelShader: {
  115119. name: string;
  115120. shader: string;
  115121. };
  115122. }
  115123. declare module BABYLON {
  115124. /**
  115125. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115126. */
  115127. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115128. private _stepSize;
  115129. private _passedProcess;
  115130. /**
  115131. * Initializes a StereoscopicInterlacePostProcessI
  115132. * @param name The name of the effect.
  115133. * @param rigCameras The rig cameras to be appled to the post process
  115134. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115135. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115137. * @param engine The engine which the post process will be applied. (default: current engine)
  115138. * @param reusable If the post process can be reused on the same frame. (default: false)
  115139. */
  115140. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115141. }
  115142. /**
  115143. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115144. */
  115145. export class StereoscopicInterlacePostProcess extends PostProcess {
  115146. private _stepSize;
  115147. private _passedProcess;
  115148. /**
  115149. * Initializes a StereoscopicInterlacePostProcess
  115150. * @param name The name of the effect.
  115151. * @param rigCameras The rig cameras to be appled to the post process
  115152. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115154. * @param engine The engine which the post process will be applied. (default: current engine)
  115155. * @param reusable If the post process can be reused on the same frame. (default: false)
  115156. */
  115157. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115158. }
  115159. }
  115160. declare module BABYLON {
  115161. /**
  115162. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115163. * @see http://doc.babylonjs.com/features/cameras
  115164. */
  115165. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115166. /**
  115167. * Creates a new StereoscopicArcRotateCamera
  115168. * @param name defines camera name
  115169. * @param alpha defines alpha angle (in radians)
  115170. * @param beta defines beta angle (in radians)
  115171. * @param radius defines radius
  115172. * @param target defines camera target
  115173. * @param interaxialDistance defines distance between each color axis
  115174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115175. * @param scene defines the hosting scene
  115176. */
  115177. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115178. /**
  115179. * Gets camera class name
  115180. * @returns StereoscopicArcRotateCamera
  115181. */
  115182. getClassName(): string;
  115183. }
  115184. }
  115185. declare module BABYLON {
  115186. /**
  115187. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115188. * @see http://doc.babylonjs.com/features/cameras
  115189. */
  115190. export class StereoscopicFreeCamera extends FreeCamera {
  115191. /**
  115192. * Creates a new StereoscopicFreeCamera
  115193. * @param name defines camera name
  115194. * @param position defines initial position
  115195. * @param interaxialDistance defines distance between each color axis
  115196. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115197. * @param scene defines the hosting scene
  115198. */
  115199. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115200. /**
  115201. * Gets camera class name
  115202. * @returns StereoscopicFreeCamera
  115203. */
  115204. getClassName(): string;
  115205. }
  115206. }
  115207. declare module BABYLON {
  115208. /**
  115209. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115210. * @see http://doc.babylonjs.com/features/cameras
  115211. */
  115212. export class StereoscopicGamepadCamera extends GamepadCamera {
  115213. /**
  115214. * Creates a new StereoscopicGamepadCamera
  115215. * @param name defines camera name
  115216. * @param position defines initial position
  115217. * @param interaxialDistance defines distance between each color axis
  115218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115219. * @param scene defines the hosting scene
  115220. */
  115221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115222. /**
  115223. * Gets camera class name
  115224. * @returns StereoscopicGamepadCamera
  115225. */
  115226. getClassName(): string;
  115227. }
  115228. }
  115229. declare module BABYLON {
  115230. /**
  115231. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115232. * @see http://doc.babylonjs.com/features/cameras
  115233. */
  115234. export class StereoscopicUniversalCamera extends UniversalCamera {
  115235. /**
  115236. * Creates a new StereoscopicUniversalCamera
  115237. * @param name defines camera name
  115238. * @param position defines initial position
  115239. * @param interaxialDistance defines distance between each color axis
  115240. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115241. * @param scene defines the hosting scene
  115242. */
  115243. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115244. /**
  115245. * Gets camera class name
  115246. * @returns StereoscopicUniversalCamera
  115247. */
  115248. getClassName(): string;
  115249. }
  115250. }
  115251. declare module BABYLON {
  115252. /**
  115253. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115254. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115255. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115256. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115257. */
  115258. export class VirtualJoysticksCamera extends FreeCamera {
  115259. /**
  115260. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115261. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115262. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115263. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115264. * @param name Define the name of the camera in the scene
  115265. * @param position Define the start position of the camera in the scene
  115266. * @param scene Define the scene the camera belongs to
  115267. */
  115268. constructor(name: string, position: Vector3, scene: Scene);
  115269. /**
  115270. * Gets the current object class name.
  115271. * @return the class name
  115272. */
  115273. getClassName(): string;
  115274. }
  115275. }
  115276. declare module BABYLON {
  115277. /**
  115278. * This represents all the required metrics to create a VR camera.
  115279. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115280. */
  115281. export class VRCameraMetrics {
  115282. /**
  115283. * Define the horizontal resolution off the screen.
  115284. */
  115285. hResolution: number;
  115286. /**
  115287. * Define the vertical resolution off the screen.
  115288. */
  115289. vResolution: number;
  115290. /**
  115291. * Define the horizontal screen size.
  115292. */
  115293. hScreenSize: number;
  115294. /**
  115295. * Define the vertical screen size.
  115296. */
  115297. vScreenSize: number;
  115298. /**
  115299. * Define the vertical screen center position.
  115300. */
  115301. vScreenCenter: number;
  115302. /**
  115303. * Define the distance of the eyes to the screen.
  115304. */
  115305. eyeToScreenDistance: number;
  115306. /**
  115307. * Define the distance between both lenses
  115308. */
  115309. lensSeparationDistance: number;
  115310. /**
  115311. * Define the distance between both viewer's eyes.
  115312. */
  115313. interpupillaryDistance: number;
  115314. /**
  115315. * Define the distortion factor of the VR postprocess.
  115316. * Please, touch with care.
  115317. */
  115318. distortionK: number[];
  115319. /**
  115320. * Define the chromatic aberration correction factors for the VR post process.
  115321. */
  115322. chromaAbCorrection: number[];
  115323. /**
  115324. * Define the scale factor of the post process.
  115325. * The smaller the better but the slower.
  115326. */
  115327. postProcessScaleFactor: number;
  115328. /**
  115329. * Define an offset for the lens center.
  115330. */
  115331. lensCenterOffset: number;
  115332. /**
  115333. * Define if the current vr camera should compensate the distortion of the lense or not.
  115334. */
  115335. compensateDistortion: boolean;
  115336. /**
  115337. * Defines if multiview should be enabled when rendering (Default: false)
  115338. */
  115339. multiviewEnabled: boolean;
  115340. /**
  115341. * Gets the rendering aspect ratio based on the provided resolutions.
  115342. */
  115343. get aspectRatio(): number;
  115344. /**
  115345. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115346. */
  115347. get aspectRatioFov(): number;
  115348. /**
  115349. * @hidden
  115350. */
  115351. get leftHMatrix(): Matrix;
  115352. /**
  115353. * @hidden
  115354. */
  115355. get rightHMatrix(): Matrix;
  115356. /**
  115357. * @hidden
  115358. */
  115359. get leftPreViewMatrix(): Matrix;
  115360. /**
  115361. * @hidden
  115362. */
  115363. get rightPreViewMatrix(): Matrix;
  115364. /**
  115365. * Get the default VRMetrics based on the most generic setup.
  115366. * @returns the default vr metrics
  115367. */
  115368. static GetDefault(): VRCameraMetrics;
  115369. }
  115370. }
  115371. declare module BABYLON {
  115372. /** @hidden */
  115373. export var vrDistortionCorrectionPixelShader: {
  115374. name: string;
  115375. shader: string;
  115376. };
  115377. }
  115378. declare module BABYLON {
  115379. /**
  115380. * VRDistortionCorrectionPostProcess used for mobile VR
  115381. */
  115382. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115383. private _isRightEye;
  115384. private _distortionFactors;
  115385. private _postProcessScaleFactor;
  115386. private _lensCenterOffset;
  115387. private _scaleIn;
  115388. private _scaleFactor;
  115389. private _lensCenter;
  115390. /**
  115391. * Initializes the VRDistortionCorrectionPostProcess
  115392. * @param name The name of the effect.
  115393. * @param camera The camera to apply the render pass to.
  115394. * @param isRightEye If this is for the right eye distortion
  115395. * @param vrMetrics All the required metrics for the VR camera
  115396. */
  115397. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115398. }
  115399. }
  115400. declare module BABYLON {
  115401. /**
  115402. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115403. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115404. */
  115405. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115406. /**
  115407. * Creates a new VRDeviceOrientationArcRotateCamera
  115408. * @param name defines camera name
  115409. * @param alpha defines the camera rotation along the logitudinal axis
  115410. * @param beta defines the camera rotation along the latitudinal axis
  115411. * @param radius defines the camera distance from its target
  115412. * @param target defines the camera target
  115413. * @param scene defines the scene the camera belongs to
  115414. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115415. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115416. */
  115417. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115418. /**
  115419. * Gets camera class name
  115420. * @returns VRDeviceOrientationArcRotateCamera
  115421. */
  115422. getClassName(): string;
  115423. }
  115424. }
  115425. declare module BABYLON {
  115426. /**
  115427. * Camera used to simulate VR rendering (based on FreeCamera)
  115428. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115429. */
  115430. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115431. /**
  115432. * Creates a new VRDeviceOrientationFreeCamera
  115433. * @param name defines camera name
  115434. * @param position defines the start position of the camera
  115435. * @param scene defines the scene the camera belongs to
  115436. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115437. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115438. */
  115439. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115440. /**
  115441. * Gets camera class name
  115442. * @returns VRDeviceOrientationFreeCamera
  115443. */
  115444. getClassName(): string;
  115445. }
  115446. }
  115447. declare module BABYLON {
  115448. /**
  115449. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115450. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115451. */
  115452. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115453. /**
  115454. * Creates a new VRDeviceOrientationGamepadCamera
  115455. * @param name defines camera name
  115456. * @param position defines the start position of the camera
  115457. * @param scene defines the scene the camera belongs to
  115458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115460. */
  115461. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115462. /**
  115463. * Gets camera class name
  115464. * @returns VRDeviceOrientationGamepadCamera
  115465. */
  115466. getClassName(): string;
  115467. }
  115468. }
  115469. declare module BABYLON {
  115470. /** @hidden */
  115471. export var imageProcessingPixelShader: {
  115472. name: string;
  115473. shader: string;
  115474. };
  115475. }
  115476. declare module BABYLON {
  115477. /**
  115478. * ImageProcessingPostProcess
  115479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115480. */
  115481. export class ImageProcessingPostProcess extends PostProcess {
  115482. /**
  115483. * Default configuration related to image processing available in the PBR Material.
  115484. */
  115485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115486. /**
  115487. * Gets the image processing configuration used either in this material.
  115488. */
  115489. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115490. /**
  115491. * Sets the Default image processing configuration used either in the this material.
  115492. *
  115493. * If sets to null, the scene one is in use.
  115494. */
  115495. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115496. /**
  115497. * Keep track of the image processing observer to allow dispose and replace.
  115498. */
  115499. private _imageProcessingObserver;
  115500. /**
  115501. * Attaches a new image processing configuration to the PBR Material.
  115502. * @param configuration
  115503. */
  115504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115505. /**
  115506. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115507. */
  115508. get colorCurves(): Nullable<ColorCurves>;
  115509. /**
  115510. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115511. */
  115512. set colorCurves(value: Nullable<ColorCurves>);
  115513. /**
  115514. * Gets wether the color curves effect is enabled.
  115515. */
  115516. get colorCurvesEnabled(): boolean;
  115517. /**
  115518. * Sets wether the color curves effect is enabled.
  115519. */
  115520. set colorCurvesEnabled(value: boolean);
  115521. /**
  115522. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115523. */
  115524. get colorGradingTexture(): Nullable<BaseTexture>;
  115525. /**
  115526. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115527. */
  115528. set colorGradingTexture(value: Nullable<BaseTexture>);
  115529. /**
  115530. * Gets wether the color grading effect is enabled.
  115531. */
  115532. get colorGradingEnabled(): boolean;
  115533. /**
  115534. * Gets wether the color grading effect is enabled.
  115535. */
  115536. set colorGradingEnabled(value: boolean);
  115537. /**
  115538. * Gets exposure used in the effect.
  115539. */
  115540. get exposure(): number;
  115541. /**
  115542. * Sets exposure used in the effect.
  115543. */
  115544. set exposure(value: number);
  115545. /**
  115546. * Gets wether tonemapping is enabled or not.
  115547. */
  115548. get toneMappingEnabled(): boolean;
  115549. /**
  115550. * Sets wether tonemapping is enabled or not
  115551. */
  115552. set toneMappingEnabled(value: boolean);
  115553. /**
  115554. * Gets the type of tone mapping effect.
  115555. */
  115556. get toneMappingType(): number;
  115557. /**
  115558. * Sets the type of tone mapping effect.
  115559. */
  115560. set toneMappingType(value: number);
  115561. /**
  115562. * Gets contrast used in the effect.
  115563. */
  115564. get contrast(): number;
  115565. /**
  115566. * Sets contrast used in the effect.
  115567. */
  115568. set contrast(value: number);
  115569. /**
  115570. * Gets Vignette stretch size.
  115571. */
  115572. get vignetteStretch(): number;
  115573. /**
  115574. * Sets Vignette stretch size.
  115575. */
  115576. set vignetteStretch(value: number);
  115577. /**
  115578. * Gets Vignette centre X Offset.
  115579. */
  115580. get vignetteCentreX(): number;
  115581. /**
  115582. * Sets Vignette centre X Offset.
  115583. */
  115584. set vignetteCentreX(value: number);
  115585. /**
  115586. * Gets Vignette centre Y Offset.
  115587. */
  115588. get vignetteCentreY(): number;
  115589. /**
  115590. * Sets Vignette centre Y Offset.
  115591. */
  115592. set vignetteCentreY(value: number);
  115593. /**
  115594. * Gets Vignette weight or intensity of the vignette effect.
  115595. */
  115596. get vignetteWeight(): number;
  115597. /**
  115598. * Sets Vignette weight or intensity of the vignette effect.
  115599. */
  115600. set vignetteWeight(value: number);
  115601. /**
  115602. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115603. * if vignetteEnabled is set to true.
  115604. */
  115605. get vignetteColor(): Color4;
  115606. /**
  115607. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115608. * if vignetteEnabled is set to true.
  115609. */
  115610. set vignetteColor(value: Color4);
  115611. /**
  115612. * Gets Camera field of view used by the Vignette effect.
  115613. */
  115614. get vignetteCameraFov(): number;
  115615. /**
  115616. * Sets Camera field of view used by the Vignette effect.
  115617. */
  115618. set vignetteCameraFov(value: number);
  115619. /**
  115620. * Gets the vignette blend mode allowing different kind of effect.
  115621. */
  115622. get vignetteBlendMode(): number;
  115623. /**
  115624. * Sets the vignette blend mode allowing different kind of effect.
  115625. */
  115626. set vignetteBlendMode(value: number);
  115627. /**
  115628. * Gets wether the vignette effect is enabled.
  115629. */
  115630. get vignetteEnabled(): boolean;
  115631. /**
  115632. * Sets wether the vignette effect is enabled.
  115633. */
  115634. set vignetteEnabled(value: boolean);
  115635. private _fromLinearSpace;
  115636. /**
  115637. * Gets wether the input of the processing is in Gamma or Linear Space.
  115638. */
  115639. get fromLinearSpace(): boolean;
  115640. /**
  115641. * Sets wether the input of the processing is in Gamma or Linear Space.
  115642. */
  115643. set fromLinearSpace(value: boolean);
  115644. /**
  115645. * Defines cache preventing GC.
  115646. */
  115647. private _defines;
  115648. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115649. /**
  115650. * "ImageProcessingPostProcess"
  115651. * @returns "ImageProcessingPostProcess"
  115652. */
  115653. getClassName(): string;
  115654. protected _updateParameters(): void;
  115655. dispose(camera?: Camera): void;
  115656. }
  115657. }
  115658. declare module BABYLON {
  115659. /**
  115660. * Class containing static functions to help procedurally build meshes
  115661. */
  115662. export class GroundBuilder {
  115663. /**
  115664. * Creates a ground mesh
  115665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115668. * @param name defines the name of the mesh
  115669. * @param options defines the options used to create the mesh
  115670. * @param scene defines the hosting scene
  115671. * @returns the ground mesh
  115672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115673. */
  115674. static CreateGround(name: string, options: {
  115675. width?: number;
  115676. height?: number;
  115677. subdivisions?: number;
  115678. subdivisionsX?: number;
  115679. subdivisionsY?: number;
  115680. updatable?: boolean;
  115681. }, scene: any): Mesh;
  115682. /**
  115683. * Creates a tiled ground mesh
  115684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115686. * * 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
  115687. * * 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
  115688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115689. * @param name defines the name of the mesh
  115690. * @param options defines the options used to create the mesh
  115691. * @param scene defines the hosting scene
  115692. * @returns the tiled ground mesh
  115693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115694. */
  115695. static CreateTiledGround(name: string, options: {
  115696. xmin: number;
  115697. zmin: number;
  115698. xmax: number;
  115699. zmax: number;
  115700. subdivisions?: {
  115701. w: number;
  115702. h: number;
  115703. };
  115704. precision?: {
  115705. w: number;
  115706. h: number;
  115707. };
  115708. updatable?: boolean;
  115709. }, scene?: Nullable<Scene>): Mesh;
  115710. /**
  115711. * Creates a ground mesh from a height map
  115712. * * The parameter `url` sets the URL of the height map image resource.
  115713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115717. * * 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.
  115718. * * 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).
  115719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115721. * @param name defines the name of the mesh
  115722. * @param url defines the url to the height map
  115723. * @param options defines the options used to create the mesh
  115724. * @param scene defines the hosting scene
  115725. * @returns the ground mesh
  115726. * @see https://doc.babylonjs.com/babylon101/height_map
  115727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115728. */
  115729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115730. width?: number;
  115731. height?: number;
  115732. subdivisions?: number;
  115733. minHeight?: number;
  115734. maxHeight?: number;
  115735. colorFilter?: Color3;
  115736. alphaFilter?: number;
  115737. updatable?: boolean;
  115738. onReady?: (mesh: GroundMesh) => void;
  115739. }, scene?: Nullable<Scene>): GroundMesh;
  115740. }
  115741. }
  115742. declare module BABYLON {
  115743. /**
  115744. * Class containing static functions to help procedurally build meshes
  115745. */
  115746. export class TorusBuilder {
  115747. /**
  115748. * Creates a torus mesh
  115749. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115750. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115751. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115755. * @param name defines the name of the mesh
  115756. * @param options defines the options used to create the mesh
  115757. * @param scene defines the hosting scene
  115758. * @returns the torus mesh
  115759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115760. */
  115761. static CreateTorus(name: string, options: {
  115762. diameter?: number;
  115763. thickness?: number;
  115764. tessellation?: number;
  115765. updatable?: boolean;
  115766. sideOrientation?: number;
  115767. frontUVs?: Vector4;
  115768. backUVs?: Vector4;
  115769. }, scene: any): Mesh;
  115770. }
  115771. }
  115772. declare module BABYLON {
  115773. /**
  115774. * Class containing static functions to help procedurally build meshes
  115775. */
  115776. export class CylinderBuilder {
  115777. /**
  115778. * Creates a cylinder or a cone mesh
  115779. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115780. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115781. * * 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.
  115782. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115783. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115784. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115785. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115786. * * 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).
  115787. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115788. * * 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).
  115789. * * 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
  115790. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115791. * * 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
  115792. * * 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.
  115793. * * If `enclose` is false, a ring surface is one element.
  115794. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115795. * * 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
  115796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115799. * @param name defines the name of the mesh
  115800. * @param options defines the options used to create the mesh
  115801. * @param scene defines the hosting scene
  115802. * @returns the cylinder mesh
  115803. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115804. */
  115805. static CreateCylinder(name: string, options: {
  115806. height?: number;
  115807. diameterTop?: number;
  115808. diameterBottom?: number;
  115809. diameter?: number;
  115810. tessellation?: number;
  115811. subdivisions?: number;
  115812. arc?: number;
  115813. faceColors?: Color4[];
  115814. faceUV?: Vector4[];
  115815. updatable?: boolean;
  115816. hasRings?: boolean;
  115817. enclose?: boolean;
  115818. cap?: number;
  115819. sideOrientation?: number;
  115820. frontUVs?: Vector4;
  115821. backUVs?: Vector4;
  115822. }, scene: any): Mesh;
  115823. }
  115824. }
  115825. declare module BABYLON {
  115826. /**
  115827. * States of the webXR experience
  115828. */
  115829. export enum WebXRState {
  115830. /**
  115831. * Transitioning to being in XR mode
  115832. */
  115833. ENTERING_XR = 0,
  115834. /**
  115835. * Transitioning to non XR mode
  115836. */
  115837. EXITING_XR = 1,
  115838. /**
  115839. * In XR mode and presenting
  115840. */
  115841. IN_XR = 2,
  115842. /**
  115843. * Not entered XR mode
  115844. */
  115845. NOT_IN_XR = 3
  115846. }
  115847. /**
  115848. * Abstraction of the XR render target
  115849. */
  115850. export interface WebXRRenderTarget extends IDisposable {
  115851. /**
  115852. * xrpresent context of the canvas which can be used to display/mirror xr content
  115853. */
  115854. canvasContext: WebGLRenderingContext;
  115855. /**
  115856. * xr layer for the canvas
  115857. */
  115858. xrLayer: Nullable<XRWebGLLayer>;
  115859. /**
  115860. * Initializes the xr layer for the session
  115861. * @param xrSession xr session
  115862. * @returns a promise that will resolve once the XR Layer has been created
  115863. */
  115864. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115865. }
  115866. }
  115867. declare module BABYLON {
  115868. /**
  115869. * COnfiguration object for WebXR output canvas
  115870. */
  115871. export class WebXRManagedOutputCanvasOptions {
  115872. /**
  115873. * Options for this XR Layer output
  115874. */
  115875. canvasOptions?: XRWebGLLayerOptions;
  115876. /**
  115877. * CSS styling for a newly created canvas (if not provided)
  115878. */
  115879. newCanvasCssStyle?: string;
  115880. /**
  115881. * An optional canvas in case you wish to create it yourself and provide it here.
  115882. * If not provided, a new canvas will be created
  115883. */
  115884. canvasElement?: HTMLCanvasElement;
  115885. /**
  115886. * Get the default values of the configuration object
  115887. * @returns default values of this configuration object
  115888. */
  115889. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115890. }
  115891. /**
  115892. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115893. */
  115894. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115895. private _options;
  115896. private _engine;
  115897. private _canvas;
  115898. /**
  115899. * Rendering context of the canvas which can be used to display/mirror xr content
  115900. */
  115901. canvasContext: WebGLRenderingContext;
  115902. /**
  115903. * xr layer for the canvas
  115904. */
  115905. xrLayer: Nullable<XRWebGLLayer>;
  115906. /**
  115907. * Initializes the xr layer for the session
  115908. * @param xrSession xr session
  115909. * @returns a promise that will resolve once the XR Layer has been created
  115910. */
  115911. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115912. /**
  115913. * Initializes the canvas to be added/removed upon entering/exiting xr
  115914. * @param _xrSessionManager The XR Session manager
  115915. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115916. */
  115917. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115918. /**
  115919. * Disposes of the object
  115920. */
  115921. dispose(): void;
  115922. private _setManagedOutputCanvas;
  115923. private _addCanvas;
  115924. private _removeCanvas;
  115925. }
  115926. }
  115927. declare module BABYLON {
  115928. /**
  115929. * Manages an XRSession to work with Babylon's engine
  115930. * @see https://doc.babylonjs.com/how_to/webxr
  115931. */
  115932. export class WebXRSessionManager implements IDisposable {
  115933. /** The scene which the session should be created for */
  115934. scene: Scene;
  115935. /**
  115936. * Fires every time a new xrFrame arrives which can be used to update the camera
  115937. */
  115938. onXRFrameObservable: Observable<XRFrame>;
  115939. /**
  115940. * Fires when the xr session is ended either by the device or manually done
  115941. */
  115942. onXRSessionEnded: Observable<any>;
  115943. /**
  115944. * Fires when the xr session is ended either by the device or manually done
  115945. */
  115946. onXRSessionInit: Observable<XRSession>;
  115947. /**
  115948. * Fires when the reference space changed
  115949. */
  115950. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115951. /**
  115952. * Underlying xr session
  115953. */
  115954. session: XRSession;
  115955. /**
  115956. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115957. * or get the offset the player is currently at.
  115958. */
  115959. viewerReferenceSpace: XRReferenceSpace;
  115960. private _referenceSpace;
  115961. /**
  115962. * The current reference space used in this session. This reference space can constantly change!
  115963. * It is mainly used to offset the camera's position.
  115964. */
  115965. get referenceSpace(): XRReferenceSpace;
  115966. /**
  115967. * Set a new reference space and triggers the observable
  115968. */
  115969. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115970. /**
  115971. * The base reference space from which the session started. good if you want to reset your
  115972. * reference space
  115973. */
  115974. baseReferenceSpace: XRReferenceSpace;
  115975. /**
  115976. * Used just in case of a failure to initialize an immersive session.
  115977. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115978. */
  115979. defaultHeightCompensation: number;
  115980. /**
  115981. * Current XR frame
  115982. */
  115983. currentFrame: Nullable<XRFrame>;
  115984. /** WebXR timestamp updated every frame */
  115985. currentTimestamp: number;
  115986. private _xrNavigator;
  115987. private baseLayer;
  115988. private _rttProvider;
  115989. private _sessionEnded;
  115990. /**
  115991. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115992. * @param scene The scene which the session should be created for
  115993. */
  115994. constructor(
  115995. /** The scene which the session should be created for */
  115996. scene: Scene);
  115997. /**
  115998. * Initializes the manager
  115999. * After initialization enterXR can be called to start an XR session
  116000. * @returns Promise which resolves after it is initialized
  116001. */
  116002. initializeAsync(): Promise<void>;
  116003. /**
  116004. * Initializes an xr session
  116005. * @param xrSessionMode mode to initialize
  116006. * @param xrSessionInit defines optional and required values to pass to the session builder
  116007. * @returns a promise which will resolve once the session has been initialized
  116008. */
  116009. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116010. /**
  116011. * Sets the reference space on the xr session
  116012. * @param referenceSpaceType space to set
  116013. * @returns a promise that will resolve once the reference space has been set
  116014. */
  116015. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116016. /**
  116017. * Resets the reference space to the one started the session
  116018. */
  116019. resetReferenceSpace(): void;
  116020. /**
  116021. * Updates the render state of the session
  116022. * @param state state to set
  116023. * @returns a promise that resolves once the render state has been updated
  116024. */
  116025. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116026. /**
  116027. * Starts rendering to the xr layer
  116028. */
  116029. runXRRenderLoop(): void;
  116030. /**
  116031. * Gets the correct render target texture to be rendered this frame for this eye
  116032. * @param eye the eye for which to get the render target
  116033. * @returns the render target for the specified eye
  116034. */
  116035. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116036. /**
  116037. * Stops the xrSession and restores the renderloop
  116038. * @returns Promise which resolves after it exits XR
  116039. */
  116040. exitXRAsync(): Promise<void>;
  116041. /**
  116042. * Checks if a session would be supported for the creation options specified
  116043. * @param sessionMode session mode to check if supported eg. immersive-vr
  116044. * @returns A Promise that resolves to true if supported and false if not
  116045. */
  116046. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116047. /**
  116048. * Creates a WebXRRenderTarget object for the XR session
  116049. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116050. * @param options optional options to provide when creating a new render target
  116051. * @returns a WebXR render target to which the session can render
  116052. */
  116053. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116054. /**
  116055. * @hidden
  116056. * Converts the render layer of xrSession to a render target
  116057. * @param session session to create render target for
  116058. * @param scene scene the new render target should be created for
  116059. * @param baseLayer the webgl layer to create the render target for
  116060. */
  116061. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  116062. /**
  116063. * Disposes of the session manager
  116064. */
  116065. dispose(): void;
  116066. /**
  116067. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116068. * @param sessionMode defines the session to test
  116069. * @returns a promise with boolean as final value
  116070. */
  116071. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116072. }
  116073. }
  116074. declare module BABYLON {
  116075. /**
  116076. * WebXR Camera which holds the views for the xrSession
  116077. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116078. */
  116079. export class WebXRCamera extends FreeCamera {
  116080. private _xrSessionManager;
  116081. private _firstFrame;
  116082. private _referenceQuaternion;
  116083. private _referencedPosition;
  116084. private _xrInvPositionCache;
  116085. private _xrInvQuaternionCache;
  116086. /**
  116087. * Should position compensation execute on first frame.
  116088. * This is used when copying the position from a native (non XR) camera
  116089. */
  116090. compensateOnFirstFrame: boolean;
  116091. /**
  116092. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116093. * @param name the name of the camera
  116094. * @param scene the scene to add the camera to
  116095. * @param _xrSessionManager a constructed xr session manager
  116096. */
  116097. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116098. /**
  116099. * Return the user's height, unrelated to the current ground.
  116100. * This will be the y position of this camera, when ground level is 0.
  116101. */
  116102. get realWorldHeight(): number;
  116103. /** @hidden */
  116104. _updateForDualEyeDebugging(): void;
  116105. /**
  116106. * Sets this camera's transformation based on a non-vr camera
  116107. * @param otherCamera the non-vr camera to copy the transformation from
  116108. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116109. */
  116110. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116111. private _updateFromXRSession;
  116112. private _updateNumberOfRigCameras;
  116113. private _updateReferenceSpace;
  116114. private _updateReferenceSpaceOffset;
  116115. }
  116116. }
  116117. declare module BABYLON {
  116118. /**
  116119. * Defining the interface required for a (webxr) feature
  116120. */
  116121. export interface IWebXRFeature extends IDisposable {
  116122. /**
  116123. * Is this feature attached
  116124. */
  116125. attached: boolean;
  116126. /**
  116127. * Should auto-attach be disabled?
  116128. */
  116129. disableAutoAttach: boolean;
  116130. /**
  116131. * Attach the feature to the session
  116132. * Will usually be called by the features manager
  116133. *
  116134. * @param force should attachment be forced (even when already attached)
  116135. * @returns true if successful.
  116136. */
  116137. attach(force?: boolean): boolean;
  116138. /**
  116139. * Detach the feature from the session
  116140. * Will usually be called by the features manager
  116141. *
  116142. * @returns true if successful.
  116143. */
  116144. detach(): boolean;
  116145. }
  116146. /**
  116147. * A list of the currently available features without referencing them
  116148. */
  116149. export class WebXRFeatureName {
  116150. /**
  116151. * The name of the hit test feature
  116152. */
  116153. static HIT_TEST: string;
  116154. /**
  116155. * The name of the anchor system feature
  116156. */
  116157. static ANCHOR_SYSTEM: string;
  116158. /**
  116159. * The name of the background remover feature
  116160. */
  116161. static BACKGROUND_REMOVER: string;
  116162. /**
  116163. * The name of the pointer selection feature
  116164. */
  116165. static POINTER_SELECTION: string;
  116166. /**
  116167. * The name of the teleportation feature
  116168. */
  116169. static TELEPORTATION: string;
  116170. /**
  116171. * The name of the plane detection feature
  116172. */
  116173. static PLANE_DETECTION: string;
  116174. /**
  116175. * physics impostors for xr controllers feature
  116176. */
  116177. static PHYSICS_CONTROLLERS: string;
  116178. }
  116179. /**
  116180. * Defining the constructor of a feature. Used to register the modules.
  116181. */
  116182. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116183. /**
  116184. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116185. * It is mainly used in AR sessions.
  116186. *
  116187. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116188. */
  116189. export class WebXRFeaturesManager implements IDisposable {
  116190. private _xrSessionManager;
  116191. private static readonly _AvailableFeatures;
  116192. /**
  116193. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116194. * Mainly used internally.
  116195. *
  116196. * @param featureName the name of the feature to register
  116197. * @param constructorFunction the function used to construct the module
  116198. * @param version the (babylon) version of the module
  116199. * @param stable is that a stable version of this module
  116200. */
  116201. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116202. /**
  116203. * Returns a constructor of a specific feature.
  116204. *
  116205. * @param featureName the name of the feature to construct
  116206. * @param version the version of the feature to load
  116207. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116208. * @param options optional options provided to the module.
  116209. * @returns a function that, when called, will return a new instance of this feature
  116210. */
  116211. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116212. /**
  116213. * Return the latest unstable version of this feature
  116214. * @param featureName the name of the feature to search
  116215. * @returns the version number. if not found will return -1
  116216. */
  116217. static GetLatestVersionOfFeature(featureName: string): number;
  116218. /**
  116219. * Return the latest stable version of this feature
  116220. * @param featureName the name of the feature to search
  116221. * @returns the version number. if not found will return -1
  116222. */
  116223. static GetStableVersionOfFeature(featureName: string): number;
  116224. /**
  116225. * Can be used to return the list of features currently registered
  116226. *
  116227. * @returns an Array of available features
  116228. */
  116229. static GetAvailableFeatures(): string[];
  116230. /**
  116231. * Gets the versions available for a specific feature
  116232. * @param featureName the name of the feature
  116233. * @returns an array with the available versions
  116234. */
  116235. static GetAvailableVersions(featureName: string): string[];
  116236. private _features;
  116237. /**
  116238. * constructs a new features manages.
  116239. *
  116240. * @param _xrSessionManager an instance of WebXRSessionManager
  116241. */
  116242. constructor(_xrSessionManager: WebXRSessionManager);
  116243. /**
  116244. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  116245. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  116246. *
  116247. * @param featureName the name of the feature to load or the class of the feature
  116248. * @param version optional version to load. if not provided the latest version will be enabled
  116249. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116250. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116251. * @returns a new constructed feature or throws an error if feature not found.
  116252. */
  116253. enableFeature(featureName: string | {
  116254. Name: string;
  116255. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116256. /**
  116257. * Used to disable an already-enabled feature
  116258. * The feature will be disposed and will be recreated once enabled.
  116259. * @param featureName the feature to disable
  116260. * @returns true if disable was successful
  116261. */
  116262. disableFeature(featureName: string | {
  116263. Name: string;
  116264. }): boolean;
  116265. /**
  116266. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116267. * Can be used during a session to start a feature
  116268. * @param featureName the name of feature to attach
  116269. */
  116270. attachFeature(featureName: string): void;
  116271. /**
  116272. * Can be used inside a session or when the session ends to detach a specific feature
  116273. * @param featureName the name of the feature to detach
  116274. */
  116275. detachFeature(featureName: string): void;
  116276. /**
  116277. * Get the list of enabled features
  116278. * @returns an array of enabled features
  116279. */
  116280. getEnabledFeatures(): string[];
  116281. /**
  116282. * get the implementation of an enabled feature.
  116283. * @param featureName the name of the feature to load
  116284. * @returns the feature class, if found
  116285. */
  116286. getEnabledFeature(featureName: string): IWebXRFeature;
  116287. /**
  116288. * dispose this features manager
  116289. */
  116290. dispose(): void;
  116291. }
  116292. }
  116293. declare module BABYLON {
  116294. /**
  116295. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116296. * @see https://doc.babylonjs.com/how_to/webxr
  116297. */
  116298. export class WebXRExperienceHelper implements IDisposable {
  116299. private scene;
  116300. /**
  116301. * Camera used to render xr content
  116302. */
  116303. camera: WebXRCamera;
  116304. /**
  116305. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116306. */
  116307. state: WebXRState;
  116308. private _setState;
  116309. /**
  116310. * Fires when the state of the experience helper has changed
  116311. */
  116312. onStateChangedObservable: Observable<WebXRState>;
  116313. /**
  116314. * Observers registered here will be triggered after the camera's initial transformation is set
  116315. * This can be used to set a different ground level or an extra rotation.
  116316. *
  116317. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116318. * to the position set after this observable is done executing.
  116319. */
  116320. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116321. /** Session manager used to keep track of xr session */
  116322. sessionManager: WebXRSessionManager;
  116323. /** A features manager for this xr session */
  116324. featuresManager: WebXRFeaturesManager;
  116325. private _nonVRCamera;
  116326. private _originalSceneAutoClear;
  116327. private _supported;
  116328. /**
  116329. * Creates the experience helper
  116330. * @param scene the scene to attach the experience helper to
  116331. * @returns a promise for the experience helper
  116332. */
  116333. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116334. /**
  116335. * Creates a WebXRExperienceHelper
  116336. * @param scene The scene the helper should be created in
  116337. */
  116338. private constructor();
  116339. /**
  116340. * Exits XR mode and returns the scene to its original state
  116341. * @returns promise that resolves after xr mode has exited
  116342. */
  116343. exitXRAsync(): Promise<void>;
  116344. /**
  116345. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116346. * @param sessionMode options for the XR session
  116347. * @param referenceSpaceType frame of reference of the XR session
  116348. * @param renderTarget the output canvas that will be used to enter XR mode
  116349. * @returns promise that resolves after xr mode has entered
  116350. */
  116351. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116352. /**
  116353. * Disposes of the experience helper
  116354. */
  116355. dispose(): void;
  116356. private _nonXRToXRCamera;
  116357. }
  116358. }
  116359. declare module BABYLON {
  116360. /**
  116361. * X-Y values for axes in WebXR
  116362. */
  116363. export interface IWebXRMotionControllerAxesValue {
  116364. /**
  116365. * The value of the x axis
  116366. */
  116367. x: number;
  116368. /**
  116369. * The value of the y-axis
  116370. */
  116371. y: number;
  116372. }
  116373. /**
  116374. * changed / previous values for the values of this component
  116375. */
  116376. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116377. /**
  116378. * current (this frame) value
  116379. */
  116380. current: T;
  116381. /**
  116382. * previous (last change) value
  116383. */
  116384. previous: T;
  116385. }
  116386. /**
  116387. * Represents changes in the component between current frame and last values recorded
  116388. */
  116389. export interface IWebXRMotionControllerComponentChanges {
  116390. /**
  116391. * will be populated with previous and current values if touched changed
  116392. */
  116393. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116394. /**
  116395. * will be populated with previous and current values if pressed changed
  116396. */
  116397. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116398. /**
  116399. * will be populated with previous and current values if value changed
  116400. */
  116401. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116402. /**
  116403. * will be populated with previous and current values if axes changed
  116404. */
  116405. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116406. }
  116407. /**
  116408. * This class represents a single component (for example button or thumbstick) of a motion controller
  116409. */
  116410. export class WebXRControllerComponent implements IDisposable {
  116411. /**
  116412. * the id of this component
  116413. */
  116414. id: string;
  116415. /**
  116416. * the type of the component
  116417. */
  116418. type: MotionControllerComponentType;
  116419. private _buttonIndex;
  116420. private _axesIndices;
  116421. /**
  116422. * Thumbstick component type
  116423. */
  116424. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116425. /**
  116426. * Touchpad component type
  116427. */
  116428. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116429. /**
  116430. * trigger component type
  116431. */
  116432. static TRIGGER_TYPE: MotionControllerComponentType;
  116433. /**
  116434. * squeeze component type
  116435. */
  116436. static SQUEEZE_TYPE: MotionControllerComponentType;
  116437. /**
  116438. * button component type
  116439. */
  116440. static BUTTON_TYPE: MotionControllerComponentType;
  116441. /**
  116442. * Observers registered here will be triggered when the state of a button changes
  116443. * State change is either pressed / touched / value
  116444. */
  116445. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116446. /**
  116447. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116448. * the axes data changes
  116449. */
  116450. onAxisValueChangedObservable: Observable<{
  116451. x: number;
  116452. y: number;
  116453. }>;
  116454. private _currentValue;
  116455. private _touched;
  116456. private _pressed;
  116457. private _axes;
  116458. private _changes;
  116459. private _hasChanges;
  116460. /**
  116461. * Return whether or not the component changed the last frame
  116462. */
  116463. get hasChanges(): boolean;
  116464. /**
  116465. * Creates a new component for a motion controller.
  116466. * It is created by the motion controller itself
  116467. *
  116468. * @param id the id of this component
  116469. * @param type the type of the component
  116470. * @param _buttonIndex index in the buttons array of the gamepad
  116471. * @param _axesIndices indices of the values in the axes array of the gamepad
  116472. */
  116473. constructor(
  116474. /**
  116475. * the id of this component
  116476. */
  116477. id: string,
  116478. /**
  116479. * the type of the component
  116480. */
  116481. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116482. /**
  116483. * Get the current value of this component
  116484. */
  116485. get value(): number;
  116486. /**
  116487. * is the button currently pressed
  116488. */
  116489. get pressed(): boolean;
  116490. /**
  116491. * is the button currently touched
  116492. */
  116493. get touched(): boolean;
  116494. /**
  116495. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116496. */
  116497. get axes(): IWebXRMotionControllerAxesValue;
  116498. /**
  116499. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116500. */
  116501. get changes(): IWebXRMotionControllerComponentChanges;
  116502. /**
  116503. * Is this component a button (hence - pressable)
  116504. * @returns true if can be pressed
  116505. */
  116506. isButton(): boolean;
  116507. /**
  116508. * Are there axes correlating to this component
  116509. * @return true is axes data is available
  116510. */
  116511. isAxes(): boolean;
  116512. /**
  116513. * update this component using the gamepad object it is in. Called on every frame
  116514. * @param nativeController the native gamepad controller object
  116515. */
  116516. update(nativeController: IMinimalMotionControllerObject): void;
  116517. /**
  116518. * Dispose this component
  116519. */
  116520. dispose(): void;
  116521. }
  116522. }
  116523. declare module BABYLON {
  116524. /**
  116525. * Class used to represent data loading progression
  116526. */
  116527. export class SceneLoaderProgressEvent {
  116528. /** defines if data length to load can be evaluated */
  116529. readonly lengthComputable: boolean;
  116530. /** defines the loaded data length */
  116531. readonly loaded: number;
  116532. /** defines the data length to load */
  116533. readonly total: number;
  116534. /**
  116535. * Create a new progress event
  116536. * @param lengthComputable defines if data length to load can be evaluated
  116537. * @param loaded defines the loaded data length
  116538. * @param total defines the data length to load
  116539. */
  116540. constructor(
  116541. /** defines if data length to load can be evaluated */
  116542. lengthComputable: boolean,
  116543. /** defines the loaded data length */
  116544. loaded: number,
  116545. /** defines the data length to load */
  116546. total: number);
  116547. /**
  116548. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116549. * @param event defines the source event
  116550. * @returns a new SceneLoaderProgressEvent
  116551. */
  116552. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116553. }
  116554. /**
  116555. * Interface used by SceneLoader plugins to define supported file extensions
  116556. */
  116557. export interface ISceneLoaderPluginExtensions {
  116558. /**
  116559. * Defines the list of supported extensions
  116560. */
  116561. [extension: string]: {
  116562. isBinary: boolean;
  116563. };
  116564. }
  116565. /**
  116566. * Interface used by SceneLoader plugin factory
  116567. */
  116568. export interface ISceneLoaderPluginFactory {
  116569. /**
  116570. * Defines the name of the factory
  116571. */
  116572. name: string;
  116573. /**
  116574. * Function called to create a new plugin
  116575. * @return the new plugin
  116576. */
  116577. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116578. /**
  116579. * The callback that returns true if the data can be directly loaded.
  116580. * @param data string containing the file data
  116581. * @returns if the data can be loaded directly
  116582. */
  116583. canDirectLoad?(data: string): boolean;
  116584. }
  116585. /**
  116586. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116587. */
  116588. export interface ISceneLoaderPluginBase {
  116589. /**
  116590. * The friendly name of this plugin.
  116591. */
  116592. name: string;
  116593. /**
  116594. * The file extensions supported by this plugin.
  116595. */
  116596. extensions: string | ISceneLoaderPluginExtensions;
  116597. /**
  116598. * The callback called when loading from a url.
  116599. * @param scene scene loading this url
  116600. * @param url url to load
  116601. * @param onSuccess callback called when the file successfully loads
  116602. * @param onProgress callback called while file is loading (if the server supports this mode)
  116603. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116604. * @param onError callback called when the file fails to load
  116605. * @returns a file request object
  116606. */
  116607. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116608. /**
  116609. * The callback called when loading from a file object.
  116610. * @param scene scene loading this file
  116611. * @param file defines the file to load
  116612. * @param onSuccess defines the callback to call when data is loaded
  116613. * @param onProgress defines the callback to call during loading process
  116614. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116615. * @param onError defines the callback to call when an error occurs
  116616. * @returns a file request object
  116617. */
  116618. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116619. /**
  116620. * The callback that returns true if the data can be directly loaded.
  116621. * @param data string containing the file data
  116622. * @returns if the data can be loaded directly
  116623. */
  116624. canDirectLoad?(data: string): boolean;
  116625. /**
  116626. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116627. * @param scene scene loading this data
  116628. * @param data string containing the data
  116629. * @returns data to pass to the plugin
  116630. */
  116631. directLoad?(scene: Scene, data: string): any;
  116632. /**
  116633. * The callback that allows custom handling of the root url based on the response url.
  116634. * @param rootUrl the original root url
  116635. * @param responseURL the response url if available
  116636. * @returns the new root url
  116637. */
  116638. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116639. }
  116640. /**
  116641. * Interface used to define a SceneLoader plugin
  116642. */
  116643. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116644. /**
  116645. * Import meshes into a scene.
  116646. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116647. * @param scene The scene to import into
  116648. * @param data The data to import
  116649. * @param rootUrl The root url for scene and resources
  116650. * @param meshes The meshes array to import into
  116651. * @param particleSystems The particle systems array to import into
  116652. * @param skeletons The skeletons array to import into
  116653. * @param onError The callback when import fails
  116654. * @returns True if successful or false otherwise
  116655. */
  116656. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116657. /**
  116658. * Load into a scene.
  116659. * @param scene The scene to load into
  116660. * @param data The data to import
  116661. * @param rootUrl The root url for scene and resources
  116662. * @param onError The callback when import fails
  116663. * @returns True if successful or false otherwise
  116664. */
  116665. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116666. /**
  116667. * Load into an asset container.
  116668. * @param scene The scene to load into
  116669. * @param data The data to import
  116670. * @param rootUrl The root url for scene and resources
  116671. * @param onError The callback when import fails
  116672. * @returns The loaded asset container
  116673. */
  116674. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116675. }
  116676. /**
  116677. * Interface used to define an async SceneLoader plugin
  116678. */
  116679. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116680. /**
  116681. * Import meshes into a scene.
  116682. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116683. * @param scene The scene to import into
  116684. * @param data The data to import
  116685. * @param rootUrl The root url for scene and resources
  116686. * @param onProgress The callback when the load progresses
  116687. * @param fileName Defines the name of the file to load
  116688. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116689. */
  116690. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116691. meshes: AbstractMesh[];
  116692. particleSystems: IParticleSystem[];
  116693. skeletons: Skeleton[];
  116694. animationGroups: AnimationGroup[];
  116695. }>;
  116696. /**
  116697. * Load into a scene.
  116698. * @param scene The scene to load into
  116699. * @param data The data to import
  116700. * @param rootUrl The root url for scene and resources
  116701. * @param onProgress The callback when the load progresses
  116702. * @param fileName Defines the name of the file to load
  116703. * @returns Nothing
  116704. */
  116705. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116706. /**
  116707. * Load into an asset container.
  116708. * @param scene The scene to load into
  116709. * @param data The data to import
  116710. * @param rootUrl The root url for scene and resources
  116711. * @param onProgress The callback when the load progresses
  116712. * @param fileName Defines the name of the file to load
  116713. * @returns The loaded asset container
  116714. */
  116715. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116716. }
  116717. /**
  116718. * Mode that determines how to handle old animation groups before loading new ones.
  116719. */
  116720. export enum SceneLoaderAnimationGroupLoadingMode {
  116721. /**
  116722. * Reset all old animations to initial state then dispose them.
  116723. */
  116724. Clean = 0,
  116725. /**
  116726. * Stop all old animations.
  116727. */
  116728. Stop = 1,
  116729. /**
  116730. * Restart old animations from first frame.
  116731. */
  116732. Sync = 2,
  116733. /**
  116734. * Old animations remains untouched.
  116735. */
  116736. NoSync = 3
  116737. }
  116738. /**
  116739. * Class used to load scene from various file formats using registered plugins
  116740. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116741. */
  116742. export class SceneLoader {
  116743. /**
  116744. * No logging while loading
  116745. */
  116746. static readonly NO_LOGGING: number;
  116747. /**
  116748. * Minimal logging while loading
  116749. */
  116750. static readonly MINIMAL_LOGGING: number;
  116751. /**
  116752. * Summary logging while loading
  116753. */
  116754. static readonly SUMMARY_LOGGING: number;
  116755. /**
  116756. * Detailled logging while loading
  116757. */
  116758. static readonly DETAILED_LOGGING: number;
  116759. /**
  116760. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116761. */
  116762. static get ForceFullSceneLoadingForIncremental(): boolean;
  116763. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116764. /**
  116765. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116766. */
  116767. static get ShowLoadingScreen(): boolean;
  116768. static set ShowLoadingScreen(value: boolean);
  116769. /**
  116770. * Defines the current logging level (while loading the scene)
  116771. * @ignorenaming
  116772. */
  116773. static get loggingLevel(): number;
  116774. static set loggingLevel(value: number);
  116775. /**
  116776. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116777. */
  116778. static get CleanBoneMatrixWeights(): boolean;
  116779. static set CleanBoneMatrixWeights(value: boolean);
  116780. /**
  116781. * Event raised when a plugin is used to load a scene
  116782. */
  116783. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116784. private static _registeredPlugins;
  116785. private static _getDefaultPlugin;
  116786. private static _getPluginForExtension;
  116787. private static _getPluginForDirectLoad;
  116788. private static _getPluginForFilename;
  116789. private static _getDirectLoad;
  116790. private static _loadData;
  116791. private static _getFileInfo;
  116792. /**
  116793. * Gets a plugin that can load the given extension
  116794. * @param extension defines the extension to load
  116795. * @returns a plugin or null if none works
  116796. */
  116797. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116798. /**
  116799. * Gets a boolean indicating that the given extension can be loaded
  116800. * @param extension defines the extension to load
  116801. * @returns true if the extension is supported
  116802. */
  116803. static IsPluginForExtensionAvailable(extension: string): boolean;
  116804. /**
  116805. * Adds a new plugin to the list of registered plugins
  116806. * @param plugin defines the plugin to add
  116807. */
  116808. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116809. /**
  116810. * Import meshes into a scene
  116811. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116812. * @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)
  116813. * @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)
  116814. * @param scene the instance of BABYLON.Scene to append to
  116815. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116816. * @param onProgress a callback with a progress event for each file being loaded
  116817. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116818. * @param pluginExtension the extension used to determine the plugin
  116819. * @returns The loaded plugin
  116820. */
  116821. 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>;
  116822. /**
  116823. * Import meshes into a scene
  116824. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116825. * @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)
  116826. * @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)
  116827. * @param scene the instance of BABYLON.Scene to append to
  116828. * @param onProgress a callback with a progress event for each file being loaded
  116829. * @param pluginExtension the extension used to determine the plugin
  116830. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116831. */
  116832. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116833. meshes: AbstractMesh[];
  116834. particleSystems: IParticleSystem[];
  116835. skeletons: Skeleton[];
  116836. animationGroups: AnimationGroup[];
  116837. }>;
  116838. /**
  116839. * Load a scene
  116840. * @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)
  116841. * @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)
  116842. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116843. * @param onSuccess a callback with the scene when import succeeds
  116844. * @param onProgress a callback with a progress event for each file being loaded
  116845. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116846. * @param pluginExtension the extension used to determine the plugin
  116847. * @returns The loaded plugin
  116848. */
  116849. 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>;
  116850. /**
  116851. * Load a scene
  116852. * @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)
  116853. * @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)
  116854. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116855. * @param onProgress a callback with a progress event for each file being loaded
  116856. * @param pluginExtension the extension used to determine the plugin
  116857. * @returns The loaded scene
  116858. */
  116859. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116860. /**
  116861. * Append a scene
  116862. * @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)
  116863. * @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)
  116864. * @param scene is the instance of BABYLON.Scene to append to
  116865. * @param onSuccess a callback with the scene when import succeeds
  116866. * @param onProgress a callback with a progress event for each file being loaded
  116867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116868. * @param pluginExtension the extension used to determine the plugin
  116869. * @returns The loaded plugin
  116870. */
  116871. 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>;
  116872. /**
  116873. * Append a scene
  116874. * @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)
  116875. * @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)
  116876. * @param scene is the instance of BABYLON.Scene to append to
  116877. * @param onProgress a callback with a progress event for each file being loaded
  116878. * @param pluginExtension the extension used to determine the plugin
  116879. * @returns The given scene
  116880. */
  116881. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116882. /**
  116883. * Load a scene into an asset container
  116884. * @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)
  116885. * @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)
  116886. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116887. * @param onSuccess a callback with the scene when import succeeds
  116888. * @param onProgress a callback with a progress event for each file being loaded
  116889. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116890. * @param pluginExtension the extension used to determine the plugin
  116891. * @returns The loaded plugin
  116892. */
  116893. 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>;
  116894. /**
  116895. * Load a scene into an asset container
  116896. * @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)
  116897. * @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)
  116898. * @param scene is the instance of Scene to append to
  116899. * @param onProgress a callback with a progress event for each file being loaded
  116900. * @param pluginExtension the extension used to determine the plugin
  116901. * @returns The loaded asset container
  116902. */
  116903. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116904. /**
  116905. * Import animations from a file into a scene
  116906. * @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)
  116907. * @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)
  116908. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116909. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116910. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116911. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116912. * @param onSuccess a callback with the scene when import succeeds
  116913. * @param onProgress a callback with a progress event for each file being loaded
  116914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116915. */
  116916. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  116917. /**
  116918. * Import animations from a file into a scene
  116919. * @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)
  116920. * @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)
  116921. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116922. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116923. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116924. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116925. * @param onSuccess a callback with the scene when import succeeds
  116926. * @param onProgress a callback with a progress event for each file being loaded
  116927. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116928. * @returns the updated scene with imported animations
  116929. */
  116930. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  116931. }
  116932. }
  116933. declare module BABYLON {
  116934. /**
  116935. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116936. */
  116937. export type MotionControllerHandness = "none" | "left" | "right";
  116938. /**
  116939. * The type of components available in motion controllers.
  116940. * This is not the name of the component.
  116941. */
  116942. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116943. /**
  116944. * The state of a controller component
  116945. */
  116946. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116947. /**
  116948. * The schema of motion controller layout.
  116949. * No object will be initialized using this interface
  116950. * This is used just to define the profile.
  116951. */
  116952. export interface IMotionControllerLayout {
  116953. /**
  116954. * Defines the main button component id
  116955. */
  116956. selectComponentId: string;
  116957. /**
  116958. * Available components (unsorted)
  116959. */
  116960. components: {
  116961. /**
  116962. * A map of component Ids
  116963. */
  116964. [componentId: string]: {
  116965. /**
  116966. * The type of input the component outputs
  116967. */
  116968. type: MotionControllerComponentType;
  116969. /**
  116970. * The indices of this component in the gamepad object
  116971. */
  116972. gamepadIndices: {
  116973. /**
  116974. * Index of button
  116975. */
  116976. button?: number;
  116977. /**
  116978. * If available, index of x-axis
  116979. */
  116980. xAxis?: number;
  116981. /**
  116982. * If available, index of y-axis
  116983. */
  116984. yAxis?: number;
  116985. };
  116986. /**
  116987. * The mesh's root node name
  116988. */
  116989. rootNodeName: string;
  116990. /**
  116991. * Animation definitions for this model
  116992. */
  116993. visualResponses: {
  116994. [stateKey: string]: {
  116995. /**
  116996. * What property will be animated
  116997. */
  116998. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116999. /**
  117000. * What states influence this visual reponse
  117001. */
  117002. states: MotionControllerComponentStateType[];
  117003. /**
  117004. * Type of animation - movement or visibility
  117005. */
  117006. valueNodeProperty: "transform" | "visibility";
  117007. /**
  117008. * Base node name to move. Its position will be calculated according to the min and max nodes
  117009. */
  117010. valueNodeName?: string;
  117011. /**
  117012. * Minimum movement node
  117013. */
  117014. minNodeName?: string;
  117015. /**
  117016. * Max movement node
  117017. */
  117018. maxNodeName?: string;
  117019. };
  117020. };
  117021. /**
  117022. * If touch enabled, what is the name of node to display user feedback
  117023. */
  117024. touchPointNodeName?: string;
  117025. };
  117026. };
  117027. /**
  117028. * Is it xr standard mapping or not
  117029. */
  117030. gamepadMapping: "" | "xr-standard";
  117031. /**
  117032. * Base root node of this entire model
  117033. */
  117034. rootNodeName: string;
  117035. /**
  117036. * Path to load the assets. Usually relative to the base path
  117037. */
  117038. assetPath: string;
  117039. }
  117040. /**
  117041. * A definition for the layout map in the input profile
  117042. */
  117043. export interface IMotionControllerLayoutMap {
  117044. /**
  117045. * Layouts with handness type as a key
  117046. */
  117047. [handness: string]: IMotionControllerLayout;
  117048. }
  117049. /**
  117050. * The XR Input profile schema
  117051. * Profiles can be found here:
  117052. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117053. */
  117054. export interface IMotionControllerProfile {
  117055. /**
  117056. * The id of this profile
  117057. * correlates to the profile(s) in the xrInput.profiles array
  117058. */
  117059. profileId: string;
  117060. /**
  117061. * fallback profiles for this profileId
  117062. */
  117063. fallbackProfileIds: string[];
  117064. /**
  117065. * The layout map, with handness as key
  117066. */
  117067. layouts: IMotionControllerLayoutMap;
  117068. }
  117069. /**
  117070. * A helper-interface for the 3 meshes needed for controller button animation
  117071. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117072. */
  117073. export interface IMotionControllerButtonMeshMap {
  117074. /**
  117075. * The mesh that will be changed when value changes
  117076. */
  117077. valueMesh: AbstractMesh;
  117078. /**
  117079. * the mesh that defines the pressed value mesh position.
  117080. * This is used to find the max-position of this button
  117081. */
  117082. pressedMesh: AbstractMesh;
  117083. /**
  117084. * the mesh that defines the unpressed value mesh position.
  117085. * This is used to find the min (or initial) position of this button
  117086. */
  117087. unpressedMesh: AbstractMesh;
  117088. }
  117089. /**
  117090. * A helper-interface for the 3 meshes needed for controller axis animation.
  117091. * This will be expanded when touchpad animations are fully supported
  117092. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117093. */
  117094. export interface IMotionControllerMeshMap {
  117095. /**
  117096. * The mesh that will be changed when axis value changes
  117097. */
  117098. valueMesh: AbstractMesh;
  117099. /**
  117100. * the mesh that defines the minimum value mesh position.
  117101. */
  117102. minMesh?: AbstractMesh;
  117103. /**
  117104. * the mesh that defines the maximum value mesh position.
  117105. */
  117106. maxMesh?: AbstractMesh;
  117107. }
  117108. /**
  117109. * The elements needed for change-detection of the gamepad objects in motion controllers
  117110. */
  117111. export interface IMinimalMotionControllerObject {
  117112. /**
  117113. * An array of available buttons
  117114. */
  117115. buttons: Array<{
  117116. /**
  117117. * Value of the button/trigger
  117118. */
  117119. value: number;
  117120. /**
  117121. * If the button/trigger is currently touched
  117122. */
  117123. touched: boolean;
  117124. /**
  117125. * If the button/trigger is currently pressed
  117126. */
  117127. pressed: boolean;
  117128. }>;
  117129. /**
  117130. * Available axes of this controller
  117131. */
  117132. axes: number[];
  117133. }
  117134. /**
  117135. * An Abstract Motion controller
  117136. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117137. * Each component has an observable to check for changes in value and state
  117138. */
  117139. export abstract class WebXRAbstractMotionController implements IDisposable {
  117140. protected scene: Scene;
  117141. protected layout: IMotionControllerLayout;
  117142. /**
  117143. * The gamepad object correlating to this controller
  117144. */
  117145. gamepadObject: IMinimalMotionControllerObject;
  117146. /**
  117147. * handness (left/right/none) of this controller
  117148. */
  117149. handness: MotionControllerHandness;
  117150. /**
  117151. * The profile id of this motion controller
  117152. */
  117153. abstract profileId: string;
  117154. /**
  117155. * A map of components (WebXRControllerComponent) in this motion controller
  117156. * Components have a ComponentType and can also have both button and axis definitions
  117157. */
  117158. readonly components: {
  117159. [id: string]: WebXRControllerComponent;
  117160. };
  117161. /**
  117162. * Observers registered here will be triggered when the model of this controller is done loading
  117163. */
  117164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117165. /**
  117166. * The root mesh of the model. It is null if the model was not yet initialized
  117167. */
  117168. rootMesh: Nullable<AbstractMesh>;
  117169. /**
  117170. * Disable the model's animation. Can be set at any time.
  117171. */
  117172. disableAnimation: boolean;
  117173. private _modelReady;
  117174. /**
  117175. * constructs a new abstract motion controller
  117176. * @param scene the scene to which the model of the controller will be added
  117177. * @param layout The profile layout to load
  117178. * @param gamepadObject The gamepad object correlating to this controller
  117179. * @param handness handness (left/right/none) of this controller
  117180. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117181. */
  117182. constructor(scene: Scene, layout: IMotionControllerLayout,
  117183. /**
  117184. * The gamepad object correlating to this controller
  117185. */
  117186. gamepadObject: IMinimalMotionControllerObject,
  117187. /**
  117188. * handness (left/right/none) of this controller
  117189. */
  117190. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117191. private _initComponent;
  117192. /**
  117193. * Update this model using the current XRFrame
  117194. * @param xrFrame the current xr frame to use and update the model
  117195. */
  117196. updateFromXRFrame(xrFrame: XRFrame): void;
  117197. /**
  117198. * Get the list of components available in this motion controller
  117199. * @returns an array of strings correlating to available components
  117200. */
  117201. getComponentIds(): string[];
  117202. /**
  117203. * Get the main (Select) component of this controller as defined in the layout
  117204. * @returns the main component of this controller
  117205. */
  117206. getMainComponent(): WebXRControllerComponent;
  117207. /**
  117208. * get a component based an its component id as defined in layout.components
  117209. * @param id the id of the component
  117210. * @returns the component correlates to the id or undefined if not found
  117211. */
  117212. getComponent(id: string): WebXRControllerComponent;
  117213. /**
  117214. * Get the first component of specific type
  117215. * @param type type of component to find
  117216. * @return a controller component or null if not found
  117217. */
  117218. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117219. /**
  117220. * Returns all components of specific type
  117221. * @param type the type to search for
  117222. * @return an array of components with this type
  117223. */
  117224. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117225. /**
  117226. * Loads the model correlating to this controller
  117227. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117228. * @returns A promise fulfilled with the result of the model loading
  117229. */
  117230. loadModel(): Promise<boolean>;
  117231. /**
  117232. * Update the model itself with the current frame data
  117233. * @param xrFrame the frame to use for updating the model mesh
  117234. */
  117235. protected updateModel(xrFrame: XRFrame): void;
  117236. /**
  117237. * Moves the axis on the controller mesh based on its current state
  117238. * @param axis the index of the axis
  117239. * @param axisValue the value of the axis which determines the meshes new position
  117240. * @hidden
  117241. */
  117242. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117243. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117244. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117245. private _getGenericFilenameAndPath;
  117246. private _getGenericParentMesh;
  117247. /**
  117248. * Get the filename and path for this controller's model
  117249. * @returns a map of filename and path
  117250. */
  117251. protected abstract _getFilenameAndPath(): {
  117252. filename: string;
  117253. path: string;
  117254. };
  117255. /**
  117256. * This function will be called after the model was successfully loaded and can be used
  117257. * for mesh transformations before it is available for the user
  117258. * @param meshes the loaded meshes
  117259. */
  117260. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117261. /**
  117262. * Set the root mesh for this controller. Important for the WebXR controller class
  117263. * @param meshes the loaded meshes
  117264. */
  117265. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117266. /**
  117267. * A function executed each frame that updates the mesh (if needed)
  117268. * @param xrFrame the current xrFrame
  117269. */
  117270. protected abstract _updateModel(xrFrame: XRFrame): void;
  117271. /**
  117272. * This function is called before the mesh is loaded. It checks for loading constraints.
  117273. * For example, this function can check if the GLB loader is available
  117274. * If this function returns false, the generic controller will be loaded instead
  117275. * @returns Is the client ready to load the mesh
  117276. */
  117277. protected abstract _getModelLoadingConstraints(): boolean;
  117278. /**
  117279. * Dispose this controller, the model mesh and all its components
  117280. */
  117281. dispose(): void;
  117282. }
  117283. }
  117284. declare module BABYLON {
  117285. /**
  117286. * A generic trigger-only motion controller for WebXR
  117287. */
  117288. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117289. /**
  117290. * Static version of the profile id of this controller
  117291. */
  117292. static ProfileId: string;
  117293. profileId: string;
  117294. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117295. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117296. protected _updateModel(): void;
  117297. protected _getFilenameAndPath(): {
  117298. filename: string;
  117299. path: string;
  117300. };
  117301. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117302. protected _getModelLoadingConstraints(): boolean;
  117303. }
  117304. }
  117305. declare module BABYLON {
  117306. /**
  117307. * Class containing static functions to help procedurally build meshes
  117308. */
  117309. export class SphereBuilder {
  117310. /**
  117311. * Creates a sphere mesh
  117312. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117313. * * 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`)
  117314. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117315. * * 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
  117316. * * 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)
  117317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117320. * @param name defines the name of the mesh
  117321. * @param options defines the options used to create the mesh
  117322. * @param scene defines the hosting scene
  117323. * @returns the sphere mesh
  117324. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117325. */
  117326. static CreateSphere(name: string, options: {
  117327. segments?: number;
  117328. diameter?: number;
  117329. diameterX?: number;
  117330. diameterY?: number;
  117331. diameterZ?: number;
  117332. arc?: number;
  117333. slice?: number;
  117334. sideOrientation?: number;
  117335. frontUVs?: Vector4;
  117336. backUVs?: Vector4;
  117337. updatable?: boolean;
  117338. }, scene?: Nullable<Scene>): Mesh;
  117339. }
  117340. }
  117341. declare module BABYLON {
  117342. /**
  117343. * A profiled motion controller has its profile loaded from an online repository.
  117344. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117345. */
  117346. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117347. private _repositoryUrl;
  117348. /**
  117349. * The profile ID of this controller. Will be populated when the controller initializes.
  117350. */
  117351. profileId: string;
  117352. private _buttonMeshMapping;
  117353. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117354. protected _getFilenameAndPath(): {
  117355. filename: string;
  117356. path: string;
  117357. };
  117358. private _touchDots;
  117359. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117360. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117361. protected _updateModel(_xrFrame: XRFrame): void;
  117362. protected _getModelLoadingConstraints(): boolean;
  117363. dispose(): void;
  117364. }
  117365. }
  117366. declare module BABYLON {
  117367. /**
  117368. * A construction function type to create a new controller based on an xrInput object
  117369. */
  117370. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117371. /**
  117372. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117373. *
  117374. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117375. * it should be replaced with auto-loaded controllers.
  117376. *
  117377. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117378. */
  117379. export class WebXRMotionControllerManager {
  117380. /**
  117381. * The base URL of the online controller repository. Can be changed at any time.
  117382. */
  117383. static BaseRepositoryUrl: string;
  117384. /**
  117385. * Use the online repository, or use only locally-defined controllers
  117386. */
  117387. static UseOnlineRepository: boolean;
  117388. /**
  117389. * Which repository gets priority - local or online
  117390. */
  117391. static PrioritizeOnlineRepository: boolean;
  117392. private static _AvailableControllers;
  117393. private static _Fallbacks;
  117394. /**
  117395. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117396. *
  117397. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117398. *
  117399. * @param type the profile type to register
  117400. * @param constructFunction the function to be called when loading this profile
  117401. */
  117402. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117403. /**
  117404. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117405. * The order of search:
  117406. *
  117407. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117408. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117409. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117410. * 4) return the generic trigger controller if none were found
  117411. *
  117412. * @param xrInput the xrInput to which a new controller is initialized
  117413. * @param scene the scene to which the model will be added
  117414. * @param forceProfile force a certain profile for this controller
  117415. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117416. */
  117417. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117418. private static _LoadProfilesFromAvailableControllers;
  117419. private static _ProfilesList;
  117420. private static _ProfileLoadingPromises;
  117421. private static _LoadProfileFromRepository;
  117422. /**
  117423. * Clear the cache used for profile loading and reload when requested again
  117424. */
  117425. static ClearProfilesCache(): void;
  117426. /**
  117427. * Will update the list of profiles available in the repository
  117428. * @return a promise that resolves to a map of profiles available online
  117429. */
  117430. static UpdateProfilesList(): Promise<{
  117431. [profile: string]: string;
  117432. }>;
  117433. /**
  117434. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117435. * @param profileId the profile to which a fallback needs to be found
  117436. * @return an array with corresponding fallback profiles
  117437. */
  117438. static FindFallbackWithProfileId(profileId: string): string[];
  117439. /**
  117440. * Register a fallback to a specific profile.
  117441. * @param profileId the profileId that will receive the fallbacks
  117442. * @param fallbacks A list of fallback profiles
  117443. */
  117444. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117445. /**
  117446. * Register the default fallbacks.
  117447. * This function is called automatically when this file is imported.
  117448. */
  117449. static DefaultFallbacks(): void;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * Configuration options for the WebXR controller creation
  117455. */
  117456. export interface IWebXRControllerOptions {
  117457. /**
  117458. * Force a specific controller type for this controller.
  117459. * This can be used when creating your own profile or when testing different controllers
  117460. */
  117461. forceControllerProfile?: string;
  117462. /**
  117463. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117464. */
  117465. doNotLoadControllerMesh?: boolean;
  117466. /**
  117467. * Should the controller mesh be animated when a user interacts with it
  117468. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117469. */
  117470. disableMotionControllerAnimation?: boolean;
  117471. }
  117472. /**
  117473. * Represents an XR controller
  117474. */
  117475. export class WebXRInputSource {
  117476. private _scene;
  117477. /** The underlying input source for the controller */
  117478. inputSource: XRInputSource;
  117479. private _options;
  117480. /**
  117481. * 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
  117482. */
  117483. grip?: AbstractMesh;
  117484. /**
  117485. * Pointer which can be used to select objects or attach a visible laser to
  117486. */
  117487. pointer: AbstractMesh;
  117488. /**
  117489. * If available, this is the gamepad object related to this controller.
  117490. * Using this object it is possible to get click events and trackpad changes of the
  117491. * webxr controller that is currently being used.
  117492. */
  117493. motionController?: WebXRAbstractMotionController;
  117494. /**
  117495. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117496. */
  117497. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117498. /**
  117499. * Will be triggered when the mesh associated with the motion controller is done loading.
  117500. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117501. * A shortened version of controller -> motion controller -> on mesh loaded.
  117502. */
  117503. onMeshLoadedObservable: Observable<AbstractMesh>;
  117504. /**
  117505. * Event that fires when the controller is removed/disposed.
  117506. * The object provided as event data is this controller, after associated assets were disposed.
  117507. * uniqueId is still available.
  117508. */
  117509. onDisposeObservable: Observable<WebXRInputSource>;
  117510. private _tmpQuaternion;
  117511. private _tmpVector;
  117512. private _uniqueId;
  117513. /**
  117514. * Creates the controller
  117515. * @see https://doc.babylonjs.com/how_to/webxr
  117516. * @param _scene the scene which the controller should be associated to
  117517. * @param inputSource the underlying input source for the controller
  117518. * @param _options options for this controller creation
  117519. */
  117520. constructor(_scene: Scene,
  117521. /** The underlying input source for the controller */
  117522. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117523. /**
  117524. * Get this controllers unique id
  117525. */
  117526. get uniqueId(): string;
  117527. /**
  117528. * Updates the controller pose based on the given XRFrame
  117529. * @param xrFrame xr frame to update the pose with
  117530. * @param referenceSpace reference space to use
  117531. */
  117532. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117533. /**
  117534. * Gets a world space ray coming from the pointer or grip
  117535. * @param result the resulting ray
  117536. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117537. */
  117538. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117539. /**
  117540. * Disposes of the object
  117541. */
  117542. dispose(): void;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * The schema for initialization options of the XR Input class
  117548. */
  117549. export interface IWebXRInputOptions {
  117550. /**
  117551. * If set to true no model will be automatically loaded
  117552. */
  117553. doNotLoadControllerMeshes?: boolean;
  117554. /**
  117555. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117556. * If not found, the xr input profile data will be used.
  117557. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117558. */
  117559. forceInputProfile?: string;
  117560. /**
  117561. * Do not send a request to the controlle repository to load the profile.
  117562. *
  117563. * Instead, use the controllers available in babylon itself.
  117564. */
  117565. disableOnlineControllerRepository?: boolean;
  117566. /**
  117567. * A custom URL for the controllers repository
  117568. */
  117569. customControllersRepositoryURL?: string;
  117570. /**
  117571. * Should the controller model's components not move according to the user input
  117572. */
  117573. disableControllerAnimation?: boolean;
  117574. }
  117575. /**
  117576. * XR input used to track XR inputs such as controllers/rays
  117577. */
  117578. export class WebXRInput implements IDisposable {
  117579. /**
  117580. * the xr session manager for this session
  117581. */
  117582. xrSessionManager: WebXRSessionManager;
  117583. /**
  117584. * the WebXR camera for this session. Mainly used for teleportation
  117585. */
  117586. xrCamera: WebXRCamera;
  117587. private readonly options;
  117588. /**
  117589. * XR controllers being tracked
  117590. */
  117591. controllers: Array<WebXRInputSource>;
  117592. private _frameObserver;
  117593. private _sessionEndedObserver;
  117594. private _sessionInitObserver;
  117595. /**
  117596. * Event when a controller has been connected/added
  117597. */
  117598. onControllerAddedObservable: Observable<WebXRInputSource>;
  117599. /**
  117600. * Event when a controller has been removed/disconnected
  117601. */
  117602. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117603. /**
  117604. * Initializes the WebXRInput
  117605. * @param xrSessionManager the xr session manager for this session
  117606. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117607. * @param options = initialization options for this xr input
  117608. */
  117609. constructor(
  117610. /**
  117611. * the xr session manager for this session
  117612. */
  117613. xrSessionManager: WebXRSessionManager,
  117614. /**
  117615. * the WebXR camera for this session. Mainly used for teleportation
  117616. */
  117617. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117618. private _onInputSourcesChange;
  117619. private _addAndRemoveControllers;
  117620. /**
  117621. * Disposes of the object
  117622. */
  117623. dispose(): void;
  117624. }
  117625. }
  117626. declare module BABYLON {
  117627. /**
  117628. * This is the base class for all WebXR features.
  117629. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117630. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117631. */
  117632. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117633. protected _xrSessionManager: WebXRSessionManager;
  117634. /**
  117635. * Construct a new (abstract) webxr feature
  117636. * @param _xrSessionManager the xr session manager for this feature
  117637. */
  117638. constructor(_xrSessionManager: WebXRSessionManager);
  117639. private _attached;
  117640. private _removeOnDetach;
  117641. /**
  117642. * Is this feature attached
  117643. */
  117644. get attached(): boolean;
  117645. /**
  117646. * Should auto-attach be disabled?
  117647. */
  117648. disableAutoAttach: boolean;
  117649. /**
  117650. * attach this feature
  117651. *
  117652. * @param force should attachment be forced (even when already attached)
  117653. * @returns true if successful, false is failed or already attached
  117654. */
  117655. attach(force?: boolean): boolean;
  117656. /**
  117657. * detach this feature.
  117658. *
  117659. * @returns true if successful, false if failed or already detached
  117660. */
  117661. detach(): boolean;
  117662. /**
  117663. * Dispose this feature and all of the resources attached
  117664. */
  117665. dispose(): void;
  117666. /**
  117667. * Code in this function will be executed on each xrFrame received from the browser.
  117668. * This function will not execute after the feature is detached.
  117669. * @param _xrFrame the current frame
  117670. */
  117671. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117672. /**
  117673. * This is used to register callbacks that will automatically be removed when detach is called.
  117674. * @param observable the observable to which the observer will be attached
  117675. * @param callback the callback to register
  117676. */
  117677. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117678. }
  117679. }
  117680. declare module BABYLON {
  117681. /**
  117682. * Renders a layer on top of an existing scene
  117683. */
  117684. export class UtilityLayerRenderer implements IDisposable {
  117685. /** the original scene that will be rendered on top of */
  117686. originalScene: Scene;
  117687. private _pointerCaptures;
  117688. private _lastPointerEvents;
  117689. private static _DefaultUtilityLayer;
  117690. private static _DefaultKeepDepthUtilityLayer;
  117691. private _sharedGizmoLight;
  117692. private _renderCamera;
  117693. /**
  117694. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117695. * @returns the camera that is used when rendering the utility layer
  117696. */
  117697. getRenderCamera(): Camera;
  117698. /**
  117699. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117700. * @param cam the camera that should be used when rendering the utility layer
  117701. */
  117702. setRenderCamera(cam: Nullable<Camera>): void;
  117703. /**
  117704. * @hidden
  117705. * Light which used by gizmos to get light shading
  117706. */
  117707. _getSharedGizmoLight(): HemisphericLight;
  117708. /**
  117709. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117710. */
  117711. pickUtilitySceneFirst: boolean;
  117712. /**
  117713. * 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)
  117714. */
  117715. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117716. /**
  117717. * 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)
  117718. */
  117719. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117720. /**
  117721. * The scene that is rendered on top of the original scene
  117722. */
  117723. utilityLayerScene: Scene;
  117724. /**
  117725. * If the utility layer should automatically be rendered on top of existing scene
  117726. */
  117727. shouldRender: boolean;
  117728. /**
  117729. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117730. */
  117731. onlyCheckPointerDownEvents: boolean;
  117732. /**
  117733. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117734. */
  117735. processAllEvents: boolean;
  117736. /**
  117737. * Observable raised when the pointer move from the utility layer scene to the main scene
  117738. */
  117739. onPointerOutObservable: Observable<number>;
  117740. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117741. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117742. private _afterRenderObserver;
  117743. private _sceneDisposeObserver;
  117744. private _originalPointerObserver;
  117745. /**
  117746. * Instantiates a UtilityLayerRenderer
  117747. * @param originalScene the original scene that will be rendered on top of
  117748. * @param handleEvents boolean indicating if the utility layer should handle events
  117749. */
  117750. constructor(
  117751. /** the original scene that will be rendered on top of */
  117752. originalScene: Scene, handleEvents?: boolean);
  117753. private _notifyObservers;
  117754. /**
  117755. * Renders the utility layers scene on top of the original scene
  117756. */
  117757. render(): void;
  117758. /**
  117759. * Disposes of the renderer
  117760. */
  117761. dispose(): void;
  117762. private _updateCamera;
  117763. }
  117764. }
  117765. declare module BABYLON {
  117766. /**
  117767. * Options interface for the pointer selection module
  117768. */
  117769. export interface IWebXRControllerPointerSelectionOptions {
  117770. /**
  117771. * the xr input to use with this pointer selection
  117772. */
  117773. xrInput: WebXRInput;
  117774. /**
  117775. * Different button type to use instead of the main component
  117776. */
  117777. overrideButtonId?: string;
  117778. /**
  117779. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117780. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117781. * 3000 means 3 seconds between pointing at something and selecting it
  117782. */
  117783. timeToSelect?: number;
  117784. /**
  117785. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  117786. * If not disabled, the last picked point will be used to execute a pointer up event
  117787. * If disabled, pointer up event will be triggered right after the pointer down event.
  117788. * Used in screen and gaze target ray mode only
  117789. */
  117790. disablePointerUpOnTouchOut: boolean;
  117791. /**
  117792. * For gaze mode (time to select instead of press)
  117793. */
  117794. forceGazeMode: boolean;
  117795. /**
  117796. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  117797. * to start a new countdown to the pointer down event.
  117798. * Defaults to 1.
  117799. */
  117800. gazeModePointerMovedFactor?: number;
  117801. /**
  117802. * Should meshes created here be added to a utility layer or the main scene
  117803. */
  117804. useUtilityLayer?: boolean;
  117805. /**
  117806. * if provided, this scene will be used to render meshes.
  117807. */
  117808. customUtilityLayerScene?: Scene;
  117809. /**
  117810. * use this rendering group id for the meshes (optional)
  117811. */
  117812. renderingGroupId?: number;
  117813. }
  117814. /**
  117815. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117816. */
  117817. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117818. private readonly _options;
  117819. /**
  117820. * The module's name
  117821. */
  117822. static readonly Name: string;
  117823. /**
  117824. * The (Babylon) version of this module.
  117825. * This is an integer representing the implementation version.
  117826. * This number does not correspond to the webxr specs version
  117827. */
  117828. static readonly Version: number;
  117829. /**
  117830. * This color will be set to the laser pointer when selection is triggered
  117831. */
  117832. laserPointerPickedColor: Color3;
  117833. /**
  117834. * This color will be applied to the selection ring when selection is triggered
  117835. */
  117836. selectionMeshPickedColor: Color3;
  117837. /**
  117838. * default color of the selection ring
  117839. */
  117840. selectionMeshDefaultColor: Color3;
  117841. /**
  117842. * Default color of the laser pointer
  117843. */
  117844. lasterPointerDefaultColor: Color3;
  117845. /**
  117846. * Should the laser pointer be displayed
  117847. */
  117848. displayLaserPointer: boolean;
  117849. /**
  117850. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117851. */
  117852. displaySelectionMesh: boolean;
  117853. /**
  117854. * Disable lighting on the laser pointer (so it will always be visible)
  117855. */
  117856. disablePointerLighting: boolean;
  117857. /**
  117858. * Disable lighting on the selection mesh (so it will always be visible)
  117859. */
  117860. disableSelectionMeshLighting: boolean;
  117861. private static _idCounter;
  117862. private _controllers;
  117863. private _scene;
  117864. /**
  117865. * constructs a new background remover module
  117866. * @param _xrSessionManager the session manager for this module
  117867. * @param _options read-only options to be used in this module
  117868. */
  117869. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117870. /**
  117871. * attach this feature
  117872. * Will usually be called by the features manager
  117873. *
  117874. * @returns true if successful.
  117875. */
  117876. attach(): boolean;
  117877. /**
  117878. * detach this feature.
  117879. * Will usually be called by the features manager
  117880. *
  117881. * @returns true if successful.
  117882. */
  117883. detach(): boolean;
  117884. /**
  117885. * Get the xr controller that correlates to the pointer id in the pointer event
  117886. *
  117887. * @param id the pointer id to search for
  117888. * @returns the controller that correlates to this id or null if not found
  117889. */
  117890. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117891. /**
  117892. * Will get the mesh under a specific pointer.
  117893. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117894. * @param controllerId the controllerId to check
  117895. * @returns The mesh under pointer or null if no mesh is under the pointer
  117896. */
  117897. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117898. protected _onXRFrame(_xrFrame: XRFrame): void;
  117899. private _attachController;
  117900. private _attachScreenRayMode;
  117901. private _attachGazeMode;
  117902. private _tmpVectorForPickCompare;
  117903. private _pickingMoved;
  117904. private _attachTrackedPointerRayMode;
  117905. private _detachController;
  117906. private _generateNewMeshPair;
  117907. private _convertNormalToDirectionOfRay;
  117908. private _updatePointerDistance;
  117909. }
  117910. }
  117911. declare module BABYLON {
  117912. /**
  117913. * Button which can be used to enter a different mode of XR
  117914. */
  117915. export class WebXREnterExitUIButton {
  117916. /** button element */
  117917. element: HTMLElement;
  117918. /** XR initialization options for the button */
  117919. sessionMode: XRSessionMode;
  117920. /** Reference space type */
  117921. referenceSpaceType: XRReferenceSpaceType;
  117922. /**
  117923. * Creates a WebXREnterExitUIButton
  117924. * @param element button element
  117925. * @param sessionMode XR initialization session mode
  117926. * @param referenceSpaceType the type of reference space to be used
  117927. */
  117928. constructor(
  117929. /** button element */
  117930. element: HTMLElement,
  117931. /** XR initialization options for the button */
  117932. sessionMode: XRSessionMode,
  117933. /** Reference space type */
  117934. referenceSpaceType: XRReferenceSpaceType);
  117935. /**
  117936. * Overwritable function which can be used to update the button's visuals when the state changes
  117937. * @param activeButton the current active button in the UI
  117938. */
  117939. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117940. }
  117941. /**
  117942. * Options to create the webXR UI
  117943. */
  117944. export class WebXREnterExitUIOptions {
  117945. /**
  117946. * Context to enter xr with
  117947. */
  117948. renderTarget?: Nullable<WebXRRenderTarget>;
  117949. /**
  117950. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117951. */
  117952. customButtons?: Array<WebXREnterExitUIButton>;
  117953. /**
  117954. * A session mode to use when creating the default button.
  117955. * Default is immersive-vr
  117956. */
  117957. sessionMode?: XRSessionMode;
  117958. /**
  117959. * A reference space type to use when creating the default button.
  117960. * Default is local-floor
  117961. */
  117962. referenceSpaceType?: XRReferenceSpaceType;
  117963. }
  117964. /**
  117965. * UI to allow the user to enter/exit XR mode
  117966. */
  117967. export class WebXREnterExitUI implements IDisposable {
  117968. private scene;
  117969. /** version of the options passed to this UI */
  117970. options: WebXREnterExitUIOptions;
  117971. private _overlay;
  117972. private _buttons;
  117973. private _activeButton;
  117974. /**
  117975. * Fired every time the active button is changed.
  117976. *
  117977. * When xr is entered via a button that launches xr that button will be the callback parameter
  117978. *
  117979. * When exiting xr the callback parameter will be null)
  117980. */
  117981. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117982. /**
  117983. * Creates UI to allow the user to enter/exit XR mode
  117984. * @param scene the scene to add the ui to
  117985. * @param helper the xr experience helper to enter/exit xr with
  117986. * @param options options to configure the UI
  117987. * @returns the created ui
  117988. */
  117989. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117990. /**
  117991. *
  117992. * @param scene babylon scene object to use
  117993. * @param options (read-only) version of the options passed to this UI
  117994. */
  117995. private constructor();
  117996. private _updateButtons;
  117997. /**
  117998. * Disposes of the object
  117999. */
  118000. dispose(): void;
  118001. }
  118002. }
  118003. declare module BABYLON {
  118004. /**
  118005. * Class containing static functions to help procedurally build meshes
  118006. */
  118007. export class LinesBuilder {
  118008. /**
  118009. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118010. * * 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
  118011. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118012. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118013. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118014. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118015. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118016. * * 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
  118017. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118020. * @param name defines the name of the new line system
  118021. * @param options defines the options used to create the line system
  118022. * @param scene defines the hosting scene
  118023. * @returns a new line system mesh
  118024. */
  118025. static CreateLineSystem(name: string, options: {
  118026. lines: Vector3[][];
  118027. updatable?: boolean;
  118028. instance?: Nullable<LinesMesh>;
  118029. colors?: Nullable<Color4[][]>;
  118030. useVertexAlpha?: boolean;
  118031. }, scene: Nullable<Scene>): LinesMesh;
  118032. /**
  118033. * Creates a line mesh
  118034. * 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
  118035. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118036. * * The parameter `points` is an array successive Vector3
  118037. * * 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
  118038. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118039. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118040. * * When updating an instance, remember that only point positions can change, not the number of points
  118041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118043. * @param name defines the name of the new line system
  118044. * @param options defines the options used to create the line system
  118045. * @param scene defines the hosting scene
  118046. * @returns a new line mesh
  118047. */
  118048. static CreateLines(name: string, options: {
  118049. points: Vector3[];
  118050. updatable?: boolean;
  118051. instance?: Nullable<LinesMesh>;
  118052. colors?: Color4[];
  118053. useVertexAlpha?: boolean;
  118054. }, scene?: Nullable<Scene>): LinesMesh;
  118055. /**
  118056. * Creates a dashed line mesh
  118057. * * 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
  118058. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118059. * * The parameter `points` is an array successive Vector3
  118060. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118061. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118062. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118063. * * 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
  118064. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118065. * * When updating an instance, remember that only point positions can change, not the number of points
  118066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118067. * @param name defines the name of the mesh
  118068. * @param options defines the options used to create the mesh
  118069. * @param scene defines the hosting scene
  118070. * @returns the dashed line mesh
  118071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118072. */
  118073. static CreateDashedLines(name: string, options: {
  118074. points: Vector3[];
  118075. dashSize?: number;
  118076. gapSize?: number;
  118077. dashNb?: number;
  118078. updatable?: boolean;
  118079. instance?: LinesMesh;
  118080. useVertexAlpha?: boolean;
  118081. }, scene?: Nullable<Scene>): LinesMesh;
  118082. }
  118083. }
  118084. declare module BABYLON {
  118085. /**
  118086. * The options container for the teleportation module
  118087. */
  118088. export interface IWebXRTeleportationOptions {
  118089. /**
  118090. * Babylon XR Input class for controller
  118091. */
  118092. xrInput: WebXRInput;
  118093. /**
  118094. * A list of meshes to use as floor meshes.
  118095. * Meshes can be added and removed after initializing the feature using the
  118096. * addFloorMesh and removeFloorMesh functions
  118097. * If empty, rotation will still work
  118098. */
  118099. floorMeshes?: AbstractMesh[];
  118100. /**
  118101. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118102. * If you want to support rotation, make sure your mesh has a direction indicator.
  118103. *
  118104. * When left untouched, the default mesh will be initialized.
  118105. */
  118106. teleportationTargetMesh?: AbstractMesh;
  118107. /**
  118108. * An array of points to which the teleportation will snap to.
  118109. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118110. */
  118111. snapPositions?: Vector3[];
  118112. /**
  118113. * How close should the teleportation ray be in order to snap to position.
  118114. * Default to 0.8 units (meters)
  118115. */
  118116. snapToPositionRadius?: number;
  118117. /**
  118118. * Should teleportation move only to snap points
  118119. */
  118120. snapPointsOnly?: boolean;
  118121. /**
  118122. * Values to configure the default target mesh
  118123. */
  118124. defaultTargetMeshOptions?: {
  118125. /**
  118126. * Fill color of the teleportation area
  118127. */
  118128. teleportationFillColor?: string;
  118129. /**
  118130. * Border color for the teleportation area
  118131. */
  118132. teleportationBorderColor?: string;
  118133. /**
  118134. * Disable the mesh's animation sequence
  118135. */
  118136. disableAnimation?: boolean;
  118137. /**
  118138. * Disable lighting on the material or the ring and arrow
  118139. */
  118140. disableLighting?: boolean;
  118141. /**
  118142. * Override the default material of the torus and arrow
  118143. */
  118144. torusArrowMaterial?: Material;
  118145. };
  118146. /**
  118147. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118148. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118149. */
  118150. useMainComponentOnly?: boolean;
  118151. /**
  118152. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118153. */
  118154. timeToTeleport?: number;
  118155. /**
  118156. * Should meshes created here be added to a utility layer or the main scene
  118157. */
  118158. useUtilityLayer?: boolean;
  118159. /**
  118160. * if provided, this scene will be used to render meshes.
  118161. */
  118162. customUtilityLayerScene?: Scene;
  118163. /**
  118164. * use this rendering group id for the meshes (optional)
  118165. */
  118166. renderingGroupId?: number;
  118167. }
  118168. /**
  118169. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118170. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118171. * the input of the attached controllers.
  118172. */
  118173. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118174. private _options;
  118175. /**
  118176. * The module's name
  118177. */
  118178. static readonly Name: string;
  118179. /**
  118180. * The (Babylon) version of this module.
  118181. * This is an integer representing the implementation version.
  118182. * This number does not correspond to the webxr specs version
  118183. */
  118184. static readonly Version: number;
  118185. /**
  118186. * Is rotation enabled when moving forward?
  118187. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118188. */
  118189. rotationEnabled: boolean;
  118190. /**
  118191. * Should the module support parabolic ray on top of direct ray
  118192. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118193. * Very helpful when moving between floors / different heights
  118194. */
  118195. parabolicRayEnabled: boolean;
  118196. /**
  118197. * The distance from the user to the inspection point in the direction of the controller
  118198. * A higher number will allow the user to move further
  118199. * defaults to 5 (meters, in xr units)
  118200. */
  118201. parabolicCheckRadius: number;
  118202. /**
  118203. * How much rotation should be applied when rotating right and left
  118204. */
  118205. rotationAngle: number;
  118206. /**
  118207. * Is movement backwards enabled
  118208. */
  118209. backwardsMovementEnabled: boolean;
  118210. /**
  118211. * Distance to travel when moving backwards
  118212. */
  118213. backwardsTeleportationDistance: number;
  118214. /**
  118215. * Add a new mesh to the floor meshes array
  118216. * @param mesh the mesh to use as floor mesh
  118217. */
  118218. addFloorMesh(mesh: AbstractMesh): void;
  118219. /**
  118220. * Remove a mesh from the floor meshes array
  118221. * @param mesh the mesh to remove
  118222. */
  118223. removeFloorMesh(mesh: AbstractMesh): void;
  118224. /**
  118225. * Remove a mesh from the floor meshes array using its name
  118226. * @param name the mesh name to remove
  118227. */
  118228. removeFloorMeshByName(name: string): void;
  118229. private _tmpRay;
  118230. private _tmpVector;
  118231. private _floorMeshes;
  118232. private _snapToPositions;
  118233. private _controllers;
  118234. /**
  118235. * constructs a new anchor system
  118236. * @param _xrSessionManager an instance of WebXRSessionManager
  118237. * @param _options configuration object for this feature
  118238. */
  118239. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118240. private _selectionFeature;
  118241. private _snappedToPoint;
  118242. private _teleportationRingMaterial?;
  118243. /**
  118244. * Get the snapPointsOnly flag
  118245. */
  118246. get snapPointsOnly(): boolean;
  118247. /**
  118248. * Sets the snapPointsOnly flag
  118249. * @param snapToPoints should teleportation be exclusively to snap points
  118250. */
  118251. set snapPointsOnly(snapToPoints: boolean);
  118252. /**
  118253. * Add a new snap-to point to fix teleportation to this position
  118254. * @param newSnapPoint The new Snap-To point
  118255. */
  118256. addSnapPoint(newSnapPoint: Vector3): void;
  118257. /**
  118258. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  118259. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118260. * @returns was the point found and removed or not
  118261. */
  118262. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118263. /**
  118264. * This function sets a selection feature that will be disabled when
  118265. * the forward ray is shown and will be reattached when hidden.
  118266. * This is used to remove the selection rays when moving.
  118267. * @param selectionFeature the feature to disable when forward movement is enabled
  118268. */
  118269. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118270. attach(): boolean;
  118271. detach(): boolean;
  118272. dispose(): void;
  118273. protected _onXRFrame(_xrFrame: XRFrame): void;
  118274. private _currentTeleportationControllerId;
  118275. private _attachController;
  118276. private _teleportForward;
  118277. private _detachController;
  118278. private _createDefaultTargetMesh;
  118279. private _setTargetMeshVisibility;
  118280. private _setTargetMeshPosition;
  118281. private _quadraticBezierCurve;
  118282. private _showParabolicPath;
  118283. private _findClosestSnapPointWithRadius;
  118284. }
  118285. }
  118286. declare module BABYLON {
  118287. /**
  118288. * Options for the default xr helper
  118289. */
  118290. export class WebXRDefaultExperienceOptions {
  118291. /**
  118292. * Floor meshes that will be used for teleporting
  118293. */
  118294. floorMeshes?: Array<AbstractMesh>;
  118295. /**
  118296. * Enable or disable default UI to enter XR
  118297. */
  118298. disableDefaultUI?: boolean;
  118299. /**
  118300. * optional configuration for the output canvas
  118301. */
  118302. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118303. /**
  118304. * optional UI options. This can be used among other to change session mode and reference space type
  118305. */
  118306. uiOptions?: WebXREnterExitUIOptions;
  118307. /**
  118308. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118309. */
  118310. inputOptions?: IWebXRInputOptions;
  118311. /**
  118312. * Should teleportation not initialize. defaults to false.
  118313. */
  118314. disableTeleportation?: boolean;
  118315. /**
  118316. * If set to true, the first frame will not be used to reset position
  118317. * The first frame is mainly used when copying transformation from the old camera
  118318. * Mainly used in AR
  118319. */
  118320. ignoreNativeCameraTransformation?: boolean;
  118321. /**
  118322. * When loading teleportation and pointer select, use stable versions instead of latest.
  118323. */
  118324. useStablePlugins?: boolean;
  118325. }
  118326. /**
  118327. * Default experience which provides a similar setup to the previous webVRExperience
  118328. */
  118329. export class WebXRDefaultExperience {
  118330. /**
  118331. * Base experience
  118332. */
  118333. baseExperience: WebXRExperienceHelper;
  118334. /**
  118335. * Input experience extension
  118336. */
  118337. input: WebXRInput;
  118338. /**
  118339. * Enables laser pointer and selection
  118340. */
  118341. pointerSelection: WebXRControllerPointerSelection;
  118342. /**
  118343. * Enables teleportation
  118344. */
  118345. teleportation: WebXRMotionControllerTeleportation;
  118346. /**
  118347. * Enables ui for entering/exiting xr
  118348. */
  118349. enterExitUI: WebXREnterExitUI;
  118350. /**
  118351. * Default target xr should render to
  118352. */
  118353. renderTarget: WebXRRenderTarget;
  118354. /**
  118355. * Creates the default xr experience
  118356. * @param scene scene
  118357. * @param options options for basic configuration
  118358. * @returns resulting WebXRDefaultExperience
  118359. */
  118360. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118361. private constructor();
  118362. /**
  118363. * DIsposes of the experience helper
  118364. */
  118365. dispose(): void;
  118366. }
  118367. }
  118368. declare module BABYLON {
  118369. /**
  118370. * Options to modify the vr teleportation behavior.
  118371. */
  118372. export interface VRTeleportationOptions {
  118373. /**
  118374. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118375. */
  118376. floorMeshName?: string;
  118377. /**
  118378. * A list of meshes to be used as the teleportation floor. (default: empty)
  118379. */
  118380. floorMeshes?: Mesh[];
  118381. /**
  118382. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118383. */
  118384. teleportationMode?: number;
  118385. /**
  118386. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118387. */
  118388. teleportationTime?: number;
  118389. /**
  118390. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118391. */
  118392. teleportationSpeed?: number;
  118393. /**
  118394. * The easing function used in the animation or null for Linear. (default CircleEase)
  118395. */
  118396. easingFunction?: EasingFunction;
  118397. }
  118398. /**
  118399. * Options to modify the vr experience helper's behavior.
  118400. */
  118401. export interface VRExperienceHelperOptions extends WebVROptions {
  118402. /**
  118403. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118404. */
  118405. createDeviceOrientationCamera?: boolean;
  118406. /**
  118407. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118408. */
  118409. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118410. /**
  118411. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118412. */
  118413. laserToggle?: boolean;
  118414. /**
  118415. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118416. */
  118417. floorMeshes?: Mesh[];
  118418. /**
  118419. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118420. */
  118421. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118422. /**
  118423. * Defines if WebXR should be used instead of WebVR (if available)
  118424. */
  118425. useXR?: boolean;
  118426. }
  118427. /**
  118428. * Event containing information after VR has been entered
  118429. */
  118430. export class OnAfterEnteringVRObservableEvent {
  118431. /**
  118432. * If entering vr was successful
  118433. */
  118434. success: boolean;
  118435. }
  118436. /**
  118437. * Helps to quickly add VR support to an existing scene.
  118438. * See http://doc.babylonjs.com/how_to/webvr_helper
  118439. */
  118440. export class VRExperienceHelper {
  118441. /** Options to modify the vr experience helper's behavior. */
  118442. webVROptions: VRExperienceHelperOptions;
  118443. private _scene;
  118444. private _position;
  118445. private _btnVR;
  118446. private _btnVRDisplayed;
  118447. private _webVRsupported;
  118448. private _webVRready;
  118449. private _webVRrequesting;
  118450. private _webVRpresenting;
  118451. private _hasEnteredVR;
  118452. private _fullscreenVRpresenting;
  118453. private _inputElement;
  118454. private _webVRCamera;
  118455. private _vrDeviceOrientationCamera;
  118456. private _deviceOrientationCamera;
  118457. private _existingCamera;
  118458. private _onKeyDown;
  118459. private _onVrDisplayPresentChange;
  118460. private _onVRDisplayChanged;
  118461. private _onVRRequestPresentStart;
  118462. private _onVRRequestPresentComplete;
  118463. /**
  118464. * 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)
  118465. */
  118466. enableGazeEvenWhenNoPointerLock: boolean;
  118467. /**
  118468. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118469. */
  118470. exitVROnDoubleTap: boolean;
  118471. /**
  118472. * Observable raised right before entering VR.
  118473. */
  118474. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118475. /**
  118476. * Observable raised when entering VR has completed.
  118477. */
  118478. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118479. /**
  118480. * Observable raised when exiting VR.
  118481. */
  118482. onExitingVRObservable: Observable<VRExperienceHelper>;
  118483. /**
  118484. * Observable raised when controller mesh is loaded.
  118485. */
  118486. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118487. /** Return this.onEnteringVRObservable
  118488. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118489. */
  118490. get onEnteringVR(): Observable<VRExperienceHelper>;
  118491. /** Return this.onExitingVRObservable
  118492. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118493. */
  118494. get onExitingVR(): Observable<VRExperienceHelper>;
  118495. /** Return this.onControllerMeshLoadedObservable
  118496. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118497. */
  118498. get onControllerMeshLoaded(): Observable<WebVRController>;
  118499. private _rayLength;
  118500. private _useCustomVRButton;
  118501. private _teleportationRequested;
  118502. private _teleportActive;
  118503. private _floorMeshName;
  118504. private _floorMeshesCollection;
  118505. private _teleportationMode;
  118506. private _teleportationTime;
  118507. private _teleportationSpeed;
  118508. private _teleportationEasing;
  118509. private _rotationAllowed;
  118510. private _teleportBackwardsVector;
  118511. private _teleportationTarget;
  118512. private _isDefaultTeleportationTarget;
  118513. private _postProcessMove;
  118514. private _teleportationFillColor;
  118515. private _teleportationBorderColor;
  118516. private _rotationAngle;
  118517. private _haloCenter;
  118518. private _cameraGazer;
  118519. private _padSensibilityUp;
  118520. private _padSensibilityDown;
  118521. private _leftController;
  118522. private _rightController;
  118523. private _gazeColor;
  118524. private _laserColor;
  118525. private _pickedLaserColor;
  118526. private _pickedGazeColor;
  118527. /**
  118528. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118529. */
  118530. onNewMeshSelected: Observable<AbstractMesh>;
  118531. /**
  118532. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118533. * This observable will provide the mesh and the controller used to select the mesh
  118534. */
  118535. onMeshSelectedWithController: Observable<{
  118536. mesh: AbstractMesh;
  118537. controller: WebVRController;
  118538. }>;
  118539. /**
  118540. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118541. */
  118542. onNewMeshPicked: Observable<PickingInfo>;
  118543. private _circleEase;
  118544. /**
  118545. * Observable raised before camera teleportation
  118546. */
  118547. onBeforeCameraTeleport: Observable<Vector3>;
  118548. /**
  118549. * Observable raised after camera teleportation
  118550. */
  118551. onAfterCameraTeleport: Observable<Vector3>;
  118552. /**
  118553. * Observable raised when current selected mesh gets unselected
  118554. */
  118555. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118556. private _raySelectionPredicate;
  118557. /**
  118558. * To be optionaly changed by user to define custom ray selection
  118559. */
  118560. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118561. /**
  118562. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118563. */
  118564. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118565. /**
  118566. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118567. */
  118568. teleportationEnabled: boolean;
  118569. private _defaultHeight;
  118570. private _teleportationInitialized;
  118571. private _interactionsEnabled;
  118572. private _interactionsRequested;
  118573. private _displayGaze;
  118574. private _displayLaserPointer;
  118575. /**
  118576. * The mesh used to display where the user is going to teleport.
  118577. */
  118578. get teleportationTarget(): Mesh;
  118579. /**
  118580. * Sets the mesh to be used to display where the user is going to teleport.
  118581. */
  118582. set teleportationTarget(value: Mesh);
  118583. /**
  118584. * 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
  118585. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118586. * See http://doc.babylonjs.com/resources/baking_transformations
  118587. */
  118588. get gazeTrackerMesh(): Mesh;
  118589. set gazeTrackerMesh(value: Mesh);
  118590. /**
  118591. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118592. */
  118593. updateGazeTrackerScale: boolean;
  118594. /**
  118595. * If the gaze trackers color should be updated when selecting meshes
  118596. */
  118597. updateGazeTrackerColor: boolean;
  118598. /**
  118599. * If the controller laser color should be updated when selecting meshes
  118600. */
  118601. updateControllerLaserColor: boolean;
  118602. /**
  118603. * The gaze tracking mesh corresponding to the left controller
  118604. */
  118605. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118606. /**
  118607. * The gaze tracking mesh corresponding to the right controller
  118608. */
  118609. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118610. /**
  118611. * If the ray of the gaze should be displayed.
  118612. */
  118613. get displayGaze(): boolean;
  118614. /**
  118615. * Sets if the ray of the gaze should be displayed.
  118616. */
  118617. set displayGaze(value: boolean);
  118618. /**
  118619. * If the ray of the LaserPointer should be displayed.
  118620. */
  118621. get displayLaserPointer(): boolean;
  118622. /**
  118623. * Sets if the ray of the LaserPointer should be displayed.
  118624. */
  118625. set displayLaserPointer(value: boolean);
  118626. /**
  118627. * The deviceOrientationCamera used as the camera when not in VR.
  118628. */
  118629. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118630. /**
  118631. * Based on the current WebVR support, returns the current VR camera used.
  118632. */
  118633. get currentVRCamera(): Nullable<Camera>;
  118634. /**
  118635. * The webVRCamera which is used when in VR.
  118636. */
  118637. get webVRCamera(): WebVRFreeCamera;
  118638. /**
  118639. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118640. */
  118641. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118642. /**
  118643. * The html button that is used to trigger entering into VR.
  118644. */
  118645. get vrButton(): Nullable<HTMLButtonElement>;
  118646. private get _teleportationRequestInitiated();
  118647. /**
  118648. * Defines whether or not Pointer lock should be requested when switching to
  118649. * full screen.
  118650. */
  118651. requestPointerLockOnFullScreen: boolean;
  118652. /**
  118653. * If asking to force XR, this will be populated with the default xr experience
  118654. */
  118655. xr: WebXRDefaultExperience;
  118656. /**
  118657. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118658. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118659. */
  118660. xrTestDone: boolean;
  118661. /**
  118662. * Instantiates a VRExperienceHelper.
  118663. * Helps to quickly add VR support to an existing scene.
  118664. * @param scene The scene the VRExperienceHelper belongs to.
  118665. * @param webVROptions Options to modify the vr experience helper's behavior.
  118666. */
  118667. constructor(scene: Scene,
  118668. /** Options to modify the vr experience helper's behavior. */
  118669. webVROptions?: VRExperienceHelperOptions);
  118670. private completeVRInit;
  118671. private _onDefaultMeshLoaded;
  118672. private _onResize;
  118673. private _onFullscreenChange;
  118674. /**
  118675. * Gets a value indicating if we are currently in VR mode.
  118676. */
  118677. get isInVRMode(): boolean;
  118678. private onVrDisplayPresentChange;
  118679. private onVRDisplayChanged;
  118680. private moveButtonToBottomRight;
  118681. private displayVRButton;
  118682. private updateButtonVisibility;
  118683. private _cachedAngularSensibility;
  118684. /**
  118685. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118686. * Otherwise, will use the fullscreen API.
  118687. */
  118688. enterVR(): void;
  118689. /**
  118690. * Attempt to exit VR, or fullscreen.
  118691. */
  118692. exitVR(): void;
  118693. /**
  118694. * The position of the vr experience helper.
  118695. */
  118696. get position(): Vector3;
  118697. /**
  118698. * Sets the position of the vr experience helper.
  118699. */
  118700. set position(value: Vector3);
  118701. /**
  118702. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118703. */
  118704. enableInteractions(): void;
  118705. private get _noControllerIsActive();
  118706. private beforeRender;
  118707. private _isTeleportationFloor;
  118708. /**
  118709. * Adds a floor mesh to be used for teleportation.
  118710. * @param floorMesh the mesh to be used for teleportation.
  118711. */
  118712. addFloorMesh(floorMesh: Mesh): void;
  118713. /**
  118714. * Removes a floor mesh from being used for teleportation.
  118715. * @param floorMesh the mesh to be removed.
  118716. */
  118717. removeFloorMesh(floorMesh: Mesh): void;
  118718. /**
  118719. * Enables interactions and teleportation using the VR controllers and gaze.
  118720. * @param vrTeleportationOptions options to modify teleportation behavior.
  118721. */
  118722. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118723. private _onNewGamepadConnected;
  118724. private _tryEnableInteractionOnController;
  118725. private _onNewGamepadDisconnected;
  118726. private _enableInteractionOnController;
  118727. private _checkTeleportWithRay;
  118728. private _checkRotate;
  118729. private _checkTeleportBackwards;
  118730. private _enableTeleportationOnController;
  118731. private _createTeleportationCircles;
  118732. private _displayTeleportationTarget;
  118733. private _hideTeleportationTarget;
  118734. private _rotateCamera;
  118735. private _moveTeleportationSelectorTo;
  118736. private _workingVector;
  118737. private _workingQuaternion;
  118738. private _workingMatrix;
  118739. /**
  118740. * Time Constant Teleportation Mode
  118741. */
  118742. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118743. /**
  118744. * Speed Constant Teleportation Mode
  118745. */
  118746. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118747. /**
  118748. * Teleports the users feet to the desired location
  118749. * @param location The location where the user's feet should be placed
  118750. */
  118751. teleportCamera(location: Vector3): void;
  118752. private _convertNormalToDirectionOfRay;
  118753. private _castRayAndSelectObject;
  118754. private _notifySelectedMeshUnselected;
  118755. /**
  118756. * Permanently set new colors for the laser pointer
  118757. * @param color the new laser color
  118758. * @param pickedColor the new laser color when picked mesh detected
  118759. */
  118760. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118761. /**
  118762. * Set lighting enabled / disabled on the laser pointer of both controllers
  118763. * @param enabled should the lighting be enabled on the laser pointer
  118764. */
  118765. setLaserLightingState(enabled?: boolean): void;
  118766. /**
  118767. * Permanently set new colors for the gaze pointer
  118768. * @param color the new gaze color
  118769. * @param pickedColor the new gaze color when picked mesh detected
  118770. */
  118771. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118772. /**
  118773. * Sets the color of the laser ray from the vr controllers.
  118774. * @param color new color for the ray.
  118775. */
  118776. changeLaserColor(color: Color3): void;
  118777. /**
  118778. * Sets the color of the ray from the vr headsets gaze.
  118779. * @param color new color for the ray.
  118780. */
  118781. changeGazeColor(color: Color3): void;
  118782. /**
  118783. * Exits VR and disposes of the vr experience helper
  118784. */
  118785. dispose(): void;
  118786. /**
  118787. * Gets the name of the VRExperienceHelper class
  118788. * @returns "VRExperienceHelper"
  118789. */
  118790. getClassName(): string;
  118791. }
  118792. }
  118793. declare module BABYLON {
  118794. /**
  118795. * Contains an array of blocks representing the octree
  118796. */
  118797. export interface IOctreeContainer<T> {
  118798. /**
  118799. * Blocks within the octree
  118800. */
  118801. blocks: Array<OctreeBlock<T>>;
  118802. }
  118803. /**
  118804. * Class used to store a cell in an octree
  118805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118806. */
  118807. export class OctreeBlock<T> {
  118808. /**
  118809. * Gets the content of the current block
  118810. */
  118811. entries: T[];
  118812. /**
  118813. * Gets the list of block children
  118814. */
  118815. blocks: Array<OctreeBlock<T>>;
  118816. private _depth;
  118817. private _maxDepth;
  118818. private _capacity;
  118819. private _minPoint;
  118820. private _maxPoint;
  118821. private _boundingVectors;
  118822. private _creationFunc;
  118823. /**
  118824. * Creates a new block
  118825. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118826. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118827. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118828. * @param depth defines the current depth of this block in the octree
  118829. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118830. * @param creationFunc defines a callback to call when an element is added to the block
  118831. */
  118832. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118833. /**
  118834. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118835. */
  118836. get capacity(): number;
  118837. /**
  118838. * Gets the minimum vector (in world space) of the block's bounding box
  118839. */
  118840. get minPoint(): Vector3;
  118841. /**
  118842. * Gets the maximum vector (in world space) of the block's bounding box
  118843. */
  118844. get maxPoint(): Vector3;
  118845. /**
  118846. * Add a new element to this block
  118847. * @param entry defines the element to add
  118848. */
  118849. addEntry(entry: T): void;
  118850. /**
  118851. * Remove an element from this block
  118852. * @param entry defines the element to remove
  118853. */
  118854. removeEntry(entry: T): void;
  118855. /**
  118856. * Add an array of elements to this block
  118857. * @param entries defines the array of elements to add
  118858. */
  118859. addEntries(entries: T[]): void;
  118860. /**
  118861. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118862. * @param frustumPlanes defines the frustum planes to test
  118863. * @param selection defines the array to store current content if selection is positive
  118864. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118865. */
  118866. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118867. /**
  118868. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118869. * @param sphereCenter defines the bounding sphere center
  118870. * @param sphereRadius defines the bounding sphere radius
  118871. * @param selection defines the array to store current content if selection is positive
  118872. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118873. */
  118874. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118875. /**
  118876. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118877. * @param ray defines the ray to test with
  118878. * @param selection defines the array to store current content if selection is positive
  118879. */
  118880. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118881. /**
  118882. * Subdivide the content into child blocks (this block will then be empty)
  118883. */
  118884. createInnerBlocks(): void;
  118885. /**
  118886. * @hidden
  118887. */
  118888. 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;
  118889. }
  118890. }
  118891. declare module BABYLON {
  118892. /**
  118893. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118894. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118895. */
  118896. export class Octree<T> {
  118897. /** 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.) */
  118898. maxDepth: number;
  118899. /**
  118900. * Blocks within the octree containing objects
  118901. */
  118902. blocks: Array<OctreeBlock<T>>;
  118903. /**
  118904. * Content stored in the octree
  118905. */
  118906. dynamicContent: T[];
  118907. private _maxBlockCapacity;
  118908. private _selectionContent;
  118909. private _creationFunc;
  118910. /**
  118911. * Creates a octree
  118912. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118913. * @param creationFunc function to be used to instatiate the octree
  118914. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118915. * @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.)
  118916. */
  118917. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118918. /** 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.) */
  118919. maxDepth?: number);
  118920. /**
  118921. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118922. * @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);
  118923. * @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);
  118924. * @param entries meshes to be added to the octree blocks
  118925. */
  118926. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118927. /**
  118928. * Adds a mesh to the octree
  118929. * @param entry Mesh to add to the octree
  118930. */
  118931. addMesh(entry: T): void;
  118932. /**
  118933. * Remove an element from the octree
  118934. * @param entry defines the element to remove
  118935. */
  118936. removeMesh(entry: T): void;
  118937. /**
  118938. * Selects an array of meshes within the frustum
  118939. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118940. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118941. * @returns array of meshes within the frustum
  118942. */
  118943. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118944. /**
  118945. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118946. * @param sphereCenter defines the bounding sphere center
  118947. * @param sphereRadius defines the bounding sphere radius
  118948. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118949. * @returns an array of objects that intersect the sphere
  118950. */
  118951. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118952. /**
  118953. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118954. * @param ray defines the ray to test with
  118955. * @returns array of intersected objects
  118956. */
  118957. intersectsRay(ray: Ray): SmartArray<T>;
  118958. /**
  118959. * Adds a mesh into the octree block if it intersects the block
  118960. */
  118961. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118962. /**
  118963. * Adds a submesh into the octree block if it intersects the block
  118964. */
  118965. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118966. }
  118967. }
  118968. declare module BABYLON {
  118969. interface Scene {
  118970. /**
  118971. * @hidden
  118972. * Backing Filed
  118973. */
  118974. _selectionOctree: Octree<AbstractMesh>;
  118975. /**
  118976. * Gets the octree used to boost mesh selection (picking)
  118977. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118978. */
  118979. selectionOctree: Octree<AbstractMesh>;
  118980. /**
  118981. * Creates or updates the octree used to boost selection (picking)
  118982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118983. * @param maxCapacity defines the maximum capacity per leaf
  118984. * @param maxDepth defines the maximum depth of the octree
  118985. * @returns an octree of AbstractMesh
  118986. */
  118987. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118988. }
  118989. interface AbstractMesh {
  118990. /**
  118991. * @hidden
  118992. * Backing Field
  118993. */
  118994. _submeshesOctree: Octree<SubMesh>;
  118995. /**
  118996. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118997. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118998. * @param maxCapacity defines the maximum size of each block (64 by default)
  118999. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119000. * @returns the new octree
  119001. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119003. */
  119004. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119005. }
  119006. /**
  119007. * Defines the octree scene component responsible to manage any octrees
  119008. * in a given scene.
  119009. */
  119010. export class OctreeSceneComponent {
  119011. /**
  119012. * The component name help to identify the component in the list of scene components.
  119013. */
  119014. readonly name: string;
  119015. /**
  119016. * The scene the component belongs to.
  119017. */
  119018. scene: Scene;
  119019. /**
  119020. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119021. */
  119022. readonly checksIsEnabled: boolean;
  119023. /**
  119024. * Creates a new instance of the component for the given scene
  119025. * @param scene Defines the scene to register the component in
  119026. */
  119027. constructor(scene: Scene);
  119028. /**
  119029. * Registers the component in a given scene
  119030. */
  119031. register(): void;
  119032. /**
  119033. * Return the list of active meshes
  119034. * @returns the list of active meshes
  119035. */
  119036. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119037. /**
  119038. * Return the list of active sub meshes
  119039. * @param mesh The mesh to get the candidates sub meshes from
  119040. * @returns the list of active sub meshes
  119041. */
  119042. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119043. private _tempRay;
  119044. /**
  119045. * Return the list of sub meshes intersecting with a given local ray
  119046. * @param mesh defines the mesh to find the submesh for
  119047. * @param localRay defines the ray in local space
  119048. * @returns the list of intersecting sub meshes
  119049. */
  119050. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119051. /**
  119052. * Return the list of sub meshes colliding with a collider
  119053. * @param mesh defines the mesh to find the submesh for
  119054. * @param collider defines the collider to evaluate the collision against
  119055. * @returns the list of colliding sub meshes
  119056. */
  119057. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119058. /**
  119059. * Rebuilds the elements related to this component in case of
  119060. * context lost for instance.
  119061. */
  119062. rebuild(): void;
  119063. /**
  119064. * Disposes the component and the associated ressources.
  119065. */
  119066. dispose(): void;
  119067. }
  119068. }
  119069. declare module BABYLON {
  119070. /**
  119071. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119072. */
  119073. export class Gizmo implements IDisposable {
  119074. /** The utility layer the gizmo will be added to */
  119075. gizmoLayer: UtilityLayerRenderer;
  119076. /**
  119077. * The root mesh of the gizmo
  119078. */
  119079. _rootMesh: Mesh;
  119080. private _attachedMesh;
  119081. /**
  119082. * Ratio for the scale of the gizmo (Default: 1)
  119083. */
  119084. scaleRatio: number;
  119085. /**
  119086. * If a custom mesh has been set (Default: false)
  119087. */
  119088. protected _customMeshSet: boolean;
  119089. /**
  119090. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119091. * * When set, interactions will be enabled
  119092. */
  119093. get attachedMesh(): Nullable<AbstractMesh>;
  119094. set attachedMesh(value: Nullable<AbstractMesh>);
  119095. /**
  119096. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119097. * @param mesh The mesh to replace the default mesh of the gizmo
  119098. */
  119099. setCustomMesh(mesh: Mesh): void;
  119100. /**
  119101. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119102. */
  119103. updateGizmoRotationToMatchAttachedMesh: boolean;
  119104. /**
  119105. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119106. */
  119107. updateGizmoPositionToMatchAttachedMesh: boolean;
  119108. /**
  119109. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119110. */
  119111. updateScale: boolean;
  119112. protected _interactionsEnabled: boolean;
  119113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119114. private _beforeRenderObserver;
  119115. private _tempVector;
  119116. /**
  119117. * Creates a gizmo
  119118. * @param gizmoLayer The utility layer the gizmo will be added to
  119119. */
  119120. constructor(
  119121. /** The utility layer the gizmo will be added to */
  119122. gizmoLayer?: UtilityLayerRenderer);
  119123. /**
  119124. * Updates the gizmo to match the attached mesh's position/rotation
  119125. */
  119126. protected _update(): void;
  119127. /**
  119128. * Disposes of the gizmo
  119129. */
  119130. dispose(): void;
  119131. }
  119132. }
  119133. declare module BABYLON {
  119134. /**
  119135. * Single plane drag gizmo
  119136. */
  119137. export class PlaneDragGizmo extends Gizmo {
  119138. /**
  119139. * Drag behavior responsible for the gizmos dragging interactions
  119140. */
  119141. dragBehavior: PointerDragBehavior;
  119142. private _pointerObserver;
  119143. /**
  119144. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119145. */
  119146. snapDistance: number;
  119147. /**
  119148. * Event that fires each time the gizmo snaps to a new location.
  119149. * * snapDistance is the the change in distance
  119150. */
  119151. onSnapObservable: Observable<{
  119152. snapDistance: number;
  119153. }>;
  119154. private _plane;
  119155. private _coloredMaterial;
  119156. private _hoverMaterial;
  119157. private _isEnabled;
  119158. private _parent;
  119159. /** @hidden */
  119160. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119161. /** @hidden */
  119162. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119163. /**
  119164. * Creates a PlaneDragGizmo
  119165. * @param gizmoLayer The utility layer the gizmo will be added to
  119166. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119167. * @param color The color of the gizmo
  119168. */
  119169. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119171. /**
  119172. * If the gizmo is enabled
  119173. */
  119174. set isEnabled(value: boolean);
  119175. get isEnabled(): boolean;
  119176. /**
  119177. * Disposes of the gizmo
  119178. */
  119179. dispose(): void;
  119180. }
  119181. }
  119182. declare module BABYLON {
  119183. /**
  119184. * Gizmo that enables dragging a mesh along 3 axis
  119185. */
  119186. export class PositionGizmo extends Gizmo {
  119187. /**
  119188. * Internal gizmo used for interactions on the x axis
  119189. */
  119190. xGizmo: AxisDragGizmo;
  119191. /**
  119192. * Internal gizmo used for interactions on the y axis
  119193. */
  119194. yGizmo: AxisDragGizmo;
  119195. /**
  119196. * Internal gizmo used for interactions on the z axis
  119197. */
  119198. zGizmo: AxisDragGizmo;
  119199. /**
  119200. * Internal gizmo used for interactions on the yz plane
  119201. */
  119202. xPlaneGizmo: PlaneDragGizmo;
  119203. /**
  119204. * Internal gizmo used for interactions on the xz plane
  119205. */
  119206. yPlaneGizmo: PlaneDragGizmo;
  119207. /**
  119208. * Internal gizmo used for interactions on the xy plane
  119209. */
  119210. zPlaneGizmo: PlaneDragGizmo;
  119211. /**
  119212. * private variables
  119213. */
  119214. private _meshAttached;
  119215. private _updateGizmoRotationToMatchAttachedMesh;
  119216. private _snapDistance;
  119217. private _scaleRatio;
  119218. /** Fires an event when any of it's sub gizmos are dragged */
  119219. onDragStartObservable: Observable<unknown>;
  119220. /** Fires an event when any of it's sub gizmos are released from dragging */
  119221. onDragEndObservable: Observable<unknown>;
  119222. /**
  119223. * If set to true, planar drag is enabled
  119224. */
  119225. private _planarGizmoEnabled;
  119226. get attachedMesh(): Nullable<AbstractMesh>;
  119227. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119228. /**
  119229. * Creates a PositionGizmo
  119230. * @param gizmoLayer The utility layer the gizmo will be added to
  119231. */
  119232. constructor(gizmoLayer?: UtilityLayerRenderer);
  119233. /**
  119234. * If the planar drag gizmo is enabled
  119235. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119236. */
  119237. set planarGizmoEnabled(value: boolean);
  119238. get planarGizmoEnabled(): boolean;
  119239. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119240. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119241. /**
  119242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119243. */
  119244. set snapDistance(value: number);
  119245. get snapDistance(): number;
  119246. /**
  119247. * Ratio for the scale of the gizmo (Default: 1)
  119248. */
  119249. set scaleRatio(value: number);
  119250. get scaleRatio(): number;
  119251. /**
  119252. * Disposes of the gizmo
  119253. */
  119254. dispose(): void;
  119255. /**
  119256. * CustomMeshes are not supported by this gizmo
  119257. * @param mesh The mesh to replace the default mesh of the gizmo
  119258. */
  119259. setCustomMesh(mesh: Mesh): void;
  119260. }
  119261. }
  119262. declare module BABYLON {
  119263. /**
  119264. * Single axis drag gizmo
  119265. */
  119266. export class AxisDragGizmo extends Gizmo {
  119267. /**
  119268. * Drag behavior responsible for the gizmos dragging interactions
  119269. */
  119270. dragBehavior: PointerDragBehavior;
  119271. private _pointerObserver;
  119272. /**
  119273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119274. */
  119275. snapDistance: number;
  119276. /**
  119277. * Event that fires each time the gizmo snaps to a new location.
  119278. * * snapDistance is the the change in distance
  119279. */
  119280. onSnapObservable: Observable<{
  119281. snapDistance: number;
  119282. }>;
  119283. private _isEnabled;
  119284. private _parent;
  119285. private _arrow;
  119286. private _coloredMaterial;
  119287. private _hoverMaterial;
  119288. /** @hidden */
  119289. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119290. /** @hidden */
  119291. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119292. /**
  119293. * Creates an AxisDragGizmo
  119294. * @param gizmoLayer The utility layer the gizmo will be added to
  119295. * @param dragAxis The axis which the gizmo will be able to drag on
  119296. * @param color The color of the gizmo
  119297. */
  119298. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119299. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119300. /**
  119301. * If the gizmo is enabled
  119302. */
  119303. set isEnabled(value: boolean);
  119304. get isEnabled(): boolean;
  119305. /**
  119306. * Disposes of the gizmo
  119307. */
  119308. dispose(): void;
  119309. }
  119310. }
  119311. declare module BABYLON.Debug {
  119312. /**
  119313. * The Axes viewer will show 3 axes in a specific point in space
  119314. */
  119315. export class AxesViewer {
  119316. private _xAxis;
  119317. private _yAxis;
  119318. private _zAxis;
  119319. private _scaleLinesFactor;
  119320. private _instanced;
  119321. /**
  119322. * Gets the hosting scene
  119323. */
  119324. scene: Scene;
  119325. /**
  119326. * Gets or sets a number used to scale line length
  119327. */
  119328. scaleLines: number;
  119329. /** Gets the node hierarchy used to render x-axis */
  119330. get xAxis(): TransformNode;
  119331. /** Gets the node hierarchy used to render y-axis */
  119332. get yAxis(): TransformNode;
  119333. /** Gets the node hierarchy used to render z-axis */
  119334. get zAxis(): TransformNode;
  119335. /**
  119336. * Creates a new AxesViewer
  119337. * @param scene defines the hosting scene
  119338. * @param scaleLines defines a number used to scale line length (1 by default)
  119339. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119340. * @param xAxis defines the node hierarchy used to render the x-axis
  119341. * @param yAxis defines the node hierarchy used to render the y-axis
  119342. * @param zAxis defines the node hierarchy used to render the z-axis
  119343. */
  119344. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119345. /**
  119346. * Force the viewer to update
  119347. * @param position defines the position of the viewer
  119348. * @param xaxis defines the x axis of the viewer
  119349. * @param yaxis defines the y axis of the viewer
  119350. * @param zaxis defines the z axis of the viewer
  119351. */
  119352. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119353. /**
  119354. * Creates an instance of this axes viewer.
  119355. * @returns a new axes viewer with instanced meshes
  119356. */
  119357. createInstance(): AxesViewer;
  119358. /** Releases resources */
  119359. dispose(): void;
  119360. private static _SetRenderingGroupId;
  119361. }
  119362. }
  119363. declare module BABYLON.Debug {
  119364. /**
  119365. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119366. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119367. */
  119368. export class BoneAxesViewer extends AxesViewer {
  119369. /**
  119370. * Gets or sets the target mesh where to display the axes viewer
  119371. */
  119372. mesh: Nullable<Mesh>;
  119373. /**
  119374. * Gets or sets the target bone where to display the axes viewer
  119375. */
  119376. bone: Nullable<Bone>;
  119377. /** Gets current position */
  119378. pos: Vector3;
  119379. /** Gets direction of X axis */
  119380. xaxis: Vector3;
  119381. /** Gets direction of Y axis */
  119382. yaxis: Vector3;
  119383. /** Gets direction of Z axis */
  119384. zaxis: Vector3;
  119385. /**
  119386. * Creates a new BoneAxesViewer
  119387. * @param scene defines the hosting scene
  119388. * @param bone defines the target bone
  119389. * @param mesh defines the target mesh
  119390. * @param scaleLines defines a scaling factor for line length (1 by default)
  119391. */
  119392. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119393. /**
  119394. * Force the viewer to update
  119395. */
  119396. update(): void;
  119397. /** Releases resources */
  119398. dispose(): void;
  119399. }
  119400. }
  119401. declare module BABYLON {
  119402. /**
  119403. * Interface used to define scene explorer extensibility option
  119404. */
  119405. export interface IExplorerExtensibilityOption {
  119406. /**
  119407. * Define the option label
  119408. */
  119409. label: string;
  119410. /**
  119411. * Defines the action to execute on click
  119412. */
  119413. action: (entity: any) => void;
  119414. }
  119415. /**
  119416. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119417. */
  119418. export interface IExplorerExtensibilityGroup {
  119419. /**
  119420. * Defines a predicate to test if a given type mut be extended
  119421. */
  119422. predicate: (entity: any) => boolean;
  119423. /**
  119424. * Gets the list of options added to a type
  119425. */
  119426. entries: IExplorerExtensibilityOption[];
  119427. }
  119428. /**
  119429. * Interface used to define the options to use to create the Inspector
  119430. */
  119431. export interface IInspectorOptions {
  119432. /**
  119433. * Display in overlay mode (default: false)
  119434. */
  119435. overlay?: boolean;
  119436. /**
  119437. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119438. */
  119439. globalRoot?: HTMLElement;
  119440. /**
  119441. * Display the Scene explorer
  119442. */
  119443. showExplorer?: boolean;
  119444. /**
  119445. * Display the property inspector
  119446. */
  119447. showInspector?: boolean;
  119448. /**
  119449. * Display in embed mode (both panes on the right)
  119450. */
  119451. embedMode?: boolean;
  119452. /**
  119453. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119454. */
  119455. handleResize?: boolean;
  119456. /**
  119457. * Allow the panes to popup (default: true)
  119458. */
  119459. enablePopup?: boolean;
  119460. /**
  119461. * Allow the panes to be closed by users (default: true)
  119462. */
  119463. enableClose?: boolean;
  119464. /**
  119465. * Optional list of extensibility entries
  119466. */
  119467. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119468. /**
  119469. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119470. */
  119471. inspectorURL?: string;
  119472. /**
  119473. * Optional initial tab (default to DebugLayerTab.Properties)
  119474. */
  119475. initialTab?: DebugLayerTab;
  119476. }
  119477. interface Scene {
  119478. /**
  119479. * @hidden
  119480. * Backing field
  119481. */
  119482. _debugLayer: DebugLayer;
  119483. /**
  119484. * Gets the debug layer (aka Inspector) associated with the scene
  119485. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119486. */
  119487. debugLayer: DebugLayer;
  119488. }
  119489. /**
  119490. * Enum of inspector action tab
  119491. */
  119492. export enum DebugLayerTab {
  119493. /**
  119494. * Properties tag (default)
  119495. */
  119496. Properties = 0,
  119497. /**
  119498. * Debug tab
  119499. */
  119500. Debug = 1,
  119501. /**
  119502. * Statistics tab
  119503. */
  119504. Statistics = 2,
  119505. /**
  119506. * Tools tab
  119507. */
  119508. Tools = 3,
  119509. /**
  119510. * Settings tab
  119511. */
  119512. Settings = 4
  119513. }
  119514. /**
  119515. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119516. * what is happening in your scene
  119517. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119518. */
  119519. export class DebugLayer {
  119520. /**
  119521. * Define the url to get the inspector script from.
  119522. * By default it uses the babylonjs CDN.
  119523. * @ignoreNaming
  119524. */
  119525. static InspectorURL: string;
  119526. private _scene;
  119527. private BJSINSPECTOR;
  119528. private _onPropertyChangedObservable?;
  119529. /**
  119530. * Observable triggered when a property is changed through the inspector.
  119531. */
  119532. get onPropertyChangedObservable(): any;
  119533. /**
  119534. * Instantiates a new debug layer.
  119535. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119536. * what is happening in your scene
  119537. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119538. * @param scene Defines the scene to inspect
  119539. */
  119540. constructor(scene: Scene);
  119541. /** Creates the inspector window. */
  119542. private _createInspector;
  119543. /**
  119544. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119545. * @param entity defines the entity to select
  119546. * @param lineContainerTitle defines the specific block to highlight
  119547. */
  119548. select(entity: any, lineContainerTitle?: string): void;
  119549. /** Get the inspector from bundle or global */
  119550. private _getGlobalInspector;
  119551. /**
  119552. * Get if the inspector is visible or not.
  119553. * @returns true if visible otherwise, false
  119554. */
  119555. isVisible(): boolean;
  119556. /**
  119557. * Hide the inspector and close its window.
  119558. */
  119559. hide(): void;
  119560. /**
  119561. * Launch the debugLayer.
  119562. * @param config Define the configuration of the inspector
  119563. * @return a promise fulfilled when the debug layer is visible
  119564. */
  119565. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119566. }
  119567. }
  119568. declare module BABYLON {
  119569. /**
  119570. * Class containing static functions to help procedurally build meshes
  119571. */
  119572. export class BoxBuilder {
  119573. /**
  119574. * Creates a box mesh
  119575. * * The parameter `size` sets the size (float) of each box side (default 1)
  119576. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119577. * * 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)
  119578. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119582. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119583. * @param name defines the name of the mesh
  119584. * @param options defines the options used to create the mesh
  119585. * @param scene defines the hosting scene
  119586. * @returns the box mesh
  119587. */
  119588. static CreateBox(name: string, options: {
  119589. size?: number;
  119590. width?: number;
  119591. height?: number;
  119592. depth?: number;
  119593. faceUV?: Vector4[];
  119594. faceColors?: Color4[];
  119595. sideOrientation?: number;
  119596. frontUVs?: Vector4;
  119597. backUVs?: Vector4;
  119598. wrap?: boolean;
  119599. topBaseAt?: number;
  119600. bottomBaseAt?: number;
  119601. updatable?: boolean;
  119602. }, scene?: Nullable<Scene>): Mesh;
  119603. }
  119604. }
  119605. declare module BABYLON.Debug {
  119606. /**
  119607. * Used to show the physics impostor around the specific mesh
  119608. */
  119609. export class PhysicsViewer {
  119610. /** @hidden */
  119611. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119612. /** @hidden */
  119613. protected _meshes: Array<Nullable<AbstractMesh>>;
  119614. /** @hidden */
  119615. protected _scene: Nullable<Scene>;
  119616. /** @hidden */
  119617. protected _numMeshes: number;
  119618. /** @hidden */
  119619. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119620. private _renderFunction;
  119621. private _utilityLayer;
  119622. private _debugBoxMesh;
  119623. private _debugSphereMesh;
  119624. private _debugCylinderMesh;
  119625. private _debugMaterial;
  119626. private _debugMeshMeshes;
  119627. /**
  119628. * Creates a new PhysicsViewer
  119629. * @param scene defines the hosting scene
  119630. */
  119631. constructor(scene: Scene);
  119632. /** @hidden */
  119633. protected _updateDebugMeshes(): void;
  119634. /**
  119635. * Renders a specified physic impostor
  119636. * @param impostor defines the impostor to render
  119637. * @param targetMesh defines the mesh represented by the impostor
  119638. * @returns the new debug mesh used to render the impostor
  119639. */
  119640. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119641. /**
  119642. * Hides a specified physic impostor
  119643. * @param impostor defines the impostor to hide
  119644. */
  119645. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119646. private _getDebugMaterial;
  119647. private _getDebugBoxMesh;
  119648. private _getDebugSphereMesh;
  119649. private _getDebugCylinderMesh;
  119650. private _getDebugMeshMesh;
  119651. private _getDebugMesh;
  119652. /** Releases all resources */
  119653. dispose(): void;
  119654. }
  119655. }
  119656. declare module BABYLON {
  119657. /**
  119658. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119659. * in order to better appreciate the issue one might have.
  119660. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119661. */
  119662. export class RayHelper {
  119663. /**
  119664. * Defines the ray we are currently tryin to visualize.
  119665. */
  119666. ray: Nullable<Ray>;
  119667. private _renderPoints;
  119668. private _renderLine;
  119669. private _renderFunction;
  119670. private _scene;
  119671. private _updateToMeshFunction;
  119672. private _attachedToMesh;
  119673. private _meshSpaceDirection;
  119674. private _meshSpaceOrigin;
  119675. /**
  119676. * Helper function to create a colored helper in a scene in one line.
  119677. * @param ray Defines the ray we are currently tryin to visualize
  119678. * @param scene Defines the scene the ray is used in
  119679. * @param color Defines the color we want to see the ray in
  119680. * @returns The newly created ray helper.
  119681. */
  119682. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119683. /**
  119684. * Instantiate a new ray helper.
  119685. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119686. * in order to better appreciate the issue one might have.
  119687. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119688. * @param ray Defines the ray we are currently tryin to visualize
  119689. */
  119690. constructor(ray: Ray);
  119691. /**
  119692. * Shows the ray we are willing to debug.
  119693. * @param scene Defines the scene the ray needs to be rendered in
  119694. * @param color Defines the color the ray needs to be rendered in
  119695. */
  119696. show(scene: Scene, color?: Color3): void;
  119697. /**
  119698. * Hides the ray we are debugging.
  119699. */
  119700. hide(): void;
  119701. private _render;
  119702. /**
  119703. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119704. * @param mesh Defines the mesh we want the helper attached to
  119705. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119706. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119707. * @param length Defines the length of the ray
  119708. */
  119709. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119710. /**
  119711. * Detach the ray helper from the mesh it has previously been attached to.
  119712. */
  119713. detachFromMesh(): void;
  119714. private _updateToMesh;
  119715. /**
  119716. * Dispose the helper and release its associated resources.
  119717. */
  119718. dispose(): void;
  119719. }
  119720. }
  119721. declare module BABYLON.Debug {
  119722. /**
  119723. * Class used to render a debug view of a given skeleton
  119724. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119725. */
  119726. export class SkeletonViewer {
  119727. /** defines the skeleton to render */
  119728. skeleton: Skeleton;
  119729. /** defines the mesh attached to the skeleton */
  119730. mesh: AbstractMesh;
  119731. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119732. autoUpdateBonesMatrices: boolean;
  119733. /** defines the rendering group id to use with the viewer */
  119734. renderingGroupId: number;
  119735. /** Gets or sets the color used to render the skeleton */
  119736. color: Color3;
  119737. private _scene;
  119738. private _debugLines;
  119739. private _debugMesh;
  119740. private _isEnabled;
  119741. private _renderFunction;
  119742. private _utilityLayer;
  119743. /**
  119744. * Returns the mesh used to render the bones
  119745. */
  119746. get debugMesh(): Nullable<LinesMesh>;
  119747. /**
  119748. * Creates a new SkeletonViewer
  119749. * @param skeleton defines the skeleton to render
  119750. * @param mesh defines the mesh attached to the skeleton
  119751. * @param scene defines the hosting scene
  119752. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119753. * @param renderingGroupId defines the rendering group id to use with the viewer
  119754. */
  119755. constructor(
  119756. /** defines the skeleton to render */
  119757. skeleton: Skeleton,
  119758. /** defines the mesh attached to the skeleton */
  119759. mesh: AbstractMesh, scene: Scene,
  119760. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119761. autoUpdateBonesMatrices?: boolean,
  119762. /** defines the rendering group id to use with the viewer */
  119763. renderingGroupId?: number);
  119764. /** Gets or sets a boolean indicating if the viewer is enabled */
  119765. set isEnabled(value: boolean);
  119766. get isEnabled(): boolean;
  119767. private _getBonePosition;
  119768. private _getLinesForBonesWithLength;
  119769. private _getLinesForBonesNoLength;
  119770. /** Update the viewer to sync with current skeleton state */
  119771. update(): void;
  119772. /** Release associated resources */
  119773. dispose(): void;
  119774. }
  119775. }
  119776. declare module BABYLON {
  119777. /**
  119778. * Options to create the null engine
  119779. */
  119780. export class NullEngineOptions {
  119781. /**
  119782. * Render width (Default: 512)
  119783. */
  119784. renderWidth: number;
  119785. /**
  119786. * Render height (Default: 256)
  119787. */
  119788. renderHeight: number;
  119789. /**
  119790. * Texture size (Default: 512)
  119791. */
  119792. textureSize: number;
  119793. /**
  119794. * If delta time between frames should be constant
  119795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119796. */
  119797. deterministicLockstep: boolean;
  119798. /**
  119799. * Maximum about of steps between frames (Default: 4)
  119800. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119801. */
  119802. lockstepMaxSteps: number;
  119803. }
  119804. /**
  119805. * The null engine class provides support for headless version of babylon.js.
  119806. * This can be used in server side scenario or for testing purposes
  119807. */
  119808. export class NullEngine extends Engine {
  119809. private _options;
  119810. /**
  119811. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119813. * @returns true if engine is in deterministic lock step mode
  119814. */
  119815. isDeterministicLockStep(): boolean;
  119816. /**
  119817. * Gets the max steps when engine is running in deterministic lock step
  119818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119819. * @returns the max steps
  119820. */
  119821. getLockstepMaxSteps(): number;
  119822. /**
  119823. * Gets the current hardware scaling level.
  119824. * By default the hardware scaling level is computed from the window device ratio.
  119825. * 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.
  119826. * @returns a number indicating the current hardware scaling level
  119827. */
  119828. getHardwareScalingLevel(): number;
  119829. constructor(options?: NullEngineOptions);
  119830. /**
  119831. * Creates a vertex buffer
  119832. * @param vertices the data for the vertex buffer
  119833. * @returns the new WebGL static buffer
  119834. */
  119835. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119836. /**
  119837. * Creates a new index buffer
  119838. * @param indices defines the content of the index buffer
  119839. * @param updatable defines if the index buffer must be updatable
  119840. * @returns a new webGL buffer
  119841. */
  119842. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119843. /**
  119844. * Clear the current render buffer or the current render target (if any is set up)
  119845. * @param color defines the color to use
  119846. * @param backBuffer defines if the back buffer must be cleared
  119847. * @param depth defines if the depth buffer must be cleared
  119848. * @param stencil defines if the stencil buffer must be cleared
  119849. */
  119850. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119851. /**
  119852. * Gets the current render width
  119853. * @param useScreen defines if screen size must be used (or the current render target if any)
  119854. * @returns a number defining the current render width
  119855. */
  119856. getRenderWidth(useScreen?: boolean): number;
  119857. /**
  119858. * Gets the current render height
  119859. * @param useScreen defines if screen size must be used (or the current render target if any)
  119860. * @returns a number defining the current render height
  119861. */
  119862. getRenderHeight(useScreen?: boolean): number;
  119863. /**
  119864. * Set the WebGL's viewport
  119865. * @param viewport defines the viewport element to be used
  119866. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119867. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119868. */
  119869. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119870. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119871. /**
  119872. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119873. * @param pipelineContext defines the pipeline context to use
  119874. * @param uniformsNames defines the list of uniform names
  119875. * @returns an array of webGL uniform locations
  119876. */
  119877. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119878. /**
  119879. * Gets the lsit of active attributes for a given webGL program
  119880. * @param pipelineContext defines the pipeline context to use
  119881. * @param attributesNames defines the list of attribute names to get
  119882. * @returns an array of indices indicating the offset of each attribute
  119883. */
  119884. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119885. /**
  119886. * Binds an effect to the webGL context
  119887. * @param effect defines the effect to bind
  119888. */
  119889. bindSamplers(effect: Effect): void;
  119890. /**
  119891. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119892. * @param effect defines the effect to activate
  119893. */
  119894. enableEffect(effect: Effect): void;
  119895. /**
  119896. * Set various states to the webGL context
  119897. * @param culling defines backface culling state
  119898. * @param zOffset defines the value to apply to zOffset (0 by default)
  119899. * @param force defines if states must be applied even if cache is up to date
  119900. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119901. */
  119902. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119903. /**
  119904. * Set the value of an uniform to an array of int32
  119905. * @param uniform defines the webGL uniform location where to store the value
  119906. * @param array defines the array of int32 to store
  119907. */
  119908. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119909. /**
  119910. * Set the value of an uniform to an array of int32 (stored as vec2)
  119911. * @param uniform defines the webGL uniform location where to store the value
  119912. * @param array defines the array of int32 to store
  119913. */
  119914. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119915. /**
  119916. * Set the value of an uniform to an array of int32 (stored as vec3)
  119917. * @param uniform defines the webGL uniform location where to store the value
  119918. * @param array defines the array of int32 to store
  119919. */
  119920. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119921. /**
  119922. * Set the value of an uniform to an array of int32 (stored as vec4)
  119923. * @param uniform defines the webGL uniform location where to store the value
  119924. * @param array defines the array of int32 to store
  119925. */
  119926. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119927. /**
  119928. * Set the value of an uniform to an array of float32
  119929. * @param uniform defines the webGL uniform location where to store the value
  119930. * @param array defines the array of float32 to store
  119931. */
  119932. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119933. /**
  119934. * Set the value of an uniform to an array of float32 (stored as vec2)
  119935. * @param uniform defines the webGL uniform location where to store the value
  119936. * @param array defines the array of float32 to store
  119937. */
  119938. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119939. /**
  119940. * Set the value of an uniform to an array of float32 (stored as vec3)
  119941. * @param uniform defines the webGL uniform location where to store the value
  119942. * @param array defines the array of float32 to store
  119943. */
  119944. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119945. /**
  119946. * Set the value of an uniform to an array of float32 (stored as vec4)
  119947. * @param uniform defines the webGL uniform location where to store the value
  119948. * @param array defines the array of float32 to store
  119949. */
  119950. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119951. /**
  119952. * Set the value of an uniform to an array of number
  119953. * @param uniform defines the webGL uniform location where to store the value
  119954. * @param array defines the array of number to store
  119955. */
  119956. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119957. /**
  119958. * Set the value of an uniform to an array of number (stored as vec2)
  119959. * @param uniform defines the webGL uniform location where to store the value
  119960. * @param array defines the array of number to store
  119961. */
  119962. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119963. /**
  119964. * Set the value of an uniform to an array of number (stored as vec3)
  119965. * @param uniform defines the webGL uniform location where to store the value
  119966. * @param array defines the array of number to store
  119967. */
  119968. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119969. /**
  119970. * Set the value of an uniform to an array of number (stored as vec4)
  119971. * @param uniform defines the webGL uniform location where to store the value
  119972. * @param array defines the array of number to store
  119973. */
  119974. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119975. /**
  119976. * Set the value of an uniform to an array of float32 (stored as matrices)
  119977. * @param uniform defines the webGL uniform location where to store the value
  119978. * @param matrices defines the array of float32 to store
  119979. */
  119980. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119981. /**
  119982. * Set the value of an uniform to a matrix (3x3)
  119983. * @param uniform defines the webGL uniform location where to store the value
  119984. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119985. */
  119986. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119987. /**
  119988. * Set the value of an uniform to a matrix (2x2)
  119989. * @param uniform defines the webGL uniform location where to store the value
  119990. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119991. */
  119992. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119993. /**
  119994. * Set the value of an uniform to a number (float)
  119995. * @param uniform defines the webGL uniform location where to store the value
  119996. * @param value defines the float number to store
  119997. */
  119998. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119999. /**
  120000. * Set the value of an uniform to a vec2
  120001. * @param uniform defines the webGL uniform location where to store the value
  120002. * @param x defines the 1st component of the value
  120003. * @param y defines the 2nd component of the value
  120004. */
  120005. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120006. /**
  120007. * Set the value of an uniform to a vec3
  120008. * @param uniform defines the webGL uniform location where to store the value
  120009. * @param x defines the 1st component of the value
  120010. * @param y defines the 2nd component of the value
  120011. * @param z defines the 3rd component of the value
  120012. */
  120013. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120014. /**
  120015. * Set the value of an uniform to a boolean
  120016. * @param uniform defines the webGL uniform location where to store the value
  120017. * @param bool defines the boolean to store
  120018. */
  120019. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120020. /**
  120021. * Set the value of an uniform to a vec4
  120022. * @param uniform defines the webGL uniform location where to store the value
  120023. * @param x defines the 1st component of the value
  120024. * @param y defines the 2nd component of the value
  120025. * @param z defines the 3rd component of the value
  120026. * @param w defines the 4th component of the value
  120027. */
  120028. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120029. /**
  120030. * Sets the current alpha mode
  120031. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120032. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120033. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120034. */
  120035. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120036. /**
  120037. * Bind webGl buffers directly to the webGL context
  120038. * @param vertexBuffers defines the vertex buffer to bind
  120039. * @param indexBuffer defines the index buffer to bind
  120040. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120041. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120042. * @param effect defines the effect associated with the vertex buffer
  120043. */
  120044. bindBuffers(vertexBuffers: {
  120045. [key: string]: VertexBuffer;
  120046. }, indexBuffer: DataBuffer, effect: Effect): void;
  120047. /**
  120048. * Force the entire cache to be cleared
  120049. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120050. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120051. */
  120052. wipeCaches(bruteForce?: boolean): void;
  120053. /**
  120054. * Send a draw order
  120055. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120056. * @param indexStart defines the starting index
  120057. * @param indexCount defines the number of index to draw
  120058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120059. */
  120060. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120061. /**
  120062. * Draw a list of indexed primitives
  120063. * @param fillMode defines the primitive to use
  120064. * @param indexStart defines the starting index
  120065. * @param indexCount defines the number of index to draw
  120066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120067. */
  120068. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120069. /**
  120070. * Draw a list of unindexed primitives
  120071. * @param fillMode defines the primitive to use
  120072. * @param verticesStart defines the index of first vertex to draw
  120073. * @param verticesCount defines the count of vertices to draw
  120074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120075. */
  120076. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120077. /** @hidden */
  120078. _createTexture(): WebGLTexture;
  120079. /** @hidden */
  120080. _releaseTexture(texture: InternalTexture): void;
  120081. /**
  120082. * Usually called from Texture.ts.
  120083. * Passed information to create a WebGLTexture
  120084. * @param urlArg defines a value which contains one of the following:
  120085. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120086. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120087. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120088. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120089. * @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)
  120090. * @param scene needed for loading to the correct scene
  120091. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120092. * @param onLoad optional callback to be called upon successful completion
  120093. * @param onError optional callback to be called upon failure
  120094. * @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
  120095. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120096. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120097. * @param forcedExtension defines the extension to use to pick the right loader
  120098. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  120099. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120100. */
  120101. 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;
  120102. /**
  120103. * Creates a new render target texture
  120104. * @param size defines the size of the texture
  120105. * @param options defines the options used to create the texture
  120106. * @returns a new render target texture stored in an InternalTexture
  120107. */
  120108. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120109. /**
  120110. * Update the sampling mode of a given texture
  120111. * @param samplingMode defines the required sampling mode
  120112. * @param texture defines the texture to update
  120113. */
  120114. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120115. /**
  120116. * Binds the frame buffer to the specified texture.
  120117. * @param texture The texture to render to or null for the default canvas
  120118. * @param faceIndex The face of the texture to render to in case of cube texture
  120119. * @param requiredWidth The width of the target to render to
  120120. * @param requiredHeight The height of the target to render to
  120121. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120122. * @param lodLevel defines le lod level to bind to the frame buffer
  120123. */
  120124. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120125. /**
  120126. * Unbind the current render target texture from the webGL context
  120127. * @param texture defines the render target texture to unbind
  120128. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120129. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120130. */
  120131. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120132. /**
  120133. * Creates a dynamic vertex buffer
  120134. * @param vertices the data for the dynamic vertex buffer
  120135. * @returns the new WebGL dynamic buffer
  120136. */
  120137. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120138. /**
  120139. * Update the content of a dynamic texture
  120140. * @param texture defines the texture to update
  120141. * @param canvas defines the canvas containing the source
  120142. * @param invertY defines if data must be stored with Y axis inverted
  120143. * @param premulAlpha defines if alpha is stored as premultiplied
  120144. * @param format defines the format of the data
  120145. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120146. */
  120147. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120148. /**
  120149. * Gets a boolean indicating if all created effects are ready
  120150. * @returns true if all effects are ready
  120151. */
  120152. areAllEffectsReady(): boolean;
  120153. /**
  120154. * @hidden
  120155. * Get the current error code of the webGL context
  120156. * @returns the error code
  120157. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120158. */
  120159. getError(): number;
  120160. /** @hidden */
  120161. _getUnpackAlignement(): number;
  120162. /** @hidden */
  120163. _unpackFlipY(value: boolean): void;
  120164. /**
  120165. * Update a dynamic index buffer
  120166. * @param indexBuffer defines the target index buffer
  120167. * @param indices defines the data to update
  120168. * @param offset defines the offset in the target index buffer where update should start
  120169. */
  120170. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120171. /**
  120172. * Updates a dynamic vertex buffer.
  120173. * @param vertexBuffer the vertex buffer to update
  120174. * @param vertices the data used to update the vertex buffer
  120175. * @param byteOffset the byte offset of the data (optional)
  120176. * @param byteLength the byte length of the data (optional)
  120177. */
  120178. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120179. /** @hidden */
  120180. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120181. /** @hidden */
  120182. _bindTexture(channel: number, texture: InternalTexture): void;
  120183. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120184. /**
  120185. * 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
  120186. */
  120187. releaseEffects(): void;
  120188. displayLoadingUI(): void;
  120189. hideLoadingUI(): void;
  120190. /** @hidden */
  120191. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120192. /** @hidden */
  120193. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120194. /** @hidden */
  120195. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120196. /** @hidden */
  120197. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120198. }
  120199. }
  120200. declare module BABYLON {
  120201. /**
  120202. * @hidden
  120203. **/
  120204. export class _TimeToken {
  120205. _startTimeQuery: Nullable<WebGLQuery>;
  120206. _endTimeQuery: Nullable<WebGLQuery>;
  120207. _timeElapsedQuery: Nullable<WebGLQuery>;
  120208. _timeElapsedQueryEnded: boolean;
  120209. }
  120210. }
  120211. declare module BABYLON {
  120212. /** @hidden */
  120213. export class _OcclusionDataStorage {
  120214. /** @hidden */
  120215. occlusionInternalRetryCounter: number;
  120216. /** @hidden */
  120217. isOcclusionQueryInProgress: boolean;
  120218. /** @hidden */
  120219. isOccluded: boolean;
  120220. /** @hidden */
  120221. occlusionRetryCount: number;
  120222. /** @hidden */
  120223. occlusionType: number;
  120224. /** @hidden */
  120225. occlusionQueryAlgorithmType: number;
  120226. }
  120227. interface Engine {
  120228. /**
  120229. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120230. * @return the new query
  120231. */
  120232. createQuery(): WebGLQuery;
  120233. /**
  120234. * Delete and release a webGL query
  120235. * @param query defines the query to delete
  120236. * @return the current engine
  120237. */
  120238. deleteQuery(query: WebGLQuery): Engine;
  120239. /**
  120240. * Check if a given query has resolved and got its value
  120241. * @param query defines the query to check
  120242. * @returns true if the query got its value
  120243. */
  120244. isQueryResultAvailable(query: WebGLQuery): boolean;
  120245. /**
  120246. * Gets the value of a given query
  120247. * @param query defines the query to check
  120248. * @returns the value of the query
  120249. */
  120250. getQueryResult(query: WebGLQuery): number;
  120251. /**
  120252. * Initiates an occlusion query
  120253. * @param algorithmType defines the algorithm to use
  120254. * @param query defines the query to use
  120255. * @returns the current engine
  120256. * @see http://doc.babylonjs.com/features/occlusionquery
  120257. */
  120258. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120259. /**
  120260. * Ends an occlusion query
  120261. * @see http://doc.babylonjs.com/features/occlusionquery
  120262. * @param algorithmType defines the algorithm to use
  120263. * @returns the current engine
  120264. */
  120265. endOcclusionQuery(algorithmType: number): Engine;
  120266. /**
  120267. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120268. * Please note that only one query can be issued at a time
  120269. * @returns a time token used to track the time span
  120270. */
  120271. startTimeQuery(): Nullable<_TimeToken>;
  120272. /**
  120273. * Ends a time query
  120274. * @param token defines the token used to measure the time span
  120275. * @returns the time spent (in ns)
  120276. */
  120277. endTimeQuery(token: _TimeToken): int;
  120278. /** @hidden */
  120279. _currentNonTimestampToken: Nullable<_TimeToken>;
  120280. /** @hidden */
  120281. _createTimeQuery(): WebGLQuery;
  120282. /** @hidden */
  120283. _deleteTimeQuery(query: WebGLQuery): void;
  120284. /** @hidden */
  120285. _getGlAlgorithmType(algorithmType: number): number;
  120286. /** @hidden */
  120287. _getTimeQueryResult(query: WebGLQuery): any;
  120288. /** @hidden */
  120289. _getTimeQueryAvailability(query: WebGLQuery): any;
  120290. }
  120291. interface AbstractMesh {
  120292. /**
  120293. * Backing filed
  120294. * @hidden
  120295. */
  120296. __occlusionDataStorage: _OcclusionDataStorage;
  120297. /**
  120298. * Access property
  120299. * @hidden
  120300. */
  120301. _occlusionDataStorage: _OcclusionDataStorage;
  120302. /**
  120303. * 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.
  120304. * The default value is -1 which means don't break the query and wait till the result
  120305. * @see http://doc.babylonjs.com/features/occlusionquery
  120306. */
  120307. occlusionRetryCount: number;
  120308. /**
  120309. * 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:
  120310. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120311. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120312. * * 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.
  120313. * @see http://doc.babylonjs.com/features/occlusionquery
  120314. */
  120315. occlusionType: number;
  120316. /**
  120317. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120318. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120319. * * 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.
  120320. * @see http://doc.babylonjs.com/features/occlusionquery
  120321. */
  120322. occlusionQueryAlgorithmType: number;
  120323. /**
  120324. * 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
  120325. * @see http://doc.babylonjs.com/features/occlusionquery
  120326. */
  120327. isOccluded: boolean;
  120328. /**
  120329. * Flag to check the progress status of the query
  120330. * @see http://doc.babylonjs.com/features/occlusionquery
  120331. */
  120332. isOcclusionQueryInProgress: boolean;
  120333. }
  120334. }
  120335. declare module BABYLON {
  120336. /** @hidden */
  120337. export var _forceTransformFeedbackToBundle: boolean;
  120338. interface Engine {
  120339. /**
  120340. * Creates a webGL transform feedback object
  120341. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120342. * @returns the webGL transform feedback object
  120343. */
  120344. createTransformFeedback(): WebGLTransformFeedback;
  120345. /**
  120346. * Delete a webGL transform feedback object
  120347. * @param value defines the webGL transform feedback object to delete
  120348. */
  120349. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120350. /**
  120351. * Bind a webGL transform feedback object to the webgl context
  120352. * @param value defines the webGL transform feedback object to bind
  120353. */
  120354. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120355. /**
  120356. * Begins a transform feedback operation
  120357. * @param usePoints defines if points or triangles must be used
  120358. */
  120359. beginTransformFeedback(usePoints: boolean): void;
  120360. /**
  120361. * Ends a transform feedback operation
  120362. */
  120363. endTransformFeedback(): void;
  120364. /**
  120365. * Specify the varyings to use with transform feedback
  120366. * @param program defines the associated webGL program
  120367. * @param value defines the list of strings representing the varying names
  120368. */
  120369. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120370. /**
  120371. * Bind a webGL buffer for a transform feedback operation
  120372. * @param value defines the webGL buffer to bind
  120373. */
  120374. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120375. }
  120376. }
  120377. declare module BABYLON {
  120378. /**
  120379. * Creation options of the multi render target texture.
  120380. */
  120381. export interface IMultiRenderTargetOptions {
  120382. /**
  120383. * Define if the texture needs to create mip maps after render.
  120384. */
  120385. generateMipMaps?: boolean;
  120386. /**
  120387. * Define the types of all the draw buffers we want to create
  120388. */
  120389. types?: number[];
  120390. /**
  120391. * Define the sampling modes of all the draw buffers we want to create
  120392. */
  120393. samplingModes?: number[];
  120394. /**
  120395. * Define if a depth buffer is required
  120396. */
  120397. generateDepthBuffer?: boolean;
  120398. /**
  120399. * Define if a stencil buffer is required
  120400. */
  120401. generateStencilBuffer?: boolean;
  120402. /**
  120403. * Define if a depth texture is required instead of a depth buffer
  120404. */
  120405. generateDepthTexture?: boolean;
  120406. /**
  120407. * Define the number of desired draw buffers
  120408. */
  120409. textureCount?: number;
  120410. /**
  120411. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120412. */
  120413. doNotChangeAspectRatio?: boolean;
  120414. /**
  120415. * Define the default type of the buffers we are creating
  120416. */
  120417. defaultType?: number;
  120418. }
  120419. /**
  120420. * A multi render target, like a render target provides the ability to render to a texture.
  120421. * Unlike the render target, it can render to several draw buffers in one draw.
  120422. * This is specially interesting in deferred rendering or for any effects requiring more than
  120423. * just one color from a single pass.
  120424. */
  120425. export class MultiRenderTarget extends RenderTargetTexture {
  120426. private _internalTextures;
  120427. private _textures;
  120428. private _multiRenderTargetOptions;
  120429. /**
  120430. * Get if draw buffers are currently supported by the used hardware and browser.
  120431. */
  120432. get isSupported(): boolean;
  120433. /**
  120434. * Get the list of textures generated by the multi render target.
  120435. */
  120436. get textures(): Texture[];
  120437. /**
  120438. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120439. */
  120440. get depthTexture(): Texture;
  120441. /**
  120442. * Set the wrapping mode on U of all the textures we are rendering to.
  120443. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120444. */
  120445. set wrapU(wrap: number);
  120446. /**
  120447. * Set the wrapping mode on V of all the textures we are rendering to.
  120448. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120449. */
  120450. set wrapV(wrap: number);
  120451. /**
  120452. * Instantiate a new multi render target texture.
  120453. * A multi render target, like a render target provides the ability to render to a texture.
  120454. * Unlike the render target, it can render to several draw buffers in one draw.
  120455. * This is specially interesting in deferred rendering or for any effects requiring more than
  120456. * just one color from a single pass.
  120457. * @param name Define the name of the texture
  120458. * @param size Define the size of the buffers to render to
  120459. * @param count Define the number of target we are rendering into
  120460. * @param scene Define the scene the texture belongs to
  120461. * @param options Define the options used to create the multi render target
  120462. */
  120463. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120464. /** @hidden */
  120465. _rebuild(): void;
  120466. private _createInternalTextures;
  120467. private _createTextures;
  120468. /**
  120469. * Define the number of samples used if MSAA is enabled.
  120470. */
  120471. get samples(): number;
  120472. set samples(value: number);
  120473. /**
  120474. * Resize all the textures in the multi render target.
  120475. * Be carrefull as it will recreate all the data in the new texture.
  120476. * @param size Define the new size
  120477. */
  120478. resize(size: any): void;
  120479. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120480. /**
  120481. * Dispose the render targets and their associated resources
  120482. */
  120483. dispose(): void;
  120484. /**
  120485. * Release all the underlying texture used as draw buffers.
  120486. */
  120487. releaseInternalTextures(): void;
  120488. }
  120489. }
  120490. declare module BABYLON {
  120491. interface ThinEngine {
  120492. /**
  120493. * Unbind a list of render target textures from the webGL context
  120494. * This is used only when drawBuffer extension or webGL2 are active
  120495. * @param textures defines the render target textures to unbind
  120496. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120497. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120498. */
  120499. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120500. /**
  120501. * Create a multi render target texture
  120502. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120503. * @param size defines the size of the texture
  120504. * @param options defines the creation options
  120505. * @returns the cube texture as an InternalTexture
  120506. */
  120507. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120508. /**
  120509. * Update the sample count for a given multiple render target texture
  120510. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120511. * @param textures defines the textures to update
  120512. * @param samples defines the sample count to set
  120513. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120514. */
  120515. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120516. }
  120517. }
  120518. declare module BABYLON {
  120519. /**
  120520. * Class used to define an additional view for the engine
  120521. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120522. */
  120523. export class EngineView {
  120524. /** Defines the canvas where to render the view */
  120525. target: HTMLCanvasElement;
  120526. /** Defines an optional camera used to render the view (will use active camera else) */
  120527. camera?: Camera;
  120528. }
  120529. interface Engine {
  120530. /**
  120531. * Gets or sets the HTML element to use for attaching events
  120532. */
  120533. inputElement: Nullable<HTMLElement>;
  120534. /**
  120535. * Gets the current engine view
  120536. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120537. */
  120538. activeView: Nullable<EngineView>;
  120539. /** Gets or sets the list of views */
  120540. views: EngineView[];
  120541. /**
  120542. * Register a new child canvas
  120543. * @param canvas defines the canvas to register
  120544. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120545. * @returns the associated view
  120546. */
  120547. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120548. /**
  120549. * Remove a registered child canvas
  120550. * @param canvas defines the canvas to remove
  120551. * @returns the current engine
  120552. */
  120553. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /**
  120558. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120559. */
  120560. export interface CubeMapInfo {
  120561. /**
  120562. * The pixel array for the front face.
  120563. * This is stored in format, left to right, up to down format.
  120564. */
  120565. front: Nullable<ArrayBufferView>;
  120566. /**
  120567. * The pixel array for the back face.
  120568. * This is stored in format, left to right, up to down format.
  120569. */
  120570. back: Nullable<ArrayBufferView>;
  120571. /**
  120572. * The pixel array for the left face.
  120573. * This is stored in format, left to right, up to down format.
  120574. */
  120575. left: Nullable<ArrayBufferView>;
  120576. /**
  120577. * The pixel array for the right face.
  120578. * This is stored in format, left to right, up to down format.
  120579. */
  120580. right: Nullable<ArrayBufferView>;
  120581. /**
  120582. * The pixel array for the up face.
  120583. * This is stored in format, left to right, up to down format.
  120584. */
  120585. up: Nullable<ArrayBufferView>;
  120586. /**
  120587. * The pixel array for the down face.
  120588. * This is stored in format, left to right, up to down format.
  120589. */
  120590. down: Nullable<ArrayBufferView>;
  120591. /**
  120592. * The size of the cubemap stored.
  120593. *
  120594. * Each faces will be size * size pixels.
  120595. */
  120596. size: number;
  120597. /**
  120598. * The format of the texture.
  120599. *
  120600. * RGBA, RGB.
  120601. */
  120602. format: number;
  120603. /**
  120604. * The type of the texture data.
  120605. *
  120606. * UNSIGNED_INT, FLOAT.
  120607. */
  120608. type: number;
  120609. /**
  120610. * Specifies whether the texture is in gamma space.
  120611. */
  120612. gammaSpace: boolean;
  120613. }
  120614. /**
  120615. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120616. */
  120617. export class PanoramaToCubeMapTools {
  120618. private static FACE_FRONT;
  120619. private static FACE_BACK;
  120620. private static FACE_RIGHT;
  120621. private static FACE_LEFT;
  120622. private static FACE_DOWN;
  120623. private static FACE_UP;
  120624. /**
  120625. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120626. *
  120627. * @param float32Array The source data.
  120628. * @param inputWidth The width of the input panorama.
  120629. * @param inputHeight The height of the input panorama.
  120630. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120631. * @return The cubemap data
  120632. */
  120633. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120634. private static CreateCubemapTexture;
  120635. private static CalcProjectionSpherical;
  120636. }
  120637. }
  120638. declare module BABYLON {
  120639. /**
  120640. * Helper class dealing with the extraction of spherical polynomial dataArray
  120641. * from a cube map.
  120642. */
  120643. export class CubeMapToSphericalPolynomialTools {
  120644. private static FileFaces;
  120645. /**
  120646. * Converts a texture to the according Spherical Polynomial data.
  120647. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120648. *
  120649. * @param texture The texture to extract the information from.
  120650. * @return The Spherical Polynomial data.
  120651. */
  120652. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120653. /**
  120654. * Converts a cubemap to the according Spherical Polynomial data.
  120655. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120656. *
  120657. * @param cubeInfo The Cube map to extract the information from.
  120658. * @return The Spherical Polynomial data.
  120659. */
  120660. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120661. }
  120662. }
  120663. declare module BABYLON {
  120664. interface BaseTexture {
  120665. /**
  120666. * Get the polynomial representation of the texture data.
  120667. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120668. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120669. */
  120670. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /** @hidden */
  120675. export var rgbdEncodePixelShader: {
  120676. name: string;
  120677. shader: string;
  120678. };
  120679. }
  120680. declare module BABYLON {
  120681. /** @hidden */
  120682. export var rgbdDecodePixelShader: {
  120683. name: string;
  120684. shader: string;
  120685. };
  120686. }
  120687. declare module BABYLON {
  120688. /**
  120689. * Raw texture data and descriptor sufficient for WebGL texture upload
  120690. */
  120691. export interface EnvironmentTextureInfo {
  120692. /**
  120693. * Version of the environment map
  120694. */
  120695. version: number;
  120696. /**
  120697. * Width of image
  120698. */
  120699. width: number;
  120700. /**
  120701. * Irradiance information stored in the file.
  120702. */
  120703. irradiance: any;
  120704. /**
  120705. * Specular information stored in the file.
  120706. */
  120707. specular: any;
  120708. }
  120709. /**
  120710. * Defines One Image in the file. It requires only the position in the file
  120711. * as well as the length.
  120712. */
  120713. interface BufferImageData {
  120714. /**
  120715. * Length of the image data.
  120716. */
  120717. length: number;
  120718. /**
  120719. * Position of the data from the null terminator delimiting the end of the JSON.
  120720. */
  120721. position: number;
  120722. }
  120723. /**
  120724. * Defines the specular data enclosed in the file.
  120725. * This corresponds to the version 1 of the data.
  120726. */
  120727. export interface EnvironmentTextureSpecularInfoV1 {
  120728. /**
  120729. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120730. */
  120731. specularDataPosition?: number;
  120732. /**
  120733. * This contains all the images data needed to reconstruct the cubemap.
  120734. */
  120735. mipmaps: Array<BufferImageData>;
  120736. /**
  120737. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120738. */
  120739. lodGenerationScale: number;
  120740. }
  120741. /**
  120742. * Sets of helpers addressing the serialization and deserialization of environment texture
  120743. * stored in a BabylonJS env file.
  120744. * Those files are usually stored as .env files.
  120745. */
  120746. export class EnvironmentTextureTools {
  120747. /**
  120748. * Magic number identifying the env file.
  120749. */
  120750. private static _MagicBytes;
  120751. /**
  120752. * Gets the environment info from an env file.
  120753. * @param data The array buffer containing the .env bytes.
  120754. * @returns the environment file info (the json header) if successfully parsed.
  120755. */
  120756. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120757. /**
  120758. * Creates an environment texture from a loaded cube texture.
  120759. * @param texture defines the cube texture to convert in env file
  120760. * @return a promise containing the environment data if succesfull.
  120761. */
  120762. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120763. /**
  120764. * Creates a JSON representation of the spherical data.
  120765. * @param texture defines the texture containing the polynomials
  120766. * @return the JSON representation of the spherical info
  120767. */
  120768. private static _CreateEnvTextureIrradiance;
  120769. /**
  120770. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120771. * @param data the image data
  120772. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120773. * @return the views described by info providing access to the underlying buffer
  120774. */
  120775. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120776. /**
  120777. * Uploads the texture info contained in the env file to the GPU.
  120778. * @param texture defines the internal texture to upload to
  120779. * @param data defines the data to load
  120780. * @param info defines the texture info retrieved through the GetEnvInfo method
  120781. * @returns a promise
  120782. */
  120783. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120784. private static _OnImageReadyAsync;
  120785. /**
  120786. * Uploads the levels of image data to the GPU.
  120787. * @param texture defines the internal texture to upload to
  120788. * @param imageData defines the array buffer views of image data [mipmap][face]
  120789. * @returns a promise
  120790. */
  120791. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120792. /**
  120793. * Uploads spherical polynomials information to the texture.
  120794. * @param texture defines the texture we are trying to upload the information to
  120795. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120796. */
  120797. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120798. /** @hidden */
  120799. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120800. }
  120801. }
  120802. declare module BABYLON {
  120803. /**
  120804. * Contains position and normal vectors for a vertex
  120805. */
  120806. export class PositionNormalVertex {
  120807. /** the position of the vertex (defaut: 0,0,0) */
  120808. position: Vector3;
  120809. /** the normal of the vertex (defaut: 0,1,0) */
  120810. normal: Vector3;
  120811. /**
  120812. * Creates a PositionNormalVertex
  120813. * @param position the position of the vertex (defaut: 0,0,0)
  120814. * @param normal the normal of the vertex (defaut: 0,1,0)
  120815. */
  120816. constructor(
  120817. /** the position of the vertex (defaut: 0,0,0) */
  120818. position?: Vector3,
  120819. /** the normal of the vertex (defaut: 0,1,0) */
  120820. normal?: Vector3);
  120821. /**
  120822. * Clones the PositionNormalVertex
  120823. * @returns the cloned PositionNormalVertex
  120824. */
  120825. clone(): PositionNormalVertex;
  120826. }
  120827. /**
  120828. * Contains position, normal and uv vectors for a vertex
  120829. */
  120830. export class PositionNormalTextureVertex {
  120831. /** the position of the vertex (defaut: 0,0,0) */
  120832. position: Vector3;
  120833. /** the normal of the vertex (defaut: 0,1,0) */
  120834. normal: Vector3;
  120835. /** the uv of the vertex (default: 0,0) */
  120836. uv: Vector2;
  120837. /**
  120838. * Creates a PositionNormalTextureVertex
  120839. * @param position the position of the vertex (defaut: 0,0,0)
  120840. * @param normal the normal of the vertex (defaut: 0,1,0)
  120841. * @param uv the uv of the vertex (default: 0,0)
  120842. */
  120843. constructor(
  120844. /** the position of the vertex (defaut: 0,0,0) */
  120845. position?: Vector3,
  120846. /** the normal of the vertex (defaut: 0,1,0) */
  120847. normal?: Vector3,
  120848. /** the uv of the vertex (default: 0,0) */
  120849. uv?: Vector2);
  120850. /**
  120851. * Clones the PositionNormalTextureVertex
  120852. * @returns the cloned PositionNormalTextureVertex
  120853. */
  120854. clone(): PositionNormalTextureVertex;
  120855. }
  120856. }
  120857. declare module BABYLON {
  120858. /** @hidden */
  120859. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120860. private _genericAttributeLocation;
  120861. private _varyingLocationCount;
  120862. private _varyingLocationMap;
  120863. private _replacements;
  120864. private _textureCount;
  120865. private _uniforms;
  120866. lineProcessor(line: string): string;
  120867. attributeProcessor(attribute: string): string;
  120868. varyingProcessor(varying: string, isFragment: boolean): string;
  120869. uniformProcessor(uniform: string): string;
  120870. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120871. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120872. }
  120873. }
  120874. declare module BABYLON {
  120875. /**
  120876. * Container for accessors for natively-stored mesh data buffers.
  120877. */
  120878. class NativeDataBuffer extends DataBuffer {
  120879. /**
  120880. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120881. */
  120882. nativeIndexBuffer?: any;
  120883. /**
  120884. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120885. */
  120886. nativeVertexBuffer?: any;
  120887. }
  120888. /** @hidden */
  120889. class NativeTexture extends InternalTexture {
  120890. getInternalTexture(): InternalTexture;
  120891. getViewCount(): number;
  120892. }
  120893. /** @hidden */
  120894. export class NativeEngine extends Engine {
  120895. private readonly _native;
  120896. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120897. private readonly INVALID_HANDLE;
  120898. getHardwareScalingLevel(): number;
  120899. constructor();
  120900. /**
  120901. * Can be used to override the current requestAnimationFrame requester.
  120902. * @hidden
  120903. */
  120904. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120905. /**
  120906. * Override default engine behavior.
  120907. * @param color
  120908. * @param backBuffer
  120909. * @param depth
  120910. * @param stencil
  120911. */
  120912. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120913. /**
  120914. * Gets host document
  120915. * @returns the host document object
  120916. */
  120917. getHostDocument(): Nullable<Document>;
  120918. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120919. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120920. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120921. recordVertexArrayObject(vertexBuffers: {
  120922. [key: string]: VertexBuffer;
  120923. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120924. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120925. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120926. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120927. /**
  120928. * Draw a list of indexed primitives
  120929. * @param fillMode defines the primitive to use
  120930. * @param indexStart defines the starting index
  120931. * @param indexCount defines the number of index to draw
  120932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120933. */
  120934. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120935. /**
  120936. * Draw a list of unindexed primitives
  120937. * @param fillMode defines the primitive to use
  120938. * @param verticesStart defines the index of first vertex to draw
  120939. * @param verticesCount defines the count of vertices to draw
  120940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120941. */
  120942. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120943. createPipelineContext(): IPipelineContext;
  120944. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120945. /** @hidden */
  120946. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120947. /** @hidden */
  120948. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120949. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120951. protected _setProgram(program: WebGLProgram): void;
  120952. _releaseEffect(effect: Effect): void;
  120953. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120954. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120955. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120956. bindSamplers(effect: Effect): void;
  120957. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120958. getRenderWidth(useScreen?: boolean): number;
  120959. getRenderHeight(useScreen?: boolean): number;
  120960. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120961. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120962. /**
  120963. * Set the z offset to apply to current rendering
  120964. * @param value defines the offset to apply
  120965. */
  120966. setZOffset(value: number): void;
  120967. /**
  120968. * Gets the current value of the zOffset
  120969. * @returns the current zOffset state
  120970. */
  120971. getZOffset(): number;
  120972. /**
  120973. * Enable or disable depth buffering
  120974. * @param enable defines the state to set
  120975. */
  120976. setDepthBuffer(enable: boolean): void;
  120977. /**
  120978. * Gets a boolean indicating if depth writing is enabled
  120979. * @returns the current depth writing state
  120980. */
  120981. getDepthWrite(): boolean;
  120982. /**
  120983. * Enable or disable depth writing
  120984. * @param enable defines the state to set
  120985. */
  120986. setDepthWrite(enable: boolean): void;
  120987. /**
  120988. * Enable or disable color writing
  120989. * @param enable defines the state to set
  120990. */
  120991. setColorWrite(enable: boolean): void;
  120992. /**
  120993. * Gets a boolean indicating if color writing is enabled
  120994. * @returns the current color writing state
  120995. */
  120996. getColorWrite(): boolean;
  120997. /**
  120998. * Sets alpha constants used by some alpha blending modes
  120999. * @param r defines the red component
  121000. * @param g defines the green component
  121001. * @param b defines the blue component
  121002. * @param a defines the alpha component
  121003. */
  121004. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121005. /**
  121006. * Sets the current alpha mode
  121007. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121008. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121009. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121010. */
  121011. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121012. /**
  121013. * Gets the current alpha mode
  121014. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121015. * @returns the current alpha mode
  121016. */
  121017. getAlphaMode(): number;
  121018. setInt(uniform: WebGLUniformLocation, int: number): void;
  121019. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121020. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121021. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121022. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121023. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121024. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121025. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121026. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121027. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121028. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121029. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121030. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121031. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121032. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121033. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121034. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121035. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121036. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121037. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121038. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121039. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121040. wipeCaches(bruteForce?: boolean): void;
  121041. _createTexture(): WebGLTexture;
  121042. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121043. /**
  121044. * Usually called from BABYLON.Texture.ts.
  121045. * Passed information to create a WebGLTexture
  121046. * @param urlArg defines a value which contains one of the following:
  121047. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121048. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121049. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121050. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121051. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  121052. * @param scene needed for loading to the correct scene
  121053. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  121054. * @param onLoad optional callback to be called upon successful completion
  121055. * @param onError optional callback to be called upon failure
  121056. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  121057. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121058. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121059. * @param forcedExtension defines the extension to use to pick the right loader
  121060. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121061. */
  121062. 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;
  121063. /**
  121064. * Creates a cube texture
  121065. * @param rootUrl defines the url where the files to load is located
  121066. * @param scene defines the current scene
  121067. * @param files defines the list of files to load (1 per face)
  121068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121069. * @param onLoad defines an optional callback raised when the texture is loaded
  121070. * @param onError defines an optional callback raised if there is an issue to load the texture
  121071. * @param format defines the format of the data
  121072. * @param forcedExtension defines the extension to use to pick the right loader
  121073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121076. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121077. * @returns the cube texture as an InternalTexture
  121078. */
  121079. 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;
  121080. private _getSamplingFilter;
  121081. private static _GetNativeTextureFormat;
  121082. createRenderTargetTexture(size: number | {
  121083. width: number;
  121084. height: number;
  121085. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121087. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121089. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121090. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121091. /**
  121092. * Updates a dynamic vertex buffer.
  121093. * @param vertexBuffer the vertex buffer to update
  121094. * @param data the data used to update the vertex buffer
  121095. * @param byteOffset the byte offset of the data (optional)
  121096. * @param byteLength the byte length of the data (optional)
  121097. */
  121098. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121099. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121100. private _updateAnisotropicLevel;
  121101. private _getAddressMode;
  121102. /** @hidden */
  121103. _bindTexture(channel: number, texture: InternalTexture): void;
  121104. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121105. releaseEffects(): void;
  121106. /** @hidden */
  121107. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121108. /** @hidden */
  121109. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121110. /** @hidden */
  121111. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121112. /** @hidden */
  121113. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121114. }
  121115. }
  121116. declare module BABYLON {
  121117. /**
  121118. * Gather the list of clipboard event types as constants.
  121119. */
  121120. export class ClipboardEventTypes {
  121121. /**
  121122. * The clipboard event is fired when a copy command is active (pressed).
  121123. */
  121124. static readonly COPY: number;
  121125. /**
  121126. * The clipboard event is fired when a cut command is active (pressed).
  121127. */
  121128. static readonly CUT: number;
  121129. /**
  121130. * The clipboard event is fired when a paste command is active (pressed).
  121131. */
  121132. static readonly PASTE: number;
  121133. }
  121134. /**
  121135. * This class is used to store clipboard related info for the onClipboardObservable event.
  121136. */
  121137. export class ClipboardInfo {
  121138. /**
  121139. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121140. */
  121141. type: number;
  121142. /**
  121143. * Defines the related dom event
  121144. */
  121145. event: ClipboardEvent;
  121146. /**
  121147. *Creates an instance of ClipboardInfo.
  121148. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121149. * @param event Defines the related dom event
  121150. */
  121151. constructor(
  121152. /**
  121153. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121154. */
  121155. type: number,
  121156. /**
  121157. * Defines the related dom event
  121158. */
  121159. event: ClipboardEvent);
  121160. /**
  121161. * Get the clipboard event's type from the keycode.
  121162. * @param keyCode Defines the keyCode for the current keyboard event.
  121163. * @return {number}
  121164. */
  121165. static GetTypeFromCharacter(keyCode: number): number;
  121166. }
  121167. }
  121168. declare module BABYLON {
  121169. /**
  121170. * Google Daydream controller
  121171. */
  121172. export class DaydreamController extends WebVRController {
  121173. /**
  121174. * Base Url for the controller model.
  121175. */
  121176. static MODEL_BASE_URL: string;
  121177. /**
  121178. * File name for the controller model.
  121179. */
  121180. static MODEL_FILENAME: string;
  121181. /**
  121182. * Gamepad Id prefix used to identify Daydream Controller.
  121183. */
  121184. static readonly GAMEPAD_ID_PREFIX: string;
  121185. /**
  121186. * Creates a new DaydreamController from a gamepad
  121187. * @param vrGamepad the gamepad that the controller should be created from
  121188. */
  121189. constructor(vrGamepad: any);
  121190. /**
  121191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121192. * @param scene scene in which to add meshes
  121193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121194. */
  121195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121196. /**
  121197. * Called once for each button that changed state since the last frame
  121198. * @param buttonIdx Which button index changed
  121199. * @param state New state of the button
  121200. * @param changes Which properties on the state changed since last frame
  121201. */
  121202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * Gear VR Controller
  121208. */
  121209. export class GearVRController extends WebVRController {
  121210. /**
  121211. * Base Url for the controller model.
  121212. */
  121213. static MODEL_BASE_URL: string;
  121214. /**
  121215. * File name for the controller model.
  121216. */
  121217. static MODEL_FILENAME: string;
  121218. /**
  121219. * Gamepad Id prefix used to identify this controller.
  121220. */
  121221. static readonly GAMEPAD_ID_PREFIX: string;
  121222. private readonly _buttonIndexToObservableNameMap;
  121223. /**
  121224. * Creates a new GearVRController from a gamepad
  121225. * @param vrGamepad the gamepad that the controller should be created from
  121226. */
  121227. constructor(vrGamepad: any);
  121228. /**
  121229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121230. * @param scene scene in which to add meshes
  121231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121232. */
  121233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121234. /**
  121235. * Called once for each button that changed state since the last frame
  121236. * @param buttonIdx Which button index changed
  121237. * @param state New state of the button
  121238. * @param changes Which properties on the state changed since last frame
  121239. */
  121240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121241. }
  121242. }
  121243. declare module BABYLON {
  121244. /**
  121245. * Generic Controller
  121246. */
  121247. export class GenericController extends WebVRController {
  121248. /**
  121249. * Base Url for the controller model.
  121250. */
  121251. static readonly MODEL_BASE_URL: string;
  121252. /**
  121253. * File name for the controller model.
  121254. */
  121255. static readonly MODEL_FILENAME: string;
  121256. /**
  121257. * Creates a new GenericController from a gamepad
  121258. * @param vrGamepad the gamepad that the controller should be created from
  121259. */
  121260. constructor(vrGamepad: any);
  121261. /**
  121262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121263. * @param scene scene in which to add meshes
  121264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121265. */
  121266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121267. /**
  121268. * Called once for each button that changed state since the last frame
  121269. * @param buttonIdx Which button index changed
  121270. * @param state New state of the button
  121271. * @param changes Which properties on the state changed since last frame
  121272. */
  121273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121274. }
  121275. }
  121276. declare module BABYLON {
  121277. /**
  121278. * Oculus Touch Controller
  121279. */
  121280. export class OculusTouchController extends WebVRController {
  121281. /**
  121282. * Base Url for the controller model.
  121283. */
  121284. static MODEL_BASE_URL: string;
  121285. /**
  121286. * File name for the left controller model.
  121287. */
  121288. static MODEL_LEFT_FILENAME: string;
  121289. /**
  121290. * File name for the right controller model.
  121291. */
  121292. static MODEL_RIGHT_FILENAME: string;
  121293. /**
  121294. * Base Url for the Quest controller model.
  121295. */
  121296. static QUEST_MODEL_BASE_URL: string;
  121297. /**
  121298. * @hidden
  121299. * If the controllers are running on a device that needs the updated Quest controller models
  121300. */
  121301. static _IsQuest: boolean;
  121302. /**
  121303. * Fired when the secondary trigger on this controller is modified
  121304. */
  121305. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121306. /**
  121307. * Fired when the thumb rest on this controller is modified
  121308. */
  121309. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121310. /**
  121311. * Creates a new OculusTouchController from a gamepad
  121312. * @param vrGamepad the gamepad that the controller should be created from
  121313. */
  121314. constructor(vrGamepad: any);
  121315. /**
  121316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121317. * @param scene scene in which to add meshes
  121318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121319. */
  121320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121321. /**
  121322. * Fired when the A button on this controller is modified
  121323. */
  121324. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121325. /**
  121326. * Fired when the B button on this controller is modified
  121327. */
  121328. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121329. /**
  121330. * Fired when the X button on this controller is modified
  121331. */
  121332. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121333. /**
  121334. * Fired when the Y button on this controller is modified
  121335. */
  121336. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121337. /**
  121338. * Called once for each button that changed state since the last frame
  121339. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121340. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121341. * 2) secondary trigger (same)
  121342. * 3) A (right) X (left), touch, pressed = value
  121343. * 4) B / Y
  121344. * 5) thumb rest
  121345. * @param buttonIdx Which button index changed
  121346. * @param state New state of the button
  121347. * @param changes Which properties on the state changed since last frame
  121348. */
  121349. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121350. }
  121351. }
  121352. declare module BABYLON {
  121353. /**
  121354. * Vive Controller
  121355. */
  121356. export class ViveController extends WebVRController {
  121357. /**
  121358. * Base Url for the controller model.
  121359. */
  121360. static MODEL_BASE_URL: string;
  121361. /**
  121362. * File name for the controller model.
  121363. */
  121364. static MODEL_FILENAME: string;
  121365. /**
  121366. * Creates a new ViveController from a gamepad
  121367. * @param vrGamepad the gamepad that the controller should be created from
  121368. */
  121369. constructor(vrGamepad: any);
  121370. /**
  121371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121372. * @param scene scene in which to add meshes
  121373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121374. */
  121375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121376. /**
  121377. * Fired when the left button on this controller is modified
  121378. */
  121379. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121380. /**
  121381. * Fired when the right button on this controller is modified
  121382. */
  121383. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121384. /**
  121385. * Fired when the menu button on this controller is modified
  121386. */
  121387. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121388. /**
  121389. * Called once for each button that changed state since the last frame
  121390. * Vive mapping:
  121391. * 0: touchpad
  121392. * 1: trigger
  121393. * 2: left AND right buttons
  121394. * 3: menu button
  121395. * @param buttonIdx Which button index changed
  121396. * @param state New state of the button
  121397. * @param changes Which properties on the state changed since last frame
  121398. */
  121399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /**
  121404. * Defines the WindowsMotionController object that the state of the windows motion controller
  121405. */
  121406. export class WindowsMotionController extends WebVRController {
  121407. /**
  121408. * The base url used to load the left and right controller models
  121409. */
  121410. static MODEL_BASE_URL: string;
  121411. /**
  121412. * The name of the left controller model file
  121413. */
  121414. static MODEL_LEFT_FILENAME: string;
  121415. /**
  121416. * The name of the right controller model file
  121417. */
  121418. static MODEL_RIGHT_FILENAME: string;
  121419. /**
  121420. * The controller name prefix for this controller type
  121421. */
  121422. static readonly GAMEPAD_ID_PREFIX: string;
  121423. /**
  121424. * The controller id pattern for this controller type
  121425. */
  121426. private static readonly GAMEPAD_ID_PATTERN;
  121427. private _loadedMeshInfo;
  121428. protected readonly _mapping: {
  121429. buttons: string[];
  121430. buttonMeshNames: {
  121431. 'trigger': string;
  121432. 'menu': string;
  121433. 'grip': string;
  121434. 'thumbstick': string;
  121435. 'trackpad': string;
  121436. };
  121437. buttonObservableNames: {
  121438. 'trigger': string;
  121439. 'menu': string;
  121440. 'grip': string;
  121441. 'thumbstick': string;
  121442. 'trackpad': string;
  121443. };
  121444. axisMeshNames: string[];
  121445. pointingPoseMeshName: string;
  121446. };
  121447. /**
  121448. * Fired when the trackpad on this controller is clicked
  121449. */
  121450. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121451. /**
  121452. * Fired when the trackpad on this controller is modified
  121453. */
  121454. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121455. /**
  121456. * The current x and y values of this controller's trackpad
  121457. */
  121458. trackpad: StickValues;
  121459. /**
  121460. * Creates a new WindowsMotionController from a gamepad
  121461. * @param vrGamepad the gamepad that the controller should be created from
  121462. */
  121463. constructor(vrGamepad: any);
  121464. /**
  121465. * Fired when the trigger on this controller is modified
  121466. */
  121467. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121468. /**
  121469. * Fired when the menu button on this controller is modified
  121470. */
  121471. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121472. /**
  121473. * Fired when the grip button on this controller is modified
  121474. */
  121475. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121476. /**
  121477. * Fired when the thumbstick button on this controller is modified
  121478. */
  121479. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121480. /**
  121481. * Fired when the touchpad button on this controller is modified
  121482. */
  121483. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121484. /**
  121485. * Fired when the touchpad values on this controller are modified
  121486. */
  121487. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121488. protected _updateTrackpad(): void;
  121489. /**
  121490. * Called once per frame by the engine.
  121491. */
  121492. update(): void;
  121493. /**
  121494. * Called once for each button that changed state since the last frame
  121495. * @param buttonIdx Which button index changed
  121496. * @param state New state of the button
  121497. * @param changes Which properties on the state changed since last frame
  121498. */
  121499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121500. /**
  121501. * Moves the buttons on the controller mesh based on their current state
  121502. * @param buttonName the name of the button to move
  121503. * @param buttonValue the value of the button which determines the buttons new position
  121504. */
  121505. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121506. /**
  121507. * Moves the axis on the controller mesh based on its current state
  121508. * @param axis the index of the axis
  121509. * @param axisValue the value of the axis which determines the meshes new position
  121510. * @hidden
  121511. */
  121512. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121513. /**
  121514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121515. * @param scene scene in which to add meshes
  121516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121517. */
  121518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121519. /**
  121520. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121521. * can be transformed by button presses and axes values, based on this._mapping.
  121522. *
  121523. * @param scene scene in which the meshes exist
  121524. * @param meshes list of meshes that make up the controller model to process
  121525. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121526. */
  121527. private processModel;
  121528. private createMeshInfo;
  121529. /**
  121530. * Gets the ray of the controller in the direction the controller is pointing
  121531. * @param length the length the resulting ray should be
  121532. * @returns a ray in the direction the controller is pointing
  121533. */
  121534. getForwardRay(length?: number): Ray;
  121535. /**
  121536. * Disposes of the controller
  121537. */
  121538. dispose(): void;
  121539. }
  121540. /**
  121541. * This class represents a new windows motion controller in XR.
  121542. */
  121543. export class XRWindowsMotionController extends WindowsMotionController {
  121544. /**
  121545. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121546. */
  121547. protected readonly _mapping: {
  121548. buttons: string[];
  121549. buttonMeshNames: {
  121550. 'trigger': string;
  121551. 'menu': string;
  121552. 'grip': string;
  121553. 'thumbstick': string;
  121554. 'trackpad': string;
  121555. };
  121556. buttonObservableNames: {
  121557. 'trigger': string;
  121558. 'menu': string;
  121559. 'grip': string;
  121560. 'thumbstick': string;
  121561. 'trackpad': string;
  121562. };
  121563. axisMeshNames: string[];
  121564. pointingPoseMeshName: string;
  121565. };
  121566. /**
  121567. * Construct a new XR-Based windows motion controller
  121568. *
  121569. * @param gamepadInfo the gamepad object from the browser
  121570. */
  121571. constructor(gamepadInfo: any);
  121572. /**
  121573. * holds the thumbstick values (X,Y)
  121574. */
  121575. thumbstickValues: StickValues;
  121576. /**
  121577. * Fired when the thumbstick on this controller is clicked
  121578. */
  121579. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121580. /**
  121581. * Fired when the thumbstick on this controller is modified
  121582. */
  121583. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121584. /**
  121585. * Fired when the touchpad button on this controller is modified
  121586. */
  121587. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121588. /**
  121589. * Fired when the touchpad values on this controller are modified
  121590. */
  121591. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121592. /**
  121593. * Fired when the thumbstick button on this controller is modified
  121594. * here to prevent breaking changes
  121595. */
  121596. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121597. /**
  121598. * updating the thumbstick(!) and not the trackpad.
  121599. * This is named this way due to the difference between WebVR and XR and to avoid
  121600. * changing the parent class.
  121601. */
  121602. protected _updateTrackpad(): void;
  121603. /**
  121604. * Disposes the class with joy
  121605. */
  121606. dispose(): void;
  121607. }
  121608. }
  121609. declare module BABYLON {
  121610. /**
  121611. * Class containing static functions to help procedurally build meshes
  121612. */
  121613. export class PolyhedronBuilder {
  121614. /**
  121615. * Creates a polyhedron mesh
  121616. * * 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
  121617. * * The parameter `size` (positive float, default 1) sets the polygon size
  121618. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121619. * * 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`
  121620. * * 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
  121621. * * 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)`)
  121622. * * 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
  121623. * * 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
  121624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121627. * @param name defines the name of the mesh
  121628. * @param options defines the options used to create the mesh
  121629. * @param scene defines the hosting scene
  121630. * @returns the polyhedron mesh
  121631. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121632. */
  121633. static CreatePolyhedron(name: string, options: {
  121634. type?: number;
  121635. size?: number;
  121636. sizeX?: number;
  121637. sizeY?: number;
  121638. sizeZ?: number;
  121639. custom?: any;
  121640. faceUV?: Vector4[];
  121641. faceColors?: Color4[];
  121642. flat?: boolean;
  121643. updatable?: boolean;
  121644. sideOrientation?: number;
  121645. frontUVs?: Vector4;
  121646. backUVs?: Vector4;
  121647. }, scene?: Nullable<Scene>): Mesh;
  121648. }
  121649. }
  121650. declare module BABYLON {
  121651. /**
  121652. * Gizmo that enables scaling a mesh along 3 axis
  121653. */
  121654. export class ScaleGizmo extends Gizmo {
  121655. /**
  121656. * Internal gizmo used for interactions on the x axis
  121657. */
  121658. xGizmo: AxisScaleGizmo;
  121659. /**
  121660. * Internal gizmo used for interactions on the y axis
  121661. */
  121662. yGizmo: AxisScaleGizmo;
  121663. /**
  121664. * Internal gizmo used for interactions on the z axis
  121665. */
  121666. zGizmo: AxisScaleGizmo;
  121667. /**
  121668. * Internal gizmo used to scale all axis equally
  121669. */
  121670. uniformScaleGizmo: AxisScaleGizmo;
  121671. private _meshAttached;
  121672. private _updateGizmoRotationToMatchAttachedMesh;
  121673. private _snapDistance;
  121674. private _scaleRatio;
  121675. private _uniformScalingMesh;
  121676. private _octahedron;
  121677. private _sensitivity;
  121678. /** Fires an event when any of it's sub gizmos are dragged */
  121679. onDragStartObservable: Observable<unknown>;
  121680. /** Fires an event when any of it's sub gizmos are released from dragging */
  121681. onDragEndObservable: Observable<unknown>;
  121682. get attachedMesh(): Nullable<AbstractMesh>;
  121683. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121684. /**
  121685. * Creates a ScaleGizmo
  121686. * @param gizmoLayer The utility layer the gizmo will be added to
  121687. */
  121688. constructor(gizmoLayer?: UtilityLayerRenderer);
  121689. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121690. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121691. /**
  121692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121693. */
  121694. set snapDistance(value: number);
  121695. get snapDistance(): number;
  121696. /**
  121697. * Ratio for the scale of the gizmo (Default: 1)
  121698. */
  121699. set scaleRatio(value: number);
  121700. get scaleRatio(): number;
  121701. /**
  121702. * Sensitivity factor for dragging (Default: 1)
  121703. */
  121704. set sensitivity(value: number);
  121705. get sensitivity(): number;
  121706. /**
  121707. * Disposes of the gizmo
  121708. */
  121709. dispose(): void;
  121710. }
  121711. }
  121712. declare module BABYLON {
  121713. /**
  121714. * Single axis scale gizmo
  121715. */
  121716. export class AxisScaleGizmo extends Gizmo {
  121717. /**
  121718. * Drag behavior responsible for the gizmos dragging interactions
  121719. */
  121720. dragBehavior: PointerDragBehavior;
  121721. private _pointerObserver;
  121722. /**
  121723. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121724. */
  121725. snapDistance: number;
  121726. /**
  121727. * Event that fires each time the gizmo snaps to a new location.
  121728. * * snapDistance is the the change in distance
  121729. */
  121730. onSnapObservable: Observable<{
  121731. snapDistance: number;
  121732. }>;
  121733. /**
  121734. * If the scaling operation should be done on all axis (default: false)
  121735. */
  121736. uniformScaling: boolean;
  121737. /**
  121738. * Custom sensitivity value for the drag strength
  121739. */
  121740. sensitivity: number;
  121741. private _isEnabled;
  121742. private _parent;
  121743. private _arrow;
  121744. private _coloredMaterial;
  121745. private _hoverMaterial;
  121746. /**
  121747. * Creates an AxisScaleGizmo
  121748. * @param gizmoLayer The utility layer the gizmo will be added to
  121749. * @param dragAxis The axis which the gizmo will be able to scale on
  121750. * @param color The color of the gizmo
  121751. */
  121752. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121753. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121754. /**
  121755. * If the gizmo is enabled
  121756. */
  121757. set isEnabled(value: boolean);
  121758. get isEnabled(): boolean;
  121759. /**
  121760. * Disposes of the gizmo
  121761. */
  121762. dispose(): void;
  121763. /**
  121764. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121765. * @param mesh The mesh to replace the default mesh of the gizmo
  121766. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121767. */
  121768. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121769. }
  121770. }
  121771. declare module BABYLON {
  121772. /**
  121773. * Bounding box gizmo
  121774. */
  121775. export class BoundingBoxGizmo extends Gizmo {
  121776. private _lineBoundingBox;
  121777. private _rotateSpheresParent;
  121778. private _scaleBoxesParent;
  121779. private _boundingDimensions;
  121780. private _renderObserver;
  121781. private _pointerObserver;
  121782. private _scaleDragSpeed;
  121783. private _tmpQuaternion;
  121784. private _tmpVector;
  121785. private _tmpRotationMatrix;
  121786. /**
  121787. * 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)
  121788. */
  121789. ignoreChildren: boolean;
  121790. /**
  121791. * 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)
  121792. */
  121793. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121794. /**
  121795. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121796. */
  121797. rotationSphereSize: number;
  121798. /**
  121799. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121800. */
  121801. scaleBoxSize: number;
  121802. /**
  121803. * 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)
  121804. */
  121805. fixedDragMeshScreenSize: boolean;
  121806. /**
  121807. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121808. */
  121809. fixedDragMeshScreenSizeDistanceFactor: number;
  121810. /**
  121811. * Fired when a rotation sphere or scale box is dragged
  121812. */
  121813. onDragStartObservable: Observable<{}>;
  121814. /**
  121815. * Fired when a scale box is dragged
  121816. */
  121817. onScaleBoxDragObservable: Observable<{}>;
  121818. /**
  121819. * Fired when a scale box drag is ended
  121820. */
  121821. onScaleBoxDragEndObservable: Observable<{}>;
  121822. /**
  121823. * Fired when a rotation sphere is dragged
  121824. */
  121825. onRotationSphereDragObservable: Observable<{}>;
  121826. /**
  121827. * Fired when a rotation sphere drag is ended
  121828. */
  121829. onRotationSphereDragEndObservable: Observable<{}>;
  121830. /**
  121831. * 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)
  121832. */
  121833. scalePivot: Nullable<Vector3>;
  121834. /**
  121835. * Mesh used as a pivot to rotate the attached mesh
  121836. */
  121837. private _anchorMesh;
  121838. private _existingMeshScale;
  121839. private _dragMesh;
  121840. private pointerDragBehavior;
  121841. private coloredMaterial;
  121842. private hoverColoredMaterial;
  121843. /**
  121844. * Sets the color of the bounding box gizmo
  121845. * @param color the color to set
  121846. */
  121847. setColor(color: Color3): void;
  121848. /**
  121849. * Creates an BoundingBoxGizmo
  121850. * @param gizmoLayer The utility layer the gizmo will be added to
  121851. * @param color The color of the gizmo
  121852. */
  121853. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121854. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121855. private _selectNode;
  121856. /**
  121857. * Updates the bounding box information for the Gizmo
  121858. */
  121859. updateBoundingBox(): void;
  121860. private _updateRotationSpheres;
  121861. private _updateScaleBoxes;
  121862. /**
  121863. * Enables rotation on the specified axis and disables rotation on the others
  121864. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121865. */
  121866. setEnabledRotationAxis(axis: string): void;
  121867. /**
  121868. * Enables/disables scaling
  121869. * @param enable if scaling should be enabled
  121870. */
  121871. setEnabledScaling(enable: boolean): void;
  121872. private _updateDummy;
  121873. /**
  121874. * Enables a pointer drag behavior on the bounding box of the gizmo
  121875. */
  121876. enableDragBehavior(): void;
  121877. /**
  121878. * Disposes of the gizmo
  121879. */
  121880. dispose(): void;
  121881. /**
  121882. * 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)
  121883. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121884. * @returns the bounding box mesh with the passed in mesh as a child
  121885. */
  121886. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121887. /**
  121888. * CustomMeshes are not supported by this gizmo
  121889. * @param mesh The mesh to replace the default mesh of the gizmo
  121890. */
  121891. setCustomMesh(mesh: Mesh): void;
  121892. }
  121893. }
  121894. declare module BABYLON {
  121895. /**
  121896. * Single plane rotation gizmo
  121897. */
  121898. export class PlaneRotationGizmo extends Gizmo {
  121899. /**
  121900. * Drag behavior responsible for the gizmos dragging interactions
  121901. */
  121902. dragBehavior: PointerDragBehavior;
  121903. private _pointerObserver;
  121904. /**
  121905. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121906. */
  121907. snapDistance: number;
  121908. /**
  121909. * Event that fires each time the gizmo snaps to a new location.
  121910. * * snapDistance is the the change in distance
  121911. */
  121912. onSnapObservable: Observable<{
  121913. snapDistance: number;
  121914. }>;
  121915. private _isEnabled;
  121916. private _parent;
  121917. /**
  121918. * Creates a PlaneRotationGizmo
  121919. * @param gizmoLayer The utility layer the gizmo will be added to
  121920. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121921. * @param color The color of the gizmo
  121922. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121923. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121924. */
  121925. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121927. /**
  121928. * If the gizmo is enabled
  121929. */
  121930. set isEnabled(value: boolean);
  121931. get isEnabled(): boolean;
  121932. /**
  121933. * Disposes of the gizmo
  121934. */
  121935. dispose(): void;
  121936. }
  121937. }
  121938. declare module BABYLON {
  121939. /**
  121940. * Gizmo that enables rotating a mesh along 3 axis
  121941. */
  121942. export class RotationGizmo extends Gizmo {
  121943. /**
  121944. * Internal gizmo used for interactions on the x axis
  121945. */
  121946. xGizmo: PlaneRotationGizmo;
  121947. /**
  121948. * Internal gizmo used for interactions on the y axis
  121949. */
  121950. yGizmo: PlaneRotationGizmo;
  121951. /**
  121952. * Internal gizmo used for interactions on the z axis
  121953. */
  121954. zGizmo: PlaneRotationGizmo;
  121955. /** Fires an event when any of it's sub gizmos are dragged */
  121956. onDragStartObservable: Observable<unknown>;
  121957. /** Fires an event when any of it's sub gizmos are released from dragging */
  121958. onDragEndObservable: Observable<unknown>;
  121959. private _meshAttached;
  121960. get attachedMesh(): Nullable<AbstractMesh>;
  121961. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121962. /**
  121963. * Creates a RotationGizmo
  121964. * @param gizmoLayer The utility layer the gizmo will be added to
  121965. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121966. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121967. */
  121968. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121969. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121970. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121971. /**
  121972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121973. */
  121974. set snapDistance(value: number);
  121975. get snapDistance(): number;
  121976. /**
  121977. * Ratio for the scale of the gizmo (Default: 1)
  121978. */
  121979. set scaleRatio(value: number);
  121980. get scaleRatio(): number;
  121981. /**
  121982. * Disposes of the gizmo
  121983. */
  121984. dispose(): void;
  121985. /**
  121986. * CustomMeshes are not supported by this gizmo
  121987. * @param mesh The mesh to replace the default mesh of the gizmo
  121988. */
  121989. setCustomMesh(mesh: Mesh): void;
  121990. }
  121991. }
  121992. declare module BABYLON {
  121993. /**
  121994. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121995. */
  121996. export class GizmoManager implements IDisposable {
  121997. private scene;
  121998. /**
  121999. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122000. */
  122001. gizmos: {
  122002. positionGizmo: Nullable<PositionGizmo>;
  122003. rotationGizmo: Nullable<RotationGizmo>;
  122004. scaleGizmo: Nullable<ScaleGizmo>;
  122005. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122006. };
  122007. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122008. clearGizmoOnEmptyPointerEvent: boolean;
  122009. /** Fires an event when the manager is attached to a mesh */
  122010. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122011. private _gizmosEnabled;
  122012. private _pointerObserver;
  122013. private _attachedMesh;
  122014. private _boundingBoxColor;
  122015. private _defaultUtilityLayer;
  122016. private _defaultKeepDepthUtilityLayer;
  122017. /**
  122018. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122019. */
  122020. boundingBoxDragBehavior: SixDofDragBehavior;
  122021. /**
  122022. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122023. */
  122024. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122025. /**
  122026. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122027. */
  122028. usePointerToAttachGizmos: boolean;
  122029. /**
  122030. * Utility layer that the bounding box gizmo belongs to
  122031. */
  122032. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122033. /**
  122034. * Utility layer that all gizmos besides bounding box belong to
  122035. */
  122036. get utilityLayer(): UtilityLayerRenderer;
  122037. /**
  122038. * Instatiates a gizmo manager
  122039. * @param scene the scene to overlay the gizmos on top of
  122040. */
  122041. constructor(scene: Scene);
  122042. /**
  122043. * Attaches a set of gizmos to the specified mesh
  122044. * @param mesh The mesh the gizmo's should be attached to
  122045. */
  122046. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122047. /**
  122048. * If the position gizmo is enabled
  122049. */
  122050. set positionGizmoEnabled(value: boolean);
  122051. get positionGizmoEnabled(): boolean;
  122052. /**
  122053. * If the rotation gizmo is enabled
  122054. */
  122055. set rotationGizmoEnabled(value: boolean);
  122056. get rotationGizmoEnabled(): boolean;
  122057. /**
  122058. * If the scale gizmo is enabled
  122059. */
  122060. set scaleGizmoEnabled(value: boolean);
  122061. get scaleGizmoEnabled(): boolean;
  122062. /**
  122063. * If the boundingBox gizmo is enabled
  122064. */
  122065. set boundingBoxGizmoEnabled(value: boolean);
  122066. get boundingBoxGizmoEnabled(): boolean;
  122067. /**
  122068. * Disposes of the gizmo manager
  122069. */
  122070. dispose(): void;
  122071. }
  122072. }
  122073. declare module BABYLON {
  122074. /**
  122075. * A directional light is defined by a direction (what a surprise!).
  122076. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122077. * 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.
  122078. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122079. */
  122080. export class DirectionalLight extends ShadowLight {
  122081. private _shadowFrustumSize;
  122082. /**
  122083. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122084. */
  122085. get shadowFrustumSize(): number;
  122086. /**
  122087. * Specifies a fix frustum size for the shadow generation.
  122088. */
  122089. set shadowFrustumSize(value: number);
  122090. private _shadowOrthoScale;
  122091. /**
  122092. * Gets the shadow projection scale against the optimal computed one.
  122093. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122094. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122095. */
  122096. get shadowOrthoScale(): number;
  122097. /**
  122098. * Sets the shadow projection scale against the optimal computed one.
  122099. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122100. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122101. */
  122102. set shadowOrthoScale(value: number);
  122103. /**
  122104. * Automatically compute the projection matrix to best fit (including all the casters)
  122105. * on each frame.
  122106. */
  122107. autoUpdateExtends: boolean;
  122108. /**
  122109. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122110. * on each frame. autoUpdateExtends must be set to true for this to work
  122111. */
  122112. autoCalcShadowZBounds: boolean;
  122113. private _orthoLeft;
  122114. private _orthoRight;
  122115. private _orthoTop;
  122116. private _orthoBottom;
  122117. /**
  122118. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122119. * The directional light is emitted from everywhere in the given direction.
  122120. * It can cast shadows.
  122121. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122122. * @param name The friendly name of the light
  122123. * @param direction The direction of the light
  122124. * @param scene The scene the light belongs to
  122125. */
  122126. constructor(name: string, direction: Vector3, scene: Scene);
  122127. /**
  122128. * Returns the string "DirectionalLight".
  122129. * @return The class name
  122130. */
  122131. getClassName(): string;
  122132. /**
  122133. * Returns the integer 1.
  122134. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122135. */
  122136. getTypeID(): number;
  122137. /**
  122138. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122139. * Returns the DirectionalLight Shadow projection matrix.
  122140. */
  122141. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122142. /**
  122143. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122144. * Returns the DirectionalLight Shadow projection matrix.
  122145. */
  122146. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122147. /**
  122148. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122149. * Returns the DirectionalLight Shadow projection matrix.
  122150. */
  122151. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122152. protected _buildUniformLayout(): void;
  122153. /**
  122154. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122155. * @param effect The effect to update
  122156. * @param lightIndex The index of the light in the effect to update
  122157. * @returns The directional light
  122158. */
  122159. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122160. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122161. /**
  122162. * Gets the minZ used for shadow according to both the scene and the light.
  122163. *
  122164. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122165. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122166. * @param activeCamera The camera we are returning the min for
  122167. * @returns the depth min z
  122168. */
  122169. getDepthMinZ(activeCamera: Camera): number;
  122170. /**
  122171. * Gets the maxZ used for shadow according to both the scene and the light.
  122172. *
  122173. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122174. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122175. * @param activeCamera The camera we are returning the max for
  122176. * @returns the depth max z
  122177. */
  122178. getDepthMaxZ(activeCamera: Camera): number;
  122179. /**
  122180. * Prepares the list of defines specific to the light type.
  122181. * @param defines the list of defines
  122182. * @param lightIndex defines the index of the light for the effect
  122183. */
  122184. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122185. }
  122186. }
  122187. declare module BABYLON {
  122188. /**
  122189. * Class containing static functions to help procedurally build meshes
  122190. */
  122191. export class HemisphereBuilder {
  122192. /**
  122193. * Creates a hemisphere mesh
  122194. * @param name defines the name of the mesh
  122195. * @param options defines the options used to create the mesh
  122196. * @param scene defines the hosting scene
  122197. * @returns the hemisphere mesh
  122198. */
  122199. static CreateHemisphere(name: string, options: {
  122200. segments?: number;
  122201. diameter?: number;
  122202. sideOrientation?: number;
  122203. }, scene: any): Mesh;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122209. * These values define a cone of light starting from the position, emitting toward the direction.
  122210. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122211. * and the exponent defines the speed of the decay of the light with distance (reach).
  122212. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122213. */
  122214. export class SpotLight extends ShadowLight {
  122215. private _angle;
  122216. private _innerAngle;
  122217. private _cosHalfAngle;
  122218. private _lightAngleScale;
  122219. private _lightAngleOffset;
  122220. /**
  122221. * Gets the cone angle of the spot light in Radians.
  122222. */
  122223. get angle(): number;
  122224. /**
  122225. * Sets the cone angle of the spot light in Radians.
  122226. */
  122227. set angle(value: number);
  122228. /**
  122229. * Only used in gltf falloff mode, this defines the angle where
  122230. * the directional falloff will start before cutting at angle which could be seen
  122231. * as outer angle.
  122232. */
  122233. get innerAngle(): number;
  122234. /**
  122235. * Only used in gltf falloff mode, this defines the angle where
  122236. * the directional falloff will start before cutting at angle which could be seen
  122237. * as outer angle.
  122238. */
  122239. set innerAngle(value: number);
  122240. private _shadowAngleScale;
  122241. /**
  122242. * Allows scaling the angle of the light for shadow generation only.
  122243. */
  122244. get shadowAngleScale(): number;
  122245. /**
  122246. * Allows scaling the angle of the light for shadow generation only.
  122247. */
  122248. set shadowAngleScale(value: number);
  122249. /**
  122250. * The light decay speed with the distance from the emission spot.
  122251. */
  122252. exponent: number;
  122253. private _projectionTextureMatrix;
  122254. /**
  122255. * Allows reading the projecton texture
  122256. */
  122257. get projectionTextureMatrix(): Matrix;
  122258. protected _projectionTextureLightNear: number;
  122259. /**
  122260. * Gets the near clip of the Spotlight for texture projection.
  122261. */
  122262. get projectionTextureLightNear(): number;
  122263. /**
  122264. * Sets the near clip of the Spotlight for texture projection.
  122265. */
  122266. set projectionTextureLightNear(value: number);
  122267. protected _projectionTextureLightFar: number;
  122268. /**
  122269. * Gets the far clip of the Spotlight for texture projection.
  122270. */
  122271. get projectionTextureLightFar(): number;
  122272. /**
  122273. * Sets the far clip of the Spotlight for texture projection.
  122274. */
  122275. set projectionTextureLightFar(value: number);
  122276. protected _projectionTextureUpDirection: Vector3;
  122277. /**
  122278. * Gets the Up vector of the Spotlight for texture projection.
  122279. */
  122280. get projectionTextureUpDirection(): Vector3;
  122281. /**
  122282. * Sets the Up vector of the Spotlight for texture projection.
  122283. */
  122284. set projectionTextureUpDirection(value: Vector3);
  122285. private _projectionTexture;
  122286. /**
  122287. * Gets the projection texture of the light.
  122288. */
  122289. get projectionTexture(): Nullable<BaseTexture>;
  122290. /**
  122291. * Sets the projection texture of the light.
  122292. */
  122293. set projectionTexture(value: Nullable<BaseTexture>);
  122294. private _projectionTextureViewLightDirty;
  122295. private _projectionTextureProjectionLightDirty;
  122296. private _projectionTextureDirty;
  122297. private _projectionTextureViewTargetVector;
  122298. private _projectionTextureViewLightMatrix;
  122299. private _projectionTextureProjectionLightMatrix;
  122300. private _projectionTextureScalingMatrix;
  122301. /**
  122302. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122303. * It can cast shadows.
  122304. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122305. * @param name The light friendly name
  122306. * @param position The position of the spot light in the scene
  122307. * @param direction The direction of the light in the scene
  122308. * @param angle The cone angle of the light in Radians
  122309. * @param exponent The light decay speed with the distance from the emission spot
  122310. * @param scene The scene the lights belongs to
  122311. */
  122312. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122313. /**
  122314. * Returns the string "SpotLight".
  122315. * @returns the class name
  122316. */
  122317. getClassName(): string;
  122318. /**
  122319. * Returns the integer 2.
  122320. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122321. */
  122322. getTypeID(): number;
  122323. /**
  122324. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122325. */
  122326. protected _setDirection(value: Vector3): void;
  122327. /**
  122328. * Overrides the position setter to recompute the projection texture view light Matrix.
  122329. */
  122330. protected _setPosition(value: Vector3): void;
  122331. /**
  122332. * 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.
  122333. * Returns the SpotLight.
  122334. */
  122335. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122336. protected _computeProjectionTextureViewLightMatrix(): void;
  122337. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122338. /**
  122339. * Main function for light texture projection matrix computing.
  122340. */
  122341. protected _computeProjectionTextureMatrix(): void;
  122342. protected _buildUniformLayout(): void;
  122343. private _computeAngleValues;
  122344. /**
  122345. * Sets the passed Effect "effect" with the Light textures.
  122346. * @param effect The effect to update
  122347. * @param lightIndex The index of the light in the effect to update
  122348. * @returns The light
  122349. */
  122350. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122351. /**
  122352. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122353. * @param effect The effect to update
  122354. * @param lightIndex The index of the light in the effect to update
  122355. * @returns The spot light
  122356. */
  122357. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122358. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122359. /**
  122360. * Disposes the light and the associated resources.
  122361. */
  122362. dispose(): void;
  122363. /**
  122364. * Prepares the list of defines specific to the light type.
  122365. * @param defines the list of defines
  122366. * @param lightIndex defines the index of the light for the effect
  122367. */
  122368. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122369. }
  122370. }
  122371. declare module BABYLON {
  122372. /**
  122373. * Gizmo that enables viewing a light
  122374. */
  122375. export class LightGizmo extends Gizmo {
  122376. private _lightMesh;
  122377. private _material;
  122378. private _cachedPosition;
  122379. private _cachedForward;
  122380. private _attachedMeshParent;
  122381. /**
  122382. * Creates a LightGizmo
  122383. * @param gizmoLayer The utility layer the gizmo will be added to
  122384. */
  122385. constructor(gizmoLayer?: UtilityLayerRenderer);
  122386. private _light;
  122387. /**
  122388. * The light that the gizmo is attached to
  122389. */
  122390. set light(light: Nullable<Light>);
  122391. get light(): Nullable<Light>;
  122392. /**
  122393. * Gets the material used to render the light gizmo
  122394. */
  122395. get material(): StandardMaterial;
  122396. /**
  122397. * @hidden
  122398. * Updates the gizmo to match the attached mesh's position/rotation
  122399. */
  122400. protected _update(): void;
  122401. private static _Scale;
  122402. /**
  122403. * Creates the lines for a light mesh
  122404. */
  122405. private static _CreateLightLines;
  122406. /**
  122407. * Disposes of the light gizmo
  122408. */
  122409. dispose(): void;
  122410. private static _CreateHemisphericLightMesh;
  122411. private static _CreatePointLightMesh;
  122412. private static _CreateSpotLightMesh;
  122413. private static _CreateDirectionalLightMesh;
  122414. }
  122415. }
  122416. declare module BABYLON {
  122417. /** @hidden */
  122418. export var backgroundFragmentDeclaration: {
  122419. name: string;
  122420. shader: string;
  122421. };
  122422. }
  122423. declare module BABYLON {
  122424. /** @hidden */
  122425. export var backgroundUboDeclaration: {
  122426. name: string;
  122427. shader: string;
  122428. };
  122429. }
  122430. declare module BABYLON {
  122431. /** @hidden */
  122432. export var backgroundPixelShader: {
  122433. name: string;
  122434. shader: string;
  122435. };
  122436. }
  122437. declare module BABYLON {
  122438. /** @hidden */
  122439. export var backgroundVertexDeclaration: {
  122440. name: string;
  122441. shader: string;
  122442. };
  122443. }
  122444. declare module BABYLON {
  122445. /** @hidden */
  122446. export var backgroundVertexShader: {
  122447. name: string;
  122448. shader: string;
  122449. };
  122450. }
  122451. declare module BABYLON {
  122452. /**
  122453. * Background material used to create an efficient environement around your scene.
  122454. */
  122455. export class BackgroundMaterial extends PushMaterial {
  122456. /**
  122457. * Standard reflectance value at parallel view angle.
  122458. */
  122459. static StandardReflectance0: number;
  122460. /**
  122461. * Standard reflectance value at grazing angle.
  122462. */
  122463. static StandardReflectance90: number;
  122464. protected _primaryColor: Color3;
  122465. /**
  122466. * Key light Color (multiply against the environement texture)
  122467. */
  122468. primaryColor: Color3;
  122469. protected __perceptualColor: Nullable<Color3>;
  122470. /**
  122471. * Experimental Internal Use Only.
  122472. *
  122473. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122474. * This acts as a helper to set the primary color to a more "human friendly" value.
  122475. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122476. * output color as close as possible from the chosen value.
  122477. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122478. * part of lighting setup.)
  122479. */
  122480. get _perceptualColor(): Nullable<Color3>;
  122481. set _perceptualColor(value: Nullable<Color3>);
  122482. protected _primaryColorShadowLevel: float;
  122483. /**
  122484. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122485. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122486. */
  122487. get primaryColorShadowLevel(): float;
  122488. set primaryColorShadowLevel(value: float);
  122489. protected _primaryColorHighlightLevel: float;
  122490. /**
  122491. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122492. * The primary color is used at the level chosen to define what the white area would look.
  122493. */
  122494. get primaryColorHighlightLevel(): float;
  122495. set primaryColorHighlightLevel(value: float);
  122496. protected _reflectionTexture: Nullable<BaseTexture>;
  122497. /**
  122498. * Reflection Texture used in the material.
  122499. * Should be author in a specific way for the best result (refer to the documentation).
  122500. */
  122501. reflectionTexture: Nullable<BaseTexture>;
  122502. protected _reflectionBlur: float;
  122503. /**
  122504. * Reflection Texture level of blur.
  122505. *
  122506. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122507. * texture twice.
  122508. */
  122509. reflectionBlur: float;
  122510. protected _diffuseTexture: Nullable<BaseTexture>;
  122511. /**
  122512. * Diffuse Texture used in the material.
  122513. * Should be author in a specific way for the best result (refer to the documentation).
  122514. */
  122515. diffuseTexture: Nullable<BaseTexture>;
  122516. protected _shadowLights: Nullable<IShadowLight[]>;
  122517. /**
  122518. * Specify the list of lights casting shadow on the material.
  122519. * All scene shadow lights will be included if null.
  122520. */
  122521. shadowLights: Nullable<IShadowLight[]>;
  122522. protected _shadowLevel: float;
  122523. /**
  122524. * Helps adjusting the shadow to a softer level if required.
  122525. * 0 means black shadows and 1 means no shadows.
  122526. */
  122527. shadowLevel: float;
  122528. protected _sceneCenter: Vector3;
  122529. /**
  122530. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122531. * It is usually zero but might be interesting to modify according to your setup.
  122532. */
  122533. sceneCenter: Vector3;
  122534. protected _opacityFresnel: boolean;
  122535. /**
  122536. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122537. * This helps ensuring a nice transition when the camera goes under the ground.
  122538. */
  122539. opacityFresnel: boolean;
  122540. protected _reflectionFresnel: boolean;
  122541. /**
  122542. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122543. * This helps adding a mirror texture on the ground.
  122544. */
  122545. reflectionFresnel: boolean;
  122546. protected _reflectionFalloffDistance: number;
  122547. /**
  122548. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122549. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122550. */
  122551. reflectionFalloffDistance: number;
  122552. protected _reflectionAmount: number;
  122553. /**
  122554. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122555. */
  122556. reflectionAmount: number;
  122557. protected _reflectionReflectance0: number;
  122558. /**
  122559. * This specifies the weight of the reflection at grazing angle.
  122560. */
  122561. reflectionReflectance0: number;
  122562. protected _reflectionReflectance90: number;
  122563. /**
  122564. * This specifies the weight of the reflection at a perpendicular point of view.
  122565. */
  122566. reflectionReflectance90: number;
  122567. /**
  122568. * Sets the reflection reflectance fresnel values according to the default standard
  122569. * empirically know to work well :-)
  122570. */
  122571. set reflectionStandardFresnelWeight(value: number);
  122572. protected _useRGBColor: boolean;
  122573. /**
  122574. * Helps to directly use the maps channels instead of their level.
  122575. */
  122576. useRGBColor: boolean;
  122577. protected _enableNoise: boolean;
  122578. /**
  122579. * This helps reducing the banding effect that could occur on the background.
  122580. */
  122581. enableNoise: boolean;
  122582. /**
  122583. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122584. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122585. * Recommended to be keep at 1.0 except for special cases.
  122586. */
  122587. get fovMultiplier(): number;
  122588. set fovMultiplier(value: number);
  122589. private _fovMultiplier;
  122590. /**
  122591. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122592. */
  122593. useEquirectangularFOV: boolean;
  122594. private _maxSimultaneousLights;
  122595. /**
  122596. * Number of Simultaneous lights allowed on the material.
  122597. */
  122598. maxSimultaneousLights: int;
  122599. /**
  122600. * Default configuration related to image processing available in the Background Material.
  122601. */
  122602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122603. /**
  122604. * Keep track of the image processing observer to allow dispose and replace.
  122605. */
  122606. private _imageProcessingObserver;
  122607. /**
  122608. * Attaches a new image processing configuration to the PBR Material.
  122609. * @param configuration (if null the scene configuration will be use)
  122610. */
  122611. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122612. /**
  122613. * Gets the image processing configuration used either in this material.
  122614. */
  122615. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122616. /**
  122617. * Sets the Default image processing configuration used either in the this material.
  122618. *
  122619. * If sets to null, the scene one is in use.
  122620. */
  122621. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122622. /**
  122623. * Gets wether the color curves effect is enabled.
  122624. */
  122625. get cameraColorCurvesEnabled(): boolean;
  122626. /**
  122627. * Sets wether the color curves effect is enabled.
  122628. */
  122629. set cameraColorCurvesEnabled(value: boolean);
  122630. /**
  122631. * Gets wether the color grading effect is enabled.
  122632. */
  122633. get cameraColorGradingEnabled(): boolean;
  122634. /**
  122635. * Gets wether the color grading effect is enabled.
  122636. */
  122637. set cameraColorGradingEnabled(value: boolean);
  122638. /**
  122639. * Gets wether tonemapping is enabled or not.
  122640. */
  122641. get cameraToneMappingEnabled(): boolean;
  122642. /**
  122643. * Sets wether tonemapping is enabled or not
  122644. */
  122645. set cameraToneMappingEnabled(value: boolean);
  122646. /**
  122647. * The camera exposure used on this material.
  122648. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122649. * This corresponds to a photographic exposure.
  122650. */
  122651. get cameraExposure(): float;
  122652. /**
  122653. * The camera exposure used on this material.
  122654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122655. * This corresponds to a photographic exposure.
  122656. */
  122657. set cameraExposure(value: float);
  122658. /**
  122659. * Gets The camera contrast used on this material.
  122660. */
  122661. get cameraContrast(): float;
  122662. /**
  122663. * Sets The camera contrast used on this material.
  122664. */
  122665. set cameraContrast(value: float);
  122666. /**
  122667. * Gets the Color Grading 2D Lookup Texture.
  122668. */
  122669. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122670. /**
  122671. * Sets the Color Grading 2D Lookup Texture.
  122672. */
  122673. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122674. /**
  122675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122677. * 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;
  122678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122679. */
  122680. get cameraColorCurves(): Nullable<ColorCurves>;
  122681. /**
  122682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122684. * 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;
  122685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122686. */
  122687. set cameraColorCurves(value: Nullable<ColorCurves>);
  122688. /**
  122689. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122690. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122691. */
  122692. switchToBGR: boolean;
  122693. private _renderTargets;
  122694. private _reflectionControls;
  122695. private _white;
  122696. private _primaryShadowColor;
  122697. private _primaryHighlightColor;
  122698. /**
  122699. * Instantiates a Background Material in the given scene
  122700. * @param name The friendly name of the material
  122701. * @param scene The scene to add the material to
  122702. */
  122703. constructor(name: string, scene: Scene);
  122704. /**
  122705. * Gets a boolean indicating that current material needs to register RTT
  122706. */
  122707. get hasRenderTargetTextures(): boolean;
  122708. /**
  122709. * The entire material has been created in order to prevent overdraw.
  122710. * @returns false
  122711. */
  122712. needAlphaTesting(): boolean;
  122713. /**
  122714. * The entire material has been created in order to prevent overdraw.
  122715. * @returns true if blending is enable
  122716. */
  122717. needAlphaBlending(): boolean;
  122718. /**
  122719. * Checks wether the material is ready to be rendered for a given mesh.
  122720. * @param mesh The mesh to render
  122721. * @param subMesh The submesh to check against
  122722. * @param useInstances Specify wether or not the material is used with instances
  122723. * @returns true if all the dependencies are ready (Textures, Effects...)
  122724. */
  122725. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122726. /**
  122727. * Compute the primary color according to the chosen perceptual color.
  122728. */
  122729. private _computePrimaryColorFromPerceptualColor;
  122730. /**
  122731. * Compute the highlights and shadow colors according to their chosen levels.
  122732. */
  122733. private _computePrimaryColors;
  122734. /**
  122735. * Build the uniform buffer used in the material.
  122736. */
  122737. buildUniformLayout(): void;
  122738. /**
  122739. * Unbind the material.
  122740. */
  122741. unbind(): void;
  122742. /**
  122743. * Bind only the world matrix to the material.
  122744. * @param world The world matrix to bind.
  122745. */
  122746. bindOnlyWorldMatrix(world: Matrix): void;
  122747. /**
  122748. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122749. * @param world The world matrix to bind.
  122750. * @param subMesh The submesh to bind for.
  122751. */
  122752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122753. /**
  122754. * Checks to see if a texture is used in the material.
  122755. * @param texture - Base texture to use.
  122756. * @returns - Boolean specifying if a texture is used in the material.
  122757. */
  122758. hasTexture(texture: BaseTexture): boolean;
  122759. /**
  122760. * Dispose the material.
  122761. * @param forceDisposeEffect Force disposal of the associated effect.
  122762. * @param forceDisposeTextures Force disposal of the associated textures.
  122763. */
  122764. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122765. /**
  122766. * Clones the material.
  122767. * @param name The cloned name.
  122768. * @returns The cloned material.
  122769. */
  122770. clone(name: string): BackgroundMaterial;
  122771. /**
  122772. * Serializes the current material to its JSON representation.
  122773. * @returns The JSON representation.
  122774. */
  122775. serialize(): any;
  122776. /**
  122777. * Gets the class name of the material
  122778. * @returns "BackgroundMaterial"
  122779. */
  122780. getClassName(): string;
  122781. /**
  122782. * Parse a JSON input to create back a background material.
  122783. * @param source The JSON data to parse
  122784. * @param scene The scene to create the parsed material in
  122785. * @param rootUrl The root url of the assets the material depends upon
  122786. * @returns the instantiated BackgroundMaterial.
  122787. */
  122788. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122789. }
  122790. }
  122791. declare module BABYLON {
  122792. /**
  122793. * Represents the different options available during the creation of
  122794. * a Environment helper.
  122795. *
  122796. * This can control the default ground, skybox and image processing setup of your scene.
  122797. */
  122798. export interface IEnvironmentHelperOptions {
  122799. /**
  122800. * Specifies whether or not to create a ground.
  122801. * True by default.
  122802. */
  122803. createGround: boolean;
  122804. /**
  122805. * Specifies the ground size.
  122806. * 15 by default.
  122807. */
  122808. groundSize: number;
  122809. /**
  122810. * The texture used on the ground for the main color.
  122811. * Comes from the BabylonJS CDN by default.
  122812. *
  122813. * Remarks: Can be either a texture or a url.
  122814. */
  122815. groundTexture: string | BaseTexture;
  122816. /**
  122817. * The color mixed in the ground texture by default.
  122818. * BabylonJS clearColor by default.
  122819. */
  122820. groundColor: Color3;
  122821. /**
  122822. * Specifies the ground opacity.
  122823. * 1 by default.
  122824. */
  122825. groundOpacity: number;
  122826. /**
  122827. * Enables the ground to receive shadows.
  122828. * True by default.
  122829. */
  122830. enableGroundShadow: boolean;
  122831. /**
  122832. * Helps preventing the shadow to be fully black on the ground.
  122833. * 0.5 by default.
  122834. */
  122835. groundShadowLevel: number;
  122836. /**
  122837. * Creates a mirror texture attach to the ground.
  122838. * false by default.
  122839. */
  122840. enableGroundMirror: boolean;
  122841. /**
  122842. * Specifies the ground mirror size ratio.
  122843. * 0.3 by default as the default kernel is 64.
  122844. */
  122845. groundMirrorSizeRatio: number;
  122846. /**
  122847. * Specifies the ground mirror blur kernel size.
  122848. * 64 by default.
  122849. */
  122850. groundMirrorBlurKernel: number;
  122851. /**
  122852. * Specifies the ground mirror visibility amount.
  122853. * 1 by default
  122854. */
  122855. groundMirrorAmount: number;
  122856. /**
  122857. * Specifies the ground mirror reflectance weight.
  122858. * This uses the standard weight of the background material to setup the fresnel effect
  122859. * of the mirror.
  122860. * 1 by default.
  122861. */
  122862. groundMirrorFresnelWeight: number;
  122863. /**
  122864. * Specifies the ground mirror Falloff distance.
  122865. * This can helps reducing the size of the reflection.
  122866. * 0 by Default.
  122867. */
  122868. groundMirrorFallOffDistance: number;
  122869. /**
  122870. * Specifies the ground mirror texture type.
  122871. * Unsigned Int by Default.
  122872. */
  122873. groundMirrorTextureType: number;
  122874. /**
  122875. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122876. * the shown objects.
  122877. */
  122878. groundYBias: number;
  122879. /**
  122880. * Specifies whether or not to create a skybox.
  122881. * True by default.
  122882. */
  122883. createSkybox: boolean;
  122884. /**
  122885. * Specifies the skybox size.
  122886. * 20 by default.
  122887. */
  122888. skyboxSize: number;
  122889. /**
  122890. * The texture used on the skybox for the main color.
  122891. * Comes from the BabylonJS CDN by default.
  122892. *
  122893. * Remarks: Can be either a texture or a url.
  122894. */
  122895. skyboxTexture: string | BaseTexture;
  122896. /**
  122897. * The color mixed in the skybox texture by default.
  122898. * BabylonJS clearColor by default.
  122899. */
  122900. skyboxColor: Color3;
  122901. /**
  122902. * The background rotation around the Y axis of the scene.
  122903. * This helps aligning the key lights of your scene with the background.
  122904. * 0 by default.
  122905. */
  122906. backgroundYRotation: number;
  122907. /**
  122908. * Compute automatically the size of the elements to best fit with the scene.
  122909. */
  122910. sizeAuto: boolean;
  122911. /**
  122912. * Default position of the rootMesh if autoSize is not true.
  122913. */
  122914. rootPosition: Vector3;
  122915. /**
  122916. * Sets up the image processing in the scene.
  122917. * true by default.
  122918. */
  122919. setupImageProcessing: boolean;
  122920. /**
  122921. * The texture used as your environment texture in the scene.
  122922. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122923. *
  122924. * Remarks: Can be either a texture or a url.
  122925. */
  122926. environmentTexture: string | BaseTexture;
  122927. /**
  122928. * The value of the exposure to apply to the scene.
  122929. * 0.6 by default if setupImageProcessing is true.
  122930. */
  122931. cameraExposure: number;
  122932. /**
  122933. * The value of the contrast to apply to the scene.
  122934. * 1.6 by default if setupImageProcessing is true.
  122935. */
  122936. cameraContrast: number;
  122937. /**
  122938. * Specifies whether or not tonemapping should be enabled in the scene.
  122939. * true by default if setupImageProcessing is true.
  122940. */
  122941. toneMappingEnabled: boolean;
  122942. }
  122943. /**
  122944. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122945. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122946. * It also helps with the default setup of your imageProcessing configuration.
  122947. */
  122948. export class EnvironmentHelper {
  122949. /**
  122950. * Default ground texture URL.
  122951. */
  122952. private static _groundTextureCDNUrl;
  122953. /**
  122954. * Default skybox texture URL.
  122955. */
  122956. private static _skyboxTextureCDNUrl;
  122957. /**
  122958. * Default environment texture URL.
  122959. */
  122960. private static _environmentTextureCDNUrl;
  122961. /**
  122962. * Creates the default options for the helper.
  122963. */
  122964. private static _getDefaultOptions;
  122965. private _rootMesh;
  122966. /**
  122967. * Gets the root mesh created by the helper.
  122968. */
  122969. get rootMesh(): Mesh;
  122970. private _skybox;
  122971. /**
  122972. * Gets the skybox created by the helper.
  122973. */
  122974. get skybox(): Nullable<Mesh>;
  122975. private _skyboxTexture;
  122976. /**
  122977. * Gets the skybox texture created by the helper.
  122978. */
  122979. get skyboxTexture(): Nullable<BaseTexture>;
  122980. private _skyboxMaterial;
  122981. /**
  122982. * Gets the skybox material created by the helper.
  122983. */
  122984. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122985. private _ground;
  122986. /**
  122987. * Gets the ground mesh created by the helper.
  122988. */
  122989. get ground(): Nullable<Mesh>;
  122990. private _groundTexture;
  122991. /**
  122992. * Gets the ground texture created by the helper.
  122993. */
  122994. get groundTexture(): Nullable<BaseTexture>;
  122995. private _groundMirror;
  122996. /**
  122997. * Gets the ground mirror created by the helper.
  122998. */
  122999. get groundMirror(): Nullable<MirrorTexture>;
  123000. /**
  123001. * Gets the ground mirror render list to helps pushing the meshes
  123002. * you wish in the ground reflection.
  123003. */
  123004. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123005. private _groundMaterial;
  123006. /**
  123007. * Gets the ground material created by the helper.
  123008. */
  123009. get groundMaterial(): Nullable<BackgroundMaterial>;
  123010. /**
  123011. * Stores the creation options.
  123012. */
  123013. private readonly _scene;
  123014. private _options;
  123015. /**
  123016. * This observable will be notified with any error during the creation of the environment,
  123017. * mainly texture creation errors.
  123018. */
  123019. onErrorObservable: Observable<{
  123020. message?: string;
  123021. exception?: any;
  123022. }>;
  123023. /**
  123024. * constructor
  123025. * @param options Defines the options we want to customize the helper
  123026. * @param scene The scene to add the material to
  123027. */
  123028. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123029. /**
  123030. * Updates the background according to the new options
  123031. * @param options
  123032. */
  123033. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123034. /**
  123035. * Sets the primary color of all the available elements.
  123036. * @param color the main color to affect to the ground and the background
  123037. */
  123038. setMainColor(color: Color3): void;
  123039. /**
  123040. * Setup the image processing according to the specified options.
  123041. */
  123042. private _setupImageProcessing;
  123043. /**
  123044. * Setup the environment texture according to the specified options.
  123045. */
  123046. private _setupEnvironmentTexture;
  123047. /**
  123048. * Setup the background according to the specified options.
  123049. */
  123050. private _setupBackground;
  123051. /**
  123052. * Get the scene sizes according to the setup.
  123053. */
  123054. private _getSceneSize;
  123055. /**
  123056. * Setup the ground according to the specified options.
  123057. */
  123058. private _setupGround;
  123059. /**
  123060. * Setup the ground material according to the specified options.
  123061. */
  123062. private _setupGroundMaterial;
  123063. /**
  123064. * Setup the ground diffuse texture according to the specified options.
  123065. */
  123066. private _setupGroundDiffuseTexture;
  123067. /**
  123068. * Setup the ground mirror texture according to the specified options.
  123069. */
  123070. private _setupGroundMirrorTexture;
  123071. /**
  123072. * Setup the ground to receive the mirror texture.
  123073. */
  123074. private _setupMirrorInGroundMaterial;
  123075. /**
  123076. * Setup the skybox according to the specified options.
  123077. */
  123078. private _setupSkybox;
  123079. /**
  123080. * Setup the skybox material according to the specified options.
  123081. */
  123082. private _setupSkyboxMaterial;
  123083. /**
  123084. * Setup the skybox reflection texture according to the specified options.
  123085. */
  123086. private _setupSkyboxReflectionTexture;
  123087. private _errorHandler;
  123088. /**
  123089. * Dispose all the elements created by the Helper.
  123090. */
  123091. dispose(): void;
  123092. }
  123093. }
  123094. declare module BABYLON {
  123095. /**
  123096. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123097. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123098. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123099. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123100. */
  123101. export class PhotoDome extends TransformNode {
  123102. /**
  123103. * Define the image as a Monoscopic panoramic 360 image.
  123104. */
  123105. static readonly MODE_MONOSCOPIC: number;
  123106. /**
  123107. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123108. */
  123109. static readonly MODE_TOPBOTTOM: number;
  123110. /**
  123111. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123112. */
  123113. static readonly MODE_SIDEBYSIDE: number;
  123114. private _useDirectMapping;
  123115. /**
  123116. * The texture being displayed on the sphere
  123117. */
  123118. protected _photoTexture: Texture;
  123119. /**
  123120. * Gets or sets the texture being displayed on the sphere
  123121. */
  123122. get photoTexture(): Texture;
  123123. set photoTexture(value: Texture);
  123124. /**
  123125. * Observable raised when an error occured while loading the 360 image
  123126. */
  123127. onLoadErrorObservable: Observable<string>;
  123128. /**
  123129. * The skybox material
  123130. */
  123131. protected _material: BackgroundMaterial;
  123132. /**
  123133. * The surface used for the skybox
  123134. */
  123135. protected _mesh: Mesh;
  123136. /**
  123137. * Gets the mesh used for the skybox.
  123138. */
  123139. get mesh(): Mesh;
  123140. /**
  123141. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123142. * Also see the options.resolution property.
  123143. */
  123144. get fovMultiplier(): number;
  123145. set fovMultiplier(value: number);
  123146. private _imageMode;
  123147. /**
  123148. * Gets or set the current video mode for the video. It can be:
  123149. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123150. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123151. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123152. */
  123153. get imageMode(): number;
  123154. set imageMode(value: number);
  123155. /**
  123156. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123157. * @param name Element's name, child elements will append suffixes for their own names.
  123158. * @param urlsOfPhoto defines the url of the photo to display
  123159. * @param options defines an object containing optional or exposed sub element properties
  123160. * @param onError defines a callback called when an error occured while loading the texture
  123161. */
  123162. constructor(name: string, urlOfPhoto: string, options: {
  123163. resolution?: number;
  123164. size?: number;
  123165. useDirectMapping?: boolean;
  123166. faceForward?: boolean;
  123167. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123168. private _onBeforeCameraRenderObserver;
  123169. private _changeImageMode;
  123170. /**
  123171. * Releases resources associated with this node.
  123172. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123173. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123174. */
  123175. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123176. }
  123177. }
  123178. declare module BABYLON {
  123179. /**
  123180. * Class used to host RGBD texture specific utilities
  123181. */
  123182. export class RGBDTextureTools {
  123183. /**
  123184. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123185. * @param texture the texture to expand.
  123186. */
  123187. static ExpandRGBDTexture(texture: Texture): void;
  123188. }
  123189. }
  123190. declare module BABYLON {
  123191. /**
  123192. * Class used to host texture specific utilities
  123193. */
  123194. export class BRDFTextureTools {
  123195. /**
  123196. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123197. * @param scene defines the hosting scene
  123198. * @returns the environment BRDF texture
  123199. */
  123200. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123201. private static _environmentBRDFBase64Texture;
  123202. }
  123203. }
  123204. declare module BABYLON {
  123205. /**
  123206. * @hidden
  123207. */
  123208. export interface IMaterialClearCoatDefines {
  123209. CLEARCOAT: boolean;
  123210. CLEARCOAT_DEFAULTIOR: boolean;
  123211. CLEARCOAT_TEXTURE: boolean;
  123212. CLEARCOAT_TEXTUREDIRECTUV: number;
  123213. CLEARCOAT_BUMP: boolean;
  123214. CLEARCOAT_BUMPDIRECTUV: number;
  123215. CLEARCOAT_TINT: boolean;
  123216. CLEARCOAT_TINT_TEXTURE: boolean;
  123217. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123218. /** @hidden */
  123219. _areTexturesDirty: boolean;
  123220. }
  123221. /**
  123222. * Define the code related to the clear coat parameters of the pbr material.
  123223. */
  123224. export class PBRClearCoatConfiguration {
  123225. /**
  123226. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123227. * The default fits with a polyurethane material.
  123228. */
  123229. private static readonly _DefaultIndexOfRefraction;
  123230. private _isEnabled;
  123231. /**
  123232. * Defines if the clear coat is enabled in the material.
  123233. */
  123234. isEnabled: boolean;
  123235. /**
  123236. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123237. */
  123238. intensity: number;
  123239. /**
  123240. * Defines the clear coat layer roughness.
  123241. */
  123242. roughness: number;
  123243. private _indexOfRefraction;
  123244. /**
  123245. * Defines the index of refraction of the clear coat.
  123246. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123247. * The default fits with a polyurethane material.
  123248. * Changing the default value is more performance intensive.
  123249. */
  123250. indexOfRefraction: number;
  123251. private _texture;
  123252. /**
  123253. * Stores the clear coat values in a texture.
  123254. */
  123255. texture: Nullable<BaseTexture>;
  123256. private _bumpTexture;
  123257. /**
  123258. * Define the clear coat specific bump texture.
  123259. */
  123260. bumpTexture: Nullable<BaseTexture>;
  123261. private _isTintEnabled;
  123262. /**
  123263. * Defines if the clear coat tint is enabled in the material.
  123264. */
  123265. isTintEnabled: boolean;
  123266. /**
  123267. * Defines the clear coat tint of the material.
  123268. * This is only use if tint is enabled
  123269. */
  123270. tintColor: Color3;
  123271. /**
  123272. * Defines the distance at which the tint color should be found in the
  123273. * clear coat media.
  123274. * This is only use if tint is enabled
  123275. */
  123276. tintColorAtDistance: number;
  123277. /**
  123278. * Defines the clear coat layer thickness.
  123279. * This is only use if tint is enabled
  123280. */
  123281. tintThickness: number;
  123282. private _tintTexture;
  123283. /**
  123284. * Stores the clear tint values in a texture.
  123285. * rgb is tint
  123286. * a is a thickness factor
  123287. */
  123288. tintTexture: Nullable<BaseTexture>;
  123289. /** @hidden */
  123290. private _internalMarkAllSubMeshesAsTexturesDirty;
  123291. /** @hidden */
  123292. _markAllSubMeshesAsTexturesDirty(): void;
  123293. /**
  123294. * Instantiate a new istance of clear coat configuration.
  123295. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123296. */
  123297. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123298. /**
  123299. * Gets wehter the submesh is ready to be used or not.
  123300. * @param defines the list of "defines" to update.
  123301. * @param scene defines the scene the material belongs to.
  123302. * @param engine defines the engine the material belongs to.
  123303. * @param disableBumpMap defines wether the material disables bump or not.
  123304. * @returns - boolean indicating that the submesh is ready or not.
  123305. */
  123306. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123307. /**
  123308. * Checks to see if a texture is used in the material.
  123309. * @param defines the list of "defines" to update.
  123310. * @param scene defines the scene to the material belongs to.
  123311. */
  123312. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123313. /**
  123314. * Binds the material data.
  123315. * @param uniformBuffer defines the Uniform buffer to fill in.
  123316. * @param scene defines the scene the material belongs to.
  123317. * @param engine defines the engine the material belongs to.
  123318. * @param disableBumpMap defines wether the material disables bump or not.
  123319. * @param isFrozen defines wether the material is frozen or not.
  123320. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123321. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123322. */
  123323. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123324. /**
  123325. * Checks to see if a texture is used in the material.
  123326. * @param texture - Base texture to use.
  123327. * @returns - Boolean specifying if a texture is used in the material.
  123328. */
  123329. hasTexture(texture: BaseTexture): boolean;
  123330. /**
  123331. * Returns an array of the actively used textures.
  123332. * @param activeTextures Array of BaseTextures
  123333. */
  123334. getActiveTextures(activeTextures: BaseTexture[]): void;
  123335. /**
  123336. * Returns the animatable textures.
  123337. * @param animatables Array of animatable textures.
  123338. */
  123339. getAnimatables(animatables: IAnimatable[]): void;
  123340. /**
  123341. * Disposes the resources of the material.
  123342. * @param forceDisposeTextures - Forces the disposal of all textures.
  123343. */
  123344. dispose(forceDisposeTextures?: boolean): void;
  123345. /**
  123346. * Get the current class name of the texture useful for serialization or dynamic coding.
  123347. * @returns "PBRClearCoatConfiguration"
  123348. */
  123349. getClassName(): string;
  123350. /**
  123351. * Add fallbacks to the effect fallbacks list.
  123352. * @param defines defines the Base texture to use.
  123353. * @param fallbacks defines the current fallback list.
  123354. * @param currentRank defines the current fallback rank.
  123355. * @returns the new fallback rank.
  123356. */
  123357. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123358. /**
  123359. * Add the required uniforms to the current list.
  123360. * @param uniforms defines the current uniform list.
  123361. */
  123362. static AddUniforms(uniforms: string[]): void;
  123363. /**
  123364. * Add the required samplers to the current list.
  123365. * @param samplers defines the current sampler list.
  123366. */
  123367. static AddSamplers(samplers: string[]): void;
  123368. /**
  123369. * Add the required uniforms to the current buffer.
  123370. * @param uniformBuffer defines the current uniform buffer.
  123371. */
  123372. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123373. /**
  123374. * Makes a duplicate of the current configuration into another one.
  123375. * @param clearCoatConfiguration define the config where to copy the info
  123376. */
  123377. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123378. /**
  123379. * Serializes this clear coat configuration.
  123380. * @returns - An object with the serialized config.
  123381. */
  123382. serialize(): any;
  123383. /**
  123384. * Parses a anisotropy Configuration from a serialized object.
  123385. * @param source - Serialized object.
  123386. * @param scene Defines the scene we are parsing for
  123387. * @param rootUrl Defines the rootUrl to load from
  123388. */
  123389. parse(source: any, scene: Scene, rootUrl: string): void;
  123390. }
  123391. }
  123392. declare module BABYLON {
  123393. /**
  123394. * @hidden
  123395. */
  123396. export interface IMaterialAnisotropicDefines {
  123397. ANISOTROPIC: boolean;
  123398. ANISOTROPIC_TEXTURE: boolean;
  123399. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123400. MAINUV1: boolean;
  123401. _areTexturesDirty: boolean;
  123402. _needUVs: boolean;
  123403. }
  123404. /**
  123405. * Define the code related to the anisotropic parameters of the pbr material.
  123406. */
  123407. export class PBRAnisotropicConfiguration {
  123408. private _isEnabled;
  123409. /**
  123410. * Defines if the anisotropy is enabled in the material.
  123411. */
  123412. isEnabled: boolean;
  123413. /**
  123414. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123415. */
  123416. intensity: number;
  123417. /**
  123418. * Defines if the effect is along the tangents, bitangents or in between.
  123419. * By default, the effect is "strectching" the highlights along the tangents.
  123420. */
  123421. direction: Vector2;
  123422. private _texture;
  123423. /**
  123424. * Stores the anisotropy values in a texture.
  123425. * rg is direction (like normal from -1 to 1)
  123426. * b is a intensity
  123427. */
  123428. texture: Nullable<BaseTexture>;
  123429. /** @hidden */
  123430. private _internalMarkAllSubMeshesAsTexturesDirty;
  123431. /** @hidden */
  123432. _markAllSubMeshesAsTexturesDirty(): void;
  123433. /**
  123434. * Instantiate a new istance of anisotropy configuration.
  123435. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123436. */
  123437. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123438. /**
  123439. * Specifies that the submesh is ready to be used.
  123440. * @param defines the list of "defines" to update.
  123441. * @param scene defines the scene the material belongs to.
  123442. * @returns - boolean indicating that the submesh is ready or not.
  123443. */
  123444. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123445. /**
  123446. * Checks to see if a texture is used in the material.
  123447. * @param defines the list of "defines" to update.
  123448. * @param mesh the mesh we are preparing the defines for.
  123449. * @param scene defines the scene the material belongs to.
  123450. */
  123451. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123452. /**
  123453. * Binds the material data.
  123454. * @param uniformBuffer defines the Uniform buffer to fill in.
  123455. * @param scene defines the scene the material belongs to.
  123456. * @param isFrozen defines wether the material is frozen or not.
  123457. */
  123458. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123459. /**
  123460. * Checks to see if a texture is used in the material.
  123461. * @param texture - Base texture to use.
  123462. * @returns - Boolean specifying if a texture is used in the material.
  123463. */
  123464. hasTexture(texture: BaseTexture): boolean;
  123465. /**
  123466. * Returns an array of the actively used textures.
  123467. * @param activeTextures Array of BaseTextures
  123468. */
  123469. getActiveTextures(activeTextures: BaseTexture[]): void;
  123470. /**
  123471. * Returns the animatable textures.
  123472. * @param animatables Array of animatable textures.
  123473. */
  123474. getAnimatables(animatables: IAnimatable[]): void;
  123475. /**
  123476. * Disposes the resources of the material.
  123477. * @param forceDisposeTextures - Forces the disposal of all textures.
  123478. */
  123479. dispose(forceDisposeTextures?: boolean): void;
  123480. /**
  123481. * Get the current class name of the texture useful for serialization or dynamic coding.
  123482. * @returns "PBRAnisotropicConfiguration"
  123483. */
  123484. getClassName(): string;
  123485. /**
  123486. * Add fallbacks to the effect fallbacks list.
  123487. * @param defines defines the Base texture to use.
  123488. * @param fallbacks defines the current fallback list.
  123489. * @param currentRank defines the current fallback rank.
  123490. * @returns the new fallback rank.
  123491. */
  123492. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123493. /**
  123494. * Add the required uniforms to the current list.
  123495. * @param uniforms defines the current uniform list.
  123496. */
  123497. static AddUniforms(uniforms: string[]): void;
  123498. /**
  123499. * Add the required uniforms to the current buffer.
  123500. * @param uniformBuffer defines the current uniform buffer.
  123501. */
  123502. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123503. /**
  123504. * Add the required samplers to the current list.
  123505. * @param samplers defines the current sampler list.
  123506. */
  123507. static AddSamplers(samplers: string[]): void;
  123508. /**
  123509. * Makes a duplicate of the current configuration into another one.
  123510. * @param anisotropicConfiguration define the config where to copy the info
  123511. */
  123512. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123513. /**
  123514. * Serializes this anisotropy configuration.
  123515. * @returns - An object with the serialized config.
  123516. */
  123517. serialize(): any;
  123518. /**
  123519. * Parses a anisotropy Configuration from a serialized object.
  123520. * @param source - Serialized object.
  123521. * @param scene Defines the scene we are parsing for
  123522. * @param rootUrl Defines the rootUrl to load from
  123523. */
  123524. parse(source: any, scene: Scene, rootUrl: string): void;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * @hidden
  123530. */
  123531. export interface IMaterialBRDFDefines {
  123532. BRDF_V_HEIGHT_CORRELATED: boolean;
  123533. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123534. SPHERICAL_HARMONICS: boolean;
  123535. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123536. /** @hidden */
  123537. _areMiscDirty: boolean;
  123538. }
  123539. /**
  123540. * Define the code related to the BRDF parameters of the pbr material.
  123541. */
  123542. export class PBRBRDFConfiguration {
  123543. /**
  123544. * Default value used for the energy conservation.
  123545. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123546. */
  123547. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123548. /**
  123549. * Default value used for the Smith Visibility Height Correlated mode.
  123550. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123551. */
  123552. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123553. /**
  123554. * Default value used for the IBL diffuse part.
  123555. * This can help switching back to the polynomials mode globally which is a tiny bit
  123556. * less GPU intensive at the drawback of a lower quality.
  123557. */
  123558. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123559. /**
  123560. * Default value used for activating energy conservation for the specular workflow.
  123561. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123562. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123563. */
  123564. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123565. private _useEnergyConservation;
  123566. /**
  123567. * Defines if the material uses energy conservation.
  123568. */
  123569. useEnergyConservation: boolean;
  123570. private _useSmithVisibilityHeightCorrelated;
  123571. /**
  123572. * LEGACY Mode set to false
  123573. * Defines if the material uses height smith correlated visibility term.
  123574. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123575. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123576. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123577. * Not relying on height correlated will also disable energy conservation.
  123578. */
  123579. useSmithVisibilityHeightCorrelated: boolean;
  123580. private _useSphericalHarmonics;
  123581. /**
  123582. * LEGACY Mode set to false
  123583. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123584. * diffuse part of the IBL.
  123585. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123586. * to the ground truth.
  123587. */
  123588. useSphericalHarmonics: boolean;
  123589. private _useSpecularGlossinessInputEnergyConservation;
  123590. /**
  123591. * Defines if the material uses energy conservation, when the specular workflow is active.
  123592. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123593. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123594. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123595. */
  123596. useSpecularGlossinessInputEnergyConservation: boolean;
  123597. /** @hidden */
  123598. private _internalMarkAllSubMeshesAsMiscDirty;
  123599. /** @hidden */
  123600. _markAllSubMeshesAsMiscDirty(): void;
  123601. /**
  123602. * Instantiate a new istance of clear coat configuration.
  123603. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123604. */
  123605. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123606. /**
  123607. * Checks to see if a texture is used in the material.
  123608. * @param defines the list of "defines" to update.
  123609. */
  123610. prepareDefines(defines: IMaterialBRDFDefines): void;
  123611. /**
  123612. * Get the current class name of the texture useful for serialization or dynamic coding.
  123613. * @returns "PBRClearCoatConfiguration"
  123614. */
  123615. getClassName(): string;
  123616. /**
  123617. * Makes a duplicate of the current configuration into another one.
  123618. * @param brdfConfiguration define the config where to copy the info
  123619. */
  123620. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123621. /**
  123622. * Serializes this BRDF configuration.
  123623. * @returns - An object with the serialized config.
  123624. */
  123625. serialize(): any;
  123626. /**
  123627. * Parses a anisotropy Configuration from a serialized object.
  123628. * @param source - Serialized object.
  123629. * @param scene Defines the scene we are parsing for
  123630. * @param rootUrl Defines the rootUrl to load from
  123631. */
  123632. parse(source: any, scene: Scene, rootUrl: string): void;
  123633. }
  123634. }
  123635. declare module BABYLON {
  123636. /**
  123637. * @hidden
  123638. */
  123639. export interface IMaterialSheenDefines {
  123640. SHEEN: boolean;
  123641. SHEEN_TEXTURE: boolean;
  123642. SHEEN_TEXTUREDIRECTUV: number;
  123643. SHEEN_LINKWITHALBEDO: boolean;
  123644. /** @hidden */
  123645. _areTexturesDirty: boolean;
  123646. }
  123647. /**
  123648. * Define the code related to the Sheen parameters of the pbr material.
  123649. */
  123650. export class PBRSheenConfiguration {
  123651. private _isEnabled;
  123652. /**
  123653. * Defines if the material uses sheen.
  123654. */
  123655. isEnabled: boolean;
  123656. private _linkSheenWithAlbedo;
  123657. /**
  123658. * Defines if the sheen is linked to the sheen color.
  123659. */
  123660. linkSheenWithAlbedo: boolean;
  123661. /**
  123662. * Defines the sheen intensity.
  123663. */
  123664. intensity: number;
  123665. /**
  123666. * Defines the sheen color.
  123667. */
  123668. color: Color3;
  123669. private _texture;
  123670. /**
  123671. * Stores the sheen tint values in a texture.
  123672. * rgb is tint
  123673. * a is a intensity
  123674. */
  123675. texture: Nullable<BaseTexture>;
  123676. /** @hidden */
  123677. private _internalMarkAllSubMeshesAsTexturesDirty;
  123678. /** @hidden */
  123679. _markAllSubMeshesAsTexturesDirty(): void;
  123680. /**
  123681. * Instantiate a new istance of clear coat configuration.
  123682. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123683. */
  123684. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123685. /**
  123686. * Specifies that the submesh is ready to be used.
  123687. * @param defines the list of "defines" to update.
  123688. * @param scene defines the scene the material belongs to.
  123689. * @returns - boolean indicating that the submesh is ready or not.
  123690. */
  123691. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123692. /**
  123693. * Checks to see if a texture is used in the material.
  123694. * @param defines the list of "defines" to update.
  123695. * @param scene defines the scene the material belongs to.
  123696. */
  123697. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123698. /**
  123699. * Binds the material data.
  123700. * @param uniformBuffer defines the Uniform buffer to fill in.
  123701. * @param scene defines the scene the material belongs to.
  123702. * @param isFrozen defines wether the material is frozen or not.
  123703. */
  123704. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123705. /**
  123706. * Checks to see if a texture is used in the material.
  123707. * @param texture - Base texture to use.
  123708. * @returns - Boolean specifying if a texture is used in the material.
  123709. */
  123710. hasTexture(texture: BaseTexture): boolean;
  123711. /**
  123712. * Returns an array of the actively used textures.
  123713. * @param activeTextures Array of BaseTextures
  123714. */
  123715. getActiveTextures(activeTextures: BaseTexture[]): void;
  123716. /**
  123717. * Returns the animatable textures.
  123718. * @param animatables Array of animatable textures.
  123719. */
  123720. getAnimatables(animatables: IAnimatable[]): void;
  123721. /**
  123722. * Disposes the resources of the material.
  123723. * @param forceDisposeTextures - Forces the disposal of all textures.
  123724. */
  123725. dispose(forceDisposeTextures?: boolean): void;
  123726. /**
  123727. * Get the current class name of the texture useful for serialization or dynamic coding.
  123728. * @returns "PBRSheenConfiguration"
  123729. */
  123730. getClassName(): string;
  123731. /**
  123732. * Add fallbacks to the effect fallbacks list.
  123733. * @param defines defines the Base texture to use.
  123734. * @param fallbacks defines the current fallback list.
  123735. * @param currentRank defines the current fallback rank.
  123736. * @returns the new fallback rank.
  123737. */
  123738. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123739. /**
  123740. * Add the required uniforms to the current list.
  123741. * @param uniforms defines the current uniform list.
  123742. */
  123743. static AddUniforms(uniforms: string[]): void;
  123744. /**
  123745. * Add the required uniforms to the current buffer.
  123746. * @param uniformBuffer defines the current uniform buffer.
  123747. */
  123748. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123749. /**
  123750. * Add the required samplers to the current list.
  123751. * @param samplers defines the current sampler list.
  123752. */
  123753. static AddSamplers(samplers: string[]): void;
  123754. /**
  123755. * Makes a duplicate of the current configuration into another one.
  123756. * @param sheenConfiguration define the config where to copy the info
  123757. */
  123758. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123759. /**
  123760. * Serializes this BRDF configuration.
  123761. * @returns - An object with the serialized config.
  123762. */
  123763. serialize(): any;
  123764. /**
  123765. * Parses a anisotropy Configuration from a serialized object.
  123766. * @param source - Serialized object.
  123767. * @param scene Defines the scene we are parsing for
  123768. * @param rootUrl Defines the rootUrl to load from
  123769. */
  123770. parse(source: any, scene: Scene, rootUrl: string): void;
  123771. }
  123772. }
  123773. declare module BABYLON {
  123774. /**
  123775. * @hidden
  123776. */
  123777. export interface IMaterialSubSurfaceDefines {
  123778. SUBSURFACE: boolean;
  123779. SS_REFRACTION: boolean;
  123780. SS_TRANSLUCENCY: boolean;
  123781. SS_SCATERRING: boolean;
  123782. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123783. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123784. SS_REFRACTIONMAP_3D: boolean;
  123785. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123786. SS_LODINREFRACTIONALPHA: boolean;
  123787. SS_GAMMAREFRACTION: boolean;
  123788. SS_RGBDREFRACTION: boolean;
  123789. SS_LINEARSPECULARREFRACTION: boolean;
  123790. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123791. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123792. /** @hidden */
  123793. _areTexturesDirty: boolean;
  123794. }
  123795. /**
  123796. * Define the code related to the sub surface parameters of the pbr material.
  123797. */
  123798. export class PBRSubSurfaceConfiguration {
  123799. private _isRefractionEnabled;
  123800. /**
  123801. * Defines if the refraction is enabled in the material.
  123802. */
  123803. isRefractionEnabled: boolean;
  123804. private _isTranslucencyEnabled;
  123805. /**
  123806. * Defines if the translucency is enabled in the material.
  123807. */
  123808. isTranslucencyEnabled: boolean;
  123809. private _isScatteringEnabled;
  123810. /**
  123811. * Defines the refraction intensity of the material.
  123812. * The refraction when enabled replaces the Diffuse part of the material.
  123813. * The intensity helps transitionning between diffuse and refraction.
  123814. */
  123815. refractionIntensity: number;
  123816. /**
  123817. * Defines the translucency intensity of the material.
  123818. * When translucency has been enabled, this defines how much of the "translucency"
  123819. * is addded to the diffuse part of the material.
  123820. */
  123821. translucencyIntensity: number;
  123822. /**
  123823. * Defines the scattering intensity of the material.
  123824. * When scattering has been enabled, this defines how much of the "scattered light"
  123825. * is addded to the diffuse part of the material.
  123826. */
  123827. scatteringIntensity: number;
  123828. private _thicknessTexture;
  123829. /**
  123830. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123831. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123832. * 0 would mean minimumThickness
  123833. * 1 would mean maximumThickness
  123834. * The other channels might be use as a mask to vary the different effects intensity.
  123835. */
  123836. thicknessTexture: Nullable<BaseTexture>;
  123837. private _refractionTexture;
  123838. /**
  123839. * Defines the texture to use for refraction.
  123840. */
  123841. refractionTexture: Nullable<BaseTexture>;
  123842. private _indexOfRefraction;
  123843. /**
  123844. * Defines the index of refraction used in the material.
  123845. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123846. */
  123847. indexOfRefraction: number;
  123848. private _invertRefractionY;
  123849. /**
  123850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123851. */
  123852. invertRefractionY: boolean;
  123853. private _linkRefractionWithTransparency;
  123854. /**
  123855. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123856. * Materials half opaque for instance using refraction could benefit from this control.
  123857. */
  123858. linkRefractionWithTransparency: boolean;
  123859. /**
  123860. * Defines the minimum thickness stored in the thickness map.
  123861. * If no thickness map is defined, this value will be used to simulate thickness.
  123862. */
  123863. minimumThickness: number;
  123864. /**
  123865. * Defines the maximum thickness stored in the thickness map.
  123866. */
  123867. maximumThickness: number;
  123868. /**
  123869. * Defines the volume tint of the material.
  123870. * This is used for both translucency and scattering.
  123871. */
  123872. tintColor: Color3;
  123873. /**
  123874. * Defines the distance at which the tint color should be found in the media.
  123875. * This is used for refraction only.
  123876. */
  123877. tintColorAtDistance: number;
  123878. /**
  123879. * Defines how far each channel transmit through the media.
  123880. * It is defined as a color to simplify it selection.
  123881. */
  123882. diffusionDistance: Color3;
  123883. private _useMaskFromThicknessTexture;
  123884. /**
  123885. * Stores the intensity of the different subsurface effects in the thickness texture.
  123886. * * the green channel is the translucency intensity.
  123887. * * the blue channel is the scattering intensity.
  123888. * * the alpha channel is the refraction intensity.
  123889. */
  123890. useMaskFromThicknessTexture: boolean;
  123891. /** @hidden */
  123892. private _internalMarkAllSubMeshesAsTexturesDirty;
  123893. /** @hidden */
  123894. _markAllSubMeshesAsTexturesDirty(): void;
  123895. /**
  123896. * Instantiate a new istance of sub surface configuration.
  123897. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123898. */
  123899. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123900. /**
  123901. * Gets wehter the submesh is ready to be used or not.
  123902. * @param defines the list of "defines" to update.
  123903. * @param scene defines the scene the material belongs to.
  123904. * @returns - boolean indicating that the submesh is ready or not.
  123905. */
  123906. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123907. /**
  123908. * Checks to see if a texture is used in the material.
  123909. * @param defines the list of "defines" to update.
  123910. * @param scene defines the scene to the material belongs to.
  123911. */
  123912. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123913. /**
  123914. * Binds the material data.
  123915. * @param uniformBuffer defines the Uniform buffer to fill in.
  123916. * @param scene defines the scene the material belongs to.
  123917. * @param engine defines the engine the material belongs to.
  123918. * @param isFrozen defines wether the material is frozen or not.
  123919. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123920. */
  123921. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123922. /**
  123923. * Unbinds the material from the mesh.
  123924. * @param activeEffect defines the effect that should be unbound from.
  123925. * @returns true if unbound, otherwise false
  123926. */
  123927. unbind(activeEffect: Effect): boolean;
  123928. /**
  123929. * Returns the texture used for refraction or null if none is used.
  123930. * @param scene defines the scene the material belongs to.
  123931. * @returns - Refraction texture if present. If no refraction texture and refraction
  123932. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123933. */
  123934. private _getRefractionTexture;
  123935. /**
  123936. * Returns true if alpha blending should be disabled.
  123937. */
  123938. get disableAlphaBlending(): boolean;
  123939. /**
  123940. * Fills the list of render target textures.
  123941. * @param renderTargets the list of render targets to update
  123942. */
  123943. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123944. /**
  123945. * Checks to see if a texture is used in the material.
  123946. * @param texture - Base texture to use.
  123947. * @returns - Boolean specifying if a texture is used in the material.
  123948. */
  123949. hasTexture(texture: BaseTexture): boolean;
  123950. /**
  123951. * Gets a boolean indicating that current material needs to register RTT
  123952. * @returns true if this uses a render target otherwise false.
  123953. */
  123954. hasRenderTargetTextures(): boolean;
  123955. /**
  123956. * Returns an array of the actively used textures.
  123957. * @param activeTextures Array of BaseTextures
  123958. */
  123959. getActiveTextures(activeTextures: BaseTexture[]): void;
  123960. /**
  123961. * Returns the animatable textures.
  123962. * @param animatables Array of animatable textures.
  123963. */
  123964. getAnimatables(animatables: IAnimatable[]): void;
  123965. /**
  123966. * Disposes the resources of the material.
  123967. * @param forceDisposeTextures - Forces the disposal of all textures.
  123968. */
  123969. dispose(forceDisposeTextures?: boolean): void;
  123970. /**
  123971. * Get the current class name of the texture useful for serialization or dynamic coding.
  123972. * @returns "PBRSubSurfaceConfiguration"
  123973. */
  123974. getClassName(): string;
  123975. /**
  123976. * Add fallbacks to the effect fallbacks list.
  123977. * @param defines defines the Base texture to use.
  123978. * @param fallbacks defines the current fallback list.
  123979. * @param currentRank defines the current fallback rank.
  123980. * @returns the new fallback rank.
  123981. */
  123982. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123983. /**
  123984. * Add the required uniforms to the current list.
  123985. * @param uniforms defines the current uniform list.
  123986. */
  123987. static AddUniforms(uniforms: string[]): void;
  123988. /**
  123989. * Add the required samplers to the current list.
  123990. * @param samplers defines the current sampler list.
  123991. */
  123992. static AddSamplers(samplers: string[]): void;
  123993. /**
  123994. * Add the required uniforms to the current buffer.
  123995. * @param uniformBuffer defines the current uniform buffer.
  123996. */
  123997. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123998. /**
  123999. * Makes a duplicate of the current configuration into another one.
  124000. * @param configuration define the config where to copy the info
  124001. */
  124002. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124003. /**
  124004. * Serializes this Sub Surface configuration.
  124005. * @returns - An object with the serialized config.
  124006. */
  124007. serialize(): any;
  124008. /**
  124009. * Parses a anisotropy Configuration from a serialized object.
  124010. * @param source - Serialized object.
  124011. * @param scene Defines the scene we are parsing for
  124012. * @param rootUrl Defines the rootUrl to load from
  124013. */
  124014. parse(source: any, scene: Scene, rootUrl: string): void;
  124015. }
  124016. }
  124017. declare module BABYLON {
  124018. /** @hidden */
  124019. export var pbrFragmentDeclaration: {
  124020. name: string;
  124021. shader: string;
  124022. };
  124023. }
  124024. declare module BABYLON {
  124025. /** @hidden */
  124026. export var pbrUboDeclaration: {
  124027. name: string;
  124028. shader: string;
  124029. };
  124030. }
  124031. declare module BABYLON {
  124032. /** @hidden */
  124033. export var pbrFragmentExtraDeclaration: {
  124034. name: string;
  124035. shader: string;
  124036. };
  124037. }
  124038. declare module BABYLON {
  124039. /** @hidden */
  124040. export var pbrFragmentSamplersDeclaration: {
  124041. name: string;
  124042. shader: string;
  124043. };
  124044. }
  124045. declare module BABYLON {
  124046. /** @hidden */
  124047. export var pbrHelperFunctions: {
  124048. name: string;
  124049. shader: string;
  124050. };
  124051. }
  124052. declare module BABYLON {
  124053. /** @hidden */
  124054. export var harmonicsFunctions: {
  124055. name: string;
  124056. shader: string;
  124057. };
  124058. }
  124059. declare module BABYLON {
  124060. /** @hidden */
  124061. export var pbrDirectLightingSetupFunctions: {
  124062. name: string;
  124063. shader: string;
  124064. };
  124065. }
  124066. declare module BABYLON {
  124067. /** @hidden */
  124068. export var pbrDirectLightingFalloffFunctions: {
  124069. name: string;
  124070. shader: string;
  124071. };
  124072. }
  124073. declare module BABYLON {
  124074. /** @hidden */
  124075. export var pbrBRDFFunctions: {
  124076. name: string;
  124077. shader: string;
  124078. };
  124079. }
  124080. declare module BABYLON {
  124081. /** @hidden */
  124082. export var pbrDirectLightingFunctions: {
  124083. name: string;
  124084. shader: string;
  124085. };
  124086. }
  124087. declare module BABYLON {
  124088. /** @hidden */
  124089. export var pbrIBLFunctions: {
  124090. name: string;
  124091. shader: string;
  124092. };
  124093. }
  124094. declare module BABYLON {
  124095. /** @hidden */
  124096. export var pbrDebug: {
  124097. name: string;
  124098. shader: string;
  124099. };
  124100. }
  124101. declare module BABYLON {
  124102. /** @hidden */
  124103. export var pbrPixelShader: {
  124104. name: string;
  124105. shader: string;
  124106. };
  124107. }
  124108. declare module BABYLON {
  124109. /** @hidden */
  124110. export var pbrVertexDeclaration: {
  124111. name: string;
  124112. shader: string;
  124113. };
  124114. }
  124115. declare module BABYLON {
  124116. /** @hidden */
  124117. export var pbrVertexShader: {
  124118. name: string;
  124119. shader: string;
  124120. };
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * Manages the defines for the PBR Material.
  124125. * @hidden
  124126. */
  124127. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124128. PBR: boolean;
  124129. MAINUV1: boolean;
  124130. MAINUV2: boolean;
  124131. UV1: boolean;
  124132. UV2: boolean;
  124133. ALBEDO: boolean;
  124134. ALBEDODIRECTUV: number;
  124135. VERTEXCOLOR: boolean;
  124136. AMBIENT: boolean;
  124137. AMBIENTDIRECTUV: number;
  124138. AMBIENTINGRAYSCALE: boolean;
  124139. OPACITY: boolean;
  124140. VERTEXALPHA: boolean;
  124141. OPACITYDIRECTUV: number;
  124142. OPACITYRGB: boolean;
  124143. ALPHATEST: boolean;
  124144. DEPTHPREPASS: boolean;
  124145. ALPHABLEND: boolean;
  124146. ALPHAFROMALBEDO: boolean;
  124147. ALPHATESTVALUE: string;
  124148. SPECULAROVERALPHA: boolean;
  124149. RADIANCEOVERALPHA: boolean;
  124150. ALPHAFRESNEL: boolean;
  124151. LINEARALPHAFRESNEL: boolean;
  124152. PREMULTIPLYALPHA: boolean;
  124153. EMISSIVE: boolean;
  124154. EMISSIVEDIRECTUV: number;
  124155. REFLECTIVITY: boolean;
  124156. REFLECTIVITYDIRECTUV: number;
  124157. SPECULARTERM: boolean;
  124158. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124159. MICROSURFACEAUTOMATIC: boolean;
  124160. LODBASEDMICROSFURACE: boolean;
  124161. MICROSURFACEMAP: boolean;
  124162. MICROSURFACEMAPDIRECTUV: number;
  124163. METALLICWORKFLOW: boolean;
  124164. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124165. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124166. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124167. AOSTOREINMETALMAPRED: boolean;
  124168. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124169. ENVIRONMENTBRDF: boolean;
  124170. ENVIRONMENTBRDF_RGBD: boolean;
  124171. NORMAL: boolean;
  124172. TANGENT: boolean;
  124173. BUMP: boolean;
  124174. BUMPDIRECTUV: number;
  124175. OBJECTSPACE_NORMALMAP: boolean;
  124176. PARALLAX: boolean;
  124177. PARALLAXOCCLUSION: boolean;
  124178. NORMALXYSCALE: boolean;
  124179. LIGHTMAP: boolean;
  124180. LIGHTMAPDIRECTUV: number;
  124181. USELIGHTMAPASSHADOWMAP: boolean;
  124182. GAMMALIGHTMAP: boolean;
  124183. RGBDLIGHTMAP: boolean;
  124184. REFLECTION: boolean;
  124185. REFLECTIONMAP_3D: boolean;
  124186. REFLECTIONMAP_SPHERICAL: boolean;
  124187. REFLECTIONMAP_PLANAR: boolean;
  124188. REFLECTIONMAP_CUBIC: boolean;
  124189. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124190. REFLECTIONMAP_PROJECTION: boolean;
  124191. REFLECTIONMAP_SKYBOX: boolean;
  124192. REFLECTIONMAP_EXPLICIT: boolean;
  124193. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124194. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124195. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124196. INVERTCUBICMAP: boolean;
  124197. USESPHERICALFROMREFLECTIONMAP: boolean;
  124198. USEIRRADIANCEMAP: boolean;
  124199. SPHERICAL_HARMONICS: boolean;
  124200. USESPHERICALINVERTEX: boolean;
  124201. REFLECTIONMAP_OPPOSITEZ: boolean;
  124202. LODINREFLECTIONALPHA: boolean;
  124203. GAMMAREFLECTION: boolean;
  124204. RGBDREFLECTION: boolean;
  124205. LINEARSPECULARREFLECTION: boolean;
  124206. RADIANCEOCCLUSION: boolean;
  124207. HORIZONOCCLUSION: boolean;
  124208. INSTANCES: boolean;
  124209. NUM_BONE_INFLUENCERS: number;
  124210. BonesPerMesh: number;
  124211. BONETEXTURE: boolean;
  124212. NONUNIFORMSCALING: boolean;
  124213. MORPHTARGETS: boolean;
  124214. MORPHTARGETS_NORMAL: boolean;
  124215. MORPHTARGETS_TANGENT: boolean;
  124216. MORPHTARGETS_UV: boolean;
  124217. NUM_MORPH_INFLUENCERS: number;
  124218. IMAGEPROCESSING: boolean;
  124219. VIGNETTE: boolean;
  124220. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124221. VIGNETTEBLENDMODEOPAQUE: boolean;
  124222. TONEMAPPING: boolean;
  124223. TONEMAPPING_ACES: boolean;
  124224. CONTRAST: boolean;
  124225. COLORCURVES: boolean;
  124226. COLORGRADING: boolean;
  124227. COLORGRADING3D: boolean;
  124228. SAMPLER3DGREENDEPTH: boolean;
  124229. SAMPLER3DBGRMAP: boolean;
  124230. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124231. EXPOSURE: boolean;
  124232. MULTIVIEW: boolean;
  124233. USEPHYSICALLIGHTFALLOFF: boolean;
  124234. USEGLTFLIGHTFALLOFF: boolean;
  124235. TWOSIDEDLIGHTING: boolean;
  124236. SHADOWFLOAT: boolean;
  124237. CLIPPLANE: boolean;
  124238. CLIPPLANE2: boolean;
  124239. CLIPPLANE3: boolean;
  124240. CLIPPLANE4: boolean;
  124241. CLIPPLANE5: boolean;
  124242. CLIPPLANE6: boolean;
  124243. POINTSIZE: boolean;
  124244. FOG: boolean;
  124245. LOGARITHMICDEPTH: boolean;
  124246. FORCENORMALFORWARD: boolean;
  124247. SPECULARAA: boolean;
  124248. CLEARCOAT: boolean;
  124249. CLEARCOAT_DEFAULTIOR: boolean;
  124250. CLEARCOAT_TEXTURE: boolean;
  124251. CLEARCOAT_TEXTUREDIRECTUV: number;
  124252. CLEARCOAT_BUMP: boolean;
  124253. CLEARCOAT_BUMPDIRECTUV: number;
  124254. CLEARCOAT_TINT: boolean;
  124255. CLEARCOAT_TINT_TEXTURE: boolean;
  124256. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124257. ANISOTROPIC: boolean;
  124258. ANISOTROPIC_TEXTURE: boolean;
  124259. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124260. BRDF_V_HEIGHT_CORRELATED: boolean;
  124261. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124262. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124263. SHEEN: boolean;
  124264. SHEEN_TEXTURE: boolean;
  124265. SHEEN_TEXTUREDIRECTUV: number;
  124266. SHEEN_LINKWITHALBEDO: boolean;
  124267. SUBSURFACE: boolean;
  124268. SS_REFRACTION: boolean;
  124269. SS_TRANSLUCENCY: boolean;
  124270. SS_SCATERRING: boolean;
  124271. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124272. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124273. SS_REFRACTIONMAP_3D: boolean;
  124274. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124275. SS_LODINREFRACTIONALPHA: boolean;
  124276. SS_GAMMAREFRACTION: boolean;
  124277. SS_RGBDREFRACTION: boolean;
  124278. SS_LINEARSPECULARREFRACTION: boolean;
  124279. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124280. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124281. UNLIT: boolean;
  124282. DEBUGMODE: number;
  124283. /**
  124284. * Initializes the PBR Material defines.
  124285. */
  124286. constructor();
  124287. /**
  124288. * Resets the PBR Material defines.
  124289. */
  124290. reset(): void;
  124291. }
  124292. /**
  124293. * The Physically based material base class of BJS.
  124294. *
  124295. * This offers the main features of a standard PBR material.
  124296. * For more information, please refer to the documentation :
  124297. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124298. */
  124299. export abstract class PBRBaseMaterial extends PushMaterial {
  124300. /**
  124301. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124302. */
  124303. static readonly PBRMATERIAL_OPAQUE: number;
  124304. /**
  124305. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124306. */
  124307. static readonly PBRMATERIAL_ALPHATEST: number;
  124308. /**
  124309. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124310. */
  124311. static readonly PBRMATERIAL_ALPHABLEND: number;
  124312. /**
  124313. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124314. * They are also discarded below the alpha cutoff threshold to improve performances.
  124315. */
  124316. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124317. /**
  124318. * Defines the default value of how much AO map is occluding the analytical lights
  124319. * (point spot...).
  124320. */
  124321. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124322. /**
  124323. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124324. */
  124325. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124326. /**
  124327. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124328. * to enhance interoperability with other engines.
  124329. */
  124330. static readonly LIGHTFALLOFF_GLTF: number;
  124331. /**
  124332. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124333. * to enhance interoperability with other materials.
  124334. */
  124335. static readonly LIGHTFALLOFF_STANDARD: number;
  124336. /**
  124337. * Intensity of the direct lights e.g. the four lights available in your scene.
  124338. * This impacts both the direct diffuse and specular highlights.
  124339. */
  124340. protected _directIntensity: number;
  124341. /**
  124342. * Intensity of the emissive part of the material.
  124343. * This helps controlling the emissive effect without modifying the emissive color.
  124344. */
  124345. protected _emissiveIntensity: number;
  124346. /**
  124347. * Intensity of the environment e.g. how much the environment will light the object
  124348. * either through harmonics for rough material or through the refelction for shiny ones.
  124349. */
  124350. protected _environmentIntensity: number;
  124351. /**
  124352. * This is a special control allowing the reduction of the specular highlights coming from the
  124353. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124354. */
  124355. protected _specularIntensity: number;
  124356. /**
  124357. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124358. */
  124359. private _lightingInfos;
  124360. /**
  124361. * Debug Control allowing disabling the bump map on this material.
  124362. */
  124363. protected _disableBumpMap: boolean;
  124364. /**
  124365. * AKA Diffuse Texture in standard nomenclature.
  124366. */
  124367. protected _albedoTexture: Nullable<BaseTexture>;
  124368. /**
  124369. * AKA Occlusion Texture in other nomenclature.
  124370. */
  124371. protected _ambientTexture: Nullable<BaseTexture>;
  124372. /**
  124373. * AKA Occlusion Texture Intensity in other nomenclature.
  124374. */
  124375. protected _ambientTextureStrength: number;
  124376. /**
  124377. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124378. * 1 means it completely occludes it
  124379. * 0 mean it has no impact
  124380. */
  124381. protected _ambientTextureImpactOnAnalyticalLights: number;
  124382. /**
  124383. * Stores the alpha values in a texture.
  124384. */
  124385. protected _opacityTexture: Nullable<BaseTexture>;
  124386. /**
  124387. * Stores the reflection values in a texture.
  124388. */
  124389. protected _reflectionTexture: Nullable<BaseTexture>;
  124390. /**
  124391. * Stores the emissive values in a texture.
  124392. */
  124393. protected _emissiveTexture: Nullable<BaseTexture>;
  124394. /**
  124395. * AKA Specular texture in other nomenclature.
  124396. */
  124397. protected _reflectivityTexture: Nullable<BaseTexture>;
  124398. /**
  124399. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124400. */
  124401. protected _metallicTexture: Nullable<BaseTexture>;
  124402. /**
  124403. * Specifies the metallic scalar of the metallic/roughness workflow.
  124404. * Can also be used to scale the metalness values of the metallic texture.
  124405. */
  124406. protected _metallic: Nullable<number>;
  124407. /**
  124408. * Specifies the roughness scalar of the metallic/roughness workflow.
  124409. * Can also be used to scale the roughness values of the metallic texture.
  124410. */
  124411. protected _roughness: Nullable<number>;
  124412. /**
  124413. * Specifies the an F0 factor to help configuring the material F0.
  124414. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124415. * to 0.5 the previously hard coded value stays the same.
  124416. * Can also be used to scale the F0 values of the metallic texture.
  124417. */
  124418. protected _metallicF0Factor: number;
  124419. /**
  124420. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124421. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124422. * your expectation as it multiplies with the texture data.
  124423. */
  124424. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124425. /**
  124426. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124427. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124428. */
  124429. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124430. /**
  124431. * Stores surface normal data used to displace a mesh in a texture.
  124432. */
  124433. protected _bumpTexture: Nullable<BaseTexture>;
  124434. /**
  124435. * Stores the pre-calculated light information of a mesh in a texture.
  124436. */
  124437. protected _lightmapTexture: Nullable<BaseTexture>;
  124438. /**
  124439. * The color of a material in ambient lighting.
  124440. */
  124441. protected _ambientColor: Color3;
  124442. /**
  124443. * AKA Diffuse Color in other nomenclature.
  124444. */
  124445. protected _albedoColor: Color3;
  124446. /**
  124447. * AKA Specular Color in other nomenclature.
  124448. */
  124449. protected _reflectivityColor: Color3;
  124450. /**
  124451. * The color applied when light is reflected from a material.
  124452. */
  124453. protected _reflectionColor: Color3;
  124454. /**
  124455. * The color applied when light is emitted from a material.
  124456. */
  124457. protected _emissiveColor: Color3;
  124458. /**
  124459. * AKA Glossiness in other nomenclature.
  124460. */
  124461. protected _microSurface: number;
  124462. /**
  124463. * Specifies that the material will use the light map as a show map.
  124464. */
  124465. protected _useLightmapAsShadowmap: boolean;
  124466. /**
  124467. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124468. * makes the reflect vector face the model (under horizon).
  124469. */
  124470. protected _useHorizonOcclusion: boolean;
  124471. /**
  124472. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124473. * too much the area relying on ambient texture to define their ambient occlusion.
  124474. */
  124475. protected _useRadianceOcclusion: boolean;
  124476. /**
  124477. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124478. */
  124479. protected _useAlphaFromAlbedoTexture: boolean;
  124480. /**
  124481. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124482. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124483. */
  124484. protected _useSpecularOverAlpha: boolean;
  124485. /**
  124486. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124487. */
  124488. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124489. /**
  124490. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124491. */
  124492. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124493. /**
  124494. * Specifies if the metallic texture contains the roughness information in its green channel.
  124495. */
  124496. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124497. /**
  124498. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124499. */
  124500. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124501. /**
  124502. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124503. */
  124504. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124505. /**
  124506. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124507. */
  124508. protected _useAmbientInGrayScale: boolean;
  124509. /**
  124510. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124511. * The material will try to infer what glossiness each pixel should be.
  124512. */
  124513. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124514. /**
  124515. * Defines the falloff type used in this material.
  124516. * It by default is Physical.
  124517. */
  124518. protected _lightFalloff: number;
  124519. /**
  124520. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124521. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124522. */
  124523. protected _useRadianceOverAlpha: boolean;
  124524. /**
  124525. * Allows using an object space normal map (instead of tangent space).
  124526. */
  124527. protected _useObjectSpaceNormalMap: boolean;
  124528. /**
  124529. * Allows using the bump map in parallax mode.
  124530. */
  124531. protected _useParallax: boolean;
  124532. /**
  124533. * Allows using the bump map in parallax occlusion mode.
  124534. */
  124535. protected _useParallaxOcclusion: boolean;
  124536. /**
  124537. * Controls the scale bias of the parallax mode.
  124538. */
  124539. protected _parallaxScaleBias: number;
  124540. /**
  124541. * If sets to true, disables all the lights affecting the material.
  124542. */
  124543. protected _disableLighting: boolean;
  124544. /**
  124545. * Number of Simultaneous lights allowed on the material.
  124546. */
  124547. protected _maxSimultaneousLights: number;
  124548. /**
  124549. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124550. */
  124551. protected _invertNormalMapX: boolean;
  124552. /**
  124553. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124554. */
  124555. protected _invertNormalMapY: boolean;
  124556. /**
  124557. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124558. */
  124559. protected _twoSidedLighting: boolean;
  124560. /**
  124561. * Defines the alpha limits in alpha test mode.
  124562. */
  124563. protected _alphaCutOff: number;
  124564. /**
  124565. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124566. */
  124567. protected _forceAlphaTest: boolean;
  124568. /**
  124569. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124570. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124571. */
  124572. protected _useAlphaFresnel: boolean;
  124573. /**
  124574. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124575. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124576. */
  124577. protected _useLinearAlphaFresnel: boolean;
  124578. /**
  124579. * The transparency mode of the material.
  124580. */
  124581. protected _transparencyMode: Nullable<number>;
  124582. /**
  124583. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124584. * from cos thetav and roughness:
  124585. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124586. */
  124587. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124588. /**
  124589. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124590. */
  124591. protected _forceIrradianceInFragment: boolean;
  124592. /**
  124593. * Force normal to face away from face.
  124594. */
  124595. protected _forceNormalForward: boolean;
  124596. /**
  124597. * Enables specular anti aliasing in the PBR shader.
  124598. * It will both interacts on the Geometry for analytical and IBL lighting.
  124599. * It also prefilter the roughness map based on the bump values.
  124600. */
  124601. protected _enableSpecularAntiAliasing: boolean;
  124602. /**
  124603. * Default configuration related to image processing available in the PBR Material.
  124604. */
  124605. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124606. /**
  124607. * Keep track of the image processing observer to allow dispose and replace.
  124608. */
  124609. private _imageProcessingObserver;
  124610. /**
  124611. * Attaches a new image processing configuration to the PBR Material.
  124612. * @param configuration
  124613. */
  124614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124615. /**
  124616. * Stores the available render targets.
  124617. */
  124618. private _renderTargets;
  124619. /**
  124620. * Sets the global ambient color for the material used in lighting calculations.
  124621. */
  124622. private _globalAmbientColor;
  124623. /**
  124624. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124625. */
  124626. private _useLogarithmicDepth;
  124627. /**
  124628. * If set to true, no lighting calculations will be applied.
  124629. */
  124630. private _unlit;
  124631. private _debugMode;
  124632. /**
  124633. * @hidden
  124634. * This is reserved for the inspector.
  124635. * Defines the material debug mode.
  124636. * It helps seeing only some components of the material while troubleshooting.
  124637. */
  124638. debugMode: number;
  124639. /**
  124640. * @hidden
  124641. * This is reserved for the inspector.
  124642. * Specify from where on screen the debug mode should start.
  124643. * The value goes from -1 (full screen) to 1 (not visible)
  124644. * It helps with side by side comparison against the final render
  124645. * This defaults to -1
  124646. */
  124647. private debugLimit;
  124648. /**
  124649. * @hidden
  124650. * This is reserved for the inspector.
  124651. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124652. * You can use the factor to better multiply the final value.
  124653. */
  124654. private debugFactor;
  124655. /**
  124656. * Defines the clear coat layer parameters for the material.
  124657. */
  124658. readonly clearCoat: PBRClearCoatConfiguration;
  124659. /**
  124660. * Defines the anisotropic parameters for the material.
  124661. */
  124662. readonly anisotropy: PBRAnisotropicConfiguration;
  124663. /**
  124664. * Defines the BRDF parameters for the material.
  124665. */
  124666. readonly brdf: PBRBRDFConfiguration;
  124667. /**
  124668. * Defines the Sheen parameters for the material.
  124669. */
  124670. readonly sheen: PBRSheenConfiguration;
  124671. /**
  124672. * Defines the SubSurface parameters for the material.
  124673. */
  124674. readonly subSurface: PBRSubSurfaceConfiguration;
  124675. /**
  124676. * Custom callback helping to override the default shader used in the material.
  124677. */
  124678. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124679. protected _rebuildInParallel: boolean;
  124680. /**
  124681. * Instantiates a new PBRMaterial instance.
  124682. *
  124683. * @param name The material name
  124684. * @param scene The scene the material will be use in.
  124685. */
  124686. constructor(name: string, scene: Scene);
  124687. /**
  124688. * Gets a boolean indicating that current material needs to register RTT
  124689. */
  124690. get hasRenderTargetTextures(): boolean;
  124691. /**
  124692. * Gets the name of the material class.
  124693. */
  124694. getClassName(): string;
  124695. /**
  124696. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124697. */
  124698. get useLogarithmicDepth(): boolean;
  124699. /**
  124700. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124701. */
  124702. set useLogarithmicDepth(value: boolean);
  124703. /**
  124704. * Gets the current transparency mode.
  124705. */
  124706. get transparencyMode(): Nullable<number>;
  124707. /**
  124708. * Sets the transparency mode of the material.
  124709. *
  124710. * | Value | Type | Description |
  124711. * | ----- | ----------------------------------- | ----------- |
  124712. * | 0 | OPAQUE | |
  124713. * | 1 | ALPHATEST | |
  124714. * | 2 | ALPHABLEND | |
  124715. * | 3 | ALPHATESTANDBLEND | |
  124716. *
  124717. */
  124718. set transparencyMode(value: Nullable<number>);
  124719. /**
  124720. * Returns true if alpha blending should be disabled.
  124721. */
  124722. private get _disableAlphaBlending();
  124723. /**
  124724. * Specifies whether or not this material should be rendered in alpha blend mode.
  124725. */
  124726. needAlphaBlending(): boolean;
  124727. /**
  124728. * Specifies if the mesh will require alpha blending.
  124729. * @param mesh - BJS mesh.
  124730. */
  124731. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124732. /**
  124733. * Specifies whether or not this material should be rendered in alpha test mode.
  124734. */
  124735. needAlphaTesting(): boolean;
  124736. /**
  124737. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124738. */
  124739. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124740. /**
  124741. * Gets the texture used for the alpha test.
  124742. */
  124743. getAlphaTestTexture(): Nullable<BaseTexture>;
  124744. /**
  124745. * Specifies that the submesh is ready to be used.
  124746. * @param mesh - BJS mesh.
  124747. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124748. * @param useInstances - Specifies that instances should be used.
  124749. * @returns - boolean indicating that the submesh is ready or not.
  124750. */
  124751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124752. /**
  124753. * Specifies if the material uses metallic roughness workflow.
  124754. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124755. */
  124756. isMetallicWorkflow(): boolean;
  124757. private _prepareEffect;
  124758. private _prepareDefines;
  124759. /**
  124760. * Force shader compilation
  124761. */
  124762. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124763. /**
  124764. * Initializes the uniform buffer layout for the shader.
  124765. */
  124766. buildUniformLayout(): void;
  124767. /**
  124768. * Unbinds the material from the mesh
  124769. */
  124770. unbind(): void;
  124771. /**
  124772. * Binds the submesh data.
  124773. * @param world - The world matrix.
  124774. * @param mesh - The BJS mesh.
  124775. * @param subMesh - A submesh of the BJS mesh.
  124776. */
  124777. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124778. /**
  124779. * Returns the animatable textures.
  124780. * @returns - Array of animatable textures.
  124781. */
  124782. getAnimatables(): IAnimatable[];
  124783. /**
  124784. * Returns the texture used for reflections.
  124785. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124786. */
  124787. private _getReflectionTexture;
  124788. /**
  124789. * Returns an array of the actively used textures.
  124790. * @returns - Array of BaseTextures
  124791. */
  124792. getActiveTextures(): BaseTexture[];
  124793. /**
  124794. * Checks to see if a texture is used in the material.
  124795. * @param texture - Base texture to use.
  124796. * @returns - Boolean specifying if a texture is used in the material.
  124797. */
  124798. hasTexture(texture: BaseTexture): boolean;
  124799. /**
  124800. * Disposes the resources of the material.
  124801. * @param forceDisposeEffect - Forces the disposal of effects.
  124802. * @param forceDisposeTextures - Forces the disposal of all textures.
  124803. */
  124804. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124805. }
  124806. }
  124807. declare module BABYLON {
  124808. /**
  124809. * The Physically based material of BJS.
  124810. *
  124811. * This offers the main features of a standard PBR material.
  124812. * For more information, please refer to the documentation :
  124813. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124814. */
  124815. export class PBRMaterial extends PBRBaseMaterial {
  124816. /**
  124817. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124818. */
  124819. static readonly PBRMATERIAL_OPAQUE: number;
  124820. /**
  124821. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124822. */
  124823. static readonly PBRMATERIAL_ALPHATEST: number;
  124824. /**
  124825. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124826. */
  124827. static readonly PBRMATERIAL_ALPHABLEND: number;
  124828. /**
  124829. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124830. * They are also discarded below the alpha cutoff threshold to improve performances.
  124831. */
  124832. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124833. /**
  124834. * Defines the default value of how much AO map is occluding the analytical lights
  124835. * (point spot...).
  124836. */
  124837. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124838. /**
  124839. * Intensity of the direct lights e.g. the four lights available in your scene.
  124840. * This impacts both the direct diffuse and specular highlights.
  124841. */
  124842. directIntensity: number;
  124843. /**
  124844. * Intensity of the emissive part of the material.
  124845. * This helps controlling the emissive effect without modifying the emissive color.
  124846. */
  124847. emissiveIntensity: number;
  124848. /**
  124849. * Intensity of the environment e.g. how much the environment will light the object
  124850. * either through harmonics for rough material or through the refelction for shiny ones.
  124851. */
  124852. environmentIntensity: number;
  124853. /**
  124854. * This is a special control allowing the reduction of the specular highlights coming from the
  124855. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124856. */
  124857. specularIntensity: number;
  124858. /**
  124859. * Debug Control allowing disabling the bump map on this material.
  124860. */
  124861. disableBumpMap: boolean;
  124862. /**
  124863. * AKA Diffuse Texture in standard nomenclature.
  124864. */
  124865. albedoTexture: BaseTexture;
  124866. /**
  124867. * AKA Occlusion Texture in other nomenclature.
  124868. */
  124869. ambientTexture: BaseTexture;
  124870. /**
  124871. * AKA Occlusion Texture Intensity in other nomenclature.
  124872. */
  124873. ambientTextureStrength: number;
  124874. /**
  124875. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124876. * 1 means it completely occludes it
  124877. * 0 mean it has no impact
  124878. */
  124879. ambientTextureImpactOnAnalyticalLights: number;
  124880. /**
  124881. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124882. */
  124883. opacityTexture: BaseTexture;
  124884. /**
  124885. * Stores the reflection values in a texture.
  124886. */
  124887. reflectionTexture: Nullable<BaseTexture>;
  124888. /**
  124889. * Stores the emissive values in a texture.
  124890. */
  124891. emissiveTexture: BaseTexture;
  124892. /**
  124893. * AKA Specular texture in other nomenclature.
  124894. */
  124895. reflectivityTexture: BaseTexture;
  124896. /**
  124897. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124898. */
  124899. metallicTexture: BaseTexture;
  124900. /**
  124901. * Specifies the metallic scalar of the metallic/roughness workflow.
  124902. * Can also be used to scale the metalness values of the metallic texture.
  124903. */
  124904. metallic: Nullable<number>;
  124905. /**
  124906. * Specifies the roughness scalar of the metallic/roughness workflow.
  124907. * Can also be used to scale the roughness values of the metallic texture.
  124908. */
  124909. roughness: Nullable<number>;
  124910. /**
  124911. * Specifies the an F0 factor to help configuring the material F0.
  124912. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124913. * to 0.5 the previously hard coded value stays the same.
  124914. * Can also be used to scale the F0 values of the metallic texture.
  124915. */
  124916. metallicF0Factor: number;
  124917. /**
  124918. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124919. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124920. * your expectation as it multiplies with the texture data.
  124921. */
  124922. useMetallicF0FactorFromMetallicTexture: boolean;
  124923. /**
  124924. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124925. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124926. */
  124927. microSurfaceTexture: BaseTexture;
  124928. /**
  124929. * Stores surface normal data used to displace a mesh in a texture.
  124930. */
  124931. bumpTexture: BaseTexture;
  124932. /**
  124933. * Stores the pre-calculated light information of a mesh in a texture.
  124934. */
  124935. lightmapTexture: BaseTexture;
  124936. /**
  124937. * Stores the refracted light information in a texture.
  124938. */
  124939. get refractionTexture(): Nullable<BaseTexture>;
  124940. set refractionTexture(value: Nullable<BaseTexture>);
  124941. /**
  124942. * The color of a material in ambient lighting.
  124943. */
  124944. ambientColor: Color3;
  124945. /**
  124946. * AKA Diffuse Color in other nomenclature.
  124947. */
  124948. albedoColor: Color3;
  124949. /**
  124950. * AKA Specular Color in other nomenclature.
  124951. */
  124952. reflectivityColor: Color3;
  124953. /**
  124954. * The color reflected from the material.
  124955. */
  124956. reflectionColor: Color3;
  124957. /**
  124958. * The color emitted from the material.
  124959. */
  124960. emissiveColor: Color3;
  124961. /**
  124962. * AKA Glossiness in other nomenclature.
  124963. */
  124964. microSurface: number;
  124965. /**
  124966. * source material index of refraction (IOR)' / 'destination material IOR.
  124967. */
  124968. get indexOfRefraction(): number;
  124969. set indexOfRefraction(value: number);
  124970. /**
  124971. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124972. */
  124973. get invertRefractionY(): boolean;
  124974. set invertRefractionY(value: boolean);
  124975. /**
  124976. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124977. * Materials half opaque for instance using refraction could benefit from this control.
  124978. */
  124979. get linkRefractionWithTransparency(): boolean;
  124980. set linkRefractionWithTransparency(value: boolean);
  124981. /**
  124982. * If true, the light map contains occlusion information instead of lighting info.
  124983. */
  124984. useLightmapAsShadowmap: boolean;
  124985. /**
  124986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124987. */
  124988. useAlphaFromAlbedoTexture: boolean;
  124989. /**
  124990. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124991. */
  124992. forceAlphaTest: boolean;
  124993. /**
  124994. * Defines the alpha limits in alpha test mode.
  124995. */
  124996. alphaCutOff: number;
  124997. /**
  124998. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125000. */
  125001. useSpecularOverAlpha: boolean;
  125002. /**
  125003. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125004. */
  125005. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125006. /**
  125007. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125008. */
  125009. useRoughnessFromMetallicTextureAlpha: boolean;
  125010. /**
  125011. * Specifies if the metallic texture contains the roughness information in its green channel.
  125012. */
  125013. useRoughnessFromMetallicTextureGreen: boolean;
  125014. /**
  125015. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125016. */
  125017. useMetallnessFromMetallicTextureBlue: boolean;
  125018. /**
  125019. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125020. */
  125021. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125022. /**
  125023. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125024. */
  125025. useAmbientInGrayScale: boolean;
  125026. /**
  125027. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125028. * The material will try to infer what glossiness each pixel should be.
  125029. */
  125030. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125031. /**
  125032. * BJS is using an harcoded light falloff based on a manually sets up range.
  125033. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125034. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125035. */
  125036. get usePhysicalLightFalloff(): boolean;
  125037. /**
  125038. * BJS is using an harcoded light falloff based on a manually sets up range.
  125039. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125040. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125041. */
  125042. set usePhysicalLightFalloff(value: boolean);
  125043. /**
  125044. * In order to support the falloff compatibility with gltf, a special mode has been added
  125045. * to reproduce the gltf light falloff.
  125046. */
  125047. get useGLTFLightFalloff(): boolean;
  125048. /**
  125049. * In order to support the falloff compatibility with gltf, a special mode has been added
  125050. * to reproduce the gltf light falloff.
  125051. */
  125052. set useGLTFLightFalloff(value: boolean);
  125053. /**
  125054. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125055. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125056. */
  125057. useRadianceOverAlpha: boolean;
  125058. /**
  125059. * Allows using an object space normal map (instead of tangent space).
  125060. */
  125061. useObjectSpaceNormalMap: boolean;
  125062. /**
  125063. * Allows using the bump map in parallax mode.
  125064. */
  125065. useParallax: boolean;
  125066. /**
  125067. * Allows using the bump map in parallax occlusion mode.
  125068. */
  125069. useParallaxOcclusion: boolean;
  125070. /**
  125071. * Controls the scale bias of the parallax mode.
  125072. */
  125073. parallaxScaleBias: number;
  125074. /**
  125075. * If sets to true, disables all the lights affecting the material.
  125076. */
  125077. disableLighting: boolean;
  125078. /**
  125079. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125080. */
  125081. forceIrradianceInFragment: boolean;
  125082. /**
  125083. * Number of Simultaneous lights allowed on the material.
  125084. */
  125085. maxSimultaneousLights: number;
  125086. /**
  125087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125088. */
  125089. invertNormalMapX: boolean;
  125090. /**
  125091. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125092. */
  125093. invertNormalMapY: boolean;
  125094. /**
  125095. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125096. */
  125097. twoSidedLighting: boolean;
  125098. /**
  125099. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125100. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125101. */
  125102. useAlphaFresnel: boolean;
  125103. /**
  125104. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125105. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125106. */
  125107. useLinearAlphaFresnel: boolean;
  125108. /**
  125109. * Let user defines the brdf lookup texture used for IBL.
  125110. * A default 8bit version is embedded but you could point at :
  125111. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125112. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125113. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125114. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125115. */
  125116. environmentBRDFTexture: Nullable<BaseTexture>;
  125117. /**
  125118. * Force normal to face away from face.
  125119. */
  125120. forceNormalForward: boolean;
  125121. /**
  125122. * Enables specular anti aliasing in the PBR shader.
  125123. * It will both interacts on the Geometry for analytical and IBL lighting.
  125124. * It also prefilter the roughness map based on the bump values.
  125125. */
  125126. enableSpecularAntiAliasing: boolean;
  125127. /**
  125128. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125129. * makes the reflect vector face the model (under horizon).
  125130. */
  125131. useHorizonOcclusion: boolean;
  125132. /**
  125133. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125134. * too much the area relying on ambient texture to define their ambient occlusion.
  125135. */
  125136. useRadianceOcclusion: boolean;
  125137. /**
  125138. * If set to true, no lighting calculations will be applied.
  125139. */
  125140. unlit: boolean;
  125141. /**
  125142. * Gets the image processing configuration used either in this material.
  125143. */
  125144. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125145. /**
  125146. * Sets the Default image processing configuration used either in the this material.
  125147. *
  125148. * If sets to null, the scene one is in use.
  125149. */
  125150. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125151. /**
  125152. * Gets wether the color curves effect is enabled.
  125153. */
  125154. get cameraColorCurvesEnabled(): boolean;
  125155. /**
  125156. * Sets wether the color curves effect is enabled.
  125157. */
  125158. set cameraColorCurvesEnabled(value: boolean);
  125159. /**
  125160. * Gets wether the color grading effect is enabled.
  125161. */
  125162. get cameraColorGradingEnabled(): boolean;
  125163. /**
  125164. * Gets wether the color grading effect is enabled.
  125165. */
  125166. set cameraColorGradingEnabled(value: boolean);
  125167. /**
  125168. * Gets wether tonemapping is enabled or not.
  125169. */
  125170. get cameraToneMappingEnabled(): boolean;
  125171. /**
  125172. * Sets wether tonemapping is enabled or not
  125173. */
  125174. set cameraToneMappingEnabled(value: boolean);
  125175. /**
  125176. * The camera exposure used on this material.
  125177. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125178. * This corresponds to a photographic exposure.
  125179. */
  125180. get cameraExposure(): number;
  125181. /**
  125182. * The camera exposure used on this material.
  125183. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125184. * This corresponds to a photographic exposure.
  125185. */
  125186. set cameraExposure(value: number);
  125187. /**
  125188. * Gets The camera contrast used on this material.
  125189. */
  125190. get cameraContrast(): number;
  125191. /**
  125192. * Sets The camera contrast used on this material.
  125193. */
  125194. set cameraContrast(value: number);
  125195. /**
  125196. * Gets the Color Grading 2D Lookup Texture.
  125197. */
  125198. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125199. /**
  125200. * Sets the Color Grading 2D Lookup Texture.
  125201. */
  125202. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125203. /**
  125204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125206. * 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;
  125207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125208. */
  125209. get cameraColorCurves(): Nullable<ColorCurves>;
  125210. /**
  125211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125213. * 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;
  125214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125215. */
  125216. set cameraColorCurves(value: Nullable<ColorCurves>);
  125217. /**
  125218. * Instantiates a new PBRMaterial instance.
  125219. *
  125220. * @param name The material name
  125221. * @param scene The scene the material will be use in.
  125222. */
  125223. constructor(name: string, scene: Scene);
  125224. /**
  125225. * Returns the name of this material class.
  125226. */
  125227. getClassName(): string;
  125228. /**
  125229. * Makes a duplicate of the current material.
  125230. * @param name - name to use for the new material.
  125231. */
  125232. clone(name: string): PBRMaterial;
  125233. /**
  125234. * Serializes this PBR Material.
  125235. * @returns - An object with the serialized material.
  125236. */
  125237. serialize(): any;
  125238. /**
  125239. * Parses a PBR Material from a serialized object.
  125240. * @param source - Serialized object.
  125241. * @param scene - BJS scene instance.
  125242. * @param rootUrl - url for the scene object
  125243. * @returns - PBRMaterial
  125244. */
  125245. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125246. }
  125247. }
  125248. declare module BABYLON {
  125249. /**
  125250. * Direct draw surface info
  125251. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125252. */
  125253. export interface DDSInfo {
  125254. /**
  125255. * Width of the texture
  125256. */
  125257. width: number;
  125258. /**
  125259. * Width of the texture
  125260. */
  125261. height: number;
  125262. /**
  125263. * Number of Mipmaps for the texture
  125264. * @see https://en.wikipedia.org/wiki/Mipmap
  125265. */
  125266. mipmapCount: number;
  125267. /**
  125268. * If the textures format is a known fourCC format
  125269. * @see https://www.fourcc.org/
  125270. */
  125271. isFourCC: boolean;
  125272. /**
  125273. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125274. */
  125275. isRGB: boolean;
  125276. /**
  125277. * If the texture is a lumincance format
  125278. */
  125279. isLuminance: boolean;
  125280. /**
  125281. * If this is a cube texture
  125282. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125283. */
  125284. isCube: boolean;
  125285. /**
  125286. * If the texture is a compressed format eg. FOURCC_DXT1
  125287. */
  125288. isCompressed: boolean;
  125289. /**
  125290. * The dxgiFormat of the texture
  125291. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125292. */
  125293. dxgiFormat: number;
  125294. /**
  125295. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125296. */
  125297. textureType: number;
  125298. /**
  125299. * Sphericle polynomial created for the dds texture
  125300. */
  125301. sphericalPolynomial?: SphericalPolynomial;
  125302. }
  125303. /**
  125304. * Class used to provide DDS decompression tools
  125305. */
  125306. export class DDSTools {
  125307. /**
  125308. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125309. */
  125310. static StoreLODInAlphaChannel: boolean;
  125311. /**
  125312. * Gets DDS information from an array buffer
  125313. * @param data defines the array buffer view to read data from
  125314. * @returns the DDS information
  125315. */
  125316. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125317. private static _FloatView;
  125318. private static _Int32View;
  125319. private static _ToHalfFloat;
  125320. private static _FromHalfFloat;
  125321. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125322. private static _GetHalfFloatRGBAArrayBuffer;
  125323. private static _GetFloatRGBAArrayBuffer;
  125324. private static _GetFloatAsUIntRGBAArrayBuffer;
  125325. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125326. private static _GetRGBAArrayBuffer;
  125327. private static _ExtractLongWordOrder;
  125328. private static _GetRGBArrayBuffer;
  125329. private static _GetLuminanceArrayBuffer;
  125330. /**
  125331. * Uploads DDS Levels to a Babylon Texture
  125332. * @hidden
  125333. */
  125334. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125335. }
  125336. interface ThinEngine {
  125337. /**
  125338. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125339. * @param rootUrl defines the url where the file to load is located
  125340. * @param scene defines the current scene
  125341. * @param lodScale defines scale to apply to the mip map selection
  125342. * @param lodOffset defines offset to apply to the mip map selection
  125343. * @param onLoad defines an optional callback raised when the texture is loaded
  125344. * @param onError defines an optional callback raised if there is an issue to load the texture
  125345. * @param format defines the format of the data
  125346. * @param forcedExtension defines the extension to use to pick the right loader
  125347. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125348. * @returns the cube texture as an InternalTexture
  125349. */
  125350. 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;
  125351. }
  125352. }
  125353. declare module BABYLON {
  125354. /**
  125355. * Implementation of the DDS Texture Loader.
  125356. * @hidden
  125357. */
  125358. export class _DDSTextureLoader implements IInternalTextureLoader {
  125359. /**
  125360. * Defines wether the loader supports cascade loading the different faces.
  125361. */
  125362. readonly supportCascades: boolean;
  125363. /**
  125364. * This returns if the loader support the current file information.
  125365. * @param extension defines the file extension of the file being loaded
  125366. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125367. * @param fallback defines the fallback internal texture if any
  125368. * @param isBase64 defines whether the texture is encoded as a base64
  125369. * @param isBuffer defines whether the texture data are stored as a buffer
  125370. * @returns true if the loader can load the specified file
  125371. */
  125372. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125373. /**
  125374. * Transform the url before loading if required.
  125375. * @param rootUrl the url of the texture
  125376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125377. * @returns the transformed texture
  125378. */
  125379. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125380. /**
  125381. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125382. * @param rootUrl the url of the texture
  125383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125384. * @returns the fallback texture
  125385. */
  125386. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125387. /**
  125388. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125389. * @param data contains the texture data
  125390. * @param texture defines the BabylonJS internal texture
  125391. * @param createPolynomials will be true if polynomials have been requested
  125392. * @param onLoad defines the callback to trigger once the texture is ready
  125393. * @param onError defines the callback to trigger in case of error
  125394. */
  125395. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125396. /**
  125397. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125398. * @param data contains the texture data
  125399. * @param texture defines the BabylonJS internal texture
  125400. * @param callback defines the method to call once ready to upload
  125401. */
  125402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125403. }
  125404. }
  125405. declare module BABYLON {
  125406. /**
  125407. * Implementation of the ENV Texture Loader.
  125408. * @hidden
  125409. */
  125410. export class _ENVTextureLoader implements IInternalTextureLoader {
  125411. /**
  125412. * Defines wether the loader supports cascade loading the different faces.
  125413. */
  125414. readonly supportCascades: boolean;
  125415. /**
  125416. * This returns if the loader support the current file information.
  125417. * @param extension defines the file extension of the file being loaded
  125418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125419. * @param fallback defines the fallback internal texture if any
  125420. * @param isBase64 defines whether the texture is encoded as a base64
  125421. * @param isBuffer defines whether the texture data are stored as a buffer
  125422. * @returns true if the loader can load the specified file
  125423. */
  125424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125425. /**
  125426. * Transform the url before loading if required.
  125427. * @param rootUrl the url of the texture
  125428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125429. * @returns the transformed texture
  125430. */
  125431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125432. /**
  125433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125434. * @param rootUrl the url of the texture
  125435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125436. * @returns the fallback texture
  125437. */
  125438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125439. /**
  125440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125441. * @param data contains the texture data
  125442. * @param texture defines the BabylonJS internal texture
  125443. * @param createPolynomials will be true if polynomials have been requested
  125444. * @param onLoad defines the callback to trigger once the texture is ready
  125445. * @param onError defines the callback to trigger in case of error
  125446. */
  125447. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125448. /**
  125449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125450. * @param data contains the texture data
  125451. * @param texture defines the BabylonJS internal texture
  125452. * @param callback defines the method to call once ready to upload
  125453. */
  125454. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125460. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125461. */
  125462. export class KhronosTextureContainer {
  125463. /** contents of the KTX container file */
  125464. data: ArrayBufferView;
  125465. private static HEADER_LEN;
  125466. private static COMPRESSED_2D;
  125467. private static COMPRESSED_3D;
  125468. private static TEX_2D;
  125469. private static TEX_3D;
  125470. /**
  125471. * Gets the openGL type
  125472. */
  125473. glType: number;
  125474. /**
  125475. * Gets the openGL type size
  125476. */
  125477. glTypeSize: number;
  125478. /**
  125479. * Gets the openGL format
  125480. */
  125481. glFormat: number;
  125482. /**
  125483. * Gets the openGL internal format
  125484. */
  125485. glInternalFormat: number;
  125486. /**
  125487. * Gets the base internal format
  125488. */
  125489. glBaseInternalFormat: number;
  125490. /**
  125491. * Gets image width in pixel
  125492. */
  125493. pixelWidth: number;
  125494. /**
  125495. * Gets image height in pixel
  125496. */
  125497. pixelHeight: number;
  125498. /**
  125499. * Gets image depth in pixels
  125500. */
  125501. pixelDepth: number;
  125502. /**
  125503. * Gets the number of array elements
  125504. */
  125505. numberOfArrayElements: number;
  125506. /**
  125507. * Gets the number of faces
  125508. */
  125509. numberOfFaces: number;
  125510. /**
  125511. * Gets the number of mipmap levels
  125512. */
  125513. numberOfMipmapLevels: number;
  125514. /**
  125515. * Gets the bytes of key value data
  125516. */
  125517. bytesOfKeyValueData: number;
  125518. /**
  125519. * Gets the load type
  125520. */
  125521. loadType: number;
  125522. /**
  125523. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125524. */
  125525. isInvalid: boolean;
  125526. /**
  125527. * Creates a new KhronosTextureContainer
  125528. * @param data contents of the KTX container file
  125529. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125530. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125531. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125532. */
  125533. constructor(
  125534. /** contents of the KTX container file */
  125535. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125536. /**
  125537. * Uploads KTX content to a Babylon Texture.
  125538. * It is assumed that the texture has already been created & is currently bound
  125539. * @hidden
  125540. */
  125541. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125542. private _upload2DCompressedLevels;
  125543. }
  125544. }
  125545. declare module BABYLON {
  125546. /**
  125547. * Implementation of the KTX Texture Loader.
  125548. * @hidden
  125549. */
  125550. export class _KTXTextureLoader implements IInternalTextureLoader {
  125551. /**
  125552. * Defines wether the loader supports cascade loading the different faces.
  125553. */
  125554. readonly supportCascades: boolean;
  125555. /**
  125556. * This returns if the loader support the current file information.
  125557. * @param extension defines the file extension of the file being loaded
  125558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125559. * @param fallback defines the fallback internal texture if any
  125560. * @param isBase64 defines whether the texture is encoded as a base64
  125561. * @param isBuffer defines whether the texture data are stored as a buffer
  125562. * @returns true if the loader can load the specified file
  125563. */
  125564. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125565. /**
  125566. * Transform the url before loading if required.
  125567. * @param rootUrl the url of the texture
  125568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125569. * @returns the transformed texture
  125570. */
  125571. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125572. /**
  125573. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125574. * @param rootUrl the url of the texture
  125575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125576. * @returns the fallback texture
  125577. */
  125578. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125579. /**
  125580. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125581. * @param data contains the texture data
  125582. * @param texture defines the BabylonJS internal texture
  125583. * @param createPolynomials will be true if polynomials have been requested
  125584. * @param onLoad defines the callback to trigger once the texture is ready
  125585. * @param onError defines the callback to trigger in case of error
  125586. */
  125587. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125588. /**
  125589. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125590. * @param data contains the texture data
  125591. * @param texture defines the BabylonJS internal texture
  125592. * @param callback defines the method to call once ready to upload
  125593. */
  125594. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125595. }
  125596. }
  125597. declare module BABYLON {
  125598. /** @hidden */
  125599. export var _forceSceneHelpersToBundle: boolean;
  125600. interface Scene {
  125601. /**
  125602. * Creates a default light for the scene.
  125603. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125604. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125605. */
  125606. createDefaultLight(replace?: boolean): void;
  125607. /**
  125608. * Creates a default camera for the scene.
  125609. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125610. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125611. * @param replace has default false, when true replaces the active camera in the scene
  125612. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125613. */
  125614. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125615. /**
  125616. * Creates a default camera and a default light.
  125617. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125618. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125619. * @param replace has the default false, when true replaces the active camera/light in the scene
  125620. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125621. */
  125622. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125623. /**
  125624. * Creates a new sky box
  125625. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125626. * @param environmentTexture defines the texture to use as environment texture
  125627. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125628. * @param scale defines the overall scale of the skybox
  125629. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125630. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125631. * @returns a new mesh holding the sky box
  125632. */
  125633. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125634. /**
  125635. * Creates a new environment
  125636. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125637. * @param options defines the options you can use to configure the environment
  125638. * @returns the new EnvironmentHelper
  125639. */
  125640. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125641. /**
  125642. * Creates a new VREXperienceHelper
  125643. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125644. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125645. * @returns a new VREXperienceHelper
  125646. */
  125647. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125648. /**
  125649. * Creates a new WebXRDefaultExperience
  125650. * @see http://doc.babylonjs.com/how_to/webxr
  125651. * @param options experience options
  125652. * @returns a promise for a new WebXRDefaultExperience
  125653. */
  125654. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125655. }
  125656. }
  125657. declare module BABYLON {
  125658. /**
  125659. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125660. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125661. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125662. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125663. */
  125664. export class VideoDome extends TransformNode {
  125665. /**
  125666. * Define the video source as a Monoscopic panoramic 360 video.
  125667. */
  125668. static readonly MODE_MONOSCOPIC: number;
  125669. /**
  125670. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125671. */
  125672. static readonly MODE_TOPBOTTOM: number;
  125673. /**
  125674. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125675. */
  125676. static readonly MODE_SIDEBYSIDE: number;
  125677. private _halfDome;
  125678. private _useDirectMapping;
  125679. /**
  125680. * The video texture being displayed on the sphere
  125681. */
  125682. protected _videoTexture: VideoTexture;
  125683. /**
  125684. * Gets the video texture being displayed on the sphere
  125685. */
  125686. get videoTexture(): VideoTexture;
  125687. /**
  125688. * The skybox material
  125689. */
  125690. protected _material: BackgroundMaterial;
  125691. /**
  125692. * The surface used for the skybox
  125693. */
  125694. protected _mesh: Mesh;
  125695. /**
  125696. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125697. */
  125698. private _halfDomeMask;
  125699. /**
  125700. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125701. * Also see the options.resolution property.
  125702. */
  125703. get fovMultiplier(): number;
  125704. set fovMultiplier(value: number);
  125705. private _videoMode;
  125706. /**
  125707. * Gets or set the current video mode for the video. It can be:
  125708. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125709. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125710. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125711. */
  125712. get videoMode(): number;
  125713. set videoMode(value: number);
  125714. /**
  125715. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125716. *
  125717. */
  125718. get halfDome(): boolean;
  125719. /**
  125720. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125721. */
  125722. set halfDome(enabled: boolean);
  125723. /**
  125724. * Oberserver used in Stereoscopic VR Mode.
  125725. */
  125726. private _onBeforeCameraRenderObserver;
  125727. /**
  125728. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125729. * @param name Element's name, child elements will append suffixes for their own names.
  125730. * @param urlsOrVideo defines the url(s) or the video element to use
  125731. * @param options An object containing optional or exposed sub element properties
  125732. */
  125733. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125734. resolution?: number;
  125735. clickToPlay?: boolean;
  125736. autoPlay?: boolean;
  125737. loop?: boolean;
  125738. size?: number;
  125739. poster?: string;
  125740. faceForward?: boolean;
  125741. useDirectMapping?: boolean;
  125742. halfDomeMode?: boolean;
  125743. }, scene: Scene);
  125744. private _changeVideoMode;
  125745. /**
  125746. * Releases resources associated with this node.
  125747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125749. */
  125750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125751. }
  125752. }
  125753. declare module BABYLON {
  125754. /**
  125755. * This class can be used to get instrumentation data from a Babylon engine
  125756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125757. */
  125758. export class EngineInstrumentation implements IDisposable {
  125759. /**
  125760. * Define the instrumented engine.
  125761. */
  125762. engine: Engine;
  125763. private _captureGPUFrameTime;
  125764. private _gpuFrameTimeToken;
  125765. private _gpuFrameTime;
  125766. private _captureShaderCompilationTime;
  125767. private _shaderCompilationTime;
  125768. private _onBeginFrameObserver;
  125769. private _onEndFrameObserver;
  125770. private _onBeforeShaderCompilationObserver;
  125771. private _onAfterShaderCompilationObserver;
  125772. /**
  125773. * Gets the perf counter used for GPU frame time
  125774. */
  125775. get gpuFrameTimeCounter(): PerfCounter;
  125776. /**
  125777. * Gets the GPU frame time capture status
  125778. */
  125779. get captureGPUFrameTime(): boolean;
  125780. /**
  125781. * Enable or disable the GPU frame time capture
  125782. */
  125783. set captureGPUFrameTime(value: boolean);
  125784. /**
  125785. * Gets the perf counter used for shader compilation time
  125786. */
  125787. get shaderCompilationTimeCounter(): PerfCounter;
  125788. /**
  125789. * Gets the shader compilation time capture status
  125790. */
  125791. get captureShaderCompilationTime(): boolean;
  125792. /**
  125793. * Enable or disable the shader compilation time capture
  125794. */
  125795. set captureShaderCompilationTime(value: boolean);
  125796. /**
  125797. * Instantiates a new engine instrumentation.
  125798. * This class can be used to get instrumentation data from a Babylon engine
  125799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125800. * @param engine Defines the engine to instrument
  125801. */
  125802. constructor(
  125803. /**
  125804. * Define the instrumented engine.
  125805. */
  125806. engine: Engine);
  125807. /**
  125808. * Dispose and release associated resources.
  125809. */
  125810. dispose(): void;
  125811. }
  125812. }
  125813. declare module BABYLON {
  125814. /**
  125815. * This class can be used to get instrumentation data from a Babylon engine
  125816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125817. */
  125818. export class SceneInstrumentation implements IDisposable {
  125819. /**
  125820. * Defines the scene to instrument
  125821. */
  125822. scene: Scene;
  125823. private _captureActiveMeshesEvaluationTime;
  125824. private _activeMeshesEvaluationTime;
  125825. private _captureRenderTargetsRenderTime;
  125826. private _renderTargetsRenderTime;
  125827. private _captureFrameTime;
  125828. private _frameTime;
  125829. private _captureRenderTime;
  125830. private _renderTime;
  125831. private _captureInterFrameTime;
  125832. private _interFrameTime;
  125833. private _captureParticlesRenderTime;
  125834. private _particlesRenderTime;
  125835. private _captureSpritesRenderTime;
  125836. private _spritesRenderTime;
  125837. private _capturePhysicsTime;
  125838. private _physicsTime;
  125839. private _captureAnimationsTime;
  125840. private _animationsTime;
  125841. private _captureCameraRenderTime;
  125842. private _cameraRenderTime;
  125843. private _onBeforeActiveMeshesEvaluationObserver;
  125844. private _onAfterActiveMeshesEvaluationObserver;
  125845. private _onBeforeRenderTargetsRenderObserver;
  125846. private _onAfterRenderTargetsRenderObserver;
  125847. private _onAfterRenderObserver;
  125848. private _onBeforeDrawPhaseObserver;
  125849. private _onAfterDrawPhaseObserver;
  125850. private _onBeforeAnimationsObserver;
  125851. private _onBeforeParticlesRenderingObserver;
  125852. private _onAfterParticlesRenderingObserver;
  125853. private _onBeforeSpritesRenderingObserver;
  125854. private _onAfterSpritesRenderingObserver;
  125855. private _onBeforePhysicsObserver;
  125856. private _onAfterPhysicsObserver;
  125857. private _onAfterAnimationsObserver;
  125858. private _onBeforeCameraRenderObserver;
  125859. private _onAfterCameraRenderObserver;
  125860. /**
  125861. * Gets the perf counter used for active meshes evaluation time
  125862. */
  125863. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125864. /**
  125865. * Gets the active meshes evaluation time capture status
  125866. */
  125867. get captureActiveMeshesEvaluationTime(): boolean;
  125868. /**
  125869. * Enable or disable the active meshes evaluation time capture
  125870. */
  125871. set captureActiveMeshesEvaluationTime(value: boolean);
  125872. /**
  125873. * Gets the perf counter used for render targets render time
  125874. */
  125875. get renderTargetsRenderTimeCounter(): PerfCounter;
  125876. /**
  125877. * Gets the render targets render time capture status
  125878. */
  125879. get captureRenderTargetsRenderTime(): boolean;
  125880. /**
  125881. * Enable or disable the render targets render time capture
  125882. */
  125883. set captureRenderTargetsRenderTime(value: boolean);
  125884. /**
  125885. * Gets the perf counter used for particles render time
  125886. */
  125887. get particlesRenderTimeCounter(): PerfCounter;
  125888. /**
  125889. * Gets the particles render time capture status
  125890. */
  125891. get captureParticlesRenderTime(): boolean;
  125892. /**
  125893. * Enable or disable the particles render time capture
  125894. */
  125895. set captureParticlesRenderTime(value: boolean);
  125896. /**
  125897. * Gets the perf counter used for sprites render time
  125898. */
  125899. get spritesRenderTimeCounter(): PerfCounter;
  125900. /**
  125901. * Gets the sprites render time capture status
  125902. */
  125903. get captureSpritesRenderTime(): boolean;
  125904. /**
  125905. * Enable or disable the sprites render time capture
  125906. */
  125907. set captureSpritesRenderTime(value: boolean);
  125908. /**
  125909. * Gets the perf counter used for physics time
  125910. */
  125911. get physicsTimeCounter(): PerfCounter;
  125912. /**
  125913. * Gets the physics time capture status
  125914. */
  125915. get capturePhysicsTime(): boolean;
  125916. /**
  125917. * Enable or disable the physics time capture
  125918. */
  125919. set capturePhysicsTime(value: boolean);
  125920. /**
  125921. * Gets the perf counter used for animations time
  125922. */
  125923. get animationsTimeCounter(): PerfCounter;
  125924. /**
  125925. * Gets the animations time capture status
  125926. */
  125927. get captureAnimationsTime(): boolean;
  125928. /**
  125929. * Enable or disable the animations time capture
  125930. */
  125931. set captureAnimationsTime(value: boolean);
  125932. /**
  125933. * Gets the perf counter used for frame time capture
  125934. */
  125935. get frameTimeCounter(): PerfCounter;
  125936. /**
  125937. * Gets the frame time capture status
  125938. */
  125939. get captureFrameTime(): boolean;
  125940. /**
  125941. * Enable or disable the frame time capture
  125942. */
  125943. set captureFrameTime(value: boolean);
  125944. /**
  125945. * Gets the perf counter used for inter-frames time capture
  125946. */
  125947. get interFrameTimeCounter(): PerfCounter;
  125948. /**
  125949. * Gets the inter-frames time capture status
  125950. */
  125951. get captureInterFrameTime(): boolean;
  125952. /**
  125953. * Enable or disable the inter-frames time capture
  125954. */
  125955. set captureInterFrameTime(value: boolean);
  125956. /**
  125957. * Gets the perf counter used for render time capture
  125958. */
  125959. get renderTimeCounter(): PerfCounter;
  125960. /**
  125961. * Gets the render time capture status
  125962. */
  125963. get captureRenderTime(): boolean;
  125964. /**
  125965. * Enable or disable the render time capture
  125966. */
  125967. set captureRenderTime(value: boolean);
  125968. /**
  125969. * Gets the perf counter used for camera render time capture
  125970. */
  125971. get cameraRenderTimeCounter(): PerfCounter;
  125972. /**
  125973. * Gets the camera render time capture status
  125974. */
  125975. get captureCameraRenderTime(): boolean;
  125976. /**
  125977. * Enable or disable the camera render time capture
  125978. */
  125979. set captureCameraRenderTime(value: boolean);
  125980. /**
  125981. * Gets the perf counter used for draw calls
  125982. */
  125983. get drawCallsCounter(): PerfCounter;
  125984. /**
  125985. * Instantiates a new scene instrumentation.
  125986. * This class can be used to get instrumentation data from a Babylon engine
  125987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125988. * @param scene Defines the scene to instrument
  125989. */
  125990. constructor(
  125991. /**
  125992. * Defines the scene to instrument
  125993. */
  125994. scene: Scene);
  125995. /**
  125996. * Dispose and release associated resources.
  125997. */
  125998. dispose(): void;
  125999. }
  126000. }
  126001. declare module BABYLON {
  126002. /** @hidden */
  126003. export var glowMapGenerationPixelShader: {
  126004. name: string;
  126005. shader: string;
  126006. };
  126007. }
  126008. declare module BABYLON {
  126009. /** @hidden */
  126010. export var glowMapGenerationVertexShader: {
  126011. name: string;
  126012. shader: string;
  126013. };
  126014. }
  126015. declare module BABYLON {
  126016. /**
  126017. * Effect layer options. This helps customizing the behaviour
  126018. * of the effect layer.
  126019. */
  126020. export interface IEffectLayerOptions {
  126021. /**
  126022. * Multiplication factor apply to the canvas size to compute the render target size
  126023. * used to generated the objects (the smaller the faster).
  126024. */
  126025. mainTextureRatio: number;
  126026. /**
  126027. * Enforces a fixed size texture to ensure effect stability across devices.
  126028. */
  126029. mainTextureFixedSize?: number;
  126030. /**
  126031. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126032. */
  126033. alphaBlendingMode: number;
  126034. /**
  126035. * The camera attached to the layer.
  126036. */
  126037. camera: Nullable<Camera>;
  126038. /**
  126039. * The rendering group to draw the layer in.
  126040. */
  126041. renderingGroupId: number;
  126042. }
  126043. /**
  126044. * The effect layer Helps adding post process effect blended with the main pass.
  126045. *
  126046. * This can be for instance use to generate glow or higlight effects on the scene.
  126047. *
  126048. * The effect layer class can not be used directly and is intented to inherited from to be
  126049. * customized per effects.
  126050. */
  126051. export abstract class EffectLayer {
  126052. private _vertexBuffers;
  126053. private _indexBuffer;
  126054. private _cachedDefines;
  126055. private _effectLayerMapGenerationEffect;
  126056. private _effectLayerOptions;
  126057. private _mergeEffect;
  126058. protected _scene: Scene;
  126059. protected _engine: Engine;
  126060. protected _maxSize: number;
  126061. protected _mainTextureDesiredSize: ISize;
  126062. protected _mainTexture: RenderTargetTexture;
  126063. protected _shouldRender: boolean;
  126064. protected _postProcesses: PostProcess[];
  126065. protected _textures: BaseTexture[];
  126066. protected _emissiveTextureAndColor: {
  126067. texture: Nullable<BaseTexture>;
  126068. color: Color4;
  126069. };
  126070. /**
  126071. * The name of the layer
  126072. */
  126073. name: string;
  126074. /**
  126075. * The clear color of the texture used to generate the glow map.
  126076. */
  126077. neutralColor: Color4;
  126078. /**
  126079. * Specifies whether the highlight layer is enabled or not.
  126080. */
  126081. isEnabled: boolean;
  126082. /**
  126083. * Gets the camera attached to the layer.
  126084. */
  126085. get camera(): Nullable<Camera>;
  126086. /**
  126087. * Gets the rendering group id the layer should render in.
  126088. */
  126089. get renderingGroupId(): number;
  126090. set renderingGroupId(renderingGroupId: number);
  126091. /**
  126092. * An event triggered when the effect layer has been disposed.
  126093. */
  126094. onDisposeObservable: Observable<EffectLayer>;
  126095. /**
  126096. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126097. */
  126098. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126099. /**
  126100. * An event triggered when the generated texture is being merged in the scene.
  126101. */
  126102. onBeforeComposeObservable: Observable<EffectLayer>;
  126103. /**
  126104. * An event triggered when the mesh is rendered into the effect render target.
  126105. */
  126106. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126107. /**
  126108. * An event triggered after the mesh has been rendered into the effect render target.
  126109. */
  126110. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126111. /**
  126112. * An event triggered when the generated texture has been merged in the scene.
  126113. */
  126114. onAfterComposeObservable: Observable<EffectLayer>;
  126115. /**
  126116. * An event triggered when the efffect layer changes its size.
  126117. */
  126118. onSizeChangedObservable: Observable<EffectLayer>;
  126119. /** @hidden */
  126120. static _SceneComponentInitialization: (scene: Scene) => void;
  126121. /**
  126122. * Instantiates a new effect Layer and references it in the scene.
  126123. * @param name The name of the layer
  126124. * @param scene The scene to use the layer in
  126125. */
  126126. constructor(
  126127. /** The Friendly of the effect in the scene */
  126128. name: string, scene: Scene);
  126129. /**
  126130. * Get the effect name of the layer.
  126131. * @return The effect name
  126132. */
  126133. abstract getEffectName(): string;
  126134. /**
  126135. * Checks for the readiness of the element composing the layer.
  126136. * @param subMesh the mesh to check for
  126137. * @param useInstances specify whether or not to use instances to render the mesh
  126138. * @return true if ready otherwise, false
  126139. */
  126140. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126141. /**
  126142. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126143. * @returns true if the effect requires stencil during the main canvas render pass.
  126144. */
  126145. abstract needStencil(): boolean;
  126146. /**
  126147. * Create the merge effect. This is the shader use to blit the information back
  126148. * to the main canvas at the end of the scene rendering.
  126149. * @returns The effect containing the shader used to merge the effect on the main canvas
  126150. */
  126151. protected abstract _createMergeEffect(): Effect;
  126152. /**
  126153. * Creates the render target textures and post processes used in the effect layer.
  126154. */
  126155. protected abstract _createTextureAndPostProcesses(): void;
  126156. /**
  126157. * Implementation specific of rendering the generating effect on the main canvas.
  126158. * @param effect The effect used to render through
  126159. */
  126160. protected abstract _internalRender(effect: Effect): void;
  126161. /**
  126162. * Sets the required values for both the emissive texture and and the main color.
  126163. */
  126164. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126165. /**
  126166. * Free any resources and references associated to a mesh.
  126167. * Internal use
  126168. * @param mesh The mesh to free.
  126169. */
  126170. abstract _disposeMesh(mesh: Mesh): void;
  126171. /**
  126172. * Serializes this layer (Glow or Highlight for example)
  126173. * @returns a serialized layer object
  126174. */
  126175. abstract serialize?(): any;
  126176. /**
  126177. * Initializes the effect layer with the required options.
  126178. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126179. */
  126180. protected _init(options: Partial<IEffectLayerOptions>): void;
  126181. /**
  126182. * Generates the index buffer of the full screen quad blending to the main canvas.
  126183. */
  126184. private _generateIndexBuffer;
  126185. /**
  126186. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126187. */
  126188. private _generateVertexBuffer;
  126189. /**
  126190. * Sets the main texture desired size which is the closest power of two
  126191. * of the engine canvas size.
  126192. */
  126193. private _setMainTextureSize;
  126194. /**
  126195. * Creates the main texture for the effect layer.
  126196. */
  126197. protected _createMainTexture(): void;
  126198. /**
  126199. * Adds specific effects defines.
  126200. * @param defines The defines to add specifics to.
  126201. */
  126202. protected _addCustomEffectDefines(defines: string[]): void;
  126203. /**
  126204. * Checks for the readiness of the element composing the layer.
  126205. * @param subMesh the mesh to check for
  126206. * @param useInstances specify whether or not to use instances to render the mesh
  126207. * @param emissiveTexture the associated emissive texture used to generate the glow
  126208. * @return true if ready otherwise, false
  126209. */
  126210. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126211. /**
  126212. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126213. */
  126214. render(): void;
  126215. /**
  126216. * Determine if a given mesh will be used in the current effect.
  126217. * @param mesh mesh to test
  126218. * @returns true if the mesh will be used
  126219. */
  126220. hasMesh(mesh: AbstractMesh): boolean;
  126221. /**
  126222. * Returns true if the layer contains information to display, otherwise false.
  126223. * @returns true if the glow layer should be rendered
  126224. */
  126225. shouldRender(): boolean;
  126226. /**
  126227. * Returns true if the mesh should render, otherwise false.
  126228. * @param mesh The mesh to render
  126229. * @returns true if it should render otherwise false
  126230. */
  126231. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126232. /**
  126233. * Returns true if the mesh can be rendered, otherwise false.
  126234. * @param mesh The mesh to render
  126235. * @param material The material used on the mesh
  126236. * @returns true if it can be rendered otherwise false
  126237. */
  126238. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126239. /**
  126240. * Returns true if the mesh should render, otherwise false.
  126241. * @param mesh The mesh to render
  126242. * @returns true if it should render otherwise false
  126243. */
  126244. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126245. /**
  126246. * Renders the submesh passed in parameter to the generation map.
  126247. */
  126248. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126249. /**
  126250. * Defines whether the current material of the mesh should be use to render the effect.
  126251. * @param mesh defines the current mesh to render
  126252. */
  126253. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126254. /**
  126255. * Rebuild the required buffers.
  126256. * @hidden Internal use only.
  126257. */
  126258. _rebuild(): void;
  126259. /**
  126260. * Dispose only the render target textures and post process.
  126261. */
  126262. private _disposeTextureAndPostProcesses;
  126263. /**
  126264. * Dispose the highlight layer and free resources.
  126265. */
  126266. dispose(): void;
  126267. /**
  126268. * Gets the class name of the effect layer
  126269. * @returns the string with the class name of the effect layer
  126270. */
  126271. getClassName(): string;
  126272. /**
  126273. * Creates an effect layer from parsed effect layer data
  126274. * @param parsedEffectLayer defines effect layer data
  126275. * @param scene defines the current scene
  126276. * @param rootUrl defines the root URL containing the effect layer information
  126277. * @returns a parsed effect Layer
  126278. */
  126279. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126280. }
  126281. }
  126282. declare module BABYLON {
  126283. interface AbstractScene {
  126284. /**
  126285. * The list of effect layers (highlights/glow) added to the scene
  126286. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126287. * @see http://doc.babylonjs.com/how_to/glow_layer
  126288. */
  126289. effectLayers: Array<EffectLayer>;
  126290. /**
  126291. * Removes the given effect layer from this scene.
  126292. * @param toRemove defines the effect layer to remove
  126293. * @returns the index of the removed effect layer
  126294. */
  126295. removeEffectLayer(toRemove: EffectLayer): number;
  126296. /**
  126297. * Adds the given effect layer to this scene
  126298. * @param newEffectLayer defines the effect layer to add
  126299. */
  126300. addEffectLayer(newEffectLayer: EffectLayer): void;
  126301. }
  126302. /**
  126303. * Defines the layer scene component responsible to manage any effect layers
  126304. * in a given scene.
  126305. */
  126306. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126307. /**
  126308. * The component name helpfull to identify the component in the list of scene components.
  126309. */
  126310. readonly name: string;
  126311. /**
  126312. * The scene the component belongs to.
  126313. */
  126314. scene: Scene;
  126315. private _engine;
  126316. private _renderEffects;
  126317. private _needStencil;
  126318. private _previousStencilState;
  126319. /**
  126320. * Creates a new instance of the component for the given scene
  126321. * @param scene Defines the scene to register the component in
  126322. */
  126323. constructor(scene: Scene);
  126324. /**
  126325. * Registers the component in a given scene
  126326. */
  126327. register(): void;
  126328. /**
  126329. * Rebuilds the elements related to this component in case of
  126330. * context lost for instance.
  126331. */
  126332. rebuild(): void;
  126333. /**
  126334. * Serializes the component data to the specified json object
  126335. * @param serializationObject The object to serialize to
  126336. */
  126337. serialize(serializationObject: any): void;
  126338. /**
  126339. * Adds all the elements from the container to the scene
  126340. * @param container the container holding the elements
  126341. */
  126342. addFromContainer(container: AbstractScene): void;
  126343. /**
  126344. * Removes all the elements in the container from the scene
  126345. * @param container contains the elements to remove
  126346. * @param dispose if the removed element should be disposed (default: false)
  126347. */
  126348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126349. /**
  126350. * Disposes the component and the associated ressources.
  126351. */
  126352. dispose(): void;
  126353. private _isReadyForMesh;
  126354. private _renderMainTexture;
  126355. private _setStencil;
  126356. private _setStencilBack;
  126357. private _draw;
  126358. private _drawCamera;
  126359. private _drawRenderingGroup;
  126360. }
  126361. }
  126362. declare module BABYLON {
  126363. /** @hidden */
  126364. export var glowMapMergePixelShader: {
  126365. name: string;
  126366. shader: string;
  126367. };
  126368. }
  126369. declare module BABYLON {
  126370. /** @hidden */
  126371. export var glowMapMergeVertexShader: {
  126372. name: string;
  126373. shader: string;
  126374. };
  126375. }
  126376. declare module BABYLON {
  126377. interface AbstractScene {
  126378. /**
  126379. * Return a the first highlight layer of the scene with a given name.
  126380. * @param name The name of the highlight layer to look for.
  126381. * @return The highlight layer if found otherwise null.
  126382. */
  126383. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126384. }
  126385. /**
  126386. * Glow layer options. This helps customizing the behaviour
  126387. * of the glow layer.
  126388. */
  126389. export interface IGlowLayerOptions {
  126390. /**
  126391. * Multiplication factor apply to the canvas size to compute the render target size
  126392. * used to generated the glowing objects (the smaller the faster).
  126393. */
  126394. mainTextureRatio: number;
  126395. /**
  126396. * Enforces a fixed size texture to ensure resize independant blur.
  126397. */
  126398. mainTextureFixedSize?: number;
  126399. /**
  126400. * How big is the kernel of the blur texture.
  126401. */
  126402. blurKernelSize: number;
  126403. /**
  126404. * The camera attached to the layer.
  126405. */
  126406. camera: Nullable<Camera>;
  126407. /**
  126408. * Enable MSAA by chosing the number of samples.
  126409. */
  126410. mainTextureSamples?: number;
  126411. /**
  126412. * The rendering group to draw the layer in.
  126413. */
  126414. renderingGroupId: number;
  126415. }
  126416. /**
  126417. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126418. *
  126419. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126420. *
  126421. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126422. */
  126423. export class GlowLayer extends EffectLayer {
  126424. /**
  126425. * Effect Name of the layer.
  126426. */
  126427. static readonly EffectName: string;
  126428. /**
  126429. * The default blur kernel size used for the glow.
  126430. */
  126431. static DefaultBlurKernelSize: number;
  126432. /**
  126433. * The default texture size ratio used for the glow.
  126434. */
  126435. static DefaultTextureRatio: number;
  126436. /**
  126437. * Sets the kernel size of the blur.
  126438. */
  126439. set blurKernelSize(value: number);
  126440. /**
  126441. * Gets the kernel size of the blur.
  126442. */
  126443. get blurKernelSize(): number;
  126444. /**
  126445. * Sets the glow intensity.
  126446. */
  126447. set intensity(value: number);
  126448. /**
  126449. * Gets the glow intensity.
  126450. */
  126451. get intensity(): number;
  126452. private _options;
  126453. private _intensity;
  126454. private _horizontalBlurPostprocess1;
  126455. private _verticalBlurPostprocess1;
  126456. private _horizontalBlurPostprocess2;
  126457. private _verticalBlurPostprocess2;
  126458. private _blurTexture1;
  126459. private _blurTexture2;
  126460. private _postProcesses1;
  126461. private _postProcesses2;
  126462. private _includedOnlyMeshes;
  126463. private _excludedMeshes;
  126464. private _meshesUsingTheirOwnMaterials;
  126465. /**
  126466. * Callback used to let the user override the color selection on a per mesh basis
  126467. */
  126468. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126469. /**
  126470. * Callback used to let the user override the texture selection on a per mesh basis
  126471. */
  126472. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126473. /**
  126474. * Instantiates a new glow Layer and references it to the scene.
  126475. * @param name The name of the layer
  126476. * @param scene The scene to use the layer in
  126477. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126478. */
  126479. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126480. /**
  126481. * Get the effect name of the layer.
  126482. * @return The effect name
  126483. */
  126484. getEffectName(): string;
  126485. /**
  126486. * Create the merge effect. This is the shader use to blit the information back
  126487. * to the main canvas at the end of the scene rendering.
  126488. */
  126489. protected _createMergeEffect(): Effect;
  126490. /**
  126491. * Creates the render target textures and post processes used in the glow layer.
  126492. */
  126493. protected _createTextureAndPostProcesses(): void;
  126494. /**
  126495. * Checks for the readiness of the element composing the layer.
  126496. * @param subMesh the mesh to check for
  126497. * @param useInstances specify wether or not to use instances to render the mesh
  126498. * @param emissiveTexture the associated emissive texture used to generate the glow
  126499. * @return true if ready otherwise, false
  126500. */
  126501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126502. /**
  126503. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126504. */
  126505. needStencil(): boolean;
  126506. /**
  126507. * Returns true if the mesh can be rendered, otherwise false.
  126508. * @param mesh The mesh to render
  126509. * @param material The material used on the mesh
  126510. * @returns true if it can be rendered otherwise false
  126511. */
  126512. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126513. /**
  126514. * Implementation specific of rendering the generating effect on the main canvas.
  126515. * @param effect The effect used to render through
  126516. */
  126517. protected _internalRender(effect: Effect): void;
  126518. /**
  126519. * Sets the required values for both the emissive texture and and the main color.
  126520. */
  126521. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126522. /**
  126523. * Returns true if the mesh should render, otherwise false.
  126524. * @param mesh The mesh to render
  126525. * @returns true if it should render otherwise false
  126526. */
  126527. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126528. /**
  126529. * Adds specific effects defines.
  126530. * @param defines The defines to add specifics to.
  126531. */
  126532. protected _addCustomEffectDefines(defines: string[]): void;
  126533. /**
  126534. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126535. * @param mesh The mesh to exclude from the glow layer
  126536. */
  126537. addExcludedMesh(mesh: Mesh): void;
  126538. /**
  126539. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126540. * @param mesh The mesh to remove
  126541. */
  126542. removeExcludedMesh(mesh: Mesh): void;
  126543. /**
  126544. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126545. * @param mesh The mesh to include in the glow layer
  126546. */
  126547. addIncludedOnlyMesh(mesh: Mesh): void;
  126548. /**
  126549. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126550. * @param mesh The mesh to remove
  126551. */
  126552. removeIncludedOnlyMesh(mesh: Mesh): void;
  126553. /**
  126554. * Determine if a given mesh will be used in the glow layer
  126555. * @param mesh The mesh to test
  126556. * @returns true if the mesh will be highlighted by the current glow layer
  126557. */
  126558. hasMesh(mesh: AbstractMesh): boolean;
  126559. /**
  126560. * Defines whether the current material of the mesh should be use to render the effect.
  126561. * @param mesh defines the current mesh to render
  126562. */
  126563. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126564. /**
  126565. * Add a mesh to be rendered through its own material and not with emissive only.
  126566. * @param mesh The mesh for which we need to use its material
  126567. */
  126568. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126569. /**
  126570. * Remove a mesh from being rendered through its own material and not with emissive only.
  126571. * @param mesh The mesh for which we need to not use its material
  126572. */
  126573. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126574. /**
  126575. * Free any resources and references associated to a mesh.
  126576. * Internal use
  126577. * @param mesh The mesh to free.
  126578. * @hidden
  126579. */
  126580. _disposeMesh(mesh: Mesh): void;
  126581. /**
  126582. * Gets the class name of the effect layer
  126583. * @returns the string with the class name of the effect layer
  126584. */
  126585. getClassName(): string;
  126586. /**
  126587. * Serializes this glow layer
  126588. * @returns a serialized glow layer object
  126589. */
  126590. serialize(): any;
  126591. /**
  126592. * Creates a Glow Layer from parsed glow layer data
  126593. * @param parsedGlowLayer defines glow layer data
  126594. * @param scene defines the current scene
  126595. * @param rootUrl defines the root URL containing the glow layer information
  126596. * @returns a parsed Glow Layer
  126597. */
  126598. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126599. }
  126600. }
  126601. declare module BABYLON {
  126602. /** @hidden */
  126603. export var glowBlurPostProcessPixelShader: {
  126604. name: string;
  126605. shader: string;
  126606. };
  126607. }
  126608. declare module BABYLON {
  126609. interface AbstractScene {
  126610. /**
  126611. * Return a the first highlight layer of the scene with a given name.
  126612. * @param name The name of the highlight layer to look for.
  126613. * @return The highlight layer if found otherwise null.
  126614. */
  126615. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126616. }
  126617. /**
  126618. * Highlight layer options. This helps customizing the behaviour
  126619. * of the highlight layer.
  126620. */
  126621. export interface IHighlightLayerOptions {
  126622. /**
  126623. * Multiplication factor apply to the canvas size to compute the render target size
  126624. * used to generated the glowing objects (the smaller the faster).
  126625. */
  126626. mainTextureRatio: number;
  126627. /**
  126628. * Enforces a fixed size texture to ensure resize independant blur.
  126629. */
  126630. mainTextureFixedSize?: number;
  126631. /**
  126632. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126633. * of the picture to blur (the smaller the faster).
  126634. */
  126635. blurTextureSizeRatio: number;
  126636. /**
  126637. * How big in texel of the blur texture is the vertical blur.
  126638. */
  126639. blurVerticalSize: number;
  126640. /**
  126641. * How big in texel of the blur texture is the horizontal blur.
  126642. */
  126643. blurHorizontalSize: number;
  126644. /**
  126645. * Alpha blending mode used to apply the blur. Default is combine.
  126646. */
  126647. alphaBlendingMode: number;
  126648. /**
  126649. * The camera attached to the layer.
  126650. */
  126651. camera: Nullable<Camera>;
  126652. /**
  126653. * Should we display highlight as a solid stroke?
  126654. */
  126655. isStroke?: boolean;
  126656. /**
  126657. * The rendering group to draw the layer in.
  126658. */
  126659. renderingGroupId: number;
  126660. }
  126661. /**
  126662. * The highlight layer Helps adding a glow effect around a mesh.
  126663. *
  126664. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126665. * glowy meshes to your scene.
  126666. *
  126667. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126668. */
  126669. export class HighlightLayer extends EffectLayer {
  126670. name: string;
  126671. /**
  126672. * Effect Name of the highlight layer.
  126673. */
  126674. static readonly EffectName: string;
  126675. /**
  126676. * The neutral color used during the preparation of the glow effect.
  126677. * This is black by default as the blend operation is a blend operation.
  126678. */
  126679. static NeutralColor: Color4;
  126680. /**
  126681. * Stencil value used for glowing meshes.
  126682. */
  126683. static GlowingMeshStencilReference: number;
  126684. /**
  126685. * Stencil value used for the other meshes in the scene.
  126686. */
  126687. static NormalMeshStencilReference: number;
  126688. /**
  126689. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126690. */
  126691. innerGlow: boolean;
  126692. /**
  126693. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126694. */
  126695. outerGlow: boolean;
  126696. /**
  126697. * Specifies the horizontal size of the blur.
  126698. */
  126699. set blurHorizontalSize(value: number);
  126700. /**
  126701. * Specifies the vertical size of the blur.
  126702. */
  126703. set blurVerticalSize(value: number);
  126704. /**
  126705. * Gets the horizontal size of the blur.
  126706. */
  126707. get blurHorizontalSize(): number;
  126708. /**
  126709. * Gets the vertical size of the blur.
  126710. */
  126711. get blurVerticalSize(): number;
  126712. /**
  126713. * An event triggered when the highlight layer is being blurred.
  126714. */
  126715. onBeforeBlurObservable: Observable<HighlightLayer>;
  126716. /**
  126717. * An event triggered when the highlight layer has been blurred.
  126718. */
  126719. onAfterBlurObservable: Observable<HighlightLayer>;
  126720. private _instanceGlowingMeshStencilReference;
  126721. private _options;
  126722. private _downSamplePostprocess;
  126723. private _horizontalBlurPostprocess;
  126724. private _verticalBlurPostprocess;
  126725. private _blurTexture;
  126726. private _meshes;
  126727. private _excludedMeshes;
  126728. /**
  126729. * Instantiates a new highlight Layer and references it to the scene..
  126730. * @param name The name of the layer
  126731. * @param scene The scene to use the layer in
  126732. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126733. */
  126734. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126735. /**
  126736. * Get the effect name of the layer.
  126737. * @return The effect name
  126738. */
  126739. getEffectName(): string;
  126740. /**
  126741. * Create the merge effect. This is the shader use to blit the information back
  126742. * to the main canvas at the end of the scene rendering.
  126743. */
  126744. protected _createMergeEffect(): Effect;
  126745. /**
  126746. * Creates the render target textures and post processes used in the highlight layer.
  126747. */
  126748. protected _createTextureAndPostProcesses(): void;
  126749. /**
  126750. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126751. */
  126752. needStencil(): boolean;
  126753. /**
  126754. * Checks for the readiness of the element composing the layer.
  126755. * @param subMesh the mesh to check for
  126756. * @param useInstances specify wether or not to use instances to render the mesh
  126757. * @param emissiveTexture the associated emissive texture used to generate the glow
  126758. * @return true if ready otherwise, false
  126759. */
  126760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126761. /**
  126762. * Implementation specific of rendering the generating effect on the main canvas.
  126763. * @param effect The effect used to render through
  126764. */
  126765. protected _internalRender(effect: Effect): void;
  126766. /**
  126767. * Returns true if the layer contains information to display, otherwise false.
  126768. */
  126769. shouldRender(): boolean;
  126770. /**
  126771. * Returns true if the mesh should render, otherwise false.
  126772. * @param mesh The mesh to render
  126773. * @returns true if it should render otherwise false
  126774. */
  126775. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126776. /**
  126777. * Sets the required values for both the emissive texture and and the main color.
  126778. */
  126779. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126780. /**
  126781. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126782. * @param mesh The mesh to exclude from the highlight layer
  126783. */
  126784. addExcludedMesh(mesh: Mesh): void;
  126785. /**
  126786. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126787. * @param mesh The mesh to highlight
  126788. */
  126789. removeExcludedMesh(mesh: Mesh): void;
  126790. /**
  126791. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126792. * @param mesh mesh to test
  126793. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126794. */
  126795. hasMesh(mesh: AbstractMesh): boolean;
  126796. /**
  126797. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126798. * @param mesh The mesh to highlight
  126799. * @param color The color of the highlight
  126800. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126801. */
  126802. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126803. /**
  126804. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126805. * @param mesh The mesh to highlight
  126806. */
  126807. removeMesh(mesh: Mesh): void;
  126808. /**
  126809. * Force the stencil to the normal expected value for none glowing parts
  126810. */
  126811. private _defaultStencilReference;
  126812. /**
  126813. * Free any resources and references associated to a mesh.
  126814. * Internal use
  126815. * @param mesh The mesh to free.
  126816. * @hidden
  126817. */
  126818. _disposeMesh(mesh: Mesh): void;
  126819. /**
  126820. * Dispose the highlight layer and free resources.
  126821. */
  126822. dispose(): void;
  126823. /**
  126824. * Gets the class name of the effect layer
  126825. * @returns the string with the class name of the effect layer
  126826. */
  126827. getClassName(): string;
  126828. /**
  126829. * Serializes this Highlight layer
  126830. * @returns a serialized Highlight layer object
  126831. */
  126832. serialize(): any;
  126833. /**
  126834. * Creates a Highlight layer from parsed Highlight layer data
  126835. * @param parsedHightlightLayer defines the Highlight layer data
  126836. * @param scene defines the current scene
  126837. * @param rootUrl defines the root URL containing the Highlight layer information
  126838. * @returns a parsed Highlight layer
  126839. */
  126840. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. interface AbstractScene {
  126845. /**
  126846. * The list of layers (background and foreground) of the scene
  126847. */
  126848. layers: Array<Layer>;
  126849. }
  126850. /**
  126851. * Defines the layer scene component responsible to manage any layers
  126852. * in a given scene.
  126853. */
  126854. export class LayerSceneComponent implements ISceneComponent {
  126855. /**
  126856. * The component name helpfull to identify the component in the list of scene components.
  126857. */
  126858. readonly name: string;
  126859. /**
  126860. * The scene the component belongs to.
  126861. */
  126862. scene: Scene;
  126863. private _engine;
  126864. /**
  126865. * Creates a new instance of the component for the given scene
  126866. * @param scene Defines the scene to register the component in
  126867. */
  126868. constructor(scene: Scene);
  126869. /**
  126870. * Registers the component in a given scene
  126871. */
  126872. register(): void;
  126873. /**
  126874. * Rebuilds the elements related to this component in case of
  126875. * context lost for instance.
  126876. */
  126877. rebuild(): void;
  126878. /**
  126879. * Disposes the component and the associated ressources.
  126880. */
  126881. dispose(): void;
  126882. private _draw;
  126883. private _drawCameraPredicate;
  126884. private _drawCameraBackground;
  126885. private _drawCameraForeground;
  126886. private _drawRenderTargetPredicate;
  126887. private _drawRenderTargetBackground;
  126888. private _drawRenderTargetForeground;
  126889. /**
  126890. * Adds all the elements from the container to the scene
  126891. * @param container the container holding the elements
  126892. */
  126893. addFromContainer(container: AbstractScene): void;
  126894. /**
  126895. * Removes all the elements in the container from the scene
  126896. * @param container contains the elements to remove
  126897. * @param dispose if the removed element should be disposed (default: false)
  126898. */
  126899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126900. }
  126901. }
  126902. declare module BABYLON {
  126903. /** @hidden */
  126904. export var layerPixelShader: {
  126905. name: string;
  126906. shader: string;
  126907. };
  126908. }
  126909. declare module BABYLON {
  126910. /** @hidden */
  126911. export var layerVertexShader: {
  126912. name: string;
  126913. shader: string;
  126914. };
  126915. }
  126916. declare module BABYLON {
  126917. /**
  126918. * This represents a full screen 2d layer.
  126919. * This can be useful to display a picture in the background of your scene for instance.
  126920. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126921. */
  126922. export class Layer {
  126923. /**
  126924. * Define the name of the layer.
  126925. */
  126926. name: string;
  126927. /**
  126928. * Define the texture the layer should display.
  126929. */
  126930. texture: Nullable<Texture>;
  126931. /**
  126932. * Is the layer in background or foreground.
  126933. */
  126934. isBackground: boolean;
  126935. /**
  126936. * Define the color of the layer (instead of texture).
  126937. */
  126938. color: Color4;
  126939. /**
  126940. * Define the scale of the layer in order to zoom in out of the texture.
  126941. */
  126942. scale: Vector2;
  126943. /**
  126944. * Define an offset for the layer in order to shift the texture.
  126945. */
  126946. offset: Vector2;
  126947. /**
  126948. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126949. */
  126950. alphaBlendingMode: number;
  126951. /**
  126952. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126953. * Alpha test will not mix with the background color in case of transparency.
  126954. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126955. */
  126956. alphaTest: boolean;
  126957. /**
  126958. * Define a mask to restrict the layer to only some of the scene cameras.
  126959. */
  126960. layerMask: number;
  126961. /**
  126962. * Define the list of render target the layer is visible into.
  126963. */
  126964. renderTargetTextures: RenderTargetTexture[];
  126965. /**
  126966. * Define if the layer is only used in renderTarget or if it also
  126967. * renders in the main frame buffer of the canvas.
  126968. */
  126969. renderOnlyInRenderTargetTextures: boolean;
  126970. private _scene;
  126971. private _vertexBuffers;
  126972. private _indexBuffer;
  126973. private _effect;
  126974. private _previousDefines;
  126975. /**
  126976. * An event triggered when the layer is disposed.
  126977. */
  126978. onDisposeObservable: Observable<Layer>;
  126979. private _onDisposeObserver;
  126980. /**
  126981. * Back compatibility with callback before the onDisposeObservable existed.
  126982. * The set callback will be triggered when the layer has been disposed.
  126983. */
  126984. set onDispose(callback: () => void);
  126985. /**
  126986. * An event triggered before rendering the scene
  126987. */
  126988. onBeforeRenderObservable: Observable<Layer>;
  126989. private _onBeforeRenderObserver;
  126990. /**
  126991. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126992. * The set callback will be triggered just before rendering the layer.
  126993. */
  126994. set onBeforeRender(callback: () => void);
  126995. /**
  126996. * An event triggered after rendering the scene
  126997. */
  126998. onAfterRenderObservable: Observable<Layer>;
  126999. private _onAfterRenderObserver;
  127000. /**
  127001. * Back compatibility with callback before the onAfterRenderObservable existed.
  127002. * The set callback will be triggered just after rendering the layer.
  127003. */
  127004. set onAfterRender(callback: () => void);
  127005. /**
  127006. * Instantiates a new layer.
  127007. * This represents a full screen 2d layer.
  127008. * This can be useful to display a picture in the background of your scene for instance.
  127009. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127010. * @param name Define the name of the layer in the scene
  127011. * @param imgUrl Define the url of the texture to display in the layer
  127012. * @param scene Define the scene the layer belongs to
  127013. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127014. * @param color Defines a color for the layer
  127015. */
  127016. constructor(
  127017. /**
  127018. * Define the name of the layer.
  127019. */
  127020. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127021. private _createIndexBuffer;
  127022. /** @hidden */
  127023. _rebuild(): void;
  127024. /**
  127025. * Renders the layer in the scene.
  127026. */
  127027. render(): void;
  127028. /**
  127029. * Disposes and releases the associated ressources.
  127030. */
  127031. dispose(): void;
  127032. }
  127033. }
  127034. declare module BABYLON {
  127035. /** @hidden */
  127036. export var lensFlarePixelShader: {
  127037. name: string;
  127038. shader: string;
  127039. };
  127040. }
  127041. declare module BABYLON {
  127042. /** @hidden */
  127043. export var lensFlareVertexShader: {
  127044. name: string;
  127045. shader: string;
  127046. };
  127047. }
  127048. declare module BABYLON {
  127049. /**
  127050. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127051. * It is usually composed of several `lensFlare`.
  127052. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127053. */
  127054. export class LensFlareSystem {
  127055. /**
  127056. * Define the name of the lens flare system
  127057. */
  127058. name: string;
  127059. /**
  127060. * List of lens flares used in this system.
  127061. */
  127062. lensFlares: LensFlare[];
  127063. /**
  127064. * Define a limit from the border the lens flare can be visible.
  127065. */
  127066. borderLimit: number;
  127067. /**
  127068. * Define a viewport border we do not want to see the lens flare in.
  127069. */
  127070. viewportBorder: number;
  127071. /**
  127072. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127073. */
  127074. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127075. /**
  127076. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127077. */
  127078. layerMask: number;
  127079. /**
  127080. * Define the id of the lens flare system in the scene.
  127081. * (equal to name by default)
  127082. */
  127083. id: string;
  127084. private _scene;
  127085. private _emitter;
  127086. private _vertexBuffers;
  127087. private _indexBuffer;
  127088. private _effect;
  127089. private _positionX;
  127090. private _positionY;
  127091. private _isEnabled;
  127092. /** @hidden */
  127093. static _SceneComponentInitialization: (scene: Scene) => void;
  127094. /**
  127095. * Instantiates a lens flare system.
  127096. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127097. * It is usually composed of several `lensFlare`.
  127098. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127099. * @param name Define the name of the lens flare system in the scene
  127100. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127101. * @param scene Define the scene the lens flare system belongs to
  127102. */
  127103. constructor(
  127104. /**
  127105. * Define the name of the lens flare system
  127106. */
  127107. name: string, emitter: any, scene: Scene);
  127108. /**
  127109. * Define if the lens flare system is enabled.
  127110. */
  127111. get isEnabled(): boolean;
  127112. set isEnabled(value: boolean);
  127113. /**
  127114. * Get the scene the effects belongs to.
  127115. * @returns the scene holding the lens flare system
  127116. */
  127117. getScene(): Scene;
  127118. /**
  127119. * Get the emitter of the lens flare system.
  127120. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127121. * @returns the emitter of the lens flare system
  127122. */
  127123. getEmitter(): any;
  127124. /**
  127125. * Set the emitter of the lens flare system.
  127126. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127127. * @param newEmitter Define the new emitter of the system
  127128. */
  127129. setEmitter(newEmitter: any): void;
  127130. /**
  127131. * Get the lens flare system emitter position.
  127132. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127133. * @returns the position
  127134. */
  127135. getEmitterPosition(): Vector3;
  127136. /**
  127137. * @hidden
  127138. */
  127139. computeEffectivePosition(globalViewport: Viewport): boolean;
  127140. /** @hidden */
  127141. _isVisible(): boolean;
  127142. /**
  127143. * @hidden
  127144. */
  127145. render(): boolean;
  127146. /**
  127147. * Dispose and release the lens flare with its associated resources.
  127148. */
  127149. dispose(): void;
  127150. /**
  127151. * Parse a lens flare system from a JSON repressentation
  127152. * @param parsedLensFlareSystem Define the JSON to parse
  127153. * @param scene Define the scene the parsed system should be instantiated in
  127154. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127155. * @returns the parsed system
  127156. */
  127157. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127158. /**
  127159. * Serialize the current Lens Flare System into a JSON representation.
  127160. * @returns the serialized JSON
  127161. */
  127162. serialize(): any;
  127163. }
  127164. }
  127165. declare module BABYLON {
  127166. /**
  127167. * This represents one of the lens effect in a `lensFlareSystem`.
  127168. * It controls one of the indiviual texture used in the effect.
  127169. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127170. */
  127171. export class LensFlare {
  127172. /**
  127173. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127174. */
  127175. size: number;
  127176. /**
  127177. * 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.
  127178. */
  127179. position: number;
  127180. /**
  127181. * Define the lens color.
  127182. */
  127183. color: Color3;
  127184. /**
  127185. * Define the lens texture.
  127186. */
  127187. texture: Nullable<Texture>;
  127188. /**
  127189. * Define the alpha mode to render this particular lens.
  127190. */
  127191. alphaMode: number;
  127192. private _system;
  127193. /**
  127194. * Creates a new Lens Flare.
  127195. * This represents one of the lens effect in a `lensFlareSystem`.
  127196. * It controls one of the indiviual texture used in the effect.
  127197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127198. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127199. * @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.
  127200. * @param color Define the lens color
  127201. * @param imgUrl Define the lens texture url
  127202. * @param system Define the `lensFlareSystem` this flare is part of
  127203. * @returns The newly created Lens Flare
  127204. */
  127205. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127206. /**
  127207. * Instantiates a new Lens Flare.
  127208. * This represents one of the lens effect in a `lensFlareSystem`.
  127209. * It controls one of the indiviual texture used in the effect.
  127210. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127211. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127212. * @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.
  127213. * @param color Define the lens color
  127214. * @param imgUrl Define the lens texture url
  127215. * @param system Define the `lensFlareSystem` this flare is part of
  127216. */
  127217. constructor(
  127218. /**
  127219. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127220. */
  127221. size: number,
  127222. /**
  127223. * 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.
  127224. */
  127225. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127226. /**
  127227. * Dispose and release the lens flare with its associated resources.
  127228. */
  127229. dispose(): void;
  127230. }
  127231. }
  127232. declare module BABYLON {
  127233. interface AbstractScene {
  127234. /**
  127235. * The list of lens flare system added to the scene
  127236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127237. */
  127238. lensFlareSystems: Array<LensFlareSystem>;
  127239. /**
  127240. * Removes the given lens flare system from this scene.
  127241. * @param toRemove The lens flare system to remove
  127242. * @returns The index of the removed lens flare system
  127243. */
  127244. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127245. /**
  127246. * Adds the given lens flare system to this scene
  127247. * @param newLensFlareSystem The lens flare system to add
  127248. */
  127249. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127250. /**
  127251. * Gets a lens flare system using its name
  127252. * @param name defines the name to look for
  127253. * @returns the lens flare system or null if not found
  127254. */
  127255. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127256. /**
  127257. * Gets a lens flare system using its id
  127258. * @param id defines the id to look for
  127259. * @returns the lens flare system or null if not found
  127260. */
  127261. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127262. }
  127263. /**
  127264. * Defines the lens flare scene component responsible to manage any lens flares
  127265. * in a given scene.
  127266. */
  127267. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127268. /**
  127269. * The component name helpfull to identify the component in the list of scene components.
  127270. */
  127271. readonly name: string;
  127272. /**
  127273. * The scene the component belongs to.
  127274. */
  127275. scene: Scene;
  127276. /**
  127277. * Creates a new instance of the component for the given scene
  127278. * @param scene Defines the scene to register the component in
  127279. */
  127280. constructor(scene: Scene);
  127281. /**
  127282. * Registers the component in a given scene
  127283. */
  127284. register(): void;
  127285. /**
  127286. * Rebuilds the elements related to this component in case of
  127287. * context lost for instance.
  127288. */
  127289. rebuild(): void;
  127290. /**
  127291. * Adds all the elements from the container to the scene
  127292. * @param container the container holding the elements
  127293. */
  127294. addFromContainer(container: AbstractScene): void;
  127295. /**
  127296. * Removes all the elements in the container from the scene
  127297. * @param container contains the elements to remove
  127298. * @param dispose if the removed element should be disposed (default: false)
  127299. */
  127300. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127301. /**
  127302. * Serializes the component data to the specified json object
  127303. * @param serializationObject The object to serialize to
  127304. */
  127305. serialize(serializationObject: any): void;
  127306. /**
  127307. * Disposes the component and the associated ressources.
  127308. */
  127309. dispose(): void;
  127310. private _draw;
  127311. }
  127312. }
  127313. declare module BABYLON {
  127314. /** @hidden */
  127315. export var depthPixelShader: {
  127316. name: string;
  127317. shader: string;
  127318. };
  127319. }
  127320. declare module BABYLON {
  127321. /** @hidden */
  127322. export var depthVertexShader: {
  127323. name: string;
  127324. shader: string;
  127325. };
  127326. }
  127327. declare module BABYLON {
  127328. /**
  127329. * This represents a depth renderer in Babylon.
  127330. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127331. */
  127332. export class DepthRenderer {
  127333. private _scene;
  127334. private _depthMap;
  127335. private _effect;
  127336. private readonly _storeNonLinearDepth;
  127337. private readonly _clearColor;
  127338. /** Get if the depth renderer is using packed depth or not */
  127339. readonly isPacked: boolean;
  127340. private _cachedDefines;
  127341. private _camera;
  127342. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127343. enabled: boolean;
  127344. /**
  127345. * Specifiess that the depth renderer will only be used within
  127346. * the camera it is created for.
  127347. * This can help forcing its rendering during the camera processing.
  127348. */
  127349. useOnlyInActiveCamera: boolean;
  127350. /** @hidden */
  127351. static _SceneComponentInitialization: (scene: Scene) => void;
  127352. /**
  127353. * Instantiates a depth renderer
  127354. * @param scene The scene the renderer belongs to
  127355. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127356. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127357. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127358. */
  127359. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127360. /**
  127361. * Creates the depth rendering effect and checks if the effect is ready.
  127362. * @param subMesh The submesh to be used to render the depth map of
  127363. * @param useInstances If multiple world instances should be used
  127364. * @returns if the depth renderer is ready to render the depth map
  127365. */
  127366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127367. /**
  127368. * Gets the texture which the depth map will be written to.
  127369. * @returns The depth map texture
  127370. */
  127371. getDepthMap(): RenderTargetTexture;
  127372. /**
  127373. * Disposes of the depth renderer.
  127374. */
  127375. dispose(): void;
  127376. }
  127377. }
  127378. declare module BABYLON {
  127379. /** @hidden */
  127380. export var minmaxReduxPixelShader: {
  127381. name: string;
  127382. shader: string;
  127383. };
  127384. }
  127385. declare module BABYLON {
  127386. /**
  127387. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127388. * and maximum values from all values of the texture.
  127389. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127390. * The source values are read from the red channel of the texture.
  127391. */
  127392. export class MinMaxReducer {
  127393. /**
  127394. * Observable triggered when the computation has been performed
  127395. */
  127396. onAfterReductionPerformed: Observable<{
  127397. min: number;
  127398. max: number;
  127399. }>;
  127400. protected _camera: Camera;
  127401. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127402. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127403. protected _postProcessManager: PostProcessManager;
  127404. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127405. protected _forceFullscreenViewport: boolean;
  127406. /**
  127407. * Creates a min/max reducer
  127408. * @param camera The camera to use for the post processes
  127409. */
  127410. constructor(camera: Camera);
  127411. /**
  127412. * Gets the texture used to read the values from.
  127413. */
  127414. get sourceTexture(): Nullable<RenderTargetTexture>;
  127415. /**
  127416. * Sets the source texture to read the values from.
  127417. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127418. * because in such textures '1' value must not be taken into account to compute the maximum
  127419. * as this value is used to clear the texture.
  127420. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127421. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127422. * @param depthRedux Indicates if the texture is a depth texture or not
  127423. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127424. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127425. */
  127426. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127427. /**
  127428. * Defines the refresh rate of the computation.
  127429. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127430. */
  127431. get refreshRate(): number;
  127432. set refreshRate(value: number);
  127433. protected _activated: boolean;
  127434. /**
  127435. * Gets the activation status of the reducer
  127436. */
  127437. get activated(): boolean;
  127438. /**
  127439. * Activates the reduction computation.
  127440. * When activated, the observers registered in onAfterReductionPerformed are
  127441. * called after the compuation is performed
  127442. */
  127443. activate(): void;
  127444. /**
  127445. * Deactivates the reduction computation.
  127446. */
  127447. deactivate(): void;
  127448. /**
  127449. * Disposes the min/max reducer
  127450. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127451. */
  127452. dispose(disposeAll?: boolean): void;
  127453. }
  127454. }
  127455. declare module BABYLON {
  127456. /**
  127457. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127458. */
  127459. export class DepthReducer extends MinMaxReducer {
  127460. private _depthRenderer;
  127461. private _depthRendererId;
  127462. /**
  127463. * Gets the depth renderer used for the computation.
  127464. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127465. */
  127466. get depthRenderer(): Nullable<DepthRenderer>;
  127467. /**
  127468. * Creates a depth reducer
  127469. * @param camera The camera used to render the depth texture
  127470. */
  127471. constructor(camera: Camera);
  127472. /**
  127473. * Sets the depth renderer to use to generate the depth map
  127474. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127475. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127476. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127477. */
  127478. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127479. /** @hidden */
  127480. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127481. /**
  127482. * Activates the reduction computation.
  127483. * When activated, the observers registered in onAfterReductionPerformed are
  127484. * called after the compuation is performed
  127485. */
  127486. activate(): void;
  127487. /**
  127488. * Deactivates the reduction computation.
  127489. */
  127490. deactivate(): void;
  127491. /**
  127492. * Disposes the depth reducer
  127493. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127494. */
  127495. dispose(disposeAll?: boolean): void;
  127496. }
  127497. }
  127498. declare module BABYLON {
  127499. /**
  127500. * A CSM implementation allowing casting shadows on large scenes.
  127501. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127502. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127503. */
  127504. export class CascadedShadowGenerator extends ShadowGenerator {
  127505. private static readonly frustumCornersNDCSpace;
  127506. /**
  127507. * Name of the CSM class
  127508. */
  127509. static CLASSNAME: string;
  127510. /**
  127511. * Defines the default number of cascades used by the CSM.
  127512. */
  127513. static readonly DEFAULT_CASCADES_COUNT: number;
  127514. /**
  127515. * Defines the minimum number of cascades used by the CSM.
  127516. */
  127517. static readonly MIN_CASCADES_COUNT: number;
  127518. /**
  127519. * Defines the maximum number of cascades used by the CSM.
  127520. */
  127521. static readonly MAX_CASCADES_COUNT: number;
  127522. protected _validateFilter(filter: number): number;
  127523. /**
  127524. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127525. */
  127526. penumbraDarkness: number;
  127527. private _numCascades;
  127528. /**
  127529. * Gets or set the number of cascades used by the CSM.
  127530. */
  127531. get numCascades(): number;
  127532. set numCascades(value: number);
  127533. /**
  127534. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127535. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127536. */
  127537. stabilizeCascades: boolean;
  127538. private _freezeShadowCastersBoundingInfo;
  127539. private _freezeShadowCastersBoundingInfoObservable;
  127540. /**
  127541. * Enables or disables the shadow casters bounding info computation.
  127542. * If your shadow casters don't move, you can disable this feature.
  127543. * If it is enabled, the bounding box computation is done every frame.
  127544. */
  127545. get freezeShadowCastersBoundingInfo(): boolean;
  127546. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127547. private _scbiMin;
  127548. private _scbiMax;
  127549. protected _computeShadowCastersBoundingInfo(): void;
  127550. protected _shadowCastersBoundingInfo: BoundingInfo;
  127551. /**
  127552. * Gets or sets the shadow casters bounding info.
  127553. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127554. * so that the system won't overwrite the bounds you provide
  127555. */
  127556. get shadowCastersBoundingInfo(): BoundingInfo;
  127557. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127558. protected _breaksAreDirty: boolean;
  127559. protected _minDistance: number;
  127560. protected _maxDistance: number;
  127561. /**
  127562. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127563. *
  127564. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127565. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127566. * @param min minimal distance for the breaks (default to 0.)
  127567. * @param max maximal distance for the breaks (default to 1.)
  127568. */
  127569. setMinMaxDistance(min: number, max: number): void;
  127570. /** Gets the minimal distance used in the cascade break computation */
  127571. get minDistance(): number;
  127572. /** Gets the maximal distance used in the cascade break computation */
  127573. get maxDistance(): number;
  127574. /**
  127575. * Gets the class name of that object
  127576. * @returns "CascadedShadowGenerator"
  127577. */
  127578. getClassName(): string;
  127579. private _cascadeMinExtents;
  127580. private _cascadeMaxExtents;
  127581. /**
  127582. * Gets a cascade minimum extents
  127583. * @param cascadeIndex index of the cascade
  127584. * @returns the minimum cascade extents
  127585. */
  127586. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127587. /**
  127588. * Gets a cascade maximum extents
  127589. * @param cascadeIndex index of the cascade
  127590. * @returns the maximum cascade extents
  127591. */
  127592. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127593. private _cascades;
  127594. private _currentLayer;
  127595. private _viewSpaceFrustumsZ;
  127596. private _viewMatrices;
  127597. private _projectionMatrices;
  127598. private _transformMatrices;
  127599. private _transformMatricesAsArray;
  127600. private _frustumLengths;
  127601. private _lightSizeUVCorrection;
  127602. private _depthCorrection;
  127603. private _frustumCornersWorldSpace;
  127604. private _frustumCenter;
  127605. private _shadowCameraPos;
  127606. private _shadowMaxZ;
  127607. /**
  127608. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127609. * It defaults to camera.maxZ
  127610. */
  127611. get shadowMaxZ(): number;
  127612. /**
  127613. * Sets the shadow max z distance.
  127614. */
  127615. set shadowMaxZ(value: number);
  127616. protected _debug: boolean;
  127617. /**
  127618. * Gets or sets the debug flag.
  127619. * When enabled, the cascades are materialized by different colors on the screen.
  127620. */
  127621. get debug(): boolean;
  127622. set debug(dbg: boolean);
  127623. private _depthClamp;
  127624. /**
  127625. * Gets or sets the depth clamping value.
  127626. *
  127627. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127628. * to account for the shadow casters far away.
  127629. *
  127630. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127631. */
  127632. get depthClamp(): boolean;
  127633. set depthClamp(value: boolean);
  127634. private _cascadeBlendPercentage;
  127635. /**
  127636. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127637. * It defaults to 0.1 (10% blending).
  127638. */
  127639. get cascadeBlendPercentage(): number;
  127640. set cascadeBlendPercentage(value: number);
  127641. private _lambda;
  127642. /**
  127643. * Gets or set the lambda parameter.
  127644. * This parameter is used to split the camera frustum and create the cascades.
  127645. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  127646. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127647. */
  127648. get lambda(): number;
  127649. set lambda(value: number);
  127650. /**
  127651. * Gets the view matrix corresponding to a given cascade
  127652. * @param cascadeNum cascade to retrieve the view matrix from
  127653. * @returns the cascade view matrix
  127654. */
  127655. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127656. /**
  127657. * Gets the projection matrix corresponding to a given cascade
  127658. * @param cascadeNum cascade to retrieve the projection matrix from
  127659. * @returns the cascade projection matrix
  127660. */
  127661. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127662. /**
  127663. * Gets the transformation matrix corresponding to a given cascade
  127664. * @param cascadeNum cascade to retrieve the transformation matrix from
  127665. * @returns the cascade transformation matrix
  127666. */
  127667. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127668. private _depthRenderer;
  127669. /**
  127670. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127671. *
  127672. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127673. *
  127674. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127675. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127676. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  127677. */
  127678. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127679. private _depthReducer;
  127680. private _autoCalcDepthBounds;
  127681. /**
  127682. * Gets or sets the autoCalcDepthBounds property.
  127683. *
  127684. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127685. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127686. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127687. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127688. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127689. */
  127690. get autoCalcDepthBounds(): boolean;
  127691. set autoCalcDepthBounds(value: boolean);
  127692. /**
  127693. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127694. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127695. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127696. * for setting the refresh rate on the renderer yourself!
  127697. */
  127698. get autoCalcDepthBoundsRefreshRate(): number;
  127699. set autoCalcDepthBoundsRefreshRate(value: number);
  127700. /**
  127701. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127702. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127703. * you change the camera near/far planes!
  127704. */
  127705. splitFrustum(): void;
  127706. private _splitFrustum;
  127707. private _computeMatrices;
  127708. private _computeFrustumInWorldSpace;
  127709. private _computeCascadeFrustum;
  127710. /** @hidden */
  127711. static _SceneComponentInitialization: (scene: Scene) => void;
  127712. /**
  127713. * Creates a Cascaded Shadow Generator object.
  127714. * A ShadowGenerator is the required tool to use the shadows.
  127715. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127716. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127717. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127718. * @param light The directional light object generating the shadows.
  127719. * @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.
  127720. */
  127721. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127722. protected _initializeGenerator(): void;
  127723. protected _createTargetRenderTexture(): void;
  127724. protected _initializeShadowMap(): void;
  127725. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127726. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127727. /**
  127728. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127729. * @param defines Defines of the material we want to update
  127730. * @param lightIndex Index of the light in the enabled light list of the material
  127731. */
  127732. prepareDefines(defines: any, lightIndex: number): void;
  127733. /**
  127734. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127735. * defined in the generator but impacting the effect).
  127736. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127737. * @param effect The effect we are binfing the information for
  127738. */
  127739. bindShadowLight(lightIndex: string, effect: Effect): void;
  127740. /**
  127741. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127742. * (eq to view projection * shadow projection matrices)
  127743. * @returns The transform matrix used to create the shadow map
  127744. */
  127745. getTransformMatrix(): Matrix;
  127746. /**
  127747. * Disposes the ShadowGenerator.
  127748. * Returns nothing.
  127749. */
  127750. dispose(): void;
  127751. /**
  127752. * Serializes the shadow generator setup to a json object.
  127753. * @returns The serialized JSON object
  127754. */
  127755. serialize(): any;
  127756. /**
  127757. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127758. * @param parsedShadowGenerator The JSON object to parse
  127759. * @param scene The scene to create the shadow map for
  127760. * @returns The parsed shadow generator
  127761. */
  127762. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127763. }
  127764. }
  127765. declare module BABYLON {
  127766. /**
  127767. * Defines the shadow generator component responsible to manage any shadow generators
  127768. * in a given scene.
  127769. */
  127770. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127771. /**
  127772. * The component name helpfull to identify the component in the list of scene components.
  127773. */
  127774. readonly name: string;
  127775. /**
  127776. * The scene the component belongs to.
  127777. */
  127778. scene: Scene;
  127779. /**
  127780. * Creates a new instance of the component for the given scene
  127781. * @param scene Defines the scene to register the component in
  127782. */
  127783. constructor(scene: Scene);
  127784. /**
  127785. * Registers the component in a given scene
  127786. */
  127787. register(): void;
  127788. /**
  127789. * Rebuilds the elements related to this component in case of
  127790. * context lost for instance.
  127791. */
  127792. rebuild(): void;
  127793. /**
  127794. * Serializes the component data to the specified json object
  127795. * @param serializationObject The object to serialize to
  127796. */
  127797. serialize(serializationObject: any): void;
  127798. /**
  127799. * Adds all the elements from the container to the scene
  127800. * @param container the container holding the elements
  127801. */
  127802. addFromContainer(container: AbstractScene): void;
  127803. /**
  127804. * Removes all the elements in the container from the scene
  127805. * @param container contains the elements to remove
  127806. * @param dispose if the removed element should be disposed (default: false)
  127807. */
  127808. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127809. /**
  127810. * Rebuilds the elements related to this component in case of
  127811. * context lost for instance.
  127812. */
  127813. dispose(): void;
  127814. private _gatherRenderTargets;
  127815. }
  127816. }
  127817. declare module BABYLON {
  127818. /**
  127819. * A point light is a light defined by an unique point in world space.
  127820. * The light is emitted in every direction from this point.
  127821. * A good example of a point light is a standard light bulb.
  127822. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127823. */
  127824. export class PointLight extends ShadowLight {
  127825. private _shadowAngle;
  127826. /**
  127827. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127828. * This specifies what angle the shadow will use to be created.
  127829. *
  127830. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127831. */
  127832. get shadowAngle(): number;
  127833. /**
  127834. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127835. * This specifies what angle the shadow will use to be created.
  127836. *
  127837. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127838. */
  127839. set shadowAngle(value: number);
  127840. /**
  127841. * Gets the direction if it has been set.
  127842. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127843. */
  127844. get direction(): Vector3;
  127845. /**
  127846. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127847. */
  127848. set direction(value: Vector3);
  127849. /**
  127850. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127851. * A PointLight emits the light in every direction.
  127852. * It can cast shadows.
  127853. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127854. * ```javascript
  127855. * var pointLight = new PointLight("pl", camera.position, scene);
  127856. * ```
  127857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127858. * @param name The light friendly name
  127859. * @param position The position of the point light in the scene
  127860. * @param scene The scene the lights belongs to
  127861. */
  127862. constructor(name: string, position: Vector3, scene: Scene);
  127863. /**
  127864. * Returns the string "PointLight"
  127865. * @returns the class name
  127866. */
  127867. getClassName(): string;
  127868. /**
  127869. * Returns the integer 0.
  127870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127871. */
  127872. getTypeID(): number;
  127873. /**
  127874. * Specifies wether or not the shadowmap should be a cube texture.
  127875. * @returns true if the shadowmap needs to be a cube texture.
  127876. */
  127877. needCube(): boolean;
  127878. /**
  127879. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127880. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127881. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127882. */
  127883. getShadowDirection(faceIndex?: number): Vector3;
  127884. /**
  127885. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127886. * - fov = PI / 2
  127887. * - aspect ratio : 1.0
  127888. * - z-near and far equal to the active camera minZ and maxZ.
  127889. * Returns the PointLight.
  127890. */
  127891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127892. protected _buildUniformLayout(): void;
  127893. /**
  127894. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127895. * @param effect The effect to update
  127896. * @param lightIndex The index of the light in the effect to update
  127897. * @returns The point light
  127898. */
  127899. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127900. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127901. /**
  127902. * Prepares the list of defines specific to the light type.
  127903. * @param defines the list of defines
  127904. * @param lightIndex defines the index of the light for the effect
  127905. */
  127906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127907. }
  127908. }
  127909. declare module BABYLON {
  127910. /**
  127911. * Header information of HDR texture files.
  127912. */
  127913. export interface HDRInfo {
  127914. /**
  127915. * The height of the texture in pixels.
  127916. */
  127917. height: number;
  127918. /**
  127919. * The width of the texture in pixels.
  127920. */
  127921. width: number;
  127922. /**
  127923. * The index of the beginning of the data in the binary file.
  127924. */
  127925. dataPosition: number;
  127926. }
  127927. /**
  127928. * This groups tools to convert HDR texture to native colors array.
  127929. */
  127930. export class HDRTools {
  127931. private static Ldexp;
  127932. private static Rgbe2float;
  127933. private static readStringLine;
  127934. /**
  127935. * Reads header information from an RGBE texture stored in a native array.
  127936. * More information on this format are available here:
  127937. * https://en.wikipedia.org/wiki/RGBE_image_format
  127938. *
  127939. * @param uint8array The binary file stored in native array.
  127940. * @return The header information.
  127941. */
  127942. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127943. /**
  127944. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127945. * This RGBE texture needs to store the information as a panorama.
  127946. *
  127947. * More information on this format are available here:
  127948. * https://en.wikipedia.org/wiki/RGBE_image_format
  127949. *
  127950. * @param buffer The binary file stored in an array buffer.
  127951. * @param size The expected size of the extracted cubemap.
  127952. * @return The Cube Map information.
  127953. */
  127954. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127955. /**
  127956. * Returns the pixels data extracted from an RGBE texture.
  127957. * This pixels will be stored left to right up to down in the R G B order in one array.
  127958. *
  127959. * More information on this format are available here:
  127960. * https://en.wikipedia.org/wiki/RGBE_image_format
  127961. *
  127962. * @param uint8array The binary file stored in an array buffer.
  127963. * @param hdrInfo The header information of the file.
  127964. * @return The pixels data in RGB right to left up to down order.
  127965. */
  127966. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127967. private static RGBE_ReadPixels_RLE;
  127968. }
  127969. }
  127970. declare module BABYLON {
  127971. /**
  127972. * This represents a texture coming from an HDR input.
  127973. *
  127974. * The only supported format is currently panorama picture stored in RGBE format.
  127975. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127976. */
  127977. export class HDRCubeTexture extends BaseTexture {
  127978. private static _facesMapping;
  127979. private _generateHarmonics;
  127980. private _noMipmap;
  127981. private _textureMatrix;
  127982. private _size;
  127983. private _onLoad;
  127984. private _onError;
  127985. /**
  127986. * The texture URL.
  127987. */
  127988. url: string;
  127989. /**
  127990. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127991. */
  127992. coordinatesMode: number;
  127993. protected _isBlocking: boolean;
  127994. /**
  127995. * Sets wether or not the texture is blocking during loading.
  127996. */
  127997. set isBlocking(value: boolean);
  127998. /**
  127999. * Gets wether or not the texture is blocking during loading.
  128000. */
  128001. get isBlocking(): boolean;
  128002. protected _rotationY: number;
  128003. /**
  128004. * Sets texture matrix rotation angle around Y axis in radians.
  128005. */
  128006. set rotationY(value: number);
  128007. /**
  128008. * Gets texture matrix rotation angle around Y axis radians.
  128009. */
  128010. get rotationY(): number;
  128011. /**
  128012. * Gets or sets the center of the bounding box associated with the cube texture
  128013. * It must define where the camera used to render the texture was set
  128014. */
  128015. boundingBoxPosition: Vector3;
  128016. private _boundingBoxSize;
  128017. /**
  128018. * Gets or sets the size of the bounding box associated with the cube texture
  128019. * When defined, the cubemap will switch to local mode
  128020. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128021. * @example https://www.babylonjs-playground.com/#RNASML
  128022. */
  128023. set boundingBoxSize(value: Vector3);
  128024. get boundingBoxSize(): Vector3;
  128025. /**
  128026. * Instantiates an HDRTexture from the following parameters.
  128027. *
  128028. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128029. * @param scene The scene the texture will be used in
  128030. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128031. * @param noMipmap Forces to not generate the mipmap if true
  128032. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128033. * @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)
  128034. * @param reserved Reserved flag for internal use.
  128035. */
  128036. 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>);
  128037. /**
  128038. * Get the current class name of the texture useful for serialization or dynamic coding.
  128039. * @returns "HDRCubeTexture"
  128040. */
  128041. getClassName(): string;
  128042. /**
  128043. * Occurs when the file is raw .hdr file.
  128044. */
  128045. private loadTexture;
  128046. clone(): HDRCubeTexture;
  128047. delayLoad(): void;
  128048. /**
  128049. * Get the texture reflection matrix used to rotate/transform the reflection.
  128050. * @returns the reflection matrix
  128051. */
  128052. getReflectionTextureMatrix(): Matrix;
  128053. /**
  128054. * Set the texture reflection matrix used to rotate/transform the reflection.
  128055. * @param value Define the reflection matrix to set
  128056. */
  128057. setReflectionTextureMatrix(value: Matrix): void;
  128058. /**
  128059. * Parses a JSON representation of an HDR Texture in order to create the texture
  128060. * @param parsedTexture Define the JSON representation
  128061. * @param scene Define the scene the texture should be created in
  128062. * @param rootUrl Define the root url in case we need to load relative dependencies
  128063. * @returns the newly created texture after parsing
  128064. */
  128065. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128066. serialize(): any;
  128067. }
  128068. }
  128069. declare module BABYLON {
  128070. /**
  128071. * Class used to control physics engine
  128072. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128073. */
  128074. export class PhysicsEngine implements IPhysicsEngine {
  128075. private _physicsPlugin;
  128076. /**
  128077. * Global value used to control the smallest number supported by the simulation
  128078. */
  128079. static Epsilon: number;
  128080. private _impostors;
  128081. private _joints;
  128082. private _subTimeStep;
  128083. /**
  128084. * Gets the gravity vector used by the simulation
  128085. */
  128086. gravity: Vector3;
  128087. /**
  128088. * Factory used to create the default physics plugin.
  128089. * @returns The default physics plugin
  128090. */
  128091. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128092. /**
  128093. * Creates a new Physics Engine
  128094. * @param gravity defines the gravity vector used by the simulation
  128095. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128096. */
  128097. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128098. /**
  128099. * Sets the gravity vector used by the simulation
  128100. * @param gravity defines the gravity vector to use
  128101. */
  128102. setGravity(gravity: Vector3): void;
  128103. /**
  128104. * Set the time step of the physics engine.
  128105. * Default is 1/60.
  128106. * To slow it down, enter 1/600 for example.
  128107. * To speed it up, 1/30
  128108. * @param newTimeStep defines the new timestep to apply to this world.
  128109. */
  128110. setTimeStep(newTimeStep?: number): void;
  128111. /**
  128112. * Get the time step of the physics engine.
  128113. * @returns the current time step
  128114. */
  128115. getTimeStep(): number;
  128116. /**
  128117. * Set the sub time step of the physics engine.
  128118. * Default is 0 meaning there is no sub steps
  128119. * To increase physics resolution precision, set a small value (like 1 ms)
  128120. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128121. */
  128122. setSubTimeStep(subTimeStep?: number): void;
  128123. /**
  128124. * Get the sub time step of the physics engine.
  128125. * @returns the current sub time step
  128126. */
  128127. getSubTimeStep(): number;
  128128. /**
  128129. * Release all resources
  128130. */
  128131. dispose(): void;
  128132. /**
  128133. * Gets the name of the current physics plugin
  128134. * @returns the name of the plugin
  128135. */
  128136. getPhysicsPluginName(): string;
  128137. /**
  128138. * Adding a new impostor for the impostor tracking.
  128139. * This will be done by the impostor itself.
  128140. * @param impostor the impostor to add
  128141. */
  128142. addImpostor(impostor: PhysicsImpostor): void;
  128143. /**
  128144. * Remove an impostor from the engine.
  128145. * This impostor and its mesh will not longer be updated by the physics engine.
  128146. * @param impostor the impostor to remove
  128147. */
  128148. removeImpostor(impostor: PhysicsImpostor): void;
  128149. /**
  128150. * Add a joint to the physics engine
  128151. * @param mainImpostor defines the main impostor to which the joint is added.
  128152. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128153. * @param joint defines the joint that will connect both impostors.
  128154. */
  128155. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128156. /**
  128157. * Removes a joint from the simulation
  128158. * @param mainImpostor defines the impostor used with the joint
  128159. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128160. * @param joint defines the joint to remove
  128161. */
  128162. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128163. /**
  128164. * Called by the scene. No need to call it.
  128165. * @param delta defines the timespam between frames
  128166. */
  128167. _step(delta: number): void;
  128168. /**
  128169. * Gets the current plugin used to run the simulation
  128170. * @returns current plugin
  128171. */
  128172. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128173. /**
  128174. * Gets the list of physic impostors
  128175. * @returns an array of PhysicsImpostor
  128176. */
  128177. getImpostors(): Array<PhysicsImpostor>;
  128178. /**
  128179. * Gets the impostor for a physics enabled object
  128180. * @param object defines the object impersonated by the impostor
  128181. * @returns the PhysicsImpostor or null if not found
  128182. */
  128183. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128184. /**
  128185. * Gets the impostor for a physics body object
  128186. * @param body defines physics body used by the impostor
  128187. * @returns the PhysicsImpostor or null if not found
  128188. */
  128189. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128190. /**
  128191. * Does a raycast in the physics world
  128192. * @param from when should the ray start?
  128193. * @param to when should the ray end?
  128194. * @returns PhysicsRaycastResult
  128195. */
  128196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128197. }
  128198. }
  128199. declare module BABYLON {
  128200. /** @hidden */
  128201. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128202. private _useDeltaForWorldStep;
  128203. world: any;
  128204. name: string;
  128205. private _physicsMaterials;
  128206. private _fixedTimeStep;
  128207. private _cannonRaycastResult;
  128208. private _raycastResult;
  128209. private _physicsBodysToRemoveAfterStep;
  128210. BJSCANNON: any;
  128211. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128212. setGravity(gravity: Vector3): void;
  128213. setTimeStep(timeStep: number): void;
  128214. getTimeStep(): number;
  128215. executeStep(delta: number): void;
  128216. private _removeMarkedPhysicsBodiesFromWorld;
  128217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128218. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128219. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128220. private _processChildMeshes;
  128221. removePhysicsBody(impostor: PhysicsImpostor): void;
  128222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128224. private _addMaterial;
  128225. private _checkWithEpsilon;
  128226. private _createShape;
  128227. private _createHeightmap;
  128228. private _minus90X;
  128229. private _plus90X;
  128230. private _tmpPosition;
  128231. private _tmpDeltaPosition;
  128232. private _tmpUnityRotation;
  128233. private _updatePhysicsBodyTransformation;
  128234. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128235. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128236. isSupported(): boolean;
  128237. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128238. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128239. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128240. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128241. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128242. getBodyMass(impostor: PhysicsImpostor): number;
  128243. getBodyFriction(impostor: PhysicsImpostor): number;
  128244. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128245. getBodyRestitution(impostor: PhysicsImpostor): number;
  128246. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128247. sleepBody(impostor: PhysicsImpostor): void;
  128248. wakeUpBody(impostor: PhysicsImpostor): void;
  128249. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128250. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128251. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128252. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128253. getRadius(impostor: PhysicsImpostor): number;
  128254. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128255. dispose(): void;
  128256. private _extendNamespace;
  128257. /**
  128258. * Does a raycast in the physics world
  128259. * @param from when should the ray start?
  128260. * @param to when should the ray end?
  128261. * @returns PhysicsRaycastResult
  128262. */
  128263. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128264. }
  128265. }
  128266. declare module BABYLON {
  128267. /** @hidden */
  128268. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128269. world: any;
  128270. name: string;
  128271. BJSOIMO: any;
  128272. private _raycastResult;
  128273. constructor(iterations?: number, oimoInjection?: any);
  128274. setGravity(gravity: Vector3): void;
  128275. setTimeStep(timeStep: number): void;
  128276. getTimeStep(): number;
  128277. private _tmpImpostorsArray;
  128278. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128279. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128280. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128281. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128282. private _tmpPositionVector;
  128283. removePhysicsBody(impostor: PhysicsImpostor): void;
  128284. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128285. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128286. isSupported(): boolean;
  128287. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128288. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128289. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128290. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128291. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128292. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128293. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128294. getBodyMass(impostor: PhysicsImpostor): number;
  128295. getBodyFriction(impostor: PhysicsImpostor): number;
  128296. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128297. getBodyRestitution(impostor: PhysicsImpostor): number;
  128298. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128299. sleepBody(impostor: PhysicsImpostor): void;
  128300. wakeUpBody(impostor: PhysicsImpostor): void;
  128301. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128302. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128303. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128304. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128305. getRadius(impostor: PhysicsImpostor): number;
  128306. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128307. dispose(): void;
  128308. /**
  128309. * Does a raycast in the physics world
  128310. * @param from when should the ray start?
  128311. * @param to when should the ray end?
  128312. * @returns PhysicsRaycastResult
  128313. */
  128314. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128315. }
  128316. }
  128317. declare module BABYLON {
  128318. /**
  128319. * Class containing static functions to help procedurally build meshes
  128320. */
  128321. export class RibbonBuilder {
  128322. /**
  128323. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128324. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128325. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128326. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128327. * * 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
  128328. * * 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
  128329. * * 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
  128330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128333. * * 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
  128334. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128335. * * 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
  128336. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128338. * @param name defines the name of the mesh
  128339. * @param options defines the options used to create the mesh
  128340. * @param scene defines the hosting scene
  128341. * @returns the ribbon mesh
  128342. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128344. */
  128345. static CreateRibbon(name: string, options: {
  128346. pathArray: Vector3[][];
  128347. closeArray?: boolean;
  128348. closePath?: boolean;
  128349. offset?: number;
  128350. updatable?: boolean;
  128351. sideOrientation?: number;
  128352. frontUVs?: Vector4;
  128353. backUVs?: Vector4;
  128354. instance?: Mesh;
  128355. invertUV?: boolean;
  128356. uvs?: Vector2[];
  128357. colors?: Color4[];
  128358. }, scene?: Nullable<Scene>): Mesh;
  128359. }
  128360. }
  128361. declare module BABYLON {
  128362. /**
  128363. * Class containing static functions to help procedurally build meshes
  128364. */
  128365. export class ShapeBuilder {
  128366. /**
  128367. * 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.
  128368. * * 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.
  128369. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128370. * * 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.
  128371. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128372. * * 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
  128373. * * 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
  128374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128379. * @param name defines the name of the mesh
  128380. * @param options defines the options used to create the mesh
  128381. * @param scene defines the hosting scene
  128382. * @returns the extruded shape mesh
  128383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128385. */
  128386. static ExtrudeShape(name: string, options: {
  128387. shape: Vector3[];
  128388. path: Vector3[];
  128389. scale?: number;
  128390. rotation?: number;
  128391. cap?: number;
  128392. updatable?: boolean;
  128393. sideOrientation?: number;
  128394. frontUVs?: Vector4;
  128395. backUVs?: Vector4;
  128396. instance?: Mesh;
  128397. invertUV?: boolean;
  128398. }, scene?: Nullable<Scene>): Mesh;
  128399. /**
  128400. * Creates an custom extruded shape mesh.
  128401. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128402. * * 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.
  128403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128404. * * 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
  128405. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128406. * * 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
  128407. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128408. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128409. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128410. * * 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
  128411. * * 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
  128412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128417. * @param name defines the name of the mesh
  128418. * @param options defines the options used to create the mesh
  128419. * @param scene defines the hosting scene
  128420. * @returns the custom extruded shape mesh
  128421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128424. */
  128425. static ExtrudeShapeCustom(name: string, options: {
  128426. shape: Vector3[];
  128427. path: Vector3[];
  128428. scaleFunction?: any;
  128429. rotationFunction?: any;
  128430. ribbonCloseArray?: boolean;
  128431. ribbonClosePath?: boolean;
  128432. cap?: number;
  128433. updatable?: boolean;
  128434. sideOrientation?: number;
  128435. frontUVs?: Vector4;
  128436. backUVs?: Vector4;
  128437. instance?: Mesh;
  128438. invertUV?: boolean;
  128439. }, scene?: Nullable<Scene>): Mesh;
  128440. private static _ExtrudeShapeGeneric;
  128441. }
  128442. }
  128443. declare module BABYLON {
  128444. /**
  128445. * AmmoJS Physics plugin
  128446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128447. * @see https://github.com/kripken/ammo.js/
  128448. */
  128449. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128450. private _useDeltaForWorldStep;
  128451. /**
  128452. * Reference to the Ammo library
  128453. */
  128454. bjsAMMO: any;
  128455. /**
  128456. * Created ammoJS world which physics bodies are added to
  128457. */
  128458. world: any;
  128459. /**
  128460. * Name of the plugin
  128461. */
  128462. name: string;
  128463. private _timeStep;
  128464. private _fixedTimeStep;
  128465. private _maxSteps;
  128466. private _tmpQuaternion;
  128467. private _tmpAmmoTransform;
  128468. private _tmpAmmoQuaternion;
  128469. private _tmpAmmoConcreteContactResultCallback;
  128470. private _collisionConfiguration;
  128471. private _dispatcher;
  128472. private _overlappingPairCache;
  128473. private _solver;
  128474. private _softBodySolver;
  128475. private _tmpAmmoVectorA;
  128476. private _tmpAmmoVectorB;
  128477. private _tmpAmmoVectorC;
  128478. private _tmpAmmoVectorD;
  128479. private _tmpContactCallbackResult;
  128480. private _tmpAmmoVectorRCA;
  128481. private _tmpAmmoVectorRCB;
  128482. private _raycastResult;
  128483. private static readonly DISABLE_COLLISION_FLAG;
  128484. private static readonly KINEMATIC_FLAG;
  128485. private static readonly DISABLE_DEACTIVATION_FLAG;
  128486. /**
  128487. * Initializes the ammoJS plugin
  128488. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128489. * @param ammoInjection can be used to inject your own ammo reference
  128490. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128491. */
  128492. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128493. /**
  128494. * Sets the gravity of the physics world (m/(s^2))
  128495. * @param gravity Gravity to set
  128496. */
  128497. setGravity(gravity: Vector3): void;
  128498. /**
  128499. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128500. * @param timeStep timestep to use in seconds
  128501. */
  128502. setTimeStep(timeStep: number): void;
  128503. /**
  128504. * 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)
  128505. * @param fixedTimeStep fixedTimeStep to use in seconds
  128506. */
  128507. setFixedTimeStep(fixedTimeStep: number): void;
  128508. /**
  128509. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128510. * @param maxSteps the maximum number of steps by the physics engine per frame
  128511. */
  128512. setMaxSteps(maxSteps: number): void;
  128513. /**
  128514. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128515. * @returns the current timestep in seconds
  128516. */
  128517. getTimeStep(): number;
  128518. /**
  128519. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128520. */
  128521. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128522. private _isImpostorInContact;
  128523. private _isImpostorPairInContact;
  128524. private _stepSimulation;
  128525. /**
  128526. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128527. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128528. * After the step the babylon meshes are set to the position of the physics imposters
  128529. * @param delta amount of time to step forward
  128530. * @param impostors array of imposters to update before/after the step
  128531. */
  128532. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128533. /**
  128534. * Update babylon mesh to match physics world object
  128535. * @param impostor imposter to match
  128536. */
  128537. private _afterSoftStep;
  128538. /**
  128539. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128540. * @param impostor imposter to match
  128541. */
  128542. private _ropeStep;
  128543. /**
  128544. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128545. * @param impostor imposter to match
  128546. */
  128547. private _softbodyOrClothStep;
  128548. private _tmpVector;
  128549. private _tmpMatrix;
  128550. /**
  128551. * Applies an impulse on the imposter
  128552. * @param impostor imposter to apply impulse to
  128553. * @param force amount of force to be applied to the imposter
  128554. * @param contactPoint the location to apply the impulse on the imposter
  128555. */
  128556. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128557. /**
  128558. * Applies a force on the imposter
  128559. * @param impostor imposter to apply force
  128560. * @param force amount of force to be applied to the imposter
  128561. * @param contactPoint the location to apply the force on the imposter
  128562. */
  128563. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128564. /**
  128565. * Creates a physics body using the plugin
  128566. * @param impostor the imposter to create the physics body on
  128567. */
  128568. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128569. /**
  128570. * Removes the physics body from the imposter and disposes of the body's memory
  128571. * @param impostor imposter to remove the physics body from
  128572. */
  128573. removePhysicsBody(impostor: PhysicsImpostor): void;
  128574. /**
  128575. * Generates a joint
  128576. * @param impostorJoint the imposter joint to create the joint with
  128577. */
  128578. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128579. /**
  128580. * Removes a joint
  128581. * @param impostorJoint the imposter joint to remove the joint from
  128582. */
  128583. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128584. private _addMeshVerts;
  128585. /**
  128586. * Initialise the soft body vertices to match its object's (mesh) vertices
  128587. * Softbody vertices (nodes) are in world space and to match this
  128588. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128589. * @param impostor to create the softbody for
  128590. */
  128591. private _softVertexData;
  128592. /**
  128593. * Create an impostor's soft body
  128594. * @param impostor to create the softbody for
  128595. */
  128596. private _createSoftbody;
  128597. /**
  128598. * Create cloth for an impostor
  128599. * @param impostor to create the softbody for
  128600. */
  128601. private _createCloth;
  128602. /**
  128603. * Create rope for an impostor
  128604. * @param impostor to create the softbody for
  128605. */
  128606. private _createRope;
  128607. /**
  128608. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128609. * @param impostor to create the custom physics shape for
  128610. */
  128611. private _createCustom;
  128612. private _addHullVerts;
  128613. private _createShape;
  128614. /**
  128615. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128616. * @param impostor imposter containing the physics body and babylon object
  128617. */
  128618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128619. /**
  128620. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128621. * @param impostor imposter containing the physics body and babylon object
  128622. * @param newPosition new position
  128623. * @param newRotation new rotation
  128624. */
  128625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128626. /**
  128627. * If this plugin is supported
  128628. * @returns true if its supported
  128629. */
  128630. isSupported(): boolean;
  128631. /**
  128632. * Sets the linear velocity of the physics body
  128633. * @param impostor imposter to set the velocity on
  128634. * @param velocity velocity to set
  128635. */
  128636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128637. /**
  128638. * Sets the angular velocity of the physics body
  128639. * @param impostor imposter to set the velocity on
  128640. * @param velocity velocity to set
  128641. */
  128642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128643. /**
  128644. * gets the linear velocity
  128645. * @param impostor imposter to get linear velocity from
  128646. * @returns linear velocity
  128647. */
  128648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128649. /**
  128650. * gets the angular velocity
  128651. * @param impostor imposter to get angular velocity from
  128652. * @returns angular velocity
  128653. */
  128654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128655. /**
  128656. * Sets the mass of physics body
  128657. * @param impostor imposter to set the mass on
  128658. * @param mass mass to set
  128659. */
  128660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128661. /**
  128662. * Gets the mass of the physics body
  128663. * @param impostor imposter to get the mass from
  128664. * @returns mass
  128665. */
  128666. getBodyMass(impostor: PhysicsImpostor): number;
  128667. /**
  128668. * Gets friction of the impostor
  128669. * @param impostor impostor to get friction from
  128670. * @returns friction value
  128671. */
  128672. getBodyFriction(impostor: PhysicsImpostor): number;
  128673. /**
  128674. * Sets friction of the impostor
  128675. * @param impostor impostor to set friction on
  128676. * @param friction friction value
  128677. */
  128678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128679. /**
  128680. * Gets restitution of the impostor
  128681. * @param impostor impostor to get restitution from
  128682. * @returns restitution value
  128683. */
  128684. getBodyRestitution(impostor: PhysicsImpostor): number;
  128685. /**
  128686. * Sets resitution of the impostor
  128687. * @param impostor impostor to set resitution on
  128688. * @param restitution resitution value
  128689. */
  128690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128691. /**
  128692. * Gets pressure inside the impostor
  128693. * @param impostor impostor to get pressure from
  128694. * @returns pressure value
  128695. */
  128696. getBodyPressure(impostor: PhysicsImpostor): number;
  128697. /**
  128698. * Sets pressure inside a soft body impostor
  128699. * Cloth and rope must remain 0 pressure
  128700. * @param impostor impostor to set pressure on
  128701. * @param pressure pressure value
  128702. */
  128703. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128704. /**
  128705. * Gets stiffness of the impostor
  128706. * @param impostor impostor to get stiffness from
  128707. * @returns pressure value
  128708. */
  128709. getBodyStiffness(impostor: PhysicsImpostor): number;
  128710. /**
  128711. * Sets stiffness of the impostor
  128712. * @param impostor impostor to set stiffness on
  128713. * @param stiffness stiffness value from 0 to 1
  128714. */
  128715. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128716. /**
  128717. * Gets velocityIterations of the impostor
  128718. * @param impostor impostor to get velocity iterations from
  128719. * @returns velocityIterations value
  128720. */
  128721. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128722. /**
  128723. * Sets velocityIterations of the impostor
  128724. * @param impostor impostor to set velocity iterations on
  128725. * @param velocityIterations velocityIterations value
  128726. */
  128727. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128728. /**
  128729. * Gets positionIterations of the impostor
  128730. * @param impostor impostor to get position iterations from
  128731. * @returns positionIterations value
  128732. */
  128733. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128734. /**
  128735. * Sets positionIterations of the impostor
  128736. * @param impostor impostor to set position on
  128737. * @param positionIterations positionIterations value
  128738. */
  128739. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128740. /**
  128741. * Append an anchor to a cloth object
  128742. * @param impostor is the cloth impostor to add anchor to
  128743. * @param otherImpostor is the rigid impostor to anchor to
  128744. * @param width ratio across width from 0 to 1
  128745. * @param height ratio up height from 0 to 1
  128746. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128748. */
  128749. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128750. /**
  128751. * Append an hook to a rope object
  128752. * @param impostor is the rope impostor to add hook to
  128753. * @param otherImpostor is the rigid impostor to hook to
  128754. * @param length ratio along the rope from 0 to 1
  128755. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128756. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128757. */
  128758. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128759. /**
  128760. * Sleeps the physics body and stops it from being active
  128761. * @param impostor impostor to sleep
  128762. */
  128763. sleepBody(impostor: PhysicsImpostor): void;
  128764. /**
  128765. * Activates the physics body
  128766. * @param impostor impostor to activate
  128767. */
  128768. wakeUpBody(impostor: PhysicsImpostor): void;
  128769. /**
  128770. * Updates the distance parameters of the joint
  128771. * @param joint joint to update
  128772. * @param maxDistance maximum distance of the joint
  128773. * @param minDistance minimum distance of the joint
  128774. */
  128775. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128776. /**
  128777. * Sets a motor on the joint
  128778. * @param joint joint to set motor on
  128779. * @param speed speed of the motor
  128780. * @param maxForce maximum force of the motor
  128781. * @param motorIndex index of the motor
  128782. */
  128783. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128784. /**
  128785. * Sets the motors limit
  128786. * @param joint joint to set limit on
  128787. * @param upperLimit upper limit
  128788. * @param lowerLimit lower limit
  128789. */
  128790. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128791. /**
  128792. * Syncs the position and rotation of a mesh with the impostor
  128793. * @param mesh mesh to sync
  128794. * @param impostor impostor to update the mesh with
  128795. */
  128796. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128797. /**
  128798. * Gets the radius of the impostor
  128799. * @param impostor impostor to get radius from
  128800. * @returns the radius
  128801. */
  128802. getRadius(impostor: PhysicsImpostor): number;
  128803. /**
  128804. * Gets the box size of the impostor
  128805. * @param impostor impostor to get box size from
  128806. * @param result the resulting box size
  128807. */
  128808. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128809. /**
  128810. * Disposes of the impostor
  128811. */
  128812. dispose(): void;
  128813. /**
  128814. * Does a raycast in the physics world
  128815. * @param from when should the ray start?
  128816. * @param to when should the ray end?
  128817. * @returns PhysicsRaycastResult
  128818. */
  128819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128820. }
  128821. }
  128822. declare module BABYLON {
  128823. interface AbstractScene {
  128824. /**
  128825. * The list of reflection probes added to the scene
  128826. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128827. */
  128828. reflectionProbes: Array<ReflectionProbe>;
  128829. /**
  128830. * Removes the given reflection probe from this scene.
  128831. * @param toRemove The reflection probe to remove
  128832. * @returns The index of the removed reflection probe
  128833. */
  128834. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128835. /**
  128836. * Adds the given reflection probe to this scene.
  128837. * @param newReflectionProbe The reflection probe to add
  128838. */
  128839. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128840. }
  128841. /**
  128842. * Class used to generate realtime reflection / refraction cube textures
  128843. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128844. */
  128845. export class ReflectionProbe {
  128846. /** defines the name of the probe */
  128847. name: string;
  128848. private _scene;
  128849. private _renderTargetTexture;
  128850. private _projectionMatrix;
  128851. private _viewMatrix;
  128852. private _target;
  128853. private _add;
  128854. private _attachedMesh;
  128855. private _invertYAxis;
  128856. /** Gets or sets probe position (center of the cube map) */
  128857. position: Vector3;
  128858. /**
  128859. * Creates a new reflection probe
  128860. * @param name defines the name of the probe
  128861. * @param size defines the texture resolution (for each face)
  128862. * @param scene defines the hosting scene
  128863. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128864. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128865. */
  128866. constructor(
  128867. /** defines the name of the probe */
  128868. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128869. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128870. get samples(): number;
  128871. set samples(value: number);
  128872. /** Gets or sets the refresh rate to use (on every frame by default) */
  128873. get refreshRate(): number;
  128874. set refreshRate(value: number);
  128875. /**
  128876. * Gets the hosting scene
  128877. * @returns a Scene
  128878. */
  128879. getScene(): Scene;
  128880. /** Gets the internal CubeTexture used to render to */
  128881. get cubeTexture(): RenderTargetTexture;
  128882. /** Gets the list of meshes to render */
  128883. get renderList(): Nullable<AbstractMesh[]>;
  128884. /**
  128885. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128886. * @param mesh defines the mesh to attach to
  128887. */
  128888. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128889. /**
  128890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128891. * @param renderingGroupId The rendering group id corresponding to its index
  128892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128893. */
  128894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128895. /**
  128896. * Clean all associated resources
  128897. */
  128898. dispose(): void;
  128899. /**
  128900. * Converts the reflection probe information to a readable string for debug purpose.
  128901. * @param fullDetails Supports for multiple levels of logging within scene loading
  128902. * @returns the human readable reflection probe info
  128903. */
  128904. toString(fullDetails?: boolean): string;
  128905. /**
  128906. * Get the class name of the relfection probe.
  128907. * @returns "ReflectionProbe"
  128908. */
  128909. getClassName(): string;
  128910. /**
  128911. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128912. * @returns The JSON representation of the texture
  128913. */
  128914. serialize(): any;
  128915. /**
  128916. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128917. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128918. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128919. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128920. * @returns The parsed reflection probe if successful
  128921. */
  128922. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128923. }
  128924. }
  128925. declare module BABYLON {
  128926. /** @hidden */
  128927. export var _BabylonLoaderRegistered: boolean;
  128928. /**
  128929. * Helps setting up some configuration for the babylon file loader.
  128930. */
  128931. export class BabylonFileLoaderConfiguration {
  128932. /**
  128933. * The loader does not allow injecting custom physix engine into the plugins.
  128934. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128935. * So you could set this variable to your engine import to make it work.
  128936. */
  128937. static LoaderInjectedPhysicsEngine: any;
  128938. }
  128939. }
  128940. declare module BABYLON {
  128941. /**
  128942. * The Physically based simple base material of BJS.
  128943. *
  128944. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128945. * It is used as the base class for both the specGloss and metalRough conventions.
  128946. */
  128947. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128948. /**
  128949. * Number of Simultaneous lights allowed on the material.
  128950. */
  128951. maxSimultaneousLights: number;
  128952. /**
  128953. * If sets to true, disables all the lights affecting the material.
  128954. */
  128955. disableLighting: boolean;
  128956. /**
  128957. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128958. */
  128959. environmentTexture: BaseTexture;
  128960. /**
  128961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128962. */
  128963. invertNormalMapX: boolean;
  128964. /**
  128965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128966. */
  128967. invertNormalMapY: boolean;
  128968. /**
  128969. * Normal map used in the model.
  128970. */
  128971. normalTexture: BaseTexture;
  128972. /**
  128973. * Emissivie color used to self-illuminate the model.
  128974. */
  128975. emissiveColor: Color3;
  128976. /**
  128977. * Emissivie texture used to self-illuminate the model.
  128978. */
  128979. emissiveTexture: BaseTexture;
  128980. /**
  128981. * Occlusion Channel Strenght.
  128982. */
  128983. occlusionStrength: number;
  128984. /**
  128985. * Occlusion Texture of the material (adding extra occlusion effects).
  128986. */
  128987. occlusionTexture: BaseTexture;
  128988. /**
  128989. * Defines the alpha limits in alpha test mode.
  128990. */
  128991. alphaCutOff: number;
  128992. /**
  128993. * Gets the current double sided mode.
  128994. */
  128995. get doubleSided(): boolean;
  128996. /**
  128997. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128998. */
  128999. set doubleSided(value: boolean);
  129000. /**
  129001. * Stores the pre-calculated light information of a mesh in a texture.
  129002. */
  129003. lightmapTexture: BaseTexture;
  129004. /**
  129005. * If true, the light map contains occlusion information instead of lighting info.
  129006. */
  129007. useLightmapAsShadowmap: boolean;
  129008. /**
  129009. * Instantiates a new PBRMaterial instance.
  129010. *
  129011. * @param name The material name
  129012. * @param scene The scene the material will be use in.
  129013. */
  129014. constructor(name: string, scene: Scene);
  129015. getClassName(): string;
  129016. }
  129017. }
  129018. declare module BABYLON {
  129019. /**
  129020. * The PBR material of BJS following the metal roughness convention.
  129021. *
  129022. * This fits to the PBR convention in the GLTF definition:
  129023. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129024. */
  129025. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129026. /**
  129027. * The base color has two different interpretations depending on the value of metalness.
  129028. * When the material is a metal, the base color is the specific measured reflectance value
  129029. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129030. * of the material.
  129031. */
  129032. baseColor: Color3;
  129033. /**
  129034. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129035. * well as opacity information in the alpha channel.
  129036. */
  129037. baseTexture: BaseTexture;
  129038. /**
  129039. * Specifies the metallic scalar value of the material.
  129040. * Can also be used to scale the metalness values of the metallic texture.
  129041. */
  129042. metallic: number;
  129043. /**
  129044. * Specifies the roughness scalar value of the material.
  129045. * Can also be used to scale the roughness values of the metallic texture.
  129046. */
  129047. roughness: number;
  129048. /**
  129049. * Texture containing both the metallic value in the B channel and the
  129050. * roughness value in the G channel to keep better precision.
  129051. */
  129052. metallicRoughnessTexture: BaseTexture;
  129053. /**
  129054. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129055. *
  129056. * @param name The material name
  129057. * @param scene The scene the material will be use in.
  129058. */
  129059. constructor(name: string, scene: Scene);
  129060. /**
  129061. * Return the currrent class name of the material.
  129062. */
  129063. getClassName(): string;
  129064. /**
  129065. * Makes a duplicate of the current material.
  129066. * @param name - name to use for the new material.
  129067. */
  129068. clone(name: string): PBRMetallicRoughnessMaterial;
  129069. /**
  129070. * Serialize the material to a parsable JSON object.
  129071. */
  129072. serialize(): any;
  129073. /**
  129074. * Parses a JSON object correponding to the serialize function.
  129075. */
  129076. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129077. }
  129078. }
  129079. declare module BABYLON {
  129080. /**
  129081. * The PBR material of BJS following the specular glossiness convention.
  129082. *
  129083. * This fits to the PBR convention in the GLTF definition:
  129084. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129085. */
  129086. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129087. /**
  129088. * Specifies the diffuse color of the material.
  129089. */
  129090. diffuseColor: Color3;
  129091. /**
  129092. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129093. * channel.
  129094. */
  129095. diffuseTexture: BaseTexture;
  129096. /**
  129097. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129098. */
  129099. specularColor: Color3;
  129100. /**
  129101. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129102. */
  129103. glossiness: number;
  129104. /**
  129105. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129106. */
  129107. specularGlossinessTexture: BaseTexture;
  129108. /**
  129109. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129110. *
  129111. * @param name The material name
  129112. * @param scene The scene the material will be use in.
  129113. */
  129114. constructor(name: string, scene: Scene);
  129115. /**
  129116. * Return the currrent class name of the material.
  129117. */
  129118. getClassName(): string;
  129119. /**
  129120. * Makes a duplicate of the current material.
  129121. * @param name - name to use for the new material.
  129122. */
  129123. clone(name: string): PBRSpecularGlossinessMaterial;
  129124. /**
  129125. * Serialize the material to a parsable JSON object.
  129126. */
  129127. serialize(): any;
  129128. /**
  129129. * Parses a JSON object correponding to the serialize function.
  129130. */
  129131. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129132. }
  129133. }
  129134. declare module BABYLON {
  129135. /**
  129136. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129137. * It can help converting any input color in a desired output one. This can then be used to create effects
  129138. * from sepia, black and white to sixties or futuristic rendering...
  129139. *
  129140. * The only supported format is currently 3dl.
  129141. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129142. */
  129143. export class ColorGradingTexture extends BaseTexture {
  129144. /**
  129145. * The current texture matrix. (will always be identity in color grading texture)
  129146. */
  129147. private _textureMatrix;
  129148. /**
  129149. * The texture URL.
  129150. */
  129151. url: string;
  129152. /**
  129153. * Empty line regex stored for GC.
  129154. */
  129155. private static _noneEmptyLineRegex;
  129156. private _engine;
  129157. /**
  129158. * Instantiates a ColorGradingTexture from the following parameters.
  129159. *
  129160. * @param url The location of the color gradind data (currently only supporting 3dl)
  129161. * @param scene The scene the texture will be used in
  129162. */
  129163. constructor(url: string, scene: Scene);
  129164. /**
  129165. * Returns the texture matrix used in most of the material.
  129166. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129167. */
  129168. getTextureMatrix(): Matrix;
  129169. /**
  129170. * Occurs when the file being loaded is a .3dl LUT file.
  129171. */
  129172. private load3dlTexture;
  129173. /**
  129174. * Starts the loading process of the texture.
  129175. */
  129176. private loadTexture;
  129177. /**
  129178. * Clones the color gradind texture.
  129179. */
  129180. clone(): ColorGradingTexture;
  129181. /**
  129182. * Called during delayed load for textures.
  129183. */
  129184. delayLoad(): void;
  129185. /**
  129186. * Parses a color grading texture serialized by Babylon.
  129187. * @param parsedTexture The texture information being parsedTexture
  129188. * @param scene The scene to load the texture in
  129189. * @param rootUrl The root url of the data assets to load
  129190. * @return A color gradind texture
  129191. */
  129192. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129193. /**
  129194. * Serializes the LUT texture to json format.
  129195. */
  129196. serialize(): any;
  129197. }
  129198. }
  129199. declare module BABYLON {
  129200. /**
  129201. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129202. */
  129203. export class EquiRectangularCubeTexture extends BaseTexture {
  129204. /** The six faces of the cube. */
  129205. private static _FacesMapping;
  129206. private _noMipmap;
  129207. private _onLoad;
  129208. private _onError;
  129209. /** The size of the cubemap. */
  129210. private _size;
  129211. /** The buffer of the image. */
  129212. private _buffer;
  129213. /** The width of the input image. */
  129214. private _width;
  129215. /** The height of the input image. */
  129216. private _height;
  129217. /** The URL to the image. */
  129218. url: string;
  129219. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129220. coordinatesMode: number;
  129221. /**
  129222. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129223. * @param url The location of the image
  129224. * @param scene The scene the texture will be used in
  129225. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129226. * @param noMipmap Forces to not generate the mipmap if true
  129227. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129228. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129229. * @param onLoad — defines a callback called when texture is loaded
  129230. * @param onError — defines a callback called if there is an error
  129231. */
  129232. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129233. /**
  129234. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129235. */
  129236. private loadImage;
  129237. /**
  129238. * Convert the image buffer into a cubemap and create a CubeTexture.
  129239. */
  129240. private loadTexture;
  129241. /**
  129242. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129243. * @param buffer The ArrayBuffer that should be converted.
  129244. * @returns The buffer as Float32Array.
  129245. */
  129246. private getFloat32ArrayFromArrayBuffer;
  129247. /**
  129248. * Get the current class name of the texture useful for serialization or dynamic coding.
  129249. * @returns "EquiRectangularCubeTexture"
  129250. */
  129251. getClassName(): string;
  129252. /**
  129253. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129254. * @returns A clone of the current EquiRectangularCubeTexture.
  129255. */
  129256. clone(): EquiRectangularCubeTexture;
  129257. }
  129258. }
  129259. declare module BABYLON {
  129260. /**
  129261. * Based on jsTGALoader - Javascript loader for TGA file
  129262. * By Vincent Thibault
  129263. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129264. */
  129265. export class TGATools {
  129266. private static _TYPE_INDEXED;
  129267. private static _TYPE_RGB;
  129268. private static _TYPE_GREY;
  129269. private static _TYPE_RLE_INDEXED;
  129270. private static _TYPE_RLE_RGB;
  129271. private static _TYPE_RLE_GREY;
  129272. private static _ORIGIN_MASK;
  129273. private static _ORIGIN_SHIFT;
  129274. private static _ORIGIN_BL;
  129275. private static _ORIGIN_BR;
  129276. private static _ORIGIN_UL;
  129277. private static _ORIGIN_UR;
  129278. /**
  129279. * Gets the header of a TGA file
  129280. * @param data defines the TGA data
  129281. * @returns the header
  129282. */
  129283. static GetTGAHeader(data: Uint8Array): any;
  129284. /**
  129285. * Uploads TGA content to a Babylon Texture
  129286. * @hidden
  129287. */
  129288. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129289. /** @hidden */
  129290. 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;
  129291. /** @hidden */
  129292. 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;
  129293. /** @hidden */
  129294. 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;
  129295. /** @hidden */
  129296. 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;
  129297. /** @hidden */
  129298. 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;
  129299. /** @hidden */
  129300. 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;
  129301. }
  129302. }
  129303. declare module BABYLON {
  129304. /**
  129305. * Implementation of the TGA Texture Loader.
  129306. * @hidden
  129307. */
  129308. export class _TGATextureLoader implements IInternalTextureLoader {
  129309. /**
  129310. * Defines wether the loader supports cascade loading the different faces.
  129311. */
  129312. readonly supportCascades: boolean;
  129313. /**
  129314. * This returns if the loader support the current file information.
  129315. * @param extension defines the file extension of the file being loaded
  129316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129317. * @param fallback defines the fallback internal texture if any
  129318. * @param isBase64 defines whether the texture is encoded as a base64
  129319. * @param isBuffer defines whether the texture data are stored as a buffer
  129320. * @returns true if the loader can load the specified file
  129321. */
  129322. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129323. /**
  129324. * Transform the url before loading if required.
  129325. * @param rootUrl the url of the texture
  129326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129327. * @returns the transformed texture
  129328. */
  129329. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129330. /**
  129331. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129332. * @param rootUrl the url of the texture
  129333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129334. * @returns the fallback texture
  129335. */
  129336. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129337. /**
  129338. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129339. * @param data contains the texture data
  129340. * @param texture defines the BabylonJS internal texture
  129341. * @param createPolynomials will be true if polynomials have been requested
  129342. * @param onLoad defines the callback to trigger once the texture is ready
  129343. * @param onError defines the callback to trigger in case of error
  129344. */
  129345. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129346. /**
  129347. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129348. * @param data contains the texture data
  129349. * @param texture defines the BabylonJS internal texture
  129350. * @param callback defines the method to call once ready to upload
  129351. */
  129352. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129353. }
  129354. }
  129355. declare module BABYLON {
  129356. /**
  129357. * Info about the .basis files
  129358. */
  129359. class BasisFileInfo {
  129360. /**
  129361. * If the file has alpha
  129362. */
  129363. hasAlpha: boolean;
  129364. /**
  129365. * Info about each image of the basis file
  129366. */
  129367. images: Array<{
  129368. levels: Array<{
  129369. width: number;
  129370. height: number;
  129371. transcodedPixels: ArrayBufferView;
  129372. }>;
  129373. }>;
  129374. }
  129375. /**
  129376. * Result of transcoding a basis file
  129377. */
  129378. class TranscodeResult {
  129379. /**
  129380. * Info about the .basis file
  129381. */
  129382. fileInfo: BasisFileInfo;
  129383. /**
  129384. * Format to use when loading the file
  129385. */
  129386. format: number;
  129387. }
  129388. /**
  129389. * Configuration options for the Basis transcoder
  129390. */
  129391. export class BasisTranscodeConfiguration {
  129392. /**
  129393. * Supported compression formats used to determine the supported output format of the transcoder
  129394. */
  129395. supportedCompressionFormats?: {
  129396. /**
  129397. * etc1 compression format
  129398. */
  129399. etc1?: boolean;
  129400. /**
  129401. * s3tc compression format
  129402. */
  129403. s3tc?: boolean;
  129404. /**
  129405. * pvrtc compression format
  129406. */
  129407. pvrtc?: boolean;
  129408. /**
  129409. * etc2 compression format
  129410. */
  129411. etc2?: boolean;
  129412. };
  129413. /**
  129414. * If mipmap levels should be loaded for transcoded images (Default: true)
  129415. */
  129416. loadMipmapLevels?: boolean;
  129417. /**
  129418. * Index of a single image to load (Default: all images)
  129419. */
  129420. loadSingleImage?: number;
  129421. }
  129422. /**
  129423. * Used to load .Basis files
  129424. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129425. */
  129426. export class BasisTools {
  129427. private static _IgnoreSupportedFormats;
  129428. /**
  129429. * URL to use when loading the basis transcoder
  129430. */
  129431. static JSModuleURL: string;
  129432. /**
  129433. * URL to use when loading the wasm module for the transcoder
  129434. */
  129435. static WasmModuleURL: string;
  129436. /**
  129437. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129438. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129439. * @returns internal format corresponding to the Basis format
  129440. */
  129441. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129442. private static _WorkerPromise;
  129443. private static _Worker;
  129444. private static _actionId;
  129445. private static _CreateWorkerAsync;
  129446. /**
  129447. * Transcodes a loaded image file to compressed pixel data
  129448. * @param data image data to transcode
  129449. * @param config configuration options for the transcoding
  129450. * @returns a promise resulting in the transcoded image
  129451. */
  129452. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129453. /**
  129454. * Loads a texture from the transcode result
  129455. * @param texture texture load to
  129456. * @param transcodeResult the result of transcoding the basis file to load from
  129457. */
  129458. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129459. }
  129460. }
  129461. declare module BABYLON {
  129462. /**
  129463. * Loader for .basis file format
  129464. */
  129465. export class _BasisTextureLoader implements IInternalTextureLoader {
  129466. /**
  129467. * Defines whether the loader supports cascade loading the different faces.
  129468. */
  129469. readonly supportCascades: boolean;
  129470. /**
  129471. * This returns if the loader support the current file information.
  129472. * @param extension defines the file extension of the file being loaded
  129473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129474. * @param fallback defines the fallback internal texture if any
  129475. * @param isBase64 defines whether the texture is encoded as a base64
  129476. * @param isBuffer defines whether the texture data are stored as a buffer
  129477. * @returns true if the loader can load the specified file
  129478. */
  129479. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129480. /**
  129481. * Transform the url before loading if required.
  129482. * @param rootUrl the url of the texture
  129483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129484. * @returns the transformed texture
  129485. */
  129486. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129487. /**
  129488. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129489. * @param rootUrl the url of the texture
  129490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129491. * @returns the fallback texture
  129492. */
  129493. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129494. /**
  129495. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129496. * @param data contains the texture data
  129497. * @param texture defines the BabylonJS internal texture
  129498. * @param createPolynomials will be true if polynomials have been requested
  129499. * @param onLoad defines the callback to trigger once the texture is ready
  129500. * @param onError defines the callback to trigger in case of error
  129501. */
  129502. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129503. /**
  129504. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129505. * @param data contains the texture data
  129506. * @param texture defines the BabylonJS internal texture
  129507. * @param callback defines the method to call once ready to upload
  129508. */
  129509. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129510. }
  129511. }
  129512. declare module BABYLON {
  129513. /**
  129514. * 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.
  129515. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129516. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129517. */
  129518. export class CustomProceduralTexture extends ProceduralTexture {
  129519. private _animate;
  129520. private _time;
  129521. private _config;
  129522. private _texturePath;
  129523. /**
  129524. * Instantiates a new Custom Procedural Texture.
  129525. * 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.
  129526. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129527. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129528. * @param name Define the name of the texture
  129529. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129530. * @param size Define the size of the texture to create
  129531. * @param scene Define the scene the texture belongs to
  129532. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129533. * @param generateMipMaps Define if the texture should creates mip maps or not
  129534. */
  129535. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129536. private _loadJson;
  129537. /**
  129538. * Is the texture ready to be used ? (rendered at least once)
  129539. * @returns true if ready, otherwise, false.
  129540. */
  129541. isReady(): boolean;
  129542. /**
  129543. * Render the texture to its associated render target.
  129544. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129545. */
  129546. render(useCameraPostProcess?: boolean): void;
  129547. /**
  129548. * Update the list of dependant textures samplers in the shader.
  129549. */
  129550. updateTextures(): void;
  129551. /**
  129552. * Update the uniform values of the procedural texture in the shader.
  129553. */
  129554. updateShaderUniforms(): void;
  129555. /**
  129556. * Define if the texture animates or not.
  129557. */
  129558. get animate(): boolean;
  129559. set animate(value: boolean);
  129560. }
  129561. }
  129562. declare module BABYLON {
  129563. /** @hidden */
  129564. export var noisePixelShader: {
  129565. name: string;
  129566. shader: string;
  129567. };
  129568. }
  129569. declare module BABYLON {
  129570. /**
  129571. * Class used to generate noise procedural textures
  129572. */
  129573. export class NoiseProceduralTexture extends ProceduralTexture {
  129574. private _time;
  129575. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129576. brightness: number;
  129577. /** Defines the number of octaves to process */
  129578. octaves: number;
  129579. /** Defines the level of persistence (0.8 by default) */
  129580. persistence: number;
  129581. /** Gets or sets animation speed factor (default is 1) */
  129582. animationSpeedFactor: number;
  129583. /**
  129584. * Creates a new NoiseProceduralTexture
  129585. * @param name defines the name fo the texture
  129586. * @param size defines the size of the texture (default is 256)
  129587. * @param scene defines the hosting scene
  129588. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129589. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129590. */
  129591. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129592. private _updateShaderUniforms;
  129593. protected _getDefines(): string;
  129594. /** Generate the current state of the procedural texture */
  129595. render(useCameraPostProcess?: boolean): void;
  129596. /**
  129597. * Serializes this noise procedural texture
  129598. * @returns a serialized noise procedural texture object
  129599. */
  129600. serialize(): any;
  129601. /**
  129602. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129603. * @param parsedTexture defines parsed texture data
  129604. * @param scene defines the current scene
  129605. * @param rootUrl defines the root URL containing noise procedural texture information
  129606. * @returns a parsed NoiseProceduralTexture
  129607. */
  129608. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129609. }
  129610. }
  129611. declare module BABYLON {
  129612. /**
  129613. * Raw cube texture where the raw buffers are passed in
  129614. */
  129615. export class RawCubeTexture extends CubeTexture {
  129616. /**
  129617. * Creates a cube texture where the raw buffers are passed in.
  129618. * @param scene defines the scene the texture is attached to
  129619. * @param data defines the array of data to use to create each face
  129620. * @param size defines the size of the textures
  129621. * @param format defines the format of the data
  129622. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129623. * @param generateMipMaps defines if the engine should generate the mip levels
  129624. * @param invertY defines if data must be stored with Y axis inverted
  129625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129626. * @param compression defines the compression used (null by default)
  129627. */
  129628. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129629. /**
  129630. * Updates the raw cube texture.
  129631. * @param data defines the data to store
  129632. * @param format defines the data format
  129633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129634. * @param invertY defines if data must be stored with Y axis inverted
  129635. * @param compression defines the compression used (null by default)
  129636. * @param level defines which level of the texture to update
  129637. */
  129638. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129639. /**
  129640. * Updates a raw cube texture with RGBD encoded data.
  129641. * @param data defines the array of data [mipmap][face] to use to create each face
  129642. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129645. * @returns a promsie that resolves when the operation is complete
  129646. */
  129647. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129648. /**
  129649. * Clones the raw cube texture.
  129650. * @return a new cube texture
  129651. */
  129652. clone(): CubeTexture;
  129653. /** @hidden */
  129654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129655. }
  129656. }
  129657. declare module BABYLON {
  129658. /**
  129659. * Class used to store 3D textures containing user data
  129660. */
  129661. export class RawTexture3D extends Texture {
  129662. /** Gets or sets the texture format to use */
  129663. format: number;
  129664. private _engine;
  129665. /**
  129666. * Create a new RawTexture3D
  129667. * @param data defines the data of the texture
  129668. * @param width defines the width of the texture
  129669. * @param height defines the height of the texture
  129670. * @param depth defines the depth of the texture
  129671. * @param format defines the texture format to use
  129672. * @param scene defines the hosting scene
  129673. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129674. * @param invertY defines if texture must be stored with Y axis inverted
  129675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129676. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129677. */
  129678. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129679. /** Gets or sets the texture format to use */
  129680. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129681. /**
  129682. * Update the texture with new data
  129683. * @param data defines the data to store in the texture
  129684. */
  129685. update(data: ArrayBufferView): void;
  129686. }
  129687. }
  129688. declare module BABYLON {
  129689. /**
  129690. * Class used to store 2D array textures containing user data
  129691. */
  129692. export class RawTexture2DArray extends Texture {
  129693. /** Gets or sets the texture format to use */
  129694. format: number;
  129695. private _engine;
  129696. /**
  129697. * Create a new RawTexture2DArray
  129698. * @param data defines the data of the texture
  129699. * @param width defines the width of the texture
  129700. * @param height defines the height of the texture
  129701. * @param depth defines the number of layers of the texture
  129702. * @param format defines the texture format to use
  129703. * @param scene defines the hosting scene
  129704. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129705. * @param invertY defines if texture must be stored with Y axis inverted
  129706. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129707. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129708. */
  129709. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129710. /** Gets or sets the texture format to use */
  129711. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129712. /**
  129713. * Update the texture with new data
  129714. * @param data defines the data to store in the texture
  129715. */
  129716. update(data: ArrayBufferView): void;
  129717. }
  129718. }
  129719. declare module BABYLON {
  129720. /**
  129721. * Creates a refraction texture used by refraction channel of the standard material.
  129722. * It is like a mirror but to see through a material.
  129723. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129724. */
  129725. export class RefractionTexture extends RenderTargetTexture {
  129726. /**
  129727. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129728. * 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.
  129729. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129730. */
  129731. refractionPlane: Plane;
  129732. /**
  129733. * Define how deep under the surface we should see.
  129734. */
  129735. depth: number;
  129736. /**
  129737. * Creates a refraction texture used by refraction channel of the standard material.
  129738. * It is like a mirror but to see through a material.
  129739. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129740. * @param name Define the texture name
  129741. * @param size Define the size of the underlying texture
  129742. * @param scene Define the scene the refraction belongs to
  129743. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129744. */
  129745. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129746. /**
  129747. * Clone the refraction texture.
  129748. * @returns the cloned texture
  129749. */
  129750. clone(): RefractionTexture;
  129751. /**
  129752. * Serialize the texture to a JSON representation you could use in Parse later on
  129753. * @returns the serialized JSON representation
  129754. */
  129755. serialize(): any;
  129756. }
  129757. }
  129758. declare module BABYLON {
  129759. /**
  129760. * Defines the options related to the creation of an HtmlElementTexture
  129761. */
  129762. export interface IHtmlElementTextureOptions {
  129763. /**
  129764. * Defines wether mip maps should be created or not.
  129765. */
  129766. generateMipMaps?: boolean;
  129767. /**
  129768. * Defines the sampling mode of the texture.
  129769. */
  129770. samplingMode?: number;
  129771. /**
  129772. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129773. */
  129774. engine: Nullable<ThinEngine>;
  129775. /**
  129776. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129777. */
  129778. scene: Nullable<Scene>;
  129779. }
  129780. /**
  129781. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129782. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129783. * is automatically managed.
  129784. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129785. * in your application.
  129786. *
  129787. * As the update is not automatic, you need to call them manually.
  129788. */
  129789. export class HtmlElementTexture extends BaseTexture {
  129790. /**
  129791. * The texture URL.
  129792. */
  129793. element: HTMLVideoElement | HTMLCanvasElement;
  129794. private static readonly DefaultOptions;
  129795. private _textureMatrix;
  129796. private _engine;
  129797. private _isVideo;
  129798. private _generateMipMaps;
  129799. private _samplingMode;
  129800. /**
  129801. * Instantiates a HtmlElementTexture from the following parameters.
  129802. *
  129803. * @param name Defines the name of the texture
  129804. * @param element Defines the video or canvas the texture is filled with
  129805. * @param options Defines the other none mandatory texture creation options
  129806. */
  129807. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129808. private _createInternalTexture;
  129809. /**
  129810. * Returns the texture matrix used in most of the material.
  129811. */
  129812. getTextureMatrix(): Matrix;
  129813. /**
  129814. * Updates the content of the texture.
  129815. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129816. */
  129817. update(invertY?: Nullable<boolean>): void;
  129818. }
  129819. }
  129820. declare module BABYLON {
  129821. /**
  129822. * Defines the basic options interface of a TexturePacker Frame
  129823. */
  129824. export interface ITexturePackerFrame {
  129825. /**
  129826. * The frame ID
  129827. */
  129828. id: number;
  129829. /**
  129830. * The frames Scale
  129831. */
  129832. scale: Vector2;
  129833. /**
  129834. * The Frames offset
  129835. */
  129836. offset: Vector2;
  129837. }
  129838. /**
  129839. * This is a support class for frame Data on texture packer sets.
  129840. */
  129841. export class TexturePackerFrame implements ITexturePackerFrame {
  129842. /**
  129843. * The frame ID
  129844. */
  129845. id: number;
  129846. /**
  129847. * The frames Scale
  129848. */
  129849. scale: Vector2;
  129850. /**
  129851. * The Frames offset
  129852. */
  129853. offset: Vector2;
  129854. /**
  129855. * Initializes a texture package frame.
  129856. * @param id The numerical frame identifier
  129857. * @param scale Scalar Vector2 for UV frame
  129858. * @param offset Vector2 for the frame position in UV units.
  129859. * @returns TexturePackerFrame
  129860. */
  129861. constructor(id: number, scale: Vector2, offset: Vector2);
  129862. }
  129863. }
  129864. declare module BABYLON {
  129865. /**
  129866. * Defines the basic options interface of a TexturePacker
  129867. */
  129868. export interface ITexturePackerOptions {
  129869. /**
  129870. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129871. */
  129872. map?: string[];
  129873. /**
  129874. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129875. */
  129876. uvsIn?: string;
  129877. /**
  129878. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129879. */
  129880. uvsOut?: string;
  129881. /**
  129882. * number representing the layout style. Defaults to LAYOUT_STRIP
  129883. */
  129884. layout?: number;
  129885. /**
  129886. * number of columns if using custom column count layout(2). This defaults to 4.
  129887. */
  129888. colnum?: number;
  129889. /**
  129890. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129891. */
  129892. updateInputMeshes?: boolean;
  129893. /**
  129894. * boolean flag to dispose all the source textures. Defaults to true.
  129895. */
  129896. disposeSources?: boolean;
  129897. /**
  129898. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129899. */
  129900. fillBlanks?: boolean;
  129901. /**
  129902. * string value representing the context fill style color. Defaults to 'black'.
  129903. */
  129904. customFillColor?: string;
  129905. /**
  129906. * Width and Height Value of each Frame in the TexturePacker Sets
  129907. */
  129908. frameSize?: number;
  129909. /**
  129910. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129911. */
  129912. paddingRatio?: number;
  129913. /**
  129914. * Number that declares the fill method for the padding gutter.
  129915. */
  129916. paddingMode?: number;
  129917. /**
  129918. * If in SUBUV_COLOR padding mode what color to use.
  129919. */
  129920. paddingColor?: Color3 | Color4;
  129921. }
  129922. /**
  129923. * Defines the basic interface of a TexturePacker JSON File
  129924. */
  129925. export interface ITexturePackerJSON {
  129926. /**
  129927. * The frame ID
  129928. */
  129929. name: string;
  129930. /**
  129931. * The base64 channel data
  129932. */
  129933. sets: any;
  129934. /**
  129935. * The options of the Packer
  129936. */
  129937. options: ITexturePackerOptions;
  129938. /**
  129939. * The frame data of the Packer
  129940. */
  129941. frames: Array<number>;
  129942. }
  129943. /**
  129944. * This is a support class that generates a series of packed texture sets.
  129945. * @see https://doc.babylonjs.com/babylon101/materials
  129946. */
  129947. export class TexturePacker {
  129948. /** Packer Layout Constant 0 */
  129949. static readonly LAYOUT_STRIP: number;
  129950. /** Packer Layout Constant 1 */
  129951. static readonly LAYOUT_POWER2: number;
  129952. /** Packer Layout Constant 2 */
  129953. static readonly LAYOUT_COLNUM: number;
  129954. /** Packer Layout Constant 0 */
  129955. static readonly SUBUV_WRAP: number;
  129956. /** Packer Layout Constant 1 */
  129957. static readonly SUBUV_EXTEND: number;
  129958. /** Packer Layout Constant 2 */
  129959. static readonly SUBUV_COLOR: number;
  129960. /** The Name of the Texture Package */
  129961. name: string;
  129962. /** The scene scope of the TexturePacker */
  129963. scene: Scene;
  129964. /** The Meshes to target */
  129965. meshes: AbstractMesh[];
  129966. /** Arguments passed with the Constructor */
  129967. options: ITexturePackerOptions;
  129968. /** The promise that is started upon initialization */
  129969. promise: Nullable<Promise<TexturePacker | string>>;
  129970. /** The Container object for the channel sets that are generated */
  129971. sets: object;
  129972. /** The Container array for the frames that are generated */
  129973. frames: TexturePackerFrame[];
  129974. /** The expected number of textures the system is parsing. */
  129975. private _expecting;
  129976. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129977. private _paddingValue;
  129978. /**
  129979. * Initializes a texture package series from an array of meshes or a single mesh.
  129980. * @param name The name of the package
  129981. * @param meshes The target meshes to compose the package from
  129982. * @param options The arguments that texture packer should follow while building.
  129983. * @param scene The scene which the textures are scoped to.
  129984. * @returns TexturePacker
  129985. */
  129986. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129987. /**
  129988. * Starts the package process
  129989. * @param resolve The promises resolution function
  129990. * @returns TexturePacker
  129991. */
  129992. private _createFrames;
  129993. /**
  129994. * Calculates the Size of the Channel Sets
  129995. * @returns Vector2
  129996. */
  129997. private _calculateSize;
  129998. /**
  129999. * Calculates the UV data for the frames.
  130000. * @param baseSize the base frameSize
  130001. * @param padding the base frame padding
  130002. * @param dtSize size of the Dynamic Texture for that channel
  130003. * @param dtUnits is 1/dtSize
  130004. * @param update flag to update the input meshes
  130005. */
  130006. private _calculateMeshUVFrames;
  130007. /**
  130008. * Calculates the frames Offset.
  130009. * @param index of the frame
  130010. * @returns Vector2
  130011. */
  130012. private _getFrameOffset;
  130013. /**
  130014. * Updates a Mesh to the frame data
  130015. * @param mesh that is the target
  130016. * @param frameID or the frame index
  130017. */
  130018. private _updateMeshUV;
  130019. /**
  130020. * Updates a Meshes materials to use the texture packer channels
  130021. * @param m is the mesh to target
  130022. * @param force all channels on the packer to be set.
  130023. */
  130024. private _updateTextureReferences;
  130025. /**
  130026. * Public method to set a Mesh to a frame
  130027. * @param m that is the target
  130028. * @param frameID or the frame index
  130029. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130030. */
  130031. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130032. /**
  130033. * Starts the async promise to compile the texture packer.
  130034. * @returns Promise<void>
  130035. */
  130036. processAsync(): Promise<void>;
  130037. /**
  130038. * Disposes all textures associated with this packer
  130039. */
  130040. dispose(): void;
  130041. /**
  130042. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130043. * @param imageType is the image type to use.
  130044. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130045. */
  130046. download(imageType?: string, quality?: number): void;
  130047. /**
  130048. * Public method to load a texturePacker JSON file.
  130049. * @param data of the JSON file in string format.
  130050. */
  130051. updateFromJSON(data: string): void;
  130052. }
  130053. }
  130054. declare module BABYLON {
  130055. /**
  130056. * Enum used to define the target of a block
  130057. */
  130058. export enum NodeMaterialBlockTargets {
  130059. /** Vertex shader */
  130060. Vertex = 1,
  130061. /** Fragment shader */
  130062. Fragment = 2,
  130063. /** Neutral */
  130064. Neutral = 4,
  130065. /** Vertex and Fragment */
  130066. VertexAndFragment = 3
  130067. }
  130068. }
  130069. declare module BABYLON {
  130070. /**
  130071. * Defines the kind of connection point for node based material
  130072. */
  130073. export enum NodeMaterialBlockConnectionPointTypes {
  130074. /** Float */
  130075. Float = 1,
  130076. /** Int */
  130077. Int = 2,
  130078. /** Vector2 */
  130079. Vector2 = 4,
  130080. /** Vector3 */
  130081. Vector3 = 8,
  130082. /** Vector4 */
  130083. Vector4 = 16,
  130084. /** Color3 */
  130085. Color3 = 32,
  130086. /** Color4 */
  130087. Color4 = 64,
  130088. /** Matrix */
  130089. Matrix = 128,
  130090. /** Detect type based on connection */
  130091. AutoDetect = 1024,
  130092. /** Output type that will be defined by input type */
  130093. BasedOnInput = 2048
  130094. }
  130095. }
  130096. declare module BABYLON {
  130097. /**
  130098. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130099. */
  130100. export enum NodeMaterialBlockConnectionPointMode {
  130101. /** Value is an uniform */
  130102. Uniform = 0,
  130103. /** Value is a mesh attribute */
  130104. Attribute = 1,
  130105. /** Value is a varying between vertex and fragment shaders */
  130106. Varying = 2,
  130107. /** Mode is undefined */
  130108. Undefined = 3
  130109. }
  130110. }
  130111. declare module BABYLON {
  130112. /**
  130113. * Enum used to define system values e.g. values automatically provided by the system
  130114. */
  130115. export enum NodeMaterialSystemValues {
  130116. /** World */
  130117. World = 1,
  130118. /** View */
  130119. View = 2,
  130120. /** Projection */
  130121. Projection = 3,
  130122. /** ViewProjection */
  130123. ViewProjection = 4,
  130124. /** WorldView */
  130125. WorldView = 5,
  130126. /** WorldViewProjection */
  130127. WorldViewProjection = 6,
  130128. /** CameraPosition */
  130129. CameraPosition = 7,
  130130. /** Fog Color */
  130131. FogColor = 8,
  130132. /** Delta time */
  130133. DeltaTime = 9
  130134. }
  130135. }
  130136. declare module BABYLON {
  130137. /**
  130138. * Root class for all node material optimizers
  130139. */
  130140. export class NodeMaterialOptimizer {
  130141. /**
  130142. * Function used to optimize a NodeMaterial graph
  130143. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130144. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130145. */
  130146. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130147. }
  130148. }
  130149. declare module BABYLON {
  130150. /**
  130151. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130152. */
  130153. export class TransformBlock extends NodeMaterialBlock {
  130154. /**
  130155. * Defines the value to use to complement W value to transform it to a Vector4
  130156. */
  130157. complementW: number;
  130158. /**
  130159. * Defines the value to use to complement z value to transform it to a Vector4
  130160. */
  130161. complementZ: number;
  130162. /**
  130163. * Creates a new TransformBlock
  130164. * @param name defines the block name
  130165. */
  130166. constructor(name: string);
  130167. /**
  130168. * Gets the current class name
  130169. * @returns the class name
  130170. */
  130171. getClassName(): string;
  130172. /**
  130173. * Gets the vector input
  130174. */
  130175. get vector(): NodeMaterialConnectionPoint;
  130176. /**
  130177. * Gets the output component
  130178. */
  130179. get output(): NodeMaterialConnectionPoint;
  130180. /**
  130181. * Gets the matrix transform input
  130182. */
  130183. get transform(): NodeMaterialConnectionPoint;
  130184. protected _buildBlock(state: NodeMaterialBuildState): this;
  130185. serialize(): any;
  130186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130187. protected _dumpPropertiesCode(): string;
  130188. }
  130189. }
  130190. declare module BABYLON {
  130191. /**
  130192. * Block used to output the vertex position
  130193. */
  130194. export class VertexOutputBlock extends NodeMaterialBlock {
  130195. /**
  130196. * Creates a new VertexOutputBlock
  130197. * @param name defines the block name
  130198. */
  130199. constructor(name: string);
  130200. /**
  130201. * Gets the current class name
  130202. * @returns the class name
  130203. */
  130204. getClassName(): string;
  130205. /**
  130206. * Gets the vector input component
  130207. */
  130208. get vector(): NodeMaterialConnectionPoint;
  130209. protected _buildBlock(state: NodeMaterialBuildState): this;
  130210. }
  130211. }
  130212. declare module BABYLON {
  130213. /**
  130214. * Block used to output the final color
  130215. */
  130216. export class FragmentOutputBlock extends NodeMaterialBlock {
  130217. /**
  130218. * Create a new FragmentOutputBlock
  130219. * @param name defines the block name
  130220. */
  130221. constructor(name: string);
  130222. /**
  130223. * Gets the current class name
  130224. * @returns the class name
  130225. */
  130226. getClassName(): string;
  130227. /**
  130228. * Gets the rgba input component
  130229. */
  130230. get rgba(): NodeMaterialConnectionPoint;
  130231. /**
  130232. * Gets the rgb input component
  130233. */
  130234. get rgb(): NodeMaterialConnectionPoint;
  130235. /**
  130236. * Gets the a input component
  130237. */
  130238. get a(): NodeMaterialConnectionPoint;
  130239. protected _buildBlock(state: NodeMaterialBuildState): this;
  130240. }
  130241. }
  130242. declare module BABYLON {
  130243. /**
  130244. * Block used to read a reflection texture from a sampler
  130245. */
  130246. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130247. private _define3DName;
  130248. private _defineCubicName;
  130249. private _defineExplicitName;
  130250. private _defineProjectionName;
  130251. private _defineLocalCubicName;
  130252. private _defineSphericalName;
  130253. private _definePlanarName;
  130254. private _defineEquirectangularName;
  130255. private _defineMirroredEquirectangularFixedName;
  130256. private _defineEquirectangularFixedName;
  130257. private _defineSkyboxName;
  130258. private _cubeSamplerName;
  130259. private _2DSamplerName;
  130260. private _positionUVWName;
  130261. private _directionWName;
  130262. private _reflectionCoordsName;
  130263. private _reflection2DCoordsName;
  130264. private _reflectionColorName;
  130265. private _reflectionMatrixName;
  130266. /**
  130267. * Gets or sets the texture associated with the node
  130268. */
  130269. texture: Nullable<BaseTexture>;
  130270. /**
  130271. * Create a new TextureBlock
  130272. * @param name defines the block name
  130273. */
  130274. constructor(name: string);
  130275. /**
  130276. * Gets the current class name
  130277. * @returns the class name
  130278. */
  130279. getClassName(): string;
  130280. /**
  130281. * Gets the world position input component
  130282. */
  130283. get position(): NodeMaterialConnectionPoint;
  130284. /**
  130285. * Gets the world position input component
  130286. */
  130287. get worldPosition(): NodeMaterialConnectionPoint;
  130288. /**
  130289. * Gets the world normal input component
  130290. */
  130291. get worldNormal(): NodeMaterialConnectionPoint;
  130292. /**
  130293. * Gets the world input component
  130294. */
  130295. get world(): NodeMaterialConnectionPoint;
  130296. /**
  130297. * Gets the camera (or eye) position component
  130298. */
  130299. get cameraPosition(): NodeMaterialConnectionPoint;
  130300. /**
  130301. * Gets the view input component
  130302. */
  130303. get view(): NodeMaterialConnectionPoint;
  130304. /**
  130305. * Gets the rgb output component
  130306. */
  130307. get rgb(): NodeMaterialConnectionPoint;
  130308. /**
  130309. * Gets the r output component
  130310. */
  130311. get r(): NodeMaterialConnectionPoint;
  130312. /**
  130313. * Gets the g output component
  130314. */
  130315. get g(): NodeMaterialConnectionPoint;
  130316. /**
  130317. * Gets the b output component
  130318. */
  130319. get b(): NodeMaterialConnectionPoint;
  130320. autoConfigure(material: NodeMaterial): void;
  130321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130322. isReady(): boolean;
  130323. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130324. private _injectVertexCode;
  130325. private _writeOutput;
  130326. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130327. protected _dumpPropertiesCode(): string;
  130328. serialize(): any;
  130329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130330. }
  130331. }
  130332. declare module BABYLON {
  130333. /**
  130334. * Interface used to configure the node material editor
  130335. */
  130336. export interface INodeMaterialEditorOptions {
  130337. /** Define the URl to load node editor script */
  130338. editorURL?: string;
  130339. }
  130340. /** @hidden */
  130341. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130342. NORMAL: boolean;
  130343. TANGENT: boolean;
  130344. UV1: boolean;
  130345. /** BONES */
  130346. NUM_BONE_INFLUENCERS: number;
  130347. BonesPerMesh: number;
  130348. BONETEXTURE: boolean;
  130349. /** MORPH TARGETS */
  130350. MORPHTARGETS: boolean;
  130351. MORPHTARGETS_NORMAL: boolean;
  130352. MORPHTARGETS_TANGENT: boolean;
  130353. MORPHTARGETS_UV: boolean;
  130354. NUM_MORPH_INFLUENCERS: number;
  130355. /** IMAGE PROCESSING */
  130356. IMAGEPROCESSING: boolean;
  130357. VIGNETTE: boolean;
  130358. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130359. VIGNETTEBLENDMODEOPAQUE: boolean;
  130360. TONEMAPPING: boolean;
  130361. TONEMAPPING_ACES: boolean;
  130362. CONTRAST: boolean;
  130363. EXPOSURE: boolean;
  130364. COLORCURVES: boolean;
  130365. COLORGRADING: boolean;
  130366. COLORGRADING3D: boolean;
  130367. SAMPLER3DGREENDEPTH: boolean;
  130368. SAMPLER3DBGRMAP: boolean;
  130369. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130370. /** MISC. */
  130371. BUMPDIRECTUV: number;
  130372. constructor();
  130373. setValue(name: string, value: boolean): void;
  130374. }
  130375. /**
  130376. * Class used to configure NodeMaterial
  130377. */
  130378. export interface INodeMaterialOptions {
  130379. /**
  130380. * Defines if blocks should emit comments
  130381. */
  130382. emitComments: boolean;
  130383. }
  130384. /**
  130385. * Class used to create a node based material built by assembling shader blocks
  130386. */
  130387. export class NodeMaterial extends PushMaterial {
  130388. private static _BuildIdGenerator;
  130389. private _options;
  130390. private _vertexCompilationState;
  130391. private _fragmentCompilationState;
  130392. private _sharedData;
  130393. private _buildId;
  130394. private _buildWasSuccessful;
  130395. private _cachedWorldViewMatrix;
  130396. private _cachedWorldViewProjectionMatrix;
  130397. private _optimizers;
  130398. private _animationFrame;
  130399. /** Define the Url to load node editor script */
  130400. static EditorURL: string;
  130401. /** Define the Url to load snippets */
  130402. static SnippetUrl: string;
  130403. private BJSNODEMATERIALEDITOR;
  130404. /** Get the inspector from bundle or global */
  130405. private _getGlobalNodeMaterialEditor;
  130406. /**
  130407. * Gets or sets data used by visual editor
  130408. * @see https://nme.babylonjs.com
  130409. */
  130410. editorData: any;
  130411. /**
  130412. * 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)
  130413. */
  130414. ignoreAlpha: boolean;
  130415. /**
  130416. * Defines the maximum number of lights that can be used in the material
  130417. */
  130418. maxSimultaneousLights: number;
  130419. /**
  130420. * Observable raised when the material is built
  130421. */
  130422. onBuildObservable: Observable<NodeMaterial>;
  130423. /**
  130424. * Gets or sets the root nodes of the material vertex shader
  130425. */
  130426. _vertexOutputNodes: NodeMaterialBlock[];
  130427. /**
  130428. * Gets or sets the root nodes of the material fragment (pixel) shader
  130429. */
  130430. _fragmentOutputNodes: NodeMaterialBlock[];
  130431. /** Gets or sets options to control the node material overall behavior */
  130432. get options(): INodeMaterialOptions;
  130433. set options(options: INodeMaterialOptions);
  130434. /**
  130435. * Default configuration related to image processing available in the standard Material.
  130436. */
  130437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130438. /**
  130439. * Gets the image processing configuration used either in this material.
  130440. */
  130441. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130442. /**
  130443. * Sets the Default image processing configuration used either in the this material.
  130444. *
  130445. * If sets to null, the scene one is in use.
  130446. */
  130447. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130448. /**
  130449. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130450. */
  130451. attachedBlocks: NodeMaterialBlock[];
  130452. /**
  130453. * Create a new node based material
  130454. * @param name defines the material name
  130455. * @param scene defines the hosting scene
  130456. * @param options defines creation option
  130457. */
  130458. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130459. /**
  130460. * Gets the current class name of the material e.g. "NodeMaterial"
  130461. * @returns the class name
  130462. */
  130463. getClassName(): string;
  130464. /**
  130465. * Keep track of the image processing observer to allow dispose and replace.
  130466. */
  130467. private _imageProcessingObserver;
  130468. /**
  130469. * Attaches a new image processing configuration to the Standard Material.
  130470. * @param configuration
  130471. */
  130472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130473. /**
  130474. * Get a block by its name
  130475. * @param name defines the name of the block to retrieve
  130476. * @returns the required block or null if not found
  130477. */
  130478. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130479. /**
  130480. * Get a block by its name
  130481. * @param predicate defines the predicate used to find the good candidate
  130482. * @returns the required block or null if not found
  130483. */
  130484. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130485. /**
  130486. * Get an input block by its name
  130487. * @param predicate defines the predicate used to find the good candidate
  130488. * @returns the required input block or null if not found
  130489. */
  130490. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130491. /**
  130492. * Gets the list of input blocks attached to this material
  130493. * @returns an array of InputBlocks
  130494. */
  130495. getInputBlocks(): InputBlock[];
  130496. /**
  130497. * Adds a new optimizer to the list of optimizers
  130498. * @param optimizer defines the optimizers to add
  130499. * @returns the current material
  130500. */
  130501. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130502. /**
  130503. * Remove an optimizer from the list of optimizers
  130504. * @param optimizer defines the optimizers to remove
  130505. * @returns the current material
  130506. */
  130507. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130508. /**
  130509. * Add a new block to the list of output nodes
  130510. * @param node defines the node to add
  130511. * @returns the current material
  130512. */
  130513. addOutputNode(node: NodeMaterialBlock): this;
  130514. /**
  130515. * Remove a block from the list of root nodes
  130516. * @param node defines the node to remove
  130517. * @returns the current material
  130518. */
  130519. removeOutputNode(node: NodeMaterialBlock): this;
  130520. private _addVertexOutputNode;
  130521. private _removeVertexOutputNode;
  130522. private _addFragmentOutputNode;
  130523. private _removeFragmentOutputNode;
  130524. /**
  130525. * Specifies if the material will require alpha blending
  130526. * @returns a boolean specifying if alpha blending is needed
  130527. */
  130528. needAlphaBlending(): boolean;
  130529. /**
  130530. * Specifies if this material should be rendered in alpha test mode
  130531. * @returns a boolean specifying if an alpha test is needed.
  130532. */
  130533. needAlphaTesting(): boolean;
  130534. private _initializeBlock;
  130535. private _resetDualBlocks;
  130536. /**
  130537. * Remove a block from the current node material
  130538. * @param block defines the block to remove
  130539. */
  130540. removeBlock(block: NodeMaterialBlock): void;
  130541. /**
  130542. * Build the material and generates the inner effect
  130543. * @param verbose defines if the build should log activity
  130544. */
  130545. build(verbose?: boolean): void;
  130546. /**
  130547. * Runs an otpimization phase to try to improve the shader code
  130548. */
  130549. optimize(): void;
  130550. private _prepareDefinesForAttributes;
  130551. /**
  130552. * Get if the submesh is ready to be used and all its information available.
  130553. * Child classes can use it to update shaders
  130554. * @param mesh defines the mesh to check
  130555. * @param subMesh defines which submesh to check
  130556. * @param useInstances specifies that instances should be used
  130557. * @returns a boolean indicating that the submesh is ready or not
  130558. */
  130559. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130560. /**
  130561. * Get a string representing the shaders built by the current node graph
  130562. */
  130563. get compiledShaders(): string;
  130564. /**
  130565. * Binds the world matrix to the material
  130566. * @param world defines the world transformation matrix
  130567. */
  130568. bindOnlyWorldMatrix(world: Matrix): void;
  130569. /**
  130570. * Binds the submesh to this material by preparing the effect and shader to draw
  130571. * @param world defines the world transformation matrix
  130572. * @param mesh defines the mesh containing the submesh
  130573. * @param subMesh defines the submesh to bind the material to
  130574. */
  130575. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130576. /**
  130577. * Gets the active textures from the material
  130578. * @returns an array of textures
  130579. */
  130580. getActiveTextures(): BaseTexture[];
  130581. /**
  130582. * Gets the list of texture blocks
  130583. * @returns an array of texture blocks
  130584. */
  130585. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130586. /**
  130587. * Specifies if the material uses a texture
  130588. * @param texture defines the texture to check against the material
  130589. * @returns a boolean specifying if the material uses the texture
  130590. */
  130591. hasTexture(texture: BaseTexture): boolean;
  130592. /**
  130593. * Disposes the material
  130594. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130595. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130596. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130597. */
  130598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130599. /** Creates the node editor window. */
  130600. private _createNodeEditor;
  130601. /**
  130602. * Launch the node material editor
  130603. * @param config Define the configuration of the editor
  130604. * @return a promise fulfilled when the node editor is visible
  130605. */
  130606. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130607. /**
  130608. * Clear the current material
  130609. */
  130610. clear(): void;
  130611. /**
  130612. * Clear the current material and set it to a default state
  130613. */
  130614. setToDefault(): void;
  130615. /**
  130616. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130617. * @param url defines the url to load from
  130618. * @returns a promise that will fullfil when the material is fully loaded
  130619. */
  130620. loadAsync(url: string): Promise<void>;
  130621. private _gatherBlocks;
  130622. /**
  130623. * Generate a string containing the code declaration required to create an equivalent of this material
  130624. * @returns a string
  130625. */
  130626. generateCode(): string;
  130627. /**
  130628. * Serializes this material in a JSON representation
  130629. * @returns the serialized material object
  130630. */
  130631. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130632. private _restoreConnections;
  130633. /**
  130634. * Clear the current graph and load a new one from a serialization object
  130635. * @param source defines the JSON representation of the material
  130636. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130637. */
  130638. loadFromSerialization(source: any, rootUrl?: string): void;
  130639. /**
  130640. * Creates a node material from parsed material data
  130641. * @param source defines the JSON representation of the material
  130642. * @param scene defines the hosting scene
  130643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130644. * @returns a new node material
  130645. */
  130646. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130647. /**
  130648. * Creates a node material from a snippet saved in a remote file
  130649. * @param name defines the name of the material to create
  130650. * @param url defines the url to load from
  130651. * @param scene defines the hosting scene
  130652. * @returns a promise that will resolve to the new node material
  130653. */
  130654. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130655. /**
  130656. * Creates a node material from a snippet saved by the node material editor
  130657. * @param snippetId defines the snippet to load
  130658. * @param scene defines the hosting scene
  130659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130660. * @returns a promise that will resolve to the new node material
  130661. */
  130662. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130663. /**
  130664. * Creates a new node material set to default basic configuration
  130665. * @param name defines the name of the material
  130666. * @param scene defines the hosting scene
  130667. * @returns a new NodeMaterial
  130668. */
  130669. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130670. }
  130671. }
  130672. declare module BABYLON {
  130673. /**
  130674. * Block used to read a texture from a sampler
  130675. */
  130676. export class TextureBlock extends NodeMaterialBlock {
  130677. private _defineName;
  130678. private _linearDefineName;
  130679. private _tempTextureRead;
  130680. private _samplerName;
  130681. private _transformedUVName;
  130682. private _textureTransformName;
  130683. private _textureInfoName;
  130684. private _mainUVName;
  130685. private _mainUVDefineName;
  130686. /**
  130687. * Gets or sets the texture associated with the node
  130688. */
  130689. texture: Nullable<Texture>;
  130690. /**
  130691. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130692. */
  130693. convertToGammaSpace: boolean;
  130694. /**
  130695. * Create a new TextureBlock
  130696. * @param name defines the block name
  130697. */
  130698. constructor(name: string);
  130699. /**
  130700. * Gets the current class name
  130701. * @returns the class name
  130702. */
  130703. getClassName(): string;
  130704. /**
  130705. * Gets the uv input component
  130706. */
  130707. get uv(): NodeMaterialConnectionPoint;
  130708. /**
  130709. * Gets the rgba output component
  130710. */
  130711. get rgba(): NodeMaterialConnectionPoint;
  130712. /**
  130713. * Gets the rgb output component
  130714. */
  130715. get rgb(): NodeMaterialConnectionPoint;
  130716. /**
  130717. * Gets the r output component
  130718. */
  130719. get r(): NodeMaterialConnectionPoint;
  130720. /**
  130721. * Gets the g output component
  130722. */
  130723. get g(): NodeMaterialConnectionPoint;
  130724. /**
  130725. * Gets the b output component
  130726. */
  130727. get b(): NodeMaterialConnectionPoint;
  130728. /**
  130729. * Gets the a output component
  130730. */
  130731. get a(): NodeMaterialConnectionPoint;
  130732. get target(): NodeMaterialBlockTargets;
  130733. autoConfigure(material: NodeMaterial): void;
  130734. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130736. isReady(): boolean;
  130737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130738. private get _isMixed();
  130739. private _injectVertexCode;
  130740. private _writeTextureRead;
  130741. private _writeOutput;
  130742. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130743. protected _dumpPropertiesCode(): string;
  130744. serialize(): any;
  130745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130746. }
  130747. }
  130748. declare module BABYLON {
  130749. /**
  130750. * Class used to store shared data between 2 NodeMaterialBuildState
  130751. */
  130752. export class NodeMaterialBuildStateSharedData {
  130753. /**
  130754. * Gets the list of emitted varyings
  130755. */
  130756. temps: string[];
  130757. /**
  130758. * Gets the list of emitted varyings
  130759. */
  130760. varyings: string[];
  130761. /**
  130762. * Gets the varying declaration string
  130763. */
  130764. varyingDeclaration: string;
  130765. /**
  130766. * Input blocks
  130767. */
  130768. inputBlocks: InputBlock[];
  130769. /**
  130770. * Input blocks
  130771. */
  130772. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130773. /**
  130774. * Bindable blocks (Blocks that need to set data to the effect)
  130775. */
  130776. bindableBlocks: NodeMaterialBlock[];
  130777. /**
  130778. * List of blocks that can provide a compilation fallback
  130779. */
  130780. blocksWithFallbacks: NodeMaterialBlock[];
  130781. /**
  130782. * List of blocks that can provide a define update
  130783. */
  130784. blocksWithDefines: NodeMaterialBlock[];
  130785. /**
  130786. * List of blocks that can provide a repeatable content
  130787. */
  130788. repeatableContentBlocks: NodeMaterialBlock[];
  130789. /**
  130790. * List of blocks that can provide a dynamic list of uniforms
  130791. */
  130792. dynamicUniformBlocks: NodeMaterialBlock[];
  130793. /**
  130794. * List of blocks that can block the isReady function for the material
  130795. */
  130796. blockingBlocks: NodeMaterialBlock[];
  130797. /**
  130798. * Gets the list of animated inputs
  130799. */
  130800. animatedInputs: InputBlock[];
  130801. /**
  130802. * Build Id used to avoid multiple recompilations
  130803. */
  130804. buildId: number;
  130805. /** List of emitted variables */
  130806. variableNames: {
  130807. [key: string]: number;
  130808. };
  130809. /** List of emitted defines */
  130810. defineNames: {
  130811. [key: string]: number;
  130812. };
  130813. /** Should emit comments? */
  130814. emitComments: boolean;
  130815. /** Emit build activity */
  130816. verbose: boolean;
  130817. /** Gets or sets the hosting scene */
  130818. scene: Scene;
  130819. /**
  130820. * Gets the compilation hints emitted at compilation time
  130821. */
  130822. hints: {
  130823. needWorldViewMatrix: boolean;
  130824. needWorldViewProjectionMatrix: boolean;
  130825. needAlphaBlending: boolean;
  130826. needAlphaTesting: boolean;
  130827. };
  130828. /**
  130829. * List of compilation checks
  130830. */
  130831. checks: {
  130832. emitVertex: boolean;
  130833. emitFragment: boolean;
  130834. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130835. };
  130836. /** Creates a new shared data */
  130837. constructor();
  130838. /**
  130839. * Emits console errors and exceptions if there is a failing check
  130840. */
  130841. emitErrors(): void;
  130842. }
  130843. }
  130844. declare module BABYLON {
  130845. /**
  130846. * Class used to store node based material build state
  130847. */
  130848. export class NodeMaterialBuildState {
  130849. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130850. supportUniformBuffers: boolean;
  130851. /**
  130852. * Gets the list of emitted attributes
  130853. */
  130854. attributes: string[];
  130855. /**
  130856. * Gets the list of emitted uniforms
  130857. */
  130858. uniforms: string[];
  130859. /**
  130860. * Gets the list of emitted constants
  130861. */
  130862. constants: string[];
  130863. /**
  130864. * Gets the list of emitted samplers
  130865. */
  130866. samplers: string[];
  130867. /**
  130868. * Gets the list of emitted functions
  130869. */
  130870. functions: {
  130871. [key: string]: string;
  130872. };
  130873. /**
  130874. * Gets the list of emitted extensions
  130875. */
  130876. extensions: {
  130877. [key: string]: string;
  130878. };
  130879. /**
  130880. * Gets the target of the compilation state
  130881. */
  130882. target: NodeMaterialBlockTargets;
  130883. /**
  130884. * Gets the list of emitted counters
  130885. */
  130886. counters: {
  130887. [key: string]: number;
  130888. };
  130889. /**
  130890. * Shared data between multiple NodeMaterialBuildState instances
  130891. */
  130892. sharedData: NodeMaterialBuildStateSharedData;
  130893. /** @hidden */
  130894. _vertexState: NodeMaterialBuildState;
  130895. /** @hidden */
  130896. _attributeDeclaration: string;
  130897. /** @hidden */
  130898. _uniformDeclaration: string;
  130899. /** @hidden */
  130900. _constantDeclaration: string;
  130901. /** @hidden */
  130902. _samplerDeclaration: string;
  130903. /** @hidden */
  130904. _varyingTransfer: string;
  130905. private _repeatableContentAnchorIndex;
  130906. /** @hidden */
  130907. _builtCompilationString: string;
  130908. /**
  130909. * Gets the emitted compilation strings
  130910. */
  130911. compilationString: string;
  130912. /**
  130913. * Finalize the compilation strings
  130914. * @param state defines the current compilation state
  130915. */
  130916. finalize(state: NodeMaterialBuildState): void;
  130917. /** @hidden */
  130918. get _repeatableContentAnchor(): string;
  130919. /** @hidden */
  130920. _getFreeVariableName(prefix: string): string;
  130921. /** @hidden */
  130922. _getFreeDefineName(prefix: string): string;
  130923. /** @hidden */
  130924. _excludeVariableName(name: string): void;
  130925. /** @hidden */
  130926. _emit2DSampler(name: string): void;
  130927. /** @hidden */
  130928. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130929. /** @hidden */
  130930. _emitExtension(name: string, extension: string): void;
  130931. /** @hidden */
  130932. _emitFunction(name: string, code: string, comments: string): void;
  130933. /** @hidden */
  130934. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130935. replaceStrings?: {
  130936. search: RegExp;
  130937. replace: string;
  130938. }[];
  130939. repeatKey?: string;
  130940. }): string;
  130941. /** @hidden */
  130942. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130943. repeatKey?: string;
  130944. removeAttributes?: boolean;
  130945. removeUniforms?: boolean;
  130946. removeVaryings?: boolean;
  130947. removeIfDef?: boolean;
  130948. replaceStrings?: {
  130949. search: RegExp;
  130950. replace: string;
  130951. }[];
  130952. }, storeKey?: string): void;
  130953. /** @hidden */
  130954. _registerTempVariable(name: string): boolean;
  130955. /** @hidden */
  130956. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130957. /** @hidden */
  130958. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130959. /** @hidden */
  130960. _emitFloat(value: number): string;
  130961. }
  130962. }
  130963. declare module BABYLON {
  130964. /**
  130965. * Defines a block that can be used inside a node based material
  130966. */
  130967. export class NodeMaterialBlock {
  130968. private _buildId;
  130969. private _buildTarget;
  130970. private _target;
  130971. private _isFinalMerger;
  130972. private _isInput;
  130973. protected _isUnique: boolean;
  130974. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130975. inputsAreExclusive: boolean;
  130976. /** @hidden */
  130977. _codeVariableName: string;
  130978. /** @hidden */
  130979. _inputs: NodeMaterialConnectionPoint[];
  130980. /** @hidden */
  130981. _outputs: NodeMaterialConnectionPoint[];
  130982. /** @hidden */
  130983. _preparationId: number;
  130984. /**
  130985. * Gets or sets the name of the block
  130986. */
  130987. name: string;
  130988. /**
  130989. * Gets or sets the unique id of the node
  130990. */
  130991. uniqueId: number;
  130992. /**
  130993. * Gets or sets the comments associated with this block
  130994. */
  130995. comments: string;
  130996. /**
  130997. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130998. */
  130999. get isUnique(): boolean;
  131000. /**
  131001. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131002. */
  131003. get isFinalMerger(): boolean;
  131004. /**
  131005. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131006. */
  131007. get isInput(): boolean;
  131008. /**
  131009. * Gets or sets the build Id
  131010. */
  131011. get buildId(): number;
  131012. set buildId(value: number);
  131013. /**
  131014. * Gets or sets the target of the block
  131015. */
  131016. get target(): NodeMaterialBlockTargets;
  131017. set target(value: NodeMaterialBlockTargets);
  131018. /**
  131019. * Gets the list of input points
  131020. */
  131021. get inputs(): NodeMaterialConnectionPoint[];
  131022. /** Gets the list of output points */
  131023. get outputs(): NodeMaterialConnectionPoint[];
  131024. /**
  131025. * Find an input by its name
  131026. * @param name defines the name of the input to look for
  131027. * @returns the input or null if not found
  131028. */
  131029. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131030. /**
  131031. * Find an output by its name
  131032. * @param name defines the name of the outputto look for
  131033. * @returns the output or null if not found
  131034. */
  131035. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131036. /**
  131037. * Creates a new NodeMaterialBlock
  131038. * @param name defines the block name
  131039. * @param target defines the target of that block (Vertex by default)
  131040. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131041. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131042. */
  131043. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131044. /**
  131045. * Initialize the block and prepare the context for build
  131046. * @param state defines the state that will be used for the build
  131047. */
  131048. initialize(state: NodeMaterialBuildState): void;
  131049. /**
  131050. * Bind data to effect. Will only be called for blocks with isBindable === true
  131051. * @param effect defines the effect to bind data to
  131052. * @param nodeMaterial defines the hosting NodeMaterial
  131053. * @param mesh defines the mesh that will be rendered
  131054. */
  131055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131056. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131057. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131058. protected _writeFloat(value: number): string;
  131059. /**
  131060. * Gets the current class name e.g. "NodeMaterialBlock"
  131061. * @returns the class name
  131062. */
  131063. getClassName(): string;
  131064. /**
  131065. * Register a new input. Must be called inside a block constructor
  131066. * @param name defines the connection point name
  131067. * @param type defines the connection point type
  131068. * @param isOptional defines a boolean indicating that this input can be omitted
  131069. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131070. * @returns the current block
  131071. */
  131072. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131073. /**
  131074. * Register a new output. Must be called inside a block constructor
  131075. * @param name defines the connection point name
  131076. * @param type defines the connection point type
  131077. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131078. * @returns the current block
  131079. */
  131080. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131081. /**
  131082. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131083. * @param forOutput defines an optional connection point to check compatibility with
  131084. * @returns the first available input or null
  131085. */
  131086. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131087. /**
  131088. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131089. * @param forBlock defines an optional block to check compatibility with
  131090. * @returns the first available input or null
  131091. */
  131092. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131093. /**
  131094. * Gets the sibling of the given output
  131095. * @param current defines the current output
  131096. * @returns the next output in the list or null
  131097. */
  131098. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131099. /**
  131100. * Connect current block with another block
  131101. * @param other defines the block to connect with
  131102. * @param options define the various options to help pick the right connections
  131103. * @returns the current block
  131104. */
  131105. connectTo(other: NodeMaterialBlock, options?: {
  131106. input?: string;
  131107. output?: string;
  131108. outputSwizzle?: string;
  131109. }): this | undefined;
  131110. protected _buildBlock(state: NodeMaterialBuildState): void;
  131111. /**
  131112. * Add uniforms, samplers and uniform buffers at compilation time
  131113. * @param state defines the state to update
  131114. * @param nodeMaterial defines the node material requesting the update
  131115. * @param defines defines the material defines to update
  131116. * @param uniformBuffers defines the list of uniform buffer names
  131117. */
  131118. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131119. /**
  131120. * Add potential fallbacks if shader compilation fails
  131121. * @param mesh defines the mesh to be rendered
  131122. * @param fallbacks defines the current prioritized list of fallbacks
  131123. */
  131124. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131125. /**
  131126. * Initialize defines for shader compilation
  131127. * @param mesh defines the mesh to be rendered
  131128. * @param nodeMaterial defines the node material requesting the update
  131129. * @param defines defines the material defines to update
  131130. * @param useInstances specifies that instances should be used
  131131. */
  131132. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131133. /**
  131134. * Update defines for shader compilation
  131135. * @param mesh defines the mesh to be rendered
  131136. * @param nodeMaterial defines the node material requesting the update
  131137. * @param defines defines the material defines to update
  131138. * @param useInstances specifies that instances should be used
  131139. */
  131140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131141. /**
  131142. * Lets the block try to connect some inputs automatically
  131143. * @param material defines the hosting NodeMaterial
  131144. */
  131145. autoConfigure(material: NodeMaterial): void;
  131146. /**
  131147. * Function called when a block is declared as repeatable content generator
  131148. * @param vertexShaderState defines the current compilation state for the vertex shader
  131149. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131150. * @param mesh defines the mesh to be rendered
  131151. * @param defines defines the material defines to update
  131152. */
  131153. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131154. /**
  131155. * Checks if the block is ready
  131156. * @param mesh defines the mesh to be rendered
  131157. * @param nodeMaterial defines the node material requesting the update
  131158. * @param defines defines the material defines to update
  131159. * @param useInstances specifies that instances should be used
  131160. * @returns true if the block is ready
  131161. */
  131162. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131163. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131164. private _processBuild;
  131165. /**
  131166. * Compile the current node and generate the shader code
  131167. * @param state defines the current compilation state (uniforms, samplers, current string)
  131168. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131169. * @returns true if already built
  131170. */
  131171. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131172. protected _inputRename(name: string): string;
  131173. protected _outputRename(name: string): string;
  131174. protected _dumpPropertiesCode(): string;
  131175. /** @hidden */
  131176. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131177. /** @hidden */
  131178. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131179. /**
  131180. * Clone the current block to a new identical block
  131181. * @param scene defines the hosting scene
  131182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131183. * @returns a copy of the current block
  131184. */
  131185. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131186. /**
  131187. * Serializes this block in a JSON representation
  131188. * @returns the serialized block object
  131189. */
  131190. serialize(): any;
  131191. /** @hidden */
  131192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131193. /**
  131194. * Release resources
  131195. */
  131196. dispose(): void;
  131197. }
  131198. }
  131199. declare module BABYLON {
  131200. /**
  131201. * Enum defining the type of animations supported by InputBlock
  131202. */
  131203. export enum AnimatedInputBlockTypes {
  131204. /** No animation */
  131205. None = 0,
  131206. /** Time based animation. Will only work for floats */
  131207. Time = 1
  131208. }
  131209. }
  131210. declare module BABYLON {
  131211. /**
  131212. * Block used to expose an input value
  131213. */
  131214. export class InputBlock extends NodeMaterialBlock {
  131215. private _mode;
  131216. private _associatedVariableName;
  131217. private _storedValue;
  131218. private _valueCallback;
  131219. private _type;
  131220. private _animationType;
  131221. /** Gets or set a value used to limit the range of float values */
  131222. min: number;
  131223. /** Gets or set a value used to limit the range of float values */
  131224. max: number;
  131225. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131226. isBoolean: boolean;
  131227. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131228. matrixMode: number;
  131229. /** @hidden */
  131230. _systemValue: Nullable<NodeMaterialSystemValues>;
  131231. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131232. visibleInInspector: boolean;
  131233. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131234. isConstant: boolean;
  131235. /** Gets or sets the group to use to display this block in the Inspector */
  131236. groupInInspector: string;
  131237. /**
  131238. * Gets or sets the connection point type (default is float)
  131239. */
  131240. get type(): NodeMaterialBlockConnectionPointTypes;
  131241. /**
  131242. * Creates a new InputBlock
  131243. * @param name defines the block name
  131244. * @param target defines the target of that block (Vertex by default)
  131245. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131246. */
  131247. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131248. /**
  131249. * Gets the output component
  131250. */
  131251. get output(): NodeMaterialConnectionPoint;
  131252. /**
  131253. * Set the source of this connection point to a vertex attribute
  131254. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131255. * @returns the current connection point
  131256. */
  131257. setAsAttribute(attributeName?: string): InputBlock;
  131258. /**
  131259. * Set the source of this connection point to a system value
  131260. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131261. * @returns the current connection point
  131262. */
  131263. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131264. /**
  131265. * Gets or sets the value of that point.
  131266. * Please note that this value will be ignored if valueCallback is defined
  131267. */
  131268. get value(): any;
  131269. set value(value: any);
  131270. /**
  131271. * Gets or sets a callback used to get the value of that point.
  131272. * Please note that setting this value will force the connection point to ignore the value property
  131273. */
  131274. get valueCallback(): () => any;
  131275. set valueCallback(value: () => any);
  131276. /**
  131277. * Gets or sets the associated variable name in the shader
  131278. */
  131279. get associatedVariableName(): string;
  131280. set associatedVariableName(value: string);
  131281. /** Gets or sets the type of animation applied to the input */
  131282. get animationType(): AnimatedInputBlockTypes;
  131283. set animationType(value: AnimatedInputBlockTypes);
  131284. /**
  131285. * Gets a boolean indicating that this connection point not defined yet
  131286. */
  131287. get isUndefined(): boolean;
  131288. /**
  131289. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131290. * In this case the connection point name must be the name of the uniform to use.
  131291. * Can only be set on inputs
  131292. */
  131293. get isUniform(): boolean;
  131294. set isUniform(value: boolean);
  131295. /**
  131296. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131297. * In this case the connection point name must be the name of the attribute to use
  131298. * Can only be set on inputs
  131299. */
  131300. get isAttribute(): boolean;
  131301. set isAttribute(value: boolean);
  131302. /**
  131303. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131304. * Can only be set on exit points
  131305. */
  131306. get isVarying(): boolean;
  131307. set isVarying(value: boolean);
  131308. /**
  131309. * Gets a boolean indicating that the current connection point is a system value
  131310. */
  131311. get isSystemValue(): boolean;
  131312. /**
  131313. * Gets or sets the current well known value or null if not defined as a system value
  131314. */
  131315. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131316. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131317. /**
  131318. * Gets the current class name
  131319. * @returns the class name
  131320. */
  131321. getClassName(): string;
  131322. /**
  131323. * Animate the input if animationType !== None
  131324. * @param scene defines the rendering scene
  131325. */
  131326. animate(scene: Scene): void;
  131327. private _emitDefine;
  131328. initialize(state: NodeMaterialBuildState): void;
  131329. /**
  131330. * Set the input block to its default value (based on its type)
  131331. */
  131332. setDefaultValue(): void;
  131333. private _emitConstant;
  131334. private _emit;
  131335. /** @hidden */
  131336. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131337. /** @hidden */
  131338. _transmit(effect: Effect, scene: Scene): void;
  131339. protected _buildBlock(state: NodeMaterialBuildState): void;
  131340. protected _dumpPropertiesCode(): string;
  131341. serialize(): any;
  131342. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * Enum used to define the compatibility state between two connection points
  131348. */
  131349. export enum NodeMaterialConnectionPointCompatibilityStates {
  131350. /** Points are compatibles */
  131351. Compatible = 0,
  131352. /** Points are incompatible because of their types */
  131353. TypeIncompatible = 1,
  131354. /** Points are incompatible because of their targets (vertex vs fragment) */
  131355. TargetIncompatible = 2
  131356. }
  131357. /**
  131358. * Defines the direction of a connection point
  131359. */
  131360. export enum NodeMaterialConnectionPointDirection {
  131361. /** Input */
  131362. Input = 0,
  131363. /** Output */
  131364. Output = 1
  131365. }
  131366. /**
  131367. * Defines a connection point for a block
  131368. */
  131369. export class NodeMaterialConnectionPoint {
  131370. /** @hidden */
  131371. _ownerBlock: NodeMaterialBlock;
  131372. /** @hidden */
  131373. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131374. private _endpoints;
  131375. private _associatedVariableName;
  131376. private _direction;
  131377. /** @hidden */
  131378. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131379. /** @hidden */
  131380. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131381. private _type;
  131382. /** @hidden */
  131383. _enforceAssociatedVariableName: boolean;
  131384. /** Gets the direction of the point */
  131385. get direction(): NodeMaterialConnectionPointDirection;
  131386. /**
  131387. * Gets or sets the additional types supported by this connection point
  131388. */
  131389. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131390. /**
  131391. * Gets or sets the additional types excluded by this connection point
  131392. */
  131393. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131394. /**
  131395. * Observable triggered when this point is connected
  131396. */
  131397. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131398. /**
  131399. * Gets or sets the associated variable name in the shader
  131400. */
  131401. get associatedVariableName(): string;
  131402. set associatedVariableName(value: string);
  131403. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131404. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131405. /**
  131406. * Gets or sets the connection point type (default is float)
  131407. */
  131408. get type(): NodeMaterialBlockConnectionPointTypes;
  131409. set type(value: NodeMaterialBlockConnectionPointTypes);
  131410. /**
  131411. * Gets or sets the connection point name
  131412. */
  131413. name: string;
  131414. /**
  131415. * Gets or sets a boolean indicating that this connection point can be omitted
  131416. */
  131417. isOptional: boolean;
  131418. /**
  131419. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131420. */
  131421. define: string;
  131422. /** @hidden */
  131423. _prioritizeVertex: boolean;
  131424. private _target;
  131425. /** Gets or sets the target of that connection point */
  131426. get target(): NodeMaterialBlockTargets;
  131427. set target(value: NodeMaterialBlockTargets);
  131428. /**
  131429. * Gets a boolean indicating that the current point is connected
  131430. */
  131431. get isConnected(): boolean;
  131432. /**
  131433. * Gets a boolean indicating that the current point is connected to an input block
  131434. */
  131435. get isConnectedToInputBlock(): boolean;
  131436. /**
  131437. * Gets a the connected input block (if any)
  131438. */
  131439. get connectInputBlock(): Nullable<InputBlock>;
  131440. /** Get the other side of the connection (if any) */
  131441. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131442. /** Get the block that owns this connection point */
  131443. get ownerBlock(): NodeMaterialBlock;
  131444. /** Get the block connected on the other side of this connection (if any) */
  131445. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131446. /** Get the block connected on the endpoints of this connection (if any) */
  131447. get connectedBlocks(): Array<NodeMaterialBlock>;
  131448. /** Gets the list of connected endpoints */
  131449. get endpoints(): NodeMaterialConnectionPoint[];
  131450. /** Gets a boolean indicating if that output point is connected to at least one input */
  131451. get hasEndpoints(): boolean;
  131452. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131453. get isConnectedInVertexShader(): boolean;
  131454. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131455. get isConnectedInFragmentShader(): boolean;
  131456. /**
  131457. * Creates a new connection point
  131458. * @param name defines the connection point name
  131459. * @param ownerBlock defines the block hosting this connection point
  131460. * @param direction defines the direction of the connection point
  131461. */
  131462. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131463. /**
  131464. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131465. * @returns the class name
  131466. */
  131467. getClassName(): string;
  131468. /**
  131469. * Gets a boolean indicating if the current point can be connected to another point
  131470. * @param connectionPoint defines the other connection point
  131471. * @returns a boolean
  131472. */
  131473. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131474. /**
  131475. * Gets a number indicating if the current point can be connected to another point
  131476. * @param connectionPoint defines the other connection point
  131477. * @returns a number defining the compatibility state
  131478. */
  131479. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131480. /**
  131481. * Connect this point to another connection point
  131482. * @param connectionPoint defines the other connection point
  131483. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131484. * @returns the current connection point
  131485. */
  131486. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131487. /**
  131488. * Disconnect this point from one of his endpoint
  131489. * @param endpoint defines the other connection point
  131490. * @returns the current connection point
  131491. */
  131492. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131493. /**
  131494. * Serializes this point in a JSON representation
  131495. * @returns the serialized point object
  131496. */
  131497. serialize(): any;
  131498. /**
  131499. * Release resources
  131500. */
  131501. dispose(): void;
  131502. }
  131503. }
  131504. declare module BABYLON {
  131505. /**
  131506. * Block used to add support for vertex skinning (bones)
  131507. */
  131508. export class BonesBlock extends NodeMaterialBlock {
  131509. /**
  131510. * Creates a new BonesBlock
  131511. * @param name defines the block name
  131512. */
  131513. constructor(name: string);
  131514. /**
  131515. * Initialize the block and prepare the context for build
  131516. * @param state defines the state that will be used for the build
  131517. */
  131518. initialize(state: NodeMaterialBuildState): void;
  131519. /**
  131520. * Gets the current class name
  131521. * @returns the class name
  131522. */
  131523. getClassName(): string;
  131524. /**
  131525. * Gets the matrix indices input component
  131526. */
  131527. get matricesIndices(): NodeMaterialConnectionPoint;
  131528. /**
  131529. * Gets the matrix weights input component
  131530. */
  131531. get matricesWeights(): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Gets the extra matrix indices input component
  131534. */
  131535. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131536. /**
  131537. * Gets the extra matrix weights input component
  131538. */
  131539. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131540. /**
  131541. * Gets the world input component
  131542. */
  131543. get world(): NodeMaterialConnectionPoint;
  131544. /**
  131545. * Gets the output component
  131546. */
  131547. get output(): NodeMaterialConnectionPoint;
  131548. autoConfigure(material: NodeMaterial): void;
  131549. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131551. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131552. protected _buildBlock(state: NodeMaterialBuildState): this;
  131553. }
  131554. }
  131555. declare module BABYLON {
  131556. /**
  131557. * Block used to add support for instances
  131558. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131559. */
  131560. export class InstancesBlock extends NodeMaterialBlock {
  131561. /**
  131562. * Creates a new InstancesBlock
  131563. * @param name defines the block name
  131564. */
  131565. constructor(name: string);
  131566. /**
  131567. * Gets the current class name
  131568. * @returns the class name
  131569. */
  131570. getClassName(): string;
  131571. /**
  131572. * Gets the first world row input component
  131573. */
  131574. get world0(): NodeMaterialConnectionPoint;
  131575. /**
  131576. * Gets the second world row input component
  131577. */
  131578. get world1(): NodeMaterialConnectionPoint;
  131579. /**
  131580. * Gets the third world row input component
  131581. */
  131582. get world2(): NodeMaterialConnectionPoint;
  131583. /**
  131584. * Gets the forth world row input component
  131585. */
  131586. get world3(): NodeMaterialConnectionPoint;
  131587. /**
  131588. * Gets the world input component
  131589. */
  131590. get world(): NodeMaterialConnectionPoint;
  131591. /**
  131592. * Gets the output component
  131593. */
  131594. get output(): NodeMaterialConnectionPoint;
  131595. /**
  131596. * Gets the isntanceID component
  131597. */
  131598. get instanceID(): NodeMaterialConnectionPoint;
  131599. autoConfigure(material: NodeMaterial): void;
  131600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131601. protected _buildBlock(state: NodeMaterialBuildState): this;
  131602. }
  131603. }
  131604. declare module BABYLON {
  131605. /**
  131606. * Block used to add morph targets support to vertex shader
  131607. */
  131608. export class MorphTargetsBlock extends NodeMaterialBlock {
  131609. private _repeatableContentAnchor;
  131610. /**
  131611. * Create a new MorphTargetsBlock
  131612. * @param name defines the block name
  131613. */
  131614. constructor(name: string);
  131615. /**
  131616. * Gets the current class name
  131617. * @returns the class name
  131618. */
  131619. getClassName(): string;
  131620. /**
  131621. * Gets the position input component
  131622. */
  131623. get position(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the normal input component
  131626. */
  131627. get normal(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the tangent input component
  131630. */
  131631. get tangent(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the tangent input component
  131634. */
  131635. get uv(): NodeMaterialConnectionPoint;
  131636. /**
  131637. * Gets the position output component
  131638. */
  131639. get positionOutput(): NodeMaterialConnectionPoint;
  131640. /**
  131641. * Gets the normal output component
  131642. */
  131643. get normalOutput(): NodeMaterialConnectionPoint;
  131644. /**
  131645. * Gets the tangent output component
  131646. */
  131647. get tangentOutput(): NodeMaterialConnectionPoint;
  131648. /**
  131649. * Gets the tangent output component
  131650. */
  131651. get uvOutput(): NodeMaterialConnectionPoint;
  131652. initialize(state: NodeMaterialBuildState): void;
  131653. autoConfigure(material: NodeMaterial): void;
  131654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131656. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131657. protected _buildBlock(state: NodeMaterialBuildState): this;
  131658. }
  131659. }
  131660. declare module BABYLON {
  131661. /**
  131662. * Block used to get data information from a light
  131663. */
  131664. export class LightInformationBlock extends NodeMaterialBlock {
  131665. private _lightDataUniformName;
  131666. private _lightColorUniformName;
  131667. private _lightTypeDefineName;
  131668. /**
  131669. * Gets or sets the light associated with this block
  131670. */
  131671. light: Nullable<Light>;
  131672. /**
  131673. * Creates a new LightInformationBlock
  131674. * @param name defines the block name
  131675. */
  131676. constructor(name: string);
  131677. /**
  131678. * Gets the current class name
  131679. * @returns the class name
  131680. */
  131681. getClassName(): string;
  131682. /**
  131683. * Gets the world position input component
  131684. */
  131685. get worldPosition(): NodeMaterialConnectionPoint;
  131686. /**
  131687. * Gets the direction output component
  131688. */
  131689. get direction(): NodeMaterialConnectionPoint;
  131690. /**
  131691. * Gets the direction output component
  131692. */
  131693. get color(): NodeMaterialConnectionPoint;
  131694. /**
  131695. * Gets the direction output component
  131696. */
  131697. get intensity(): NodeMaterialConnectionPoint;
  131698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131700. protected _buildBlock(state: NodeMaterialBuildState): this;
  131701. serialize(): any;
  131702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131703. }
  131704. }
  131705. declare module BABYLON {
  131706. /**
  131707. * Block used to add image processing support to fragment shader
  131708. */
  131709. export class ImageProcessingBlock extends NodeMaterialBlock {
  131710. /**
  131711. * Create a new ImageProcessingBlock
  131712. * @param name defines the block name
  131713. */
  131714. constructor(name: string);
  131715. /**
  131716. * Gets the current class name
  131717. * @returns the class name
  131718. */
  131719. getClassName(): string;
  131720. /**
  131721. * Gets the color input component
  131722. */
  131723. get color(): NodeMaterialConnectionPoint;
  131724. /**
  131725. * Gets the output component
  131726. */
  131727. get output(): NodeMaterialConnectionPoint;
  131728. /**
  131729. * Initialize the block and prepare the context for build
  131730. * @param state defines the state that will be used for the build
  131731. */
  131732. initialize(state: NodeMaterialBuildState): void;
  131733. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131736. protected _buildBlock(state: NodeMaterialBuildState): this;
  131737. }
  131738. }
  131739. declare module BABYLON {
  131740. /**
  131741. * Block used to pertub normals based on a normal map
  131742. */
  131743. export class PerturbNormalBlock extends NodeMaterialBlock {
  131744. private _tangentSpaceParameterName;
  131745. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131746. invertX: boolean;
  131747. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131748. invertY: boolean;
  131749. /**
  131750. * Create a new PerturbNormalBlock
  131751. * @param name defines the block name
  131752. */
  131753. constructor(name: string);
  131754. /**
  131755. * Gets the current class name
  131756. * @returns the class name
  131757. */
  131758. getClassName(): string;
  131759. /**
  131760. * Gets the world position input component
  131761. */
  131762. get worldPosition(): NodeMaterialConnectionPoint;
  131763. /**
  131764. * Gets the world normal input component
  131765. */
  131766. get worldNormal(): NodeMaterialConnectionPoint;
  131767. /**
  131768. * Gets the world tangent input component
  131769. */
  131770. get worldTangent(): NodeMaterialConnectionPoint;
  131771. /**
  131772. * Gets the uv input component
  131773. */
  131774. get uv(): NodeMaterialConnectionPoint;
  131775. /**
  131776. * Gets the normal map color input component
  131777. */
  131778. get normalMapColor(): NodeMaterialConnectionPoint;
  131779. /**
  131780. * Gets the strength input component
  131781. */
  131782. get strength(): NodeMaterialConnectionPoint;
  131783. /**
  131784. * Gets the output component
  131785. */
  131786. get output(): NodeMaterialConnectionPoint;
  131787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131789. autoConfigure(material: NodeMaterial): void;
  131790. protected _buildBlock(state: NodeMaterialBuildState): this;
  131791. protected _dumpPropertiesCode(): string;
  131792. serialize(): any;
  131793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131794. }
  131795. }
  131796. declare module BABYLON {
  131797. /**
  131798. * Block used to discard a pixel if a value is smaller than a cutoff
  131799. */
  131800. export class DiscardBlock extends NodeMaterialBlock {
  131801. /**
  131802. * Create a new DiscardBlock
  131803. * @param name defines the block name
  131804. */
  131805. constructor(name: string);
  131806. /**
  131807. * Gets the current class name
  131808. * @returns the class name
  131809. */
  131810. getClassName(): string;
  131811. /**
  131812. * Gets the color input component
  131813. */
  131814. get value(): NodeMaterialConnectionPoint;
  131815. /**
  131816. * Gets the cutoff input component
  131817. */
  131818. get cutoff(): NodeMaterialConnectionPoint;
  131819. protected _buildBlock(state: NodeMaterialBuildState): this;
  131820. }
  131821. }
  131822. declare module BABYLON {
  131823. /**
  131824. * Block used to test if the fragment shader is front facing
  131825. */
  131826. export class FrontFacingBlock extends NodeMaterialBlock {
  131827. /**
  131828. * Creates a new FrontFacingBlock
  131829. * @param name defines the block name
  131830. */
  131831. constructor(name: string);
  131832. /**
  131833. * Gets the current class name
  131834. * @returns the class name
  131835. */
  131836. getClassName(): string;
  131837. /**
  131838. * Gets the output component
  131839. */
  131840. get output(): NodeMaterialConnectionPoint;
  131841. protected _buildBlock(state: NodeMaterialBuildState): this;
  131842. }
  131843. }
  131844. declare module BABYLON {
  131845. /**
  131846. * Block used to get the derivative value on x and y of a given input
  131847. */
  131848. export class DerivativeBlock extends NodeMaterialBlock {
  131849. /**
  131850. * Create a new DerivativeBlock
  131851. * @param name defines the block name
  131852. */
  131853. constructor(name: string);
  131854. /**
  131855. * Gets the current class name
  131856. * @returns the class name
  131857. */
  131858. getClassName(): string;
  131859. /**
  131860. * Gets the input component
  131861. */
  131862. get input(): NodeMaterialConnectionPoint;
  131863. /**
  131864. * Gets the derivative output on x
  131865. */
  131866. get dx(): NodeMaterialConnectionPoint;
  131867. /**
  131868. * Gets the derivative output on y
  131869. */
  131870. get dy(): NodeMaterialConnectionPoint;
  131871. protected _buildBlock(state: NodeMaterialBuildState): this;
  131872. }
  131873. }
  131874. declare module BABYLON {
  131875. /**
  131876. * Block used to add support for scene fog
  131877. */
  131878. export class FogBlock extends NodeMaterialBlock {
  131879. private _fogDistanceName;
  131880. private _fogParameters;
  131881. /**
  131882. * Create a new FogBlock
  131883. * @param name defines the block name
  131884. */
  131885. constructor(name: string);
  131886. /**
  131887. * Gets the current class name
  131888. * @returns the class name
  131889. */
  131890. getClassName(): string;
  131891. /**
  131892. * Gets the world position input component
  131893. */
  131894. get worldPosition(): NodeMaterialConnectionPoint;
  131895. /**
  131896. * Gets the view input component
  131897. */
  131898. get view(): NodeMaterialConnectionPoint;
  131899. /**
  131900. * Gets the color input component
  131901. */
  131902. get input(): NodeMaterialConnectionPoint;
  131903. /**
  131904. * Gets the fog color input component
  131905. */
  131906. get fogColor(): NodeMaterialConnectionPoint;
  131907. /**
  131908. * Gets the output component
  131909. */
  131910. get output(): NodeMaterialConnectionPoint;
  131911. autoConfigure(material: NodeMaterial): void;
  131912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131914. protected _buildBlock(state: NodeMaterialBuildState): this;
  131915. }
  131916. }
  131917. declare module BABYLON {
  131918. /**
  131919. * Block used to add light in the fragment shader
  131920. */
  131921. export class LightBlock extends NodeMaterialBlock {
  131922. private _lightId;
  131923. /**
  131924. * Gets or sets the light associated with this block
  131925. */
  131926. light: Nullable<Light>;
  131927. /**
  131928. * Create a new LightBlock
  131929. * @param name defines the block name
  131930. */
  131931. constructor(name: string);
  131932. /**
  131933. * Gets the current class name
  131934. * @returns the class name
  131935. */
  131936. getClassName(): string;
  131937. /**
  131938. * Gets the world position input component
  131939. */
  131940. get worldPosition(): NodeMaterialConnectionPoint;
  131941. /**
  131942. * Gets the world normal input component
  131943. */
  131944. get worldNormal(): NodeMaterialConnectionPoint;
  131945. /**
  131946. * Gets the camera (or eye) position component
  131947. */
  131948. get cameraPosition(): NodeMaterialConnectionPoint;
  131949. /**
  131950. * Gets the glossiness component
  131951. */
  131952. get glossiness(): NodeMaterialConnectionPoint;
  131953. /**
  131954. * Gets the glossinness power component
  131955. */
  131956. get glossPower(): NodeMaterialConnectionPoint;
  131957. /**
  131958. * Gets the diffuse color component
  131959. */
  131960. get diffuseColor(): NodeMaterialConnectionPoint;
  131961. /**
  131962. * Gets the specular color component
  131963. */
  131964. get specularColor(): NodeMaterialConnectionPoint;
  131965. /**
  131966. * Gets the diffuse output component
  131967. */
  131968. get diffuseOutput(): NodeMaterialConnectionPoint;
  131969. /**
  131970. * Gets the specular output component
  131971. */
  131972. get specularOutput(): NodeMaterialConnectionPoint;
  131973. /**
  131974. * Gets the shadow output component
  131975. */
  131976. get shadow(): NodeMaterialConnectionPoint;
  131977. autoConfigure(material: NodeMaterial): void;
  131978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131979. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131981. private _injectVertexCode;
  131982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131983. serialize(): any;
  131984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131985. }
  131986. }
  131987. declare module BABYLON {
  131988. /**
  131989. * Block used to multiply 2 values
  131990. */
  131991. export class MultiplyBlock extends NodeMaterialBlock {
  131992. /**
  131993. * Creates a new MultiplyBlock
  131994. * @param name defines the block name
  131995. */
  131996. constructor(name: string);
  131997. /**
  131998. * Gets the current class name
  131999. * @returns the class name
  132000. */
  132001. getClassName(): string;
  132002. /**
  132003. * Gets the left operand input component
  132004. */
  132005. get left(): NodeMaterialConnectionPoint;
  132006. /**
  132007. * Gets the right operand input component
  132008. */
  132009. get right(): NodeMaterialConnectionPoint;
  132010. /**
  132011. * Gets the output component
  132012. */
  132013. get output(): NodeMaterialConnectionPoint;
  132014. protected _buildBlock(state: NodeMaterialBuildState): this;
  132015. }
  132016. }
  132017. declare module BABYLON {
  132018. /**
  132019. * Block used to add 2 vectors
  132020. */
  132021. export class AddBlock extends NodeMaterialBlock {
  132022. /**
  132023. * Creates a new AddBlock
  132024. * @param name defines the block name
  132025. */
  132026. constructor(name: string);
  132027. /**
  132028. * Gets the current class name
  132029. * @returns the class name
  132030. */
  132031. getClassName(): string;
  132032. /**
  132033. * Gets the left operand input component
  132034. */
  132035. get left(): NodeMaterialConnectionPoint;
  132036. /**
  132037. * Gets the right operand input component
  132038. */
  132039. get right(): NodeMaterialConnectionPoint;
  132040. /**
  132041. * Gets the output component
  132042. */
  132043. get output(): NodeMaterialConnectionPoint;
  132044. protected _buildBlock(state: NodeMaterialBuildState): this;
  132045. }
  132046. }
  132047. declare module BABYLON {
  132048. /**
  132049. * Block used to scale a vector by a float
  132050. */
  132051. export class ScaleBlock extends NodeMaterialBlock {
  132052. /**
  132053. * Creates a new ScaleBlock
  132054. * @param name defines the block name
  132055. */
  132056. constructor(name: string);
  132057. /**
  132058. * Gets the current class name
  132059. * @returns the class name
  132060. */
  132061. getClassName(): string;
  132062. /**
  132063. * Gets the input component
  132064. */
  132065. get input(): NodeMaterialConnectionPoint;
  132066. /**
  132067. * Gets the factor input component
  132068. */
  132069. get factor(): NodeMaterialConnectionPoint;
  132070. /**
  132071. * Gets the output component
  132072. */
  132073. get output(): NodeMaterialConnectionPoint;
  132074. protected _buildBlock(state: NodeMaterialBuildState): this;
  132075. }
  132076. }
  132077. declare module BABYLON {
  132078. /**
  132079. * Block used to clamp a float
  132080. */
  132081. export class ClampBlock extends NodeMaterialBlock {
  132082. /** Gets or sets the minimum range */
  132083. minimum: number;
  132084. /** Gets or sets the maximum range */
  132085. maximum: number;
  132086. /**
  132087. * Creates a new ClampBlock
  132088. * @param name defines the block name
  132089. */
  132090. constructor(name: string);
  132091. /**
  132092. * Gets the current class name
  132093. * @returns the class name
  132094. */
  132095. getClassName(): string;
  132096. /**
  132097. * Gets the value input component
  132098. */
  132099. get value(): NodeMaterialConnectionPoint;
  132100. /**
  132101. * Gets the output component
  132102. */
  132103. get output(): NodeMaterialConnectionPoint;
  132104. protected _buildBlock(state: NodeMaterialBuildState): this;
  132105. protected _dumpPropertiesCode(): string;
  132106. serialize(): any;
  132107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132108. }
  132109. }
  132110. declare module BABYLON {
  132111. /**
  132112. * Block used to apply a cross product between 2 vectors
  132113. */
  132114. export class CrossBlock extends NodeMaterialBlock {
  132115. /**
  132116. * Creates a new CrossBlock
  132117. * @param name defines the block name
  132118. */
  132119. constructor(name: string);
  132120. /**
  132121. * Gets the current class name
  132122. * @returns the class name
  132123. */
  132124. getClassName(): string;
  132125. /**
  132126. * Gets the left operand input component
  132127. */
  132128. get left(): NodeMaterialConnectionPoint;
  132129. /**
  132130. * Gets the right operand input component
  132131. */
  132132. get right(): NodeMaterialConnectionPoint;
  132133. /**
  132134. * Gets the output component
  132135. */
  132136. get output(): NodeMaterialConnectionPoint;
  132137. protected _buildBlock(state: NodeMaterialBuildState): this;
  132138. }
  132139. }
  132140. declare module BABYLON {
  132141. /**
  132142. * Block used to apply a dot product between 2 vectors
  132143. */
  132144. export class DotBlock extends NodeMaterialBlock {
  132145. /**
  132146. * Creates a new DotBlock
  132147. * @param name defines the block name
  132148. */
  132149. constructor(name: string);
  132150. /**
  132151. * Gets the current class name
  132152. * @returns the class name
  132153. */
  132154. getClassName(): string;
  132155. /**
  132156. * Gets the left operand input component
  132157. */
  132158. get left(): NodeMaterialConnectionPoint;
  132159. /**
  132160. * Gets the right operand input component
  132161. */
  132162. get right(): NodeMaterialConnectionPoint;
  132163. /**
  132164. * Gets the output component
  132165. */
  132166. get output(): NodeMaterialConnectionPoint;
  132167. protected _buildBlock(state: NodeMaterialBuildState): this;
  132168. }
  132169. }
  132170. declare module BABYLON {
  132171. /**
  132172. * Block used to remap a float from a range to a new one
  132173. */
  132174. export class RemapBlock extends NodeMaterialBlock {
  132175. /**
  132176. * Gets or sets the source range
  132177. */
  132178. sourceRange: Vector2;
  132179. /**
  132180. * Gets or sets the target range
  132181. */
  132182. targetRange: Vector2;
  132183. /**
  132184. * Creates a new RemapBlock
  132185. * @param name defines the block name
  132186. */
  132187. constructor(name: string);
  132188. /**
  132189. * Gets the current class name
  132190. * @returns the class name
  132191. */
  132192. getClassName(): string;
  132193. /**
  132194. * Gets the input component
  132195. */
  132196. get input(): NodeMaterialConnectionPoint;
  132197. /**
  132198. * Gets the source min input component
  132199. */
  132200. get sourceMin(): NodeMaterialConnectionPoint;
  132201. /**
  132202. * Gets the source max input component
  132203. */
  132204. get sourceMax(): NodeMaterialConnectionPoint;
  132205. /**
  132206. * Gets the target min input component
  132207. */
  132208. get targetMin(): NodeMaterialConnectionPoint;
  132209. /**
  132210. * Gets the target max input component
  132211. */
  132212. get targetMax(): NodeMaterialConnectionPoint;
  132213. /**
  132214. * Gets the output component
  132215. */
  132216. get output(): NodeMaterialConnectionPoint;
  132217. protected _buildBlock(state: NodeMaterialBuildState): this;
  132218. protected _dumpPropertiesCode(): string;
  132219. serialize(): any;
  132220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132221. }
  132222. }
  132223. declare module BABYLON {
  132224. /**
  132225. * Block used to normalize a vector
  132226. */
  132227. export class NormalizeBlock extends NodeMaterialBlock {
  132228. /**
  132229. * Creates a new NormalizeBlock
  132230. * @param name defines the block name
  132231. */
  132232. constructor(name: string);
  132233. /**
  132234. * Gets the current class name
  132235. * @returns the class name
  132236. */
  132237. getClassName(): string;
  132238. /**
  132239. * Gets the input component
  132240. */
  132241. get input(): NodeMaterialConnectionPoint;
  132242. /**
  132243. * Gets the output component
  132244. */
  132245. get output(): NodeMaterialConnectionPoint;
  132246. protected _buildBlock(state: NodeMaterialBuildState): this;
  132247. }
  132248. }
  132249. declare module BABYLON {
  132250. /**
  132251. * Operations supported by the Trigonometry block
  132252. */
  132253. export enum TrigonometryBlockOperations {
  132254. /** Cos */
  132255. Cos = 0,
  132256. /** Sin */
  132257. Sin = 1,
  132258. /** Abs */
  132259. Abs = 2,
  132260. /** Exp */
  132261. Exp = 3,
  132262. /** Exp2 */
  132263. Exp2 = 4,
  132264. /** Round */
  132265. Round = 5,
  132266. /** Floor */
  132267. Floor = 6,
  132268. /** Ceiling */
  132269. Ceiling = 7,
  132270. /** Square root */
  132271. Sqrt = 8,
  132272. /** Log */
  132273. Log = 9,
  132274. /** Tangent */
  132275. Tan = 10,
  132276. /** Arc tangent */
  132277. ArcTan = 11,
  132278. /** Arc cosinus */
  132279. ArcCos = 12,
  132280. /** Arc sinus */
  132281. ArcSin = 13,
  132282. /** Fraction */
  132283. Fract = 14,
  132284. /** Sign */
  132285. Sign = 15,
  132286. /** To radians (from degrees) */
  132287. Radians = 16,
  132288. /** To degrees (from radians) */
  132289. Degrees = 17
  132290. }
  132291. /**
  132292. * Block used to apply trigonometry operation to floats
  132293. */
  132294. export class TrigonometryBlock extends NodeMaterialBlock {
  132295. /**
  132296. * Gets or sets the operation applied by the block
  132297. */
  132298. operation: TrigonometryBlockOperations;
  132299. /**
  132300. * Creates a new TrigonometryBlock
  132301. * @param name defines the block name
  132302. */
  132303. constructor(name: string);
  132304. /**
  132305. * Gets the current class name
  132306. * @returns the class name
  132307. */
  132308. getClassName(): string;
  132309. /**
  132310. * Gets the input component
  132311. */
  132312. get input(): NodeMaterialConnectionPoint;
  132313. /**
  132314. * Gets the output component
  132315. */
  132316. get output(): NodeMaterialConnectionPoint;
  132317. protected _buildBlock(state: NodeMaterialBuildState): this;
  132318. serialize(): any;
  132319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132320. protected _dumpPropertiesCode(): string;
  132321. }
  132322. }
  132323. declare module BABYLON {
  132324. /**
  132325. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132326. */
  132327. export class ColorMergerBlock extends NodeMaterialBlock {
  132328. /**
  132329. * Create a new ColorMergerBlock
  132330. * @param name defines the block name
  132331. */
  132332. constructor(name: string);
  132333. /**
  132334. * Gets the current class name
  132335. * @returns the class name
  132336. */
  132337. getClassName(): string;
  132338. /**
  132339. * Gets the rgb component (input)
  132340. */
  132341. get rgbIn(): NodeMaterialConnectionPoint;
  132342. /**
  132343. * Gets the r component (input)
  132344. */
  132345. get r(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the g component (input)
  132348. */
  132349. get g(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the b component (input)
  132352. */
  132353. get b(): NodeMaterialConnectionPoint;
  132354. /**
  132355. * Gets the a component (input)
  132356. */
  132357. get a(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the rgba component (output)
  132360. */
  132361. get rgba(): NodeMaterialConnectionPoint;
  132362. /**
  132363. * Gets the rgb component (output)
  132364. */
  132365. get rgbOut(): NodeMaterialConnectionPoint;
  132366. /**
  132367. * Gets the rgb component (output)
  132368. * @deprecated Please use rgbOut instead.
  132369. */
  132370. get rgb(): NodeMaterialConnectionPoint;
  132371. protected _buildBlock(state: NodeMaterialBuildState): this;
  132372. }
  132373. }
  132374. declare module BABYLON {
  132375. /**
  132376. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132377. */
  132378. export class VectorMergerBlock extends NodeMaterialBlock {
  132379. /**
  132380. * Create a new VectorMergerBlock
  132381. * @param name defines the block name
  132382. */
  132383. constructor(name: string);
  132384. /**
  132385. * Gets the current class name
  132386. * @returns the class name
  132387. */
  132388. getClassName(): string;
  132389. /**
  132390. * Gets the xyz component (input)
  132391. */
  132392. get xyzIn(): NodeMaterialConnectionPoint;
  132393. /**
  132394. * Gets the xy component (input)
  132395. */
  132396. get xyIn(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the x component (input)
  132399. */
  132400. get x(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the y component (input)
  132403. */
  132404. get y(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the z component (input)
  132407. */
  132408. get z(): NodeMaterialConnectionPoint;
  132409. /**
  132410. * Gets the w component (input)
  132411. */
  132412. get w(): NodeMaterialConnectionPoint;
  132413. /**
  132414. * Gets the xyzw component (output)
  132415. */
  132416. get xyzw(): NodeMaterialConnectionPoint;
  132417. /**
  132418. * Gets the xyz component (output)
  132419. */
  132420. get xyzOut(): NodeMaterialConnectionPoint;
  132421. /**
  132422. * Gets the xy component (output)
  132423. */
  132424. get xyOut(): NodeMaterialConnectionPoint;
  132425. /**
  132426. * Gets the xy component (output)
  132427. * @deprecated Please use xyOut instead.
  132428. */
  132429. get xy(): NodeMaterialConnectionPoint;
  132430. /**
  132431. * Gets the xyz component (output)
  132432. * @deprecated Please use xyzOut instead.
  132433. */
  132434. get xyz(): NodeMaterialConnectionPoint;
  132435. protected _buildBlock(state: NodeMaterialBuildState): this;
  132436. }
  132437. }
  132438. declare module BABYLON {
  132439. /**
  132440. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132441. */
  132442. export class ColorSplitterBlock extends NodeMaterialBlock {
  132443. /**
  132444. * Create a new ColorSplitterBlock
  132445. * @param name defines the block name
  132446. */
  132447. constructor(name: string);
  132448. /**
  132449. * Gets the current class name
  132450. * @returns the class name
  132451. */
  132452. getClassName(): string;
  132453. /**
  132454. * Gets the rgba component (input)
  132455. */
  132456. get rgba(): NodeMaterialConnectionPoint;
  132457. /**
  132458. * Gets the rgb component (input)
  132459. */
  132460. get rgbIn(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the rgb component (output)
  132463. */
  132464. get rgbOut(): NodeMaterialConnectionPoint;
  132465. /**
  132466. * Gets the r component (output)
  132467. */
  132468. get r(): NodeMaterialConnectionPoint;
  132469. /**
  132470. * Gets the g component (output)
  132471. */
  132472. get g(): NodeMaterialConnectionPoint;
  132473. /**
  132474. * Gets the b component (output)
  132475. */
  132476. get b(): NodeMaterialConnectionPoint;
  132477. /**
  132478. * Gets the a component (output)
  132479. */
  132480. get a(): NodeMaterialConnectionPoint;
  132481. protected _inputRename(name: string): string;
  132482. protected _outputRename(name: string): string;
  132483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132484. }
  132485. }
  132486. declare module BABYLON {
  132487. /**
  132488. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132489. */
  132490. export class VectorSplitterBlock extends NodeMaterialBlock {
  132491. /**
  132492. * Create a new VectorSplitterBlock
  132493. * @param name defines the block name
  132494. */
  132495. constructor(name: string);
  132496. /**
  132497. * Gets the current class name
  132498. * @returns the class name
  132499. */
  132500. getClassName(): string;
  132501. /**
  132502. * Gets the xyzw component (input)
  132503. */
  132504. get xyzw(): NodeMaterialConnectionPoint;
  132505. /**
  132506. * Gets the xyz component (input)
  132507. */
  132508. get xyzIn(): NodeMaterialConnectionPoint;
  132509. /**
  132510. * Gets the xy component (input)
  132511. */
  132512. get xyIn(): NodeMaterialConnectionPoint;
  132513. /**
  132514. * Gets the xyz component (output)
  132515. */
  132516. get xyzOut(): NodeMaterialConnectionPoint;
  132517. /**
  132518. * Gets the xy component (output)
  132519. */
  132520. get xyOut(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the x component (output)
  132523. */
  132524. get x(): NodeMaterialConnectionPoint;
  132525. /**
  132526. * Gets the y component (output)
  132527. */
  132528. get y(): NodeMaterialConnectionPoint;
  132529. /**
  132530. * Gets the z component (output)
  132531. */
  132532. get z(): NodeMaterialConnectionPoint;
  132533. /**
  132534. * Gets the w component (output)
  132535. */
  132536. get w(): NodeMaterialConnectionPoint;
  132537. protected _inputRename(name: string): string;
  132538. protected _outputRename(name: string): string;
  132539. protected _buildBlock(state: NodeMaterialBuildState): this;
  132540. }
  132541. }
  132542. declare module BABYLON {
  132543. /**
  132544. * Block used to lerp between 2 values
  132545. */
  132546. export class LerpBlock extends NodeMaterialBlock {
  132547. /**
  132548. * Creates a new LerpBlock
  132549. * @param name defines the block name
  132550. */
  132551. constructor(name: string);
  132552. /**
  132553. * Gets the current class name
  132554. * @returns the class name
  132555. */
  132556. getClassName(): string;
  132557. /**
  132558. * Gets the left operand input component
  132559. */
  132560. get left(): NodeMaterialConnectionPoint;
  132561. /**
  132562. * Gets the right operand input component
  132563. */
  132564. get right(): NodeMaterialConnectionPoint;
  132565. /**
  132566. * Gets the gradient operand input component
  132567. */
  132568. get gradient(): NodeMaterialConnectionPoint;
  132569. /**
  132570. * Gets the output component
  132571. */
  132572. get output(): NodeMaterialConnectionPoint;
  132573. protected _buildBlock(state: NodeMaterialBuildState): this;
  132574. }
  132575. }
  132576. declare module BABYLON {
  132577. /**
  132578. * Block used to divide 2 vectors
  132579. */
  132580. export class DivideBlock extends NodeMaterialBlock {
  132581. /**
  132582. * Creates a new DivideBlock
  132583. * @param name defines the block name
  132584. */
  132585. constructor(name: string);
  132586. /**
  132587. * Gets the current class name
  132588. * @returns the class name
  132589. */
  132590. getClassName(): string;
  132591. /**
  132592. * Gets the left operand input component
  132593. */
  132594. get left(): NodeMaterialConnectionPoint;
  132595. /**
  132596. * Gets the right operand input component
  132597. */
  132598. get right(): NodeMaterialConnectionPoint;
  132599. /**
  132600. * Gets the output component
  132601. */
  132602. get output(): NodeMaterialConnectionPoint;
  132603. protected _buildBlock(state: NodeMaterialBuildState): this;
  132604. }
  132605. }
  132606. declare module BABYLON {
  132607. /**
  132608. * Block used to subtract 2 vectors
  132609. */
  132610. export class SubtractBlock extends NodeMaterialBlock {
  132611. /**
  132612. * Creates a new SubtractBlock
  132613. * @param name defines the block name
  132614. */
  132615. constructor(name: string);
  132616. /**
  132617. * Gets the current class name
  132618. * @returns the class name
  132619. */
  132620. getClassName(): string;
  132621. /**
  132622. * Gets the left operand input component
  132623. */
  132624. get left(): NodeMaterialConnectionPoint;
  132625. /**
  132626. * Gets the right operand input component
  132627. */
  132628. get right(): NodeMaterialConnectionPoint;
  132629. /**
  132630. * Gets the output component
  132631. */
  132632. get output(): NodeMaterialConnectionPoint;
  132633. protected _buildBlock(state: NodeMaterialBuildState): this;
  132634. }
  132635. }
  132636. declare module BABYLON {
  132637. /**
  132638. * Block used to step a value
  132639. */
  132640. export class StepBlock extends NodeMaterialBlock {
  132641. /**
  132642. * Creates a new StepBlock
  132643. * @param name defines the block name
  132644. */
  132645. constructor(name: string);
  132646. /**
  132647. * Gets the current class name
  132648. * @returns the class name
  132649. */
  132650. getClassName(): string;
  132651. /**
  132652. * Gets the value operand input component
  132653. */
  132654. get value(): NodeMaterialConnectionPoint;
  132655. /**
  132656. * Gets the edge operand input component
  132657. */
  132658. get edge(): NodeMaterialConnectionPoint;
  132659. /**
  132660. * Gets the output component
  132661. */
  132662. get output(): NodeMaterialConnectionPoint;
  132663. protected _buildBlock(state: NodeMaterialBuildState): this;
  132664. }
  132665. }
  132666. declare module BABYLON {
  132667. /**
  132668. * Block used to get the opposite (1 - x) of a value
  132669. */
  132670. export class OneMinusBlock extends NodeMaterialBlock {
  132671. /**
  132672. * Creates a new OneMinusBlock
  132673. * @param name defines the block name
  132674. */
  132675. constructor(name: string);
  132676. /**
  132677. * Gets the current class name
  132678. * @returns the class name
  132679. */
  132680. getClassName(): string;
  132681. /**
  132682. * Gets the input component
  132683. */
  132684. get input(): NodeMaterialConnectionPoint;
  132685. /**
  132686. * Gets the output component
  132687. */
  132688. get output(): NodeMaterialConnectionPoint;
  132689. protected _buildBlock(state: NodeMaterialBuildState): this;
  132690. }
  132691. }
  132692. declare module BABYLON {
  132693. /**
  132694. * Block used to get the view direction
  132695. */
  132696. export class ViewDirectionBlock extends NodeMaterialBlock {
  132697. /**
  132698. * Creates a new ViewDirectionBlock
  132699. * @param name defines the block name
  132700. */
  132701. constructor(name: string);
  132702. /**
  132703. * Gets the current class name
  132704. * @returns the class name
  132705. */
  132706. getClassName(): string;
  132707. /**
  132708. * Gets the world position component
  132709. */
  132710. get worldPosition(): NodeMaterialConnectionPoint;
  132711. /**
  132712. * Gets the camera position component
  132713. */
  132714. get cameraPosition(): NodeMaterialConnectionPoint;
  132715. /**
  132716. * Gets the output component
  132717. */
  132718. get output(): NodeMaterialConnectionPoint;
  132719. autoConfigure(material: NodeMaterial): void;
  132720. protected _buildBlock(state: NodeMaterialBuildState): this;
  132721. }
  132722. }
  132723. declare module BABYLON {
  132724. /**
  132725. * Block used to compute fresnel value
  132726. */
  132727. export class FresnelBlock extends NodeMaterialBlock {
  132728. /**
  132729. * Create a new FresnelBlock
  132730. * @param name defines the block name
  132731. */
  132732. constructor(name: string);
  132733. /**
  132734. * Gets the current class name
  132735. * @returns the class name
  132736. */
  132737. getClassName(): string;
  132738. /**
  132739. * Gets the world normal input component
  132740. */
  132741. get worldNormal(): NodeMaterialConnectionPoint;
  132742. /**
  132743. * Gets the view direction input component
  132744. */
  132745. get viewDirection(): NodeMaterialConnectionPoint;
  132746. /**
  132747. * Gets the bias input component
  132748. */
  132749. get bias(): NodeMaterialConnectionPoint;
  132750. /**
  132751. * Gets the camera (or eye) position component
  132752. */
  132753. get power(): NodeMaterialConnectionPoint;
  132754. /**
  132755. * Gets the fresnel output component
  132756. */
  132757. get fresnel(): NodeMaterialConnectionPoint;
  132758. autoConfigure(material: NodeMaterial): void;
  132759. protected _buildBlock(state: NodeMaterialBuildState): this;
  132760. }
  132761. }
  132762. declare module BABYLON {
  132763. /**
  132764. * Block used to get the max of 2 values
  132765. */
  132766. export class MaxBlock extends NodeMaterialBlock {
  132767. /**
  132768. * Creates a new MaxBlock
  132769. * @param name defines the block name
  132770. */
  132771. constructor(name: string);
  132772. /**
  132773. * Gets the current class name
  132774. * @returns the class name
  132775. */
  132776. getClassName(): string;
  132777. /**
  132778. * Gets the left operand input component
  132779. */
  132780. get left(): NodeMaterialConnectionPoint;
  132781. /**
  132782. * Gets the right operand input component
  132783. */
  132784. get right(): NodeMaterialConnectionPoint;
  132785. /**
  132786. * Gets the output component
  132787. */
  132788. get output(): NodeMaterialConnectionPoint;
  132789. protected _buildBlock(state: NodeMaterialBuildState): this;
  132790. }
  132791. }
  132792. declare module BABYLON {
  132793. /**
  132794. * Block used to get the min of 2 values
  132795. */
  132796. export class MinBlock extends NodeMaterialBlock {
  132797. /**
  132798. * Creates a new MinBlock
  132799. * @param name defines the block name
  132800. */
  132801. constructor(name: string);
  132802. /**
  132803. * Gets the current class name
  132804. * @returns the class name
  132805. */
  132806. getClassName(): string;
  132807. /**
  132808. * Gets the left operand input component
  132809. */
  132810. get left(): NodeMaterialConnectionPoint;
  132811. /**
  132812. * Gets the right operand input component
  132813. */
  132814. get right(): NodeMaterialConnectionPoint;
  132815. /**
  132816. * Gets the output component
  132817. */
  132818. get output(): NodeMaterialConnectionPoint;
  132819. protected _buildBlock(state: NodeMaterialBuildState): this;
  132820. }
  132821. }
  132822. declare module BABYLON {
  132823. /**
  132824. * Block used to get the distance between 2 values
  132825. */
  132826. export class DistanceBlock extends NodeMaterialBlock {
  132827. /**
  132828. * Creates a new DistanceBlock
  132829. * @param name defines the block name
  132830. */
  132831. constructor(name: string);
  132832. /**
  132833. * Gets the current class name
  132834. * @returns the class name
  132835. */
  132836. getClassName(): string;
  132837. /**
  132838. * Gets the left operand input component
  132839. */
  132840. get left(): NodeMaterialConnectionPoint;
  132841. /**
  132842. * Gets the right operand input component
  132843. */
  132844. get right(): NodeMaterialConnectionPoint;
  132845. /**
  132846. * Gets the output component
  132847. */
  132848. get output(): NodeMaterialConnectionPoint;
  132849. protected _buildBlock(state: NodeMaterialBuildState): this;
  132850. }
  132851. }
  132852. declare module BABYLON {
  132853. /**
  132854. * Block used to get the length of a vector
  132855. */
  132856. export class LengthBlock extends NodeMaterialBlock {
  132857. /**
  132858. * Creates a new LengthBlock
  132859. * @param name defines the block name
  132860. */
  132861. constructor(name: string);
  132862. /**
  132863. * Gets the current class name
  132864. * @returns the class name
  132865. */
  132866. getClassName(): string;
  132867. /**
  132868. * Gets the value input component
  132869. */
  132870. get value(): NodeMaterialConnectionPoint;
  132871. /**
  132872. * Gets the output component
  132873. */
  132874. get output(): NodeMaterialConnectionPoint;
  132875. protected _buildBlock(state: NodeMaterialBuildState): this;
  132876. }
  132877. }
  132878. declare module BABYLON {
  132879. /**
  132880. * Block used to get negative version of a value (i.e. x * -1)
  132881. */
  132882. export class NegateBlock extends NodeMaterialBlock {
  132883. /**
  132884. * Creates a new NegateBlock
  132885. * @param name defines the block name
  132886. */
  132887. constructor(name: string);
  132888. /**
  132889. * Gets the current class name
  132890. * @returns the class name
  132891. */
  132892. getClassName(): string;
  132893. /**
  132894. * Gets the value input component
  132895. */
  132896. get value(): NodeMaterialConnectionPoint;
  132897. /**
  132898. * Gets the output component
  132899. */
  132900. get output(): NodeMaterialConnectionPoint;
  132901. protected _buildBlock(state: NodeMaterialBuildState): this;
  132902. }
  132903. }
  132904. declare module BABYLON {
  132905. /**
  132906. * Block used to get the value of the first parameter raised to the power of the second
  132907. */
  132908. export class PowBlock extends NodeMaterialBlock {
  132909. /**
  132910. * Creates a new PowBlock
  132911. * @param name defines the block name
  132912. */
  132913. constructor(name: string);
  132914. /**
  132915. * Gets the current class name
  132916. * @returns the class name
  132917. */
  132918. getClassName(): string;
  132919. /**
  132920. * Gets the value operand input component
  132921. */
  132922. get value(): NodeMaterialConnectionPoint;
  132923. /**
  132924. * Gets the power operand input component
  132925. */
  132926. get power(): NodeMaterialConnectionPoint;
  132927. /**
  132928. * Gets the output component
  132929. */
  132930. get output(): NodeMaterialConnectionPoint;
  132931. protected _buildBlock(state: NodeMaterialBuildState): this;
  132932. }
  132933. }
  132934. declare module BABYLON {
  132935. /**
  132936. * Block used to get a random number
  132937. */
  132938. export class RandomNumberBlock extends NodeMaterialBlock {
  132939. /**
  132940. * Creates a new RandomNumberBlock
  132941. * @param name defines the block name
  132942. */
  132943. constructor(name: string);
  132944. /**
  132945. * Gets the current class name
  132946. * @returns the class name
  132947. */
  132948. getClassName(): string;
  132949. /**
  132950. * Gets the seed input component
  132951. */
  132952. get seed(): NodeMaterialConnectionPoint;
  132953. /**
  132954. * Gets the output component
  132955. */
  132956. get output(): NodeMaterialConnectionPoint;
  132957. protected _buildBlock(state: NodeMaterialBuildState): this;
  132958. }
  132959. }
  132960. declare module BABYLON {
  132961. /**
  132962. * Block used to compute arc tangent of 2 values
  132963. */
  132964. export class ArcTan2Block extends NodeMaterialBlock {
  132965. /**
  132966. * Creates a new ArcTan2Block
  132967. * @param name defines the block name
  132968. */
  132969. constructor(name: string);
  132970. /**
  132971. * Gets the current class name
  132972. * @returns the class name
  132973. */
  132974. getClassName(): string;
  132975. /**
  132976. * Gets the x operand input component
  132977. */
  132978. get x(): NodeMaterialConnectionPoint;
  132979. /**
  132980. * Gets the y operand input component
  132981. */
  132982. get y(): NodeMaterialConnectionPoint;
  132983. /**
  132984. * Gets the output component
  132985. */
  132986. get output(): NodeMaterialConnectionPoint;
  132987. protected _buildBlock(state: NodeMaterialBuildState): this;
  132988. }
  132989. }
  132990. declare module BABYLON {
  132991. /**
  132992. * Block used to smooth step a value
  132993. */
  132994. export class SmoothStepBlock extends NodeMaterialBlock {
  132995. /**
  132996. * Creates a new SmoothStepBlock
  132997. * @param name defines the block name
  132998. */
  132999. constructor(name: string);
  133000. /**
  133001. * Gets the current class name
  133002. * @returns the class name
  133003. */
  133004. getClassName(): string;
  133005. /**
  133006. * Gets the value operand input component
  133007. */
  133008. get value(): NodeMaterialConnectionPoint;
  133009. /**
  133010. * Gets the first edge operand input component
  133011. */
  133012. get edge0(): NodeMaterialConnectionPoint;
  133013. /**
  133014. * Gets the second edge operand input component
  133015. */
  133016. get edge1(): NodeMaterialConnectionPoint;
  133017. /**
  133018. * Gets the output component
  133019. */
  133020. get output(): NodeMaterialConnectionPoint;
  133021. protected _buildBlock(state: NodeMaterialBuildState): this;
  133022. }
  133023. }
  133024. declare module BABYLON {
  133025. /**
  133026. * Block used to get the reciprocal (1 / x) of a value
  133027. */
  133028. export class ReciprocalBlock extends NodeMaterialBlock {
  133029. /**
  133030. * Creates a new ReciprocalBlock
  133031. * @param name defines the block name
  133032. */
  133033. constructor(name: string);
  133034. /**
  133035. * Gets the current class name
  133036. * @returns the class name
  133037. */
  133038. getClassName(): string;
  133039. /**
  133040. * Gets the input component
  133041. */
  133042. get input(): NodeMaterialConnectionPoint;
  133043. /**
  133044. * Gets the output component
  133045. */
  133046. get output(): NodeMaterialConnectionPoint;
  133047. protected _buildBlock(state: NodeMaterialBuildState): this;
  133048. }
  133049. }
  133050. declare module BABYLON {
  133051. /**
  133052. * Block used to replace a color by another one
  133053. */
  133054. export class ReplaceColorBlock extends NodeMaterialBlock {
  133055. /**
  133056. * Creates a new ReplaceColorBlock
  133057. * @param name defines the block name
  133058. */
  133059. constructor(name: string);
  133060. /**
  133061. * Gets the current class name
  133062. * @returns the class name
  133063. */
  133064. getClassName(): string;
  133065. /**
  133066. * Gets the value input component
  133067. */
  133068. get value(): NodeMaterialConnectionPoint;
  133069. /**
  133070. * Gets the reference input component
  133071. */
  133072. get reference(): NodeMaterialConnectionPoint;
  133073. /**
  133074. * Gets the distance input component
  133075. */
  133076. get distance(): NodeMaterialConnectionPoint;
  133077. /**
  133078. * Gets the replacement input component
  133079. */
  133080. get replacement(): NodeMaterialConnectionPoint;
  133081. /**
  133082. * Gets the output component
  133083. */
  133084. get output(): NodeMaterialConnectionPoint;
  133085. protected _buildBlock(state: NodeMaterialBuildState): this;
  133086. }
  133087. }
  133088. declare module BABYLON {
  133089. /**
  133090. * Block used to posterize a value
  133091. * @see https://en.wikipedia.org/wiki/Posterization
  133092. */
  133093. export class PosterizeBlock extends NodeMaterialBlock {
  133094. /**
  133095. * Creates a new PosterizeBlock
  133096. * @param name defines the block name
  133097. */
  133098. constructor(name: string);
  133099. /**
  133100. * Gets the current class name
  133101. * @returns the class name
  133102. */
  133103. getClassName(): string;
  133104. /**
  133105. * Gets the value input component
  133106. */
  133107. get value(): NodeMaterialConnectionPoint;
  133108. /**
  133109. * Gets the steps input component
  133110. */
  133111. get steps(): NodeMaterialConnectionPoint;
  133112. /**
  133113. * Gets the output component
  133114. */
  133115. get output(): NodeMaterialConnectionPoint;
  133116. protected _buildBlock(state: NodeMaterialBuildState): this;
  133117. }
  133118. }
  133119. declare module BABYLON {
  133120. /**
  133121. * Operations supported by the Wave block
  133122. */
  133123. export enum WaveBlockKind {
  133124. /** SawTooth */
  133125. SawTooth = 0,
  133126. /** Square */
  133127. Square = 1,
  133128. /** Triangle */
  133129. Triangle = 2
  133130. }
  133131. /**
  133132. * Block used to apply wave operation to floats
  133133. */
  133134. export class WaveBlock extends NodeMaterialBlock {
  133135. /**
  133136. * Gets or sets the kibnd of wave to be applied by the block
  133137. */
  133138. kind: WaveBlockKind;
  133139. /**
  133140. * Creates a new WaveBlock
  133141. * @param name defines the block name
  133142. */
  133143. constructor(name: string);
  133144. /**
  133145. * Gets the current class name
  133146. * @returns the class name
  133147. */
  133148. getClassName(): string;
  133149. /**
  133150. * Gets the input component
  133151. */
  133152. get input(): NodeMaterialConnectionPoint;
  133153. /**
  133154. * Gets the output component
  133155. */
  133156. get output(): NodeMaterialConnectionPoint;
  133157. protected _buildBlock(state: NodeMaterialBuildState): this;
  133158. serialize(): any;
  133159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133160. }
  133161. }
  133162. declare module BABYLON {
  133163. /**
  133164. * Class used to store a color step for the GradientBlock
  133165. */
  133166. export class GradientBlockColorStep {
  133167. /**
  133168. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133169. */
  133170. step: number;
  133171. /**
  133172. * Gets or sets the color associated with this step
  133173. */
  133174. color: Color3;
  133175. /**
  133176. * Creates a new GradientBlockColorStep
  133177. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133178. * @param color defines the color associated with this step
  133179. */
  133180. constructor(
  133181. /**
  133182. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133183. */
  133184. step: number,
  133185. /**
  133186. * Gets or sets the color associated with this step
  133187. */
  133188. color: Color3);
  133189. }
  133190. /**
  133191. * Block used to return a color from a gradient based on an input value between 0 and 1
  133192. */
  133193. export class GradientBlock extends NodeMaterialBlock {
  133194. /**
  133195. * Gets or sets the list of color steps
  133196. */
  133197. colorSteps: GradientBlockColorStep[];
  133198. /**
  133199. * Creates a new GradientBlock
  133200. * @param name defines the block name
  133201. */
  133202. constructor(name: string);
  133203. /**
  133204. * Gets the current class name
  133205. * @returns the class name
  133206. */
  133207. getClassName(): string;
  133208. /**
  133209. * Gets the gradient input component
  133210. */
  133211. get gradient(): NodeMaterialConnectionPoint;
  133212. /**
  133213. * Gets the output component
  133214. */
  133215. get output(): NodeMaterialConnectionPoint;
  133216. private _writeColorConstant;
  133217. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133218. serialize(): any;
  133219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133220. protected _dumpPropertiesCode(): string;
  133221. }
  133222. }
  133223. declare module BABYLON {
  133224. /**
  133225. * Block used to normalize lerp between 2 values
  133226. */
  133227. export class NLerpBlock extends NodeMaterialBlock {
  133228. /**
  133229. * Creates a new NLerpBlock
  133230. * @param name defines the block name
  133231. */
  133232. constructor(name: string);
  133233. /**
  133234. * Gets the current class name
  133235. * @returns the class name
  133236. */
  133237. getClassName(): string;
  133238. /**
  133239. * Gets the left operand input component
  133240. */
  133241. get left(): NodeMaterialConnectionPoint;
  133242. /**
  133243. * Gets the right operand input component
  133244. */
  133245. get right(): NodeMaterialConnectionPoint;
  133246. /**
  133247. * Gets the gradient operand input component
  133248. */
  133249. get gradient(): NodeMaterialConnectionPoint;
  133250. /**
  133251. * Gets the output component
  133252. */
  133253. get output(): NodeMaterialConnectionPoint;
  133254. protected _buildBlock(state: NodeMaterialBuildState): this;
  133255. }
  133256. }
  133257. declare module BABYLON {
  133258. /**
  133259. * block used to Generate a Worley Noise 3D Noise Pattern
  133260. */
  133261. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133262. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133263. manhattanDistance: boolean;
  133264. /**
  133265. * Creates a new WorleyNoise3DBlock
  133266. * @param name defines the block name
  133267. */
  133268. constructor(name: string);
  133269. /**
  133270. * Gets the current class name
  133271. * @returns the class name
  133272. */
  133273. getClassName(): string;
  133274. /**
  133275. * Gets the seed input component
  133276. */
  133277. get seed(): NodeMaterialConnectionPoint;
  133278. /**
  133279. * Gets the jitter input component
  133280. */
  133281. get jitter(): NodeMaterialConnectionPoint;
  133282. /**
  133283. * Gets the output component
  133284. */
  133285. get output(): NodeMaterialConnectionPoint;
  133286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133287. /**
  133288. * Exposes the properties to the UI?
  133289. */
  133290. protected _dumpPropertiesCode(): string;
  133291. /**
  133292. * Exposes the properties to the Seralize?
  133293. */
  133294. serialize(): any;
  133295. /**
  133296. * Exposes the properties to the deseralize?
  133297. */
  133298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133299. }
  133300. }
  133301. declare module BABYLON {
  133302. /**
  133303. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133304. */
  133305. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133306. /**
  133307. * Creates a new SimplexPerlin3DBlock
  133308. * @param name defines the block name
  133309. */
  133310. constructor(name: string);
  133311. /**
  133312. * Gets the current class name
  133313. * @returns the class name
  133314. */
  133315. getClassName(): string;
  133316. /**
  133317. * Gets the seed operand input component
  133318. */
  133319. get seed(): NodeMaterialConnectionPoint;
  133320. /**
  133321. * Gets the output component
  133322. */
  133323. get output(): NodeMaterialConnectionPoint;
  133324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133325. }
  133326. }
  133327. declare module BABYLON {
  133328. /**
  133329. * Block used to blend normals
  133330. */
  133331. export class NormalBlendBlock extends NodeMaterialBlock {
  133332. /**
  133333. * Creates a new NormalBlendBlock
  133334. * @param name defines the block name
  133335. */
  133336. constructor(name: string);
  133337. /**
  133338. * Gets the current class name
  133339. * @returns the class name
  133340. */
  133341. getClassName(): string;
  133342. /**
  133343. * Gets the first input component
  133344. */
  133345. get normalMap0(): NodeMaterialConnectionPoint;
  133346. /**
  133347. * Gets the second input component
  133348. */
  133349. get normalMap1(): NodeMaterialConnectionPoint;
  133350. /**
  133351. * Gets the output component
  133352. */
  133353. get output(): NodeMaterialConnectionPoint;
  133354. protected _buildBlock(state: NodeMaterialBuildState): this;
  133355. }
  133356. }
  133357. declare module BABYLON {
  133358. /**
  133359. * Block used to rotate a 2d vector by a given angle
  133360. */
  133361. export class Rotate2dBlock extends NodeMaterialBlock {
  133362. /**
  133363. * Creates a new Rotate2dBlock
  133364. * @param name defines the block name
  133365. */
  133366. constructor(name: string);
  133367. /**
  133368. * Gets the current class name
  133369. * @returns the class name
  133370. */
  133371. getClassName(): string;
  133372. /**
  133373. * Gets the input vector
  133374. */
  133375. get input(): NodeMaterialConnectionPoint;
  133376. /**
  133377. * Gets the input angle
  133378. */
  133379. get angle(): NodeMaterialConnectionPoint;
  133380. /**
  133381. * Gets the output component
  133382. */
  133383. get output(): NodeMaterialConnectionPoint;
  133384. autoConfigure(material: NodeMaterial): void;
  133385. protected _buildBlock(state: NodeMaterialBuildState): this;
  133386. }
  133387. }
  133388. declare module BABYLON {
  133389. /**
  133390. * Block used to get the reflected vector from a direction and a normal
  133391. */
  133392. export class ReflectBlock extends NodeMaterialBlock {
  133393. /**
  133394. * Creates a new ReflectBlock
  133395. * @param name defines the block name
  133396. */
  133397. constructor(name: string);
  133398. /**
  133399. * Gets the current class name
  133400. * @returns the class name
  133401. */
  133402. getClassName(): string;
  133403. /**
  133404. * Gets the incident component
  133405. */
  133406. get incident(): NodeMaterialConnectionPoint;
  133407. /**
  133408. * Gets the normal component
  133409. */
  133410. get normal(): NodeMaterialConnectionPoint;
  133411. /**
  133412. * Gets the output component
  133413. */
  133414. get output(): NodeMaterialConnectionPoint;
  133415. protected _buildBlock(state: NodeMaterialBuildState): this;
  133416. }
  133417. }
  133418. declare module BABYLON {
  133419. /**
  133420. * Block used to get the refracted vector from a direction and a normal
  133421. */
  133422. export class RefractBlock extends NodeMaterialBlock {
  133423. /**
  133424. * Creates a new RefractBlock
  133425. * @param name defines the block name
  133426. */
  133427. constructor(name: string);
  133428. /**
  133429. * Gets the current class name
  133430. * @returns the class name
  133431. */
  133432. getClassName(): string;
  133433. /**
  133434. * Gets the incident component
  133435. */
  133436. get incident(): NodeMaterialConnectionPoint;
  133437. /**
  133438. * Gets the normal component
  133439. */
  133440. get normal(): NodeMaterialConnectionPoint;
  133441. /**
  133442. * Gets the index of refraction component
  133443. */
  133444. get ior(): NodeMaterialConnectionPoint;
  133445. /**
  133446. * Gets the output component
  133447. */
  133448. get output(): NodeMaterialConnectionPoint;
  133449. protected _buildBlock(state: NodeMaterialBuildState): this;
  133450. }
  133451. }
  133452. declare module BABYLON {
  133453. /**
  133454. * Block used to desaturate a color
  133455. */
  133456. export class DesaturateBlock extends NodeMaterialBlock {
  133457. /**
  133458. * Creates a new DesaturateBlock
  133459. * @param name defines the block name
  133460. */
  133461. constructor(name: string);
  133462. /**
  133463. * Gets the current class name
  133464. * @returns the class name
  133465. */
  133466. getClassName(): string;
  133467. /**
  133468. * Gets the color operand input component
  133469. */
  133470. get color(): NodeMaterialConnectionPoint;
  133471. /**
  133472. * Gets the level operand input component
  133473. */
  133474. get level(): NodeMaterialConnectionPoint;
  133475. /**
  133476. * Gets the output component
  133477. */
  133478. get output(): NodeMaterialConnectionPoint;
  133479. protected _buildBlock(state: NodeMaterialBuildState): this;
  133480. }
  133481. }
  133482. declare module BABYLON {
  133483. /**
  133484. * Effect Render Options
  133485. */
  133486. export interface IEffectRendererOptions {
  133487. /**
  133488. * Defines the vertices positions.
  133489. */
  133490. positions?: number[];
  133491. /**
  133492. * Defines the indices.
  133493. */
  133494. indices?: number[];
  133495. }
  133496. /**
  133497. * Helper class to render one or more effects
  133498. */
  133499. export class EffectRenderer {
  133500. private engine;
  133501. private static _DefaultOptions;
  133502. private _vertexBuffers;
  133503. private _indexBuffer;
  133504. private _ringBufferIndex;
  133505. private _ringScreenBuffer;
  133506. private _fullscreenViewport;
  133507. private _getNextFrameBuffer;
  133508. /**
  133509. * Creates an effect renderer
  133510. * @param engine the engine to use for rendering
  133511. * @param options defines the options of the effect renderer
  133512. */
  133513. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133514. /**
  133515. * Sets the current viewport in normalized coordinates 0-1
  133516. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133517. */
  133518. setViewport(viewport?: Viewport): void;
  133519. /**
  133520. * Binds the embedded attributes buffer to the effect.
  133521. * @param effect Defines the effect to bind the attributes for
  133522. */
  133523. bindBuffers(effect: Effect): void;
  133524. /**
  133525. * Sets the current effect wrapper to use during draw.
  133526. * The effect needs to be ready before calling this api.
  133527. * This also sets the default full screen position attribute.
  133528. * @param effectWrapper Defines the effect to draw with
  133529. */
  133530. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133531. /**
  133532. * Draws a full screen quad.
  133533. */
  133534. draw(): void;
  133535. /**
  133536. * renders one or more effects to a specified texture
  133537. * @param effectWrappers list of effects to renderer
  133538. * @param outputTexture texture to draw to, if null it will render to the screen
  133539. */
  133540. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133541. /**
  133542. * Disposes of the effect renderer
  133543. */
  133544. dispose(): void;
  133545. }
  133546. /**
  133547. * Options to create an EffectWrapper
  133548. */
  133549. interface EffectWrapperCreationOptions {
  133550. /**
  133551. * Engine to use to create the effect
  133552. */
  133553. engine: ThinEngine;
  133554. /**
  133555. * Fragment shader for the effect
  133556. */
  133557. fragmentShader: string;
  133558. /**
  133559. * Vertex shader for the effect
  133560. */
  133561. vertexShader?: string;
  133562. /**
  133563. * Attributes to use in the shader
  133564. */
  133565. attributeNames?: Array<string>;
  133566. /**
  133567. * Uniforms to use in the shader
  133568. */
  133569. uniformNames?: Array<string>;
  133570. /**
  133571. * Texture sampler names to use in the shader
  133572. */
  133573. samplerNames?: Array<string>;
  133574. /**
  133575. * The friendly name of the effect displayed in Spector.
  133576. */
  133577. name?: string;
  133578. }
  133579. /**
  133580. * Wraps an effect to be used for rendering
  133581. */
  133582. export class EffectWrapper {
  133583. /**
  133584. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133585. */
  133586. onApplyObservable: Observable<{}>;
  133587. /**
  133588. * The underlying effect
  133589. */
  133590. effect: Effect;
  133591. /**
  133592. * Creates an effect to be renderer
  133593. * @param creationOptions options to create the effect
  133594. */
  133595. constructor(creationOptions: EffectWrapperCreationOptions);
  133596. /**
  133597. * Disposes of the effect wrapper
  133598. */
  133599. dispose(): void;
  133600. }
  133601. }
  133602. declare module BABYLON {
  133603. /**
  133604. * Helper class to push actions to a pool of workers.
  133605. */
  133606. export class WorkerPool implements IDisposable {
  133607. private _workerInfos;
  133608. private _pendingActions;
  133609. /**
  133610. * Constructor
  133611. * @param workers Array of workers to use for actions
  133612. */
  133613. constructor(workers: Array<Worker>);
  133614. /**
  133615. * Terminates all workers and clears any pending actions.
  133616. */
  133617. dispose(): void;
  133618. /**
  133619. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133620. * pended until a worker has completed its action.
  133621. * @param action The action to perform. Call onComplete when the action is complete.
  133622. */
  133623. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133624. private _execute;
  133625. }
  133626. }
  133627. declare module BABYLON {
  133628. /**
  133629. * Configuration for Draco compression
  133630. */
  133631. export interface IDracoCompressionConfiguration {
  133632. /**
  133633. * Configuration for the decoder.
  133634. */
  133635. decoder: {
  133636. /**
  133637. * The url to the WebAssembly module.
  133638. */
  133639. wasmUrl?: string;
  133640. /**
  133641. * The url to the WebAssembly binary.
  133642. */
  133643. wasmBinaryUrl?: string;
  133644. /**
  133645. * The url to the fallback JavaScript module.
  133646. */
  133647. fallbackUrl?: string;
  133648. };
  133649. }
  133650. /**
  133651. * Draco compression (https://google.github.io/draco/)
  133652. *
  133653. * This class wraps the Draco module.
  133654. *
  133655. * **Encoder**
  133656. *
  133657. * The encoder is not currently implemented.
  133658. *
  133659. * **Decoder**
  133660. *
  133661. * 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.
  133662. *
  133663. * To update the configuration, use the following code:
  133664. * ```javascript
  133665. * DracoCompression.Configuration = {
  133666. * decoder: {
  133667. * wasmUrl: "<url to the WebAssembly library>",
  133668. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133669. * fallbackUrl: "<url to the fallback JavaScript library>",
  133670. * }
  133671. * };
  133672. * ```
  133673. *
  133674. * 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.
  133675. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133676. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133677. *
  133678. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133679. * ```javascript
  133680. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133681. * ```
  133682. *
  133683. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133684. */
  133685. export class DracoCompression implements IDisposable {
  133686. private _workerPoolPromise?;
  133687. private _decoderModulePromise?;
  133688. /**
  133689. * The configuration. Defaults to the following urls:
  133690. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133691. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133692. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133693. */
  133694. static Configuration: IDracoCompressionConfiguration;
  133695. /**
  133696. * Returns true if the decoder configuration is available.
  133697. */
  133698. static get DecoderAvailable(): boolean;
  133699. /**
  133700. * Default number of workers to create when creating the draco compression object.
  133701. */
  133702. static DefaultNumWorkers: number;
  133703. private static GetDefaultNumWorkers;
  133704. private static _Default;
  133705. /**
  133706. * Default instance for the draco compression object.
  133707. */
  133708. static get Default(): DracoCompression;
  133709. /**
  133710. * Constructor
  133711. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133712. */
  133713. constructor(numWorkers?: number);
  133714. /**
  133715. * Stop all async operations and release resources.
  133716. */
  133717. dispose(): void;
  133718. /**
  133719. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133720. * @returns a promise that resolves when ready
  133721. */
  133722. whenReadyAsync(): Promise<void>;
  133723. /**
  133724. * Decode Draco compressed mesh data to vertex data.
  133725. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133726. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133727. * @returns A promise that resolves with the decoded vertex data
  133728. */
  133729. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133730. [kind: string]: number;
  133731. }): Promise<VertexData>;
  133732. }
  133733. }
  133734. declare module BABYLON {
  133735. /**
  133736. * Class for building Constructive Solid Geometry
  133737. */
  133738. export class CSG {
  133739. private polygons;
  133740. /**
  133741. * The world matrix
  133742. */
  133743. matrix: Matrix;
  133744. /**
  133745. * Stores the position
  133746. */
  133747. position: Vector3;
  133748. /**
  133749. * Stores the rotation
  133750. */
  133751. rotation: Vector3;
  133752. /**
  133753. * Stores the rotation quaternion
  133754. */
  133755. rotationQuaternion: Nullable<Quaternion>;
  133756. /**
  133757. * Stores the scaling vector
  133758. */
  133759. scaling: Vector3;
  133760. /**
  133761. * Convert the Mesh to CSG
  133762. * @param mesh The Mesh to convert to CSG
  133763. * @returns A new CSG from the Mesh
  133764. */
  133765. static FromMesh(mesh: Mesh): CSG;
  133766. /**
  133767. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133768. * @param polygons Polygons used to construct a CSG solid
  133769. */
  133770. private static FromPolygons;
  133771. /**
  133772. * Clones, or makes a deep copy, of the CSG
  133773. * @returns A new CSG
  133774. */
  133775. clone(): CSG;
  133776. /**
  133777. * Unions this CSG with another CSG
  133778. * @param csg The CSG to union against this CSG
  133779. * @returns The unioned CSG
  133780. */
  133781. union(csg: CSG): CSG;
  133782. /**
  133783. * Unions this CSG with another CSG in place
  133784. * @param csg The CSG to union against this CSG
  133785. */
  133786. unionInPlace(csg: CSG): void;
  133787. /**
  133788. * Subtracts this CSG with another CSG
  133789. * @param csg The CSG to subtract against this CSG
  133790. * @returns A new CSG
  133791. */
  133792. subtract(csg: CSG): CSG;
  133793. /**
  133794. * Subtracts this CSG with another CSG in place
  133795. * @param csg The CSG to subtact against this CSG
  133796. */
  133797. subtractInPlace(csg: CSG): void;
  133798. /**
  133799. * Intersect this CSG with another CSG
  133800. * @param csg The CSG to intersect against this CSG
  133801. * @returns A new CSG
  133802. */
  133803. intersect(csg: CSG): CSG;
  133804. /**
  133805. * Intersects this CSG with another CSG in place
  133806. * @param csg The CSG to intersect against this CSG
  133807. */
  133808. intersectInPlace(csg: CSG): void;
  133809. /**
  133810. * Return a new CSG solid with solid and empty space switched. This solid is
  133811. * not modified.
  133812. * @returns A new CSG solid with solid and empty space switched
  133813. */
  133814. inverse(): CSG;
  133815. /**
  133816. * Inverses the CSG in place
  133817. */
  133818. inverseInPlace(): void;
  133819. /**
  133820. * This is used to keep meshes transformations so they can be restored
  133821. * when we build back a Babylon Mesh
  133822. * NB : All CSG operations are performed in world coordinates
  133823. * @param csg The CSG to copy the transform attributes from
  133824. * @returns This CSG
  133825. */
  133826. copyTransformAttributes(csg: CSG): CSG;
  133827. /**
  133828. * Build Raw mesh from CSG
  133829. * Coordinates here are in world space
  133830. * @param name The name of the mesh geometry
  133831. * @param scene The Scene
  133832. * @param keepSubMeshes Specifies if the submeshes should be kept
  133833. * @returns A new Mesh
  133834. */
  133835. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133836. /**
  133837. * Build Mesh from CSG taking material and transforms into account
  133838. * @param name The name of the Mesh
  133839. * @param material The material of the Mesh
  133840. * @param scene The Scene
  133841. * @param keepSubMeshes Specifies if submeshes should be kept
  133842. * @returns The new Mesh
  133843. */
  133844. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133845. }
  133846. }
  133847. declare module BABYLON {
  133848. /**
  133849. * Class used to create a trail following a mesh
  133850. */
  133851. export class TrailMesh extends Mesh {
  133852. private _generator;
  133853. private _autoStart;
  133854. private _running;
  133855. private _diameter;
  133856. private _length;
  133857. private _sectionPolygonPointsCount;
  133858. private _sectionVectors;
  133859. private _sectionNormalVectors;
  133860. private _beforeRenderObserver;
  133861. /**
  133862. * @constructor
  133863. * @param name The value used by scene.getMeshByName() to do a lookup.
  133864. * @param generator The mesh or transform node to generate a trail.
  133865. * @param scene The scene to add this mesh to.
  133866. * @param diameter Diameter of trailing mesh. Default is 1.
  133867. * @param length Length of trailing mesh. Default is 60.
  133868. * @param autoStart Automatically start trailing mesh. Default true.
  133869. */
  133870. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133871. /**
  133872. * "TrailMesh"
  133873. * @returns "TrailMesh"
  133874. */
  133875. getClassName(): string;
  133876. private _createMesh;
  133877. /**
  133878. * Start trailing mesh.
  133879. */
  133880. start(): void;
  133881. /**
  133882. * Stop trailing mesh.
  133883. */
  133884. stop(): void;
  133885. /**
  133886. * Update trailing mesh geometry.
  133887. */
  133888. update(): void;
  133889. /**
  133890. * Returns a new TrailMesh object.
  133891. * @param name is a string, the name given to the new mesh
  133892. * @param newGenerator use new generator object for cloned trail mesh
  133893. * @returns a new mesh
  133894. */
  133895. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133896. /**
  133897. * Serializes this trail mesh
  133898. * @param serializationObject object to write serialization to
  133899. */
  133900. serialize(serializationObject: any): void;
  133901. /**
  133902. * Parses a serialized trail mesh
  133903. * @param parsedMesh the serialized mesh
  133904. * @param scene the scene to create the trail mesh in
  133905. * @returns the created trail mesh
  133906. */
  133907. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133908. }
  133909. }
  133910. declare module BABYLON {
  133911. /**
  133912. * Class containing static functions to help procedurally build meshes
  133913. */
  133914. export class TiledBoxBuilder {
  133915. /**
  133916. * Creates a box mesh
  133917. * 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)
  133918. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133922. * @param name defines the name of the mesh
  133923. * @param options defines the options used to create the mesh
  133924. * @param scene defines the hosting scene
  133925. * @returns the box mesh
  133926. */
  133927. static CreateTiledBox(name: string, options: {
  133928. pattern?: number;
  133929. width?: number;
  133930. height?: number;
  133931. depth?: number;
  133932. tileSize?: number;
  133933. tileWidth?: number;
  133934. tileHeight?: number;
  133935. alignHorizontal?: number;
  133936. alignVertical?: number;
  133937. faceUV?: Vector4[];
  133938. faceColors?: Color4[];
  133939. sideOrientation?: number;
  133940. updatable?: boolean;
  133941. }, scene?: Nullable<Scene>): Mesh;
  133942. }
  133943. }
  133944. declare module BABYLON {
  133945. /**
  133946. * Class containing static functions to help procedurally build meshes
  133947. */
  133948. export class TorusKnotBuilder {
  133949. /**
  133950. * Creates a torus knot mesh
  133951. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133952. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133953. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133954. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133958. * @param name defines the name of the mesh
  133959. * @param options defines the options used to create the mesh
  133960. * @param scene defines the hosting scene
  133961. * @returns the torus knot mesh
  133962. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133963. */
  133964. static CreateTorusKnot(name: string, options: {
  133965. radius?: number;
  133966. tube?: number;
  133967. radialSegments?: number;
  133968. tubularSegments?: number;
  133969. p?: number;
  133970. q?: number;
  133971. updatable?: boolean;
  133972. sideOrientation?: number;
  133973. frontUVs?: Vector4;
  133974. backUVs?: Vector4;
  133975. }, scene: any): Mesh;
  133976. }
  133977. }
  133978. declare module BABYLON {
  133979. /**
  133980. * Polygon
  133981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133982. */
  133983. export class Polygon {
  133984. /**
  133985. * Creates a rectangle
  133986. * @param xmin bottom X coord
  133987. * @param ymin bottom Y coord
  133988. * @param xmax top X coord
  133989. * @param ymax top Y coord
  133990. * @returns points that make the resulting rectation
  133991. */
  133992. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133993. /**
  133994. * Creates a circle
  133995. * @param radius radius of circle
  133996. * @param cx scale in x
  133997. * @param cy scale in y
  133998. * @param numberOfSides number of sides that make up the circle
  133999. * @returns points that make the resulting circle
  134000. */
  134001. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134002. /**
  134003. * Creates a polygon from input string
  134004. * @param input Input polygon data
  134005. * @returns the parsed points
  134006. */
  134007. static Parse(input: string): Vector2[];
  134008. /**
  134009. * Starts building a polygon from x and y coordinates
  134010. * @param x x coordinate
  134011. * @param y y coordinate
  134012. * @returns the started path2
  134013. */
  134014. static StartingAt(x: number, y: number): Path2;
  134015. }
  134016. /**
  134017. * Builds a polygon
  134018. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134019. */
  134020. export class PolygonMeshBuilder {
  134021. private _points;
  134022. private _outlinepoints;
  134023. private _holes;
  134024. private _name;
  134025. private _scene;
  134026. private _epoints;
  134027. private _eholes;
  134028. private _addToepoint;
  134029. /**
  134030. * Babylon reference to the earcut plugin.
  134031. */
  134032. bjsEarcut: any;
  134033. /**
  134034. * Creates a PolygonMeshBuilder
  134035. * @param name name of the builder
  134036. * @param contours Path of the polygon
  134037. * @param scene scene to add to when creating the mesh
  134038. * @param earcutInjection can be used to inject your own earcut reference
  134039. */
  134040. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134041. /**
  134042. * Adds a whole within the polygon
  134043. * @param hole Array of points defining the hole
  134044. * @returns this
  134045. */
  134046. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134047. /**
  134048. * Creates the polygon
  134049. * @param updatable If the mesh should be updatable
  134050. * @param depth The depth of the mesh created
  134051. * @returns the created mesh
  134052. */
  134053. build(updatable?: boolean, depth?: number): Mesh;
  134054. /**
  134055. * Creates the polygon
  134056. * @param depth The depth of the mesh created
  134057. * @returns the created VertexData
  134058. */
  134059. buildVertexData(depth?: number): VertexData;
  134060. /**
  134061. * Adds a side to the polygon
  134062. * @param positions points that make the polygon
  134063. * @param normals normals of the polygon
  134064. * @param uvs uvs of the polygon
  134065. * @param indices indices of the polygon
  134066. * @param bounds bounds of the polygon
  134067. * @param points points of the polygon
  134068. * @param depth depth of the polygon
  134069. * @param flip flip of the polygon
  134070. */
  134071. private addSide;
  134072. }
  134073. }
  134074. declare module BABYLON {
  134075. /**
  134076. * Class containing static functions to help procedurally build meshes
  134077. */
  134078. export class PolygonBuilder {
  134079. /**
  134080. * Creates a polygon mesh
  134081. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134082. * * 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
  134083. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134086. * * Remember you can only change the shape positions, not their number when updating a polygon
  134087. * @param name defines the name of the mesh
  134088. * @param options defines the options used to create the mesh
  134089. * @param scene defines the hosting scene
  134090. * @param earcutInjection can be used to inject your own earcut reference
  134091. * @returns the polygon mesh
  134092. */
  134093. static CreatePolygon(name: string, options: {
  134094. shape: Vector3[];
  134095. holes?: Vector3[][];
  134096. depth?: number;
  134097. faceUV?: Vector4[];
  134098. faceColors?: Color4[];
  134099. updatable?: boolean;
  134100. sideOrientation?: number;
  134101. frontUVs?: Vector4;
  134102. backUVs?: Vector4;
  134103. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134104. /**
  134105. * Creates an extruded polygon mesh, with depth in the Y direction.
  134106. * * 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)
  134107. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134108. * @param name defines the name of the mesh
  134109. * @param options defines the options used to create the mesh
  134110. * @param scene defines the hosting scene
  134111. * @param earcutInjection can be used to inject your own earcut reference
  134112. * @returns the polygon mesh
  134113. */
  134114. static ExtrudePolygon(name: string, options: {
  134115. shape: Vector3[];
  134116. holes?: Vector3[][];
  134117. depth?: number;
  134118. faceUV?: Vector4[];
  134119. faceColors?: Color4[];
  134120. updatable?: boolean;
  134121. sideOrientation?: number;
  134122. frontUVs?: Vector4;
  134123. backUVs?: Vector4;
  134124. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134125. }
  134126. }
  134127. declare module BABYLON {
  134128. /**
  134129. * Class containing static functions to help procedurally build meshes
  134130. */
  134131. export class LatheBuilder {
  134132. /**
  134133. * Creates lathe mesh.
  134134. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134135. * * 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
  134136. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134137. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134138. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134139. * * 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
  134140. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134141. * * 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
  134142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134146. * @param name defines the name of the mesh
  134147. * @param options defines the options used to create the mesh
  134148. * @param scene defines the hosting scene
  134149. * @returns the lathe mesh
  134150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134151. */
  134152. static CreateLathe(name: string, options: {
  134153. shape: Vector3[];
  134154. radius?: number;
  134155. tessellation?: number;
  134156. clip?: number;
  134157. arc?: number;
  134158. closed?: boolean;
  134159. updatable?: boolean;
  134160. sideOrientation?: number;
  134161. frontUVs?: Vector4;
  134162. backUVs?: Vector4;
  134163. cap?: number;
  134164. invertUV?: boolean;
  134165. }, scene?: Nullable<Scene>): Mesh;
  134166. }
  134167. }
  134168. declare module BABYLON {
  134169. /**
  134170. * Class containing static functions to help procedurally build meshes
  134171. */
  134172. export class TiledPlaneBuilder {
  134173. /**
  134174. * Creates a tiled plane mesh
  134175. * * The parameter `pattern` will, depending on value, do nothing or
  134176. * * * flip (reflect about central vertical) alternate tiles across and up
  134177. * * * flip every tile on alternate rows
  134178. * * * rotate (180 degs) alternate tiles across and up
  134179. * * * rotate every tile on alternate rows
  134180. * * * flip and rotate alternate tiles across and up
  134181. * * * flip and rotate every tile on alternate rows
  134182. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134183. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134186. * * 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)
  134187. * * 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)
  134188. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134189. * @param name defines the name of the mesh
  134190. * @param options defines the options used to create the mesh
  134191. * @param scene defines the hosting scene
  134192. * @returns the box mesh
  134193. */
  134194. static CreateTiledPlane(name: string, options: {
  134195. pattern?: number;
  134196. tileSize?: number;
  134197. tileWidth?: number;
  134198. tileHeight?: number;
  134199. size?: number;
  134200. width?: number;
  134201. height?: number;
  134202. alignHorizontal?: number;
  134203. alignVertical?: number;
  134204. sideOrientation?: number;
  134205. frontUVs?: Vector4;
  134206. backUVs?: Vector4;
  134207. updatable?: boolean;
  134208. }, scene?: Nullable<Scene>): Mesh;
  134209. }
  134210. }
  134211. declare module BABYLON {
  134212. /**
  134213. * Class containing static functions to help procedurally build meshes
  134214. */
  134215. export class TubeBuilder {
  134216. /**
  134217. * Creates a tube mesh.
  134218. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134219. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134220. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134221. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134222. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134223. * * 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)
  134224. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134225. * * 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
  134226. * * 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
  134227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134229. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134231. * @param name defines the name of the mesh
  134232. * @param options defines the options used to create the mesh
  134233. * @param scene defines the hosting scene
  134234. * @returns the tube mesh
  134235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134236. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134237. */
  134238. static CreateTube(name: string, options: {
  134239. path: Vector3[];
  134240. radius?: number;
  134241. tessellation?: number;
  134242. radiusFunction?: {
  134243. (i: number, distance: number): number;
  134244. };
  134245. cap?: number;
  134246. arc?: number;
  134247. updatable?: boolean;
  134248. sideOrientation?: number;
  134249. frontUVs?: Vector4;
  134250. backUVs?: Vector4;
  134251. instance?: Mesh;
  134252. invertUV?: boolean;
  134253. }, scene?: Nullable<Scene>): Mesh;
  134254. }
  134255. }
  134256. declare module BABYLON {
  134257. /**
  134258. * Class containing static functions to help procedurally build meshes
  134259. */
  134260. export class IcoSphereBuilder {
  134261. /**
  134262. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134263. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134264. * * 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`)
  134265. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134266. * * 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
  134267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134270. * @param name defines the name of the mesh
  134271. * @param options defines the options used to create the mesh
  134272. * @param scene defines the hosting scene
  134273. * @returns the icosahedron mesh
  134274. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134275. */
  134276. static CreateIcoSphere(name: string, options: {
  134277. radius?: number;
  134278. radiusX?: number;
  134279. radiusY?: number;
  134280. radiusZ?: number;
  134281. flat?: boolean;
  134282. subdivisions?: number;
  134283. sideOrientation?: number;
  134284. frontUVs?: Vector4;
  134285. backUVs?: Vector4;
  134286. updatable?: boolean;
  134287. }, scene?: Nullable<Scene>): Mesh;
  134288. }
  134289. }
  134290. declare module BABYLON {
  134291. /**
  134292. * Class containing static functions to help procedurally build meshes
  134293. */
  134294. export class DecalBuilder {
  134295. /**
  134296. * Creates a decal mesh.
  134297. * 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
  134298. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134299. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134300. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134301. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134302. * @param name defines the name of the mesh
  134303. * @param sourceMesh defines the mesh where the decal must be applied
  134304. * @param options defines the options used to create the mesh
  134305. * @param scene defines the hosting scene
  134306. * @returns the decal mesh
  134307. * @see https://doc.babylonjs.com/how_to/decals
  134308. */
  134309. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134310. position?: Vector3;
  134311. normal?: Vector3;
  134312. size?: Vector3;
  134313. angle?: number;
  134314. }): Mesh;
  134315. }
  134316. }
  134317. declare module BABYLON {
  134318. /**
  134319. * Class containing static functions to help procedurally build meshes
  134320. */
  134321. export class MeshBuilder {
  134322. /**
  134323. * Creates a box mesh
  134324. * * The parameter `size` sets the size (float) of each box side (default 1)
  134325. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134326. * * 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)
  134327. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134331. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134332. * @param name defines the name of the mesh
  134333. * @param options defines the options used to create the mesh
  134334. * @param scene defines the hosting scene
  134335. * @returns the box mesh
  134336. */
  134337. static CreateBox(name: string, options: {
  134338. size?: number;
  134339. width?: number;
  134340. height?: number;
  134341. depth?: number;
  134342. faceUV?: Vector4[];
  134343. faceColors?: Color4[];
  134344. sideOrientation?: number;
  134345. frontUVs?: Vector4;
  134346. backUVs?: Vector4;
  134347. updatable?: boolean;
  134348. }, scene?: Nullable<Scene>): Mesh;
  134349. /**
  134350. * Creates a tiled box mesh
  134351. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134353. * @param name defines the name of the mesh
  134354. * @param options defines the options used to create the mesh
  134355. * @param scene defines the hosting scene
  134356. * @returns the tiled box mesh
  134357. */
  134358. static CreateTiledBox(name: string, options: {
  134359. pattern?: number;
  134360. size?: number;
  134361. width?: number;
  134362. height?: number;
  134363. depth: number;
  134364. tileSize?: number;
  134365. tileWidth?: number;
  134366. tileHeight?: number;
  134367. faceUV?: Vector4[];
  134368. faceColors?: Color4[];
  134369. alignHorizontal?: number;
  134370. alignVertical?: number;
  134371. sideOrientation?: number;
  134372. updatable?: boolean;
  134373. }, scene?: Nullable<Scene>): Mesh;
  134374. /**
  134375. * Creates a sphere mesh
  134376. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134377. * * 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`)
  134378. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134379. * * 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
  134380. * * 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)
  134381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134384. * @param name defines the name of the mesh
  134385. * @param options defines the options used to create the mesh
  134386. * @param scene defines the hosting scene
  134387. * @returns the sphere mesh
  134388. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134389. */
  134390. static CreateSphere(name: string, options: {
  134391. segments?: number;
  134392. diameter?: number;
  134393. diameterX?: number;
  134394. diameterY?: number;
  134395. diameterZ?: number;
  134396. arc?: number;
  134397. slice?: number;
  134398. sideOrientation?: number;
  134399. frontUVs?: Vector4;
  134400. backUVs?: Vector4;
  134401. updatable?: boolean;
  134402. }, scene?: Nullable<Scene>): Mesh;
  134403. /**
  134404. * Creates a plane polygonal mesh. By default, this is a disc
  134405. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134406. * * 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
  134407. * * 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
  134408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134411. * @param name defines the name of the mesh
  134412. * @param options defines the options used to create the mesh
  134413. * @param scene defines the hosting scene
  134414. * @returns the plane polygonal mesh
  134415. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134416. */
  134417. static CreateDisc(name: string, options: {
  134418. radius?: number;
  134419. tessellation?: number;
  134420. arc?: number;
  134421. updatable?: boolean;
  134422. sideOrientation?: number;
  134423. frontUVs?: Vector4;
  134424. backUVs?: Vector4;
  134425. }, scene?: Nullable<Scene>): Mesh;
  134426. /**
  134427. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134428. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134429. * * 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`)
  134430. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134431. * * 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
  134432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134435. * @param name defines the name of the mesh
  134436. * @param options defines the options used to create the mesh
  134437. * @param scene defines the hosting scene
  134438. * @returns the icosahedron mesh
  134439. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134440. */
  134441. static CreateIcoSphere(name: string, options: {
  134442. radius?: number;
  134443. radiusX?: number;
  134444. radiusY?: number;
  134445. radiusZ?: number;
  134446. flat?: boolean;
  134447. subdivisions?: number;
  134448. sideOrientation?: number;
  134449. frontUVs?: Vector4;
  134450. backUVs?: Vector4;
  134451. updatable?: boolean;
  134452. }, scene?: Nullable<Scene>): Mesh;
  134453. /**
  134454. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134455. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134456. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134457. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134458. * * 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
  134459. * * 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
  134460. * * 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
  134461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134464. * * 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
  134465. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134466. * * 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
  134467. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134469. * @param name defines the name of the mesh
  134470. * @param options defines the options used to create the mesh
  134471. * @param scene defines the hosting scene
  134472. * @returns the ribbon mesh
  134473. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134475. */
  134476. static CreateRibbon(name: string, options: {
  134477. pathArray: Vector3[][];
  134478. closeArray?: boolean;
  134479. closePath?: boolean;
  134480. offset?: number;
  134481. updatable?: boolean;
  134482. sideOrientation?: number;
  134483. frontUVs?: Vector4;
  134484. backUVs?: Vector4;
  134485. instance?: Mesh;
  134486. invertUV?: boolean;
  134487. uvs?: Vector2[];
  134488. colors?: Color4[];
  134489. }, scene?: Nullable<Scene>): Mesh;
  134490. /**
  134491. * Creates a cylinder or a cone mesh
  134492. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134493. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134494. * * 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.
  134495. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134496. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134497. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134498. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134499. * * 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).
  134500. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134501. * * 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).
  134502. * * 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
  134503. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134504. * * 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
  134505. * * 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.
  134506. * * If `enclose` is false, a ring surface is one element.
  134507. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134508. * * 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
  134509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134512. * @param name defines the name of the mesh
  134513. * @param options defines the options used to create the mesh
  134514. * @param scene defines the hosting scene
  134515. * @returns the cylinder mesh
  134516. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134517. */
  134518. static CreateCylinder(name: string, options: {
  134519. height?: number;
  134520. diameterTop?: number;
  134521. diameterBottom?: number;
  134522. diameter?: number;
  134523. tessellation?: number;
  134524. subdivisions?: number;
  134525. arc?: number;
  134526. faceColors?: Color4[];
  134527. faceUV?: Vector4[];
  134528. updatable?: boolean;
  134529. hasRings?: boolean;
  134530. enclose?: boolean;
  134531. cap?: number;
  134532. sideOrientation?: number;
  134533. frontUVs?: Vector4;
  134534. backUVs?: Vector4;
  134535. }, scene?: Nullable<Scene>): Mesh;
  134536. /**
  134537. * Creates a torus mesh
  134538. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134539. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134540. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134544. * @param name defines the name of the mesh
  134545. * @param options defines the options used to create the mesh
  134546. * @param scene defines the hosting scene
  134547. * @returns the torus mesh
  134548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134549. */
  134550. static CreateTorus(name: string, options: {
  134551. diameter?: number;
  134552. thickness?: number;
  134553. tessellation?: number;
  134554. updatable?: boolean;
  134555. sideOrientation?: number;
  134556. frontUVs?: Vector4;
  134557. backUVs?: Vector4;
  134558. }, scene?: Nullable<Scene>): Mesh;
  134559. /**
  134560. * Creates a torus knot mesh
  134561. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134562. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134563. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134564. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134568. * @param name defines the name of the mesh
  134569. * @param options defines the options used to create the mesh
  134570. * @param scene defines the hosting scene
  134571. * @returns the torus knot mesh
  134572. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134573. */
  134574. static CreateTorusKnot(name: string, options: {
  134575. radius?: number;
  134576. tube?: number;
  134577. radialSegments?: number;
  134578. tubularSegments?: number;
  134579. p?: number;
  134580. q?: number;
  134581. updatable?: boolean;
  134582. sideOrientation?: number;
  134583. frontUVs?: Vector4;
  134584. backUVs?: Vector4;
  134585. }, scene?: Nullable<Scene>): Mesh;
  134586. /**
  134587. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134588. * * 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
  134589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134590. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134591. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134592. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134593. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134594. * * 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
  134595. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134598. * @param name defines the name of the new line system
  134599. * @param options defines the options used to create the line system
  134600. * @param scene defines the hosting scene
  134601. * @returns a new line system mesh
  134602. */
  134603. static CreateLineSystem(name: string, options: {
  134604. lines: Vector3[][];
  134605. updatable?: boolean;
  134606. instance?: Nullable<LinesMesh>;
  134607. colors?: Nullable<Color4[][]>;
  134608. useVertexAlpha?: boolean;
  134609. }, scene: Nullable<Scene>): LinesMesh;
  134610. /**
  134611. * Creates a line mesh
  134612. * 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
  134613. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134614. * * The parameter `points` is an array successive Vector3
  134615. * * 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
  134616. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134617. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134618. * * When updating an instance, remember that only point positions can change, not the number of points
  134619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134621. * @param name defines the name of the new line system
  134622. * @param options defines the options used to create the line system
  134623. * @param scene defines the hosting scene
  134624. * @returns a new line mesh
  134625. */
  134626. static CreateLines(name: string, options: {
  134627. points: Vector3[];
  134628. updatable?: boolean;
  134629. instance?: Nullable<LinesMesh>;
  134630. colors?: Color4[];
  134631. useVertexAlpha?: boolean;
  134632. }, scene?: Nullable<Scene>): LinesMesh;
  134633. /**
  134634. * Creates a dashed line mesh
  134635. * * 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
  134636. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134637. * * The parameter `points` is an array successive Vector3
  134638. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134639. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134640. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134641. * * 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
  134642. * * When updating an instance, remember that only point positions can change, not the number of points
  134643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134644. * @param name defines the name of the mesh
  134645. * @param options defines the options used to create the mesh
  134646. * @param scene defines the hosting scene
  134647. * @returns the dashed line mesh
  134648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134649. */
  134650. static CreateDashedLines(name: string, options: {
  134651. points: Vector3[];
  134652. dashSize?: number;
  134653. gapSize?: number;
  134654. dashNb?: number;
  134655. updatable?: boolean;
  134656. instance?: LinesMesh;
  134657. }, scene?: Nullable<Scene>): LinesMesh;
  134658. /**
  134659. * 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.
  134660. * * 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.
  134661. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134662. * * 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.
  134663. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134664. * * 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
  134665. * * 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
  134666. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134671. * @param name defines the name of the mesh
  134672. * @param options defines the options used to create the mesh
  134673. * @param scene defines the hosting scene
  134674. * @returns the extruded shape mesh
  134675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134677. */
  134678. static ExtrudeShape(name: string, options: {
  134679. shape: Vector3[];
  134680. path: Vector3[];
  134681. scale?: number;
  134682. rotation?: number;
  134683. cap?: number;
  134684. updatable?: boolean;
  134685. sideOrientation?: number;
  134686. frontUVs?: Vector4;
  134687. backUVs?: Vector4;
  134688. instance?: Mesh;
  134689. invertUV?: boolean;
  134690. }, scene?: Nullable<Scene>): Mesh;
  134691. /**
  134692. * Creates an custom extruded shape mesh.
  134693. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134694. * * 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.
  134695. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134696. * * 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
  134697. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134698. * * 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
  134699. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134700. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134701. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134702. * * 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
  134703. * * 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
  134704. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134709. * @param name defines the name of the mesh
  134710. * @param options defines the options used to create the mesh
  134711. * @param scene defines the hosting scene
  134712. * @returns the custom extruded shape mesh
  134713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134716. */
  134717. static ExtrudeShapeCustom(name: string, options: {
  134718. shape: Vector3[];
  134719. path: Vector3[];
  134720. scaleFunction?: any;
  134721. rotationFunction?: any;
  134722. ribbonCloseArray?: boolean;
  134723. ribbonClosePath?: boolean;
  134724. cap?: number;
  134725. updatable?: boolean;
  134726. sideOrientation?: number;
  134727. frontUVs?: Vector4;
  134728. backUVs?: Vector4;
  134729. instance?: Mesh;
  134730. invertUV?: boolean;
  134731. }, scene?: Nullable<Scene>): Mesh;
  134732. /**
  134733. * Creates lathe mesh.
  134734. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134735. * * 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
  134736. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134737. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134738. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134739. * * 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
  134740. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134741. * * 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
  134742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134746. * @param name defines the name of the mesh
  134747. * @param options defines the options used to create the mesh
  134748. * @param scene defines the hosting scene
  134749. * @returns the lathe mesh
  134750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134751. */
  134752. static CreateLathe(name: string, options: {
  134753. shape: Vector3[];
  134754. radius?: number;
  134755. tessellation?: number;
  134756. clip?: number;
  134757. arc?: number;
  134758. closed?: boolean;
  134759. updatable?: boolean;
  134760. sideOrientation?: number;
  134761. frontUVs?: Vector4;
  134762. backUVs?: Vector4;
  134763. cap?: number;
  134764. invertUV?: boolean;
  134765. }, scene?: Nullable<Scene>): Mesh;
  134766. /**
  134767. * Creates a tiled plane mesh
  134768. * * You can set a limited pattern arrangement with the tiles
  134769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134772. * @param name defines the name of the mesh
  134773. * @param options defines the options used to create the mesh
  134774. * @param scene defines the hosting scene
  134775. * @returns the plane mesh
  134776. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134777. */
  134778. static CreateTiledPlane(name: string, options: {
  134779. pattern?: number;
  134780. tileSize?: number;
  134781. tileWidth?: number;
  134782. tileHeight?: number;
  134783. size?: number;
  134784. width?: number;
  134785. height?: number;
  134786. alignHorizontal?: number;
  134787. alignVertical?: number;
  134788. sideOrientation?: number;
  134789. frontUVs?: Vector4;
  134790. backUVs?: Vector4;
  134791. updatable?: boolean;
  134792. }, scene?: Nullable<Scene>): Mesh;
  134793. /**
  134794. * Creates a plane mesh
  134795. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134796. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134797. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134801. * @param name defines the name of the mesh
  134802. * @param options defines the options used to create the mesh
  134803. * @param scene defines the hosting scene
  134804. * @returns the plane mesh
  134805. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134806. */
  134807. static CreatePlane(name: string, options: {
  134808. size?: number;
  134809. width?: number;
  134810. height?: number;
  134811. sideOrientation?: number;
  134812. frontUVs?: Vector4;
  134813. backUVs?: Vector4;
  134814. updatable?: boolean;
  134815. sourcePlane?: Plane;
  134816. }, scene?: Nullable<Scene>): Mesh;
  134817. /**
  134818. * Creates a ground mesh
  134819. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134820. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134822. * @param name defines the name of the mesh
  134823. * @param options defines the options used to create the mesh
  134824. * @param scene defines the hosting scene
  134825. * @returns the ground mesh
  134826. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134827. */
  134828. static CreateGround(name: string, options: {
  134829. width?: number;
  134830. height?: number;
  134831. subdivisions?: number;
  134832. subdivisionsX?: number;
  134833. subdivisionsY?: number;
  134834. updatable?: boolean;
  134835. }, scene?: Nullable<Scene>): Mesh;
  134836. /**
  134837. * Creates a tiled ground mesh
  134838. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134839. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134840. * * 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
  134841. * * 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
  134842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134843. * @param name defines the name of the mesh
  134844. * @param options defines the options used to create the mesh
  134845. * @param scene defines the hosting scene
  134846. * @returns the tiled ground mesh
  134847. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134848. */
  134849. static CreateTiledGround(name: string, options: {
  134850. xmin: number;
  134851. zmin: number;
  134852. xmax: number;
  134853. zmax: number;
  134854. subdivisions?: {
  134855. w: number;
  134856. h: number;
  134857. };
  134858. precision?: {
  134859. w: number;
  134860. h: number;
  134861. };
  134862. updatable?: boolean;
  134863. }, scene?: Nullable<Scene>): Mesh;
  134864. /**
  134865. * Creates a ground mesh from a height map
  134866. * * The parameter `url` sets the URL of the height map image resource.
  134867. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134868. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134869. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134870. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134871. * * 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.
  134872. * * 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).
  134873. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134875. * @param name defines the name of the mesh
  134876. * @param url defines the url to the height map
  134877. * @param options defines the options used to create the mesh
  134878. * @param scene defines the hosting scene
  134879. * @returns the ground mesh
  134880. * @see https://doc.babylonjs.com/babylon101/height_map
  134881. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134882. */
  134883. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134884. width?: number;
  134885. height?: number;
  134886. subdivisions?: number;
  134887. minHeight?: number;
  134888. maxHeight?: number;
  134889. colorFilter?: Color3;
  134890. alphaFilter?: number;
  134891. updatable?: boolean;
  134892. onReady?: (mesh: GroundMesh) => void;
  134893. }, scene?: Nullable<Scene>): GroundMesh;
  134894. /**
  134895. * Creates a polygon mesh
  134896. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134897. * * 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
  134898. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134901. * * Remember you can only change the shape positions, not their number when updating a polygon
  134902. * @param name defines the name of the mesh
  134903. * @param options defines the options used to create the mesh
  134904. * @param scene defines the hosting scene
  134905. * @param earcutInjection can be used to inject your own earcut reference
  134906. * @returns the polygon mesh
  134907. */
  134908. static CreatePolygon(name: string, options: {
  134909. shape: Vector3[];
  134910. holes?: Vector3[][];
  134911. depth?: number;
  134912. faceUV?: Vector4[];
  134913. faceColors?: Color4[];
  134914. updatable?: boolean;
  134915. sideOrientation?: number;
  134916. frontUVs?: Vector4;
  134917. backUVs?: Vector4;
  134918. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134919. /**
  134920. * Creates an extruded polygon mesh, with depth in the Y direction.
  134921. * * 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)
  134922. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134923. * @param name defines the name of the mesh
  134924. * @param options defines the options used to create the mesh
  134925. * @param scene defines the hosting scene
  134926. * @param earcutInjection can be used to inject your own earcut reference
  134927. * @returns the polygon mesh
  134928. */
  134929. static ExtrudePolygon(name: string, options: {
  134930. shape: Vector3[];
  134931. holes?: Vector3[][];
  134932. depth?: number;
  134933. faceUV?: Vector4[];
  134934. faceColors?: Color4[];
  134935. updatable?: boolean;
  134936. sideOrientation?: number;
  134937. frontUVs?: Vector4;
  134938. backUVs?: Vector4;
  134939. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134940. /**
  134941. * Creates a tube mesh.
  134942. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134943. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134944. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134945. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134946. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134947. * * 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)
  134948. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134949. * * 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
  134950. * * 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
  134951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134953. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134955. * @param name defines the name of the mesh
  134956. * @param options defines the options used to create the mesh
  134957. * @param scene defines the hosting scene
  134958. * @returns the tube mesh
  134959. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134960. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134961. */
  134962. static CreateTube(name: string, options: {
  134963. path: Vector3[];
  134964. radius?: number;
  134965. tessellation?: number;
  134966. radiusFunction?: {
  134967. (i: number, distance: number): number;
  134968. };
  134969. cap?: number;
  134970. arc?: number;
  134971. updatable?: boolean;
  134972. sideOrientation?: number;
  134973. frontUVs?: Vector4;
  134974. backUVs?: Vector4;
  134975. instance?: Mesh;
  134976. invertUV?: boolean;
  134977. }, scene?: Nullable<Scene>): Mesh;
  134978. /**
  134979. * Creates a polyhedron mesh
  134980. * * 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
  134981. * * The parameter `size` (positive float, default 1) sets the polygon size
  134982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134983. * * 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`
  134984. * * 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
  134985. * * 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)`)
  134986. * * 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
  134987. * * 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
  134988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134991. * @param name defines the name of the mesh
  134992. * @param options defines the options used to create the mesh
  134993. * @param scene defines the hosting scene
  134994. * @returns the polyhedron mesh
  134995. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134996. */
  134997. static CreatePolyhedron(name: string, options: {
  134998. type?: number;
  134999. size?: number;
  135000. sizeX?: number;
  135001. sizeY?: number;
  135002. sizeZ?: number;
  135003. custom?: any;
  135004. faceUV?: Vector4[];
  135005. faceColors?: Color4[];
  135006. flat?: boolean;
  135007. updatable?: boolean;
  135008. sideOrientation?: number;
  135009. frontUVs?: Vector4;
  135010. backUVs?: Vector4;
  135011. }, scene?: Nullable<Scene>): Mesh;
  135012. /**
  135013. * Creates a decal mesh.
  135014. * 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
  135015. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135016. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135017. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135018. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135019. * @param name defines the name of the mesh
  135020. * @param sourceMesh defines the mesh where the decal must be applied
  135021. * @param options defines the options used to create the mesh
  135022. * @param scene defines the hosting scene
  135023. * @returns the decal mesh
  135024. * @see https://doc.babylonjs.com/how_to/decals
  135025. */
  135026. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135027. position?: Vector3;
  135028. normal?: Vector3;
  135029. size?: Vector3;
  135030. angle?: number;
  135031. }): Mesh;
  135032. }
  135033. }
  135034. declare module BABYLON {
  135035. /**
  135036. * A simplifier interface for future simplification implementations
  135037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135038. */
  135039. export interface ISimplifier {
  135040. /**
  135041. * Simplification of a given mesh according to the given settings.
  135042. * Since this requires computation, it is assumed that the function runs async.
  135043. * @param settings The settings of the simplification, including quality and distance
  135044. * @param successCallback A callback that will be called after the mesh was simplified.
  135045. * @param errorCallback in case of an error, this callback will be called. optional.
  135046. */
  135047. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135048. }
  135049. /**
  135050. * Expected simplification settings.
  135051. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135052. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135053. */
  135054. export interface ISimplificationSettings {
  135055. /**
  135056. * Gets or sets the expected quality
  135057. */
  135058. quality: number;
  135059. /**
  135060. * Gets or sets the distance when this optimized version should be used
  135061. */
  135062. distance: number;
  135063. /**
  135064. * Gets an already optimized mesh
  135065. */
  135066. optimizeMesh?: boolean;
  135067. }
  135068. /**
  135069. * Class used to specify simplification options
  135070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135071. */
  135072. export class SimplificationSettings implements ISimplificationSettings {
  135073. /** expected quality */
  135074. quality: number;
  135075. /** distance when this optimized version should be used */
  135076. distance: number;
  135077. /** already optimized mesh */
  135078. optimizeMesh?: boolean | undefined;
  135079. /**
  135080. * Creates a SimplificationSettings
  135081. * @param quality expected quality
  135082. * @param distance distance when this optimized version should be used
  135083. * @param optimizeMesh already optimized mesh
  135084. */
  135085. constructor(
  135086. /** expected quality */
  135087. quality: number,
  135088. /** distance when this optimized version should be used */
  135089. distance: number,
  135090. /** already optimized mesh */
  135091. optimizeMesh?: boolean | undefined);
  135092. }
  135093. /**
  135094. * Interface used to define a simplification task
  135095. */
  135096. export interface ISimplificationTask {
  135097. /**
  135098. * Array of settings
  135099. */
  135100. settings: Array<ISimplificationSettings>;
  135101. /**
  135102. * Simplification type
  135103. */
  135104. simplificationType: SimplificationType;
  135105. /**
  135106. * Mesh to simplify
  135107. */
  135108. mesh: Mesh;
  135109. /**
  135110. * Callback called on success
  135111. */
  135112. successCallback?: () => void;
  135113. /**
  135114. * Defines if parallel processing can be used
  135115. */
  135116. parallelProcessing: boolean;
  135117. }
  135118. /**
  135119. * Queue used to order the simplification tasks
  135120. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135121. */
  135122. export class SimplificationQueue {
  135123. private _simplificationArray;
  135124. /**
  135125. * Gets a boolean indicating that the process is still running
  135126. */
  135127. running: boolean;
  135128. /**
  135129. * Creates a new queue
  135130. */
  135131. constructor();
  135132. /**
  135133. * Adds a new simplification task
  135134. * @param task defines a task to add
  135135. */
  135136. addTask(task: ISimplificationTask): void;
  135137. /**
  135138. * Execute next task
  135139. */
  135140. executeNext(): void;
  135141. /**
  135142. * Execute a simplification task
  135143. * @param task defines the task to run
  135144. */
  135145. runSimplification(task: ISimplificationTask): void;
  135146. private getSimplifier;
  135147. }
  135148. /**
  135149. * The implemented types of simplification
  135150. * At the moment only Quadratic Error Decimation is implemented
  135151. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135152. */
  135153. export enum SimplificationType {
  135154. /** Quadratic error decimation */
  135155. QUADRATIC = 0
  135156. }
  135157. }
  135158. declare module BABYLON {
  135159. interface Scene {
  135160. /** @hidden (Backing field) */
  135161. _simplificationQueue: SimplificationQueue;
  135162. /**
  135163. * Gets or sets the simplification queue attached to the scene
  135164. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135165. */
  135166. simplificationQueue: SimplificationQueue;
  135167. }
  135168. interface Mesh {
  135169. /**
  135170. * Simplify the mesh according to the given array of settings.
  135171. * Function will return immediately and will simplify async
  135172. * @param settings a collection of simplification settings
  135173. * @param parallelProcessing should all levels calculate parallel or one after the other
  135174. * @param simplificationType the type of simplification to run
  135175. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135176. * @returns the current mesh
  135177. */
  135178. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135179. }
  135180. /**
  135181. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135182. * created in a scene
  135183. */
  135184. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135185. /**
  135186. * The component name helpfull to identify the component in the list of scene components.
  135187. */
  135188. readonly name: string;
  135189. /**
  135190. * The scene the component belongs to.
  135191. */
  135192. scene: Scene;
  135193. /**
  135194. * Creates a new instance of the component for the given scene
  135195. * @param scene Defines the scene to register the component in
  135196. */
  135197. constructor(scene: Scene);
  135198. /**
  135199. * Registers the component in a given scene
  135200. */
  135201. register(): void;
  135202. /**
  135203. * Rebuilds the elements related to this component in case of
  135204. * context lost for instance.
  135205. */
  135206. rebuild(): void;
  135207. /**
  135208. * Disposes the component and the associated ressources
  135209. */
  135210. dispose(): void;
  135211. private _beforeCameraUpdate;
  135212. }
  135213. }
  135214. declare module BABYLON {
  135215. /**
  135216. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135217. */
  135218. export interface INavigationEnginePlugin {
  135219. /**
  135220. * plugin name
  135221. */
  135222. name: string;
  135223. /**
  135224. * Creates a navigation mesh
  135225. * @param meshes array of all the geometry used to compute the navigatio mesh
  135226. * @param parameters bunch of parameters used to filter geometry
  135227. */
  135228. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135229. /**
  135230. * Create a navigation mesh debug mesh
  135231. * @param scene is where the mesh will be added
  135232. * @returns debug display mesh
  135233. */
  135234. createDebugNavMesh(scene: Scene): Mesh;
  135235. /**
  135236. * Get a navigation mesh constrained position, closest to the parameter position
  135237. * @param position world position
  135238. * @returns the closest point to position constrained by the navigation mesh
  135239. */
  135240. getClosestPoint(position: Vector3): Vector3;
  135241. /**
  135242. * Get a navigation mesh constrained position, within a particular radius
  135243. * @param position world position
  135244. * @param maxRadius the maximum distance to the constrained world position
  135245. * @returns the closest point to position constrained by the navigation mesh
  135246. */
  135247. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135248. /**
  135249. * Compute the final position from a segment made of destination-position
  135250. * @param position world position
  135251. * @param destination world position
  135252. * @returns the resulting point along the navmesh
  135253. */
  135254. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135255. /**
  135256. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135257. * @param start world position
  135258. * @param end world position
  135259. * @returns array containing world position composing the path
  135260. */
  135261. computePath(start: Vector3, end: Vector3): Vector3[];
  135262. /**
  135263. * If this plugin is supported
  135264. * @returns true if plugin is supported
  135265. */
  135266. isSupported(): boolean;
  135267. /**
  135268. * Create a new Crowd so you can add agents
  135269. * @param maxAgents the maximum agent count in the crowd
  135270. * @param maxAgentRadius the maximum radius an agent can have
  135271. * @param scene to attach the crowd to
  135272. * @returns the crowd you can add agents to
  135273. */
  135274. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135275. /**
  135276. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135277. * The queries will try to find a solution within those bounds
  135278. * default is (1,1,1)
  135279. * @param extent x,y,z value that define the extent around the queries point of reference
  135280. */
  135281. setDefaultQueryExtent(extent: Vector3): void;
  135282. /**
  135283. * Get the Bounding box extent specified by setDefaultQueryExtent
  135284. * @returns the box extent values
  135285. */
  135286. getDefaultQueryExtent(): Vector3;
  135287. /**
  135288. * Release all resources
  135289. */
  135290. dispose(): void;
  135291. }
  135292. /**
  135293. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135294. */
  135295. export interface ICrowd {
  135296. /**
  135297. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135298. * You can attach anything to that node. The node position is updated in the scene update tick.
  135299. * @param pos world position that will be constrained by the navigation mesh
  135300. * @param parameters agent parameters
  135301. * @param transform hooked to the agent that will be update by the scene
  135302. * @returns agent index
  135303. */
  135304. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135305. /**
  135306. * Returns the agent position in world space
  135307. * @param index agent index returned by addAgent
  135308. * @returns world space position
  135309. */
  135310. getAgentPosition(index: number): Vector3;
  135311. /**
  135312. * Gets the agent velocity in world space
  135313. * @param index agent index returned by addAgent
  135314. * @returns world space velocity
  135315. */
  135316. getAgentVelocity(index: number): Vector3;
  135317. /**
  135318. * remove a particular agent previously created
  135319. * @param index agent index returned by addAgent
  135320. */
  135321. removeAgent(index: number): void;
  135322. /**
  135323. * get the list of all agents attached to this crowd
  135324. * @returns list of agent indices
  135325. */
  135326. getAgents(): number[];
  135327. /**
  135328. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135329. * @param deltaTime in seconds
  135330. */
  135331. update(deltaTime: number): void;
  135332. /**
  135333. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135334. * @param index agent index returned by addAgent
  135335. * @param destination targeted world position
  135336. */
  135337. agentGoto(index: number, destination: Vector3): void;
  135338. /**
  135339. * Teleport the agent to a new position
  135340. * @param index agent index returned by addAgent
  135341. * @param destination targeted world position
  135342. */
  135343. agentTeleport(index: number, destination: Vector3): void;
  135344. /**
  135345. * Update agent parameters
  135346. * @param index agent index returned by addAgent
  135347. * @param parameters agent parameters
  135348. */
  135349. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135350. /**
  135351. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135352. * The queries will try to find a solution within those bounds
  135353. * default is (1,1,1)
  135354. * @param extent x,y,z value that define the extent around the queries point of reference
  135355. */
  135356. setDefaultQueryExtent(extent: Vector3): void;
  135357. /**
  135358. * Get the Bounding box extent specified by setDefaultQueryExtent
  135359. * @returns the box extent values
  135360. */
  135361. getDefaultQueryExtent(): Vector3;
  135362. /**
  135363. * Release all resources
  135364. */
  135365. dispose(): void;
  135366. }
  135367. /**
  135368. * Configures an agent
  135369. */
  135370. export interface IAgentParameters {
  135371. /**
  135372. * Agent radius. [Limit: >= 0]
  135373. */
  135374. radius: number;
  135375. /**
  135376. * Agent height. [Limit: > 0]
  135377. */
  135378. height: number;
  135379. /**
  135380. * Maximum allowed acceleration. [Limit: >= 0]
  135381. */
  135382. maxAcceleration: number;
  135383. /**
  135384. * Maximum allowed speed. [Limit: >= 0]
  135385. */
  135386. maxSpeed: number;
  135387. /**
  135388. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135389. */
  135390. collisionQueryRange: number;
  135391. /**
  135392. * The path visibility optimization range. [Limit: > 0]
  135393. */
  135394. pathOptimizationRange: number;
  135395. /**
  135396. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135397. */
  135398. separationWeight: number;
  135399. }
  135400. /**
  135401. * Configures the navigation mesh creation
  135402. */
  135403. export interface INavMeshParameters {
  135404. /**
  135405. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135406. */
  135407. cs: number;
  135408. /**
  135409. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135410. */
  135411. ch: number;
  135412. /**
  135413. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135414. */
  135415. walkableSlopeAngle: number;
  135416. /**
  135417. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135418. * be considered walkable. [Limit: >= 3] [Units: vx]
  135419. */
  135420. walkableHeight: number;
  135421. /**
  135422. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135423. */
  135424. walkableClimb: number;
  135425. /**
  135426. * The distance to erode/shrink the walkable area of the heightfield away from
  135427. * obstructions. [Limit: >=0] [Units: vx]
  135428. */
  135429. walkableRadius: number;
  135430. /**
  135431. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135432. */
  135433. maxEdgeLen: number;
  135434. /**
  135435. * The maximum distance a simplfied contour's border edges should deviate
  135436. * the original raw contour. [Limit: >=0] [Units: vx]
  135437. */
  135438. maxSimplificationError: number;
  135439. /**
  135440. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135441. */
  135442. minRegionArea: number;
  135443. /**
  135444. * Any regions with a span count smaller than this value will, if possible,
  135445. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135446. */
  135447. mergeRegionArea: number;
  135448. /**
  135449. * The maximum number of vertices allowed for polygons generated during the
  135450. * contour to polygon conversion process. [Limit: >= 3]
  135451. */
  135452. maxVertsPerPoly: number;
  135453. /**
  135454. * Sets the sampling distance to use when generating the detail mesh.
  135455. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135456. */
  135457. detailSampleDist: number;
  135458. /**
  135459. * The maximum distance the detail mesh surface should deviate from heightfield
  135460. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135461. */
  135462. detailSampleMaxError: number;
  135463. }
  135464. }
  135465. declare module BABYLON {
  135466. /**
  135467. * RecastJS navigation plugin
  135468. */
  135469. export class RecastJSPlugin implements INavigationEnginePlugin {
  135470. /**
  135471. * Reference to the Recast library
  135472. */
  135473. bjsRECAST: any;
  135474. /**
  135475. * plugin name
  135476. */
  135477. name: string;
  135478. /**
  135479. * the first navmesh created. We might extend this to support multiple navmeshes
  135480. */
  135481. navMesh: any;
  135482. /**
  135483. * Initializes the recastJS plugin
  135484. * @param recastInjection can be used to inject your own recast reference
  135485. */
  135486. constructor(recastInjection?: any);
  135487. /**
  135488. * Creates a navigation mesh
  135489. * @param meshes array of all the geometry used to compute the navigatio mesh
  135490. * @param parameters bunch of parameters used to filter geometry
  135491. */
  135492. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135493. /**
  135494. * Create a navigation mesh debug mesh
  135495. * @param scene is where the mesh will be added
  135496. * @returns debug display mesh
  135497. */
  135498. createDebugNavMesh(scene: Scene): Mesh;
  135499. /**
  135500. * Get a navigation mesh constrained position, closest to the parameter position
  135501. * @param position world position
  135502. * @returns the closest point to position constrained by the navigation mesh
  135503. */
  135504. getClosestPoint(position: Vector3): Vector3;
  135505. /**
  135506. * Get a navigation mesh constrained position, within a particular radius
  135507. * @param position world position
  135508. * @param maxRadius the maximum distance to the constrained world position
  135509. * @returns the closest point to position constrained by the navigation mesh
  135510. */
  135511. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135512. /**
  135513. * Compute the final position from a segment made of destination-position
  135514. * @param position world position
  135515. * @param destination world position
  135516. * @returns the resulting point along the navmesh
  135517. */
  135518. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135519. /**
  135520. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135521. * @param start world position
  135522. * @param end world position
  135523. * @returns array containing world position composing the path
  135524. */
  135525. computePath(start: Vector3, end: Vector3): Vector3[];
  135526. /**
  135527. * Create a new Crowd so you can add agents
  135528. * @param maxAgents the maximum agent count in the crowd
  135529. * @param maxAgentRadius the maximum radius an agent can have
  135530. * @param scene to attach the crowd to
  135531. * @returns the crowd you can add agents to
  135532. */
  135533. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135534. /**
  135535. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135536. * The queries will try to find a solution within those bounds
  135537. * default is (1,1,1)
  135538. * @param extent x,y,z value that define the extent around the queries point of reference
  135539. */
  135540. setDefaultQueryExtent(extent: Vector3): void;
  135541. /**
  135542. * Get the Bounding box extent specified by setDefaultQueryExtent
  135543. * @returns the box extent values
  135544. */
  135545. getDefaultQueryExtent(): Vector3;
  135546. /**
  135547. * Disposes
  135548. */
  135549. dispose(): void;
  135550. /**
  135551. * If this plugin is supported
  135552. * @returns true if plugin is supported
  135553. */
  135554. isSupported(): boolean;
  135555. }
  135556. /**
  135557. * Recast detour crowd implementation
  135558. */
  135559. export class RecastJSCrowd implements ICrowd {
  135560. /**
  135561. * Recast/detour plugin
  135562. */
  135563. bjsRECASTPlugin: RecastJSPlugin;
  135564. /**
  135565. * Link to the detour crowd
  135566. */
  135567. recastCrowd: any;
  135568. /**
  135569. * One transform per agent
  135570. */
  135571. transforms: TransformNode[];
  135572. /**
  135573. * All agents created
  135574. */
  135575. agents: number[];
  135576. /**
  135577. * Link to the scene is kept to unregister the crowd from the scene
  135578. */
  135579. private _scene;
  135580. /**
  135581. * Observer for crowd updates
  135582. */
  135583. private _onBeforeAnimationsObserver;
  135584. /**
  135585. * Constructor
  135586. * @param plugin recastJS plugin
  135587. * @param maxAgents the maximum agent count in the crowd
  135588. * @param maxAgentRadius the maximum radius an agent can have
  135589. * @param scene to attach the crowd to
  135590. * @returns the crowd you can add agents to
  135591. */
  135592. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135593. /**
  135594. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135595. * You can attach anything to that node. The node position is updated in the scene update tick.
  135596. * @param pos world position that will be constrained by the navigation mesh
  135597. * @param parameters agent parameters
  135598. * @param transform hooked to the agent that will be update by the scene
  135599. * @returns agent index
  135600. */
  135601. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135602. /**
  135603. * Returns the agent position in world space
  135604. * @param index agent index returned by addAgent
  135605. * @returns world space position
  135606. */
  135607. getAgentPosition(index: number): Vector3;
  135608. /**
  135609. * Returns the agent velocity in world space
  135610. * @param index agent index returned by addAgent
  135611. * @returns world space velocity
  135612. */
  135613. getAgentVelocity(index: number): Vector3;
  135614. /**
  135615. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135616. * @param index agent index returned by addAgent
  135617. * @param destination targeted world position
  135618. */
  135619. agentGoto(index: number, destination: Vector3): void;
  135620. /**
  135621. * Teleport the agent to a new position
  135622. * @param index agent index returned by addAgent
  135623. * @param destination targeted world position
  135624. */
  135625. agentTeleport(index: number, destination: Vector3): void;
  135626. /**
  135627. * Update agent parameters
  135628. * @param index agent index returned by addAgent
  135629. * @param parameters agent parameters
  135630. */
  135631. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135632. /**
  135633. * remove a particular agent previously created
  135634. * @param index agent index returned by addAgent
  135635. */
  135636. removeAgent(index: number): void;
  135637. /**
  135638. * get the list of all agents attached to this crowd
  135639. * @returns list of agent indices
  135640. */
  135641. getAgents(): number[];
  135642. /**
  135643. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135644. * @param deltaTime in seconds
  135645. */
  135646. update(deltaTime: number): void;
  135647. /**
  135648. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135649. * The queries will try to find a solution within those bounds
  135650. * default is (1,1,1)
  135651. * @param extent x,y,z value that define the extent around the queries point of reference
  135652. */
  135653. setDefaultQueryExtent(extent: Vector3): void;
  135654. /**
  135655. * Get the Bounding box extent specified by setDefaultQueryExtent
  135656. * @returns the box extent values
  135657. */
  135658. getDefaultQueryExtent(): Vector3;
  135659. /**
  135660. * Release all resources
  135661. */
  135662. dispose(): void;
  135663. }
  135664. }
  135665. declare module BABYLON {
  135666. /**
  135667. * Class used to enable access to IndexedDB
  135668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135669. */
  135670. export class Database implements IOfflineProvider {
  135671. private _callbackManifestChecked;
  135672. private _currentSceneUrl;
  135673. private _db;
  135674. private _enableSceneOffline;
  135675. private _enableTexturesOffline;
  135676. private _manifestVersionFound;
  135677. private _mustUpdateRessources;
  135678. private _hasReachedQuota;
  135679. private _isSupported;
  135680. private _idbFactory;
  135681. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135682. private static IsUASupportingBlobStorage;
  135683. /**
  135684. * Gets a boolean indicating if Database storate is enabled (off by default)
  135685. */
  135686. static IDBStorageEnabled: boolean;
  135687. /**
  135688. * Gets a boolean indicating if scene must be saved in the database
  135689. */
  135690. get enableSceneOffline(): boolean;
  135691. /**
  135692. * Gets a boolean indicating if textures must be saved in the database
  135693. */
  135694. get enableTexturesOffline(): boolean;
  135695. /**
  135696. * Creates a new Database
  135697. * @param urlToScene defines the url to load the scene
  135698. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135699. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135700. */
  135701. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135702. private static _ParseURL;
  135703. private static _ReturnFullUrlLocation;
  135704. private _checkManifestFile;
  135705. /**
  135706. * Open the database and make it available
  135707. * @param successCallback defines the callback to call on success
  135708. * @param errorCallback defines the callback to call on error
  135709. */
  135710. open(successCallback: () => void, errorCallback: () => void): void;
  135711. /**
  135712. * Loads an image from the database
  135713. * @param url defines the url to load from
  135714. * @param image defines the target DOM image
  135715. */
  135716. loadImage(url: string, image: HTMLImageElement): void;
  135717. private _loadImageFromDBAsync;
  135718. private _saveImageIntoDBAsync;
  135719. private _checkVersionFromDB;
  135720. private _loadVersionFromDBAsync;
  135721. private _saveVersionIntoDBAsync;
  135722. /**
  135723. * Loads a file from database
  135724. * @param url defines the URL to load from
  135725. * @param sceneLoaded defines a callback to call on success
  135726. * @param progressCallBack defines a callback to call when progress changed
  135727. * @param errorCallback defines a callback to call on error
  135728. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135729. */
  135730. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135731. private _loadFileAsync;
  135732. private _saveFileAsync;
  135733. /**
  135734. * Validates if xhr data is correct
  135735. * @param xhr defines the request to validate
  135736. * @param dataType defines the expected data type
  135737. * @returns true if data is correct
  135738. */
  135739. private static _ValidateXHRData;
  135740. }
  135741. }
  135742. declare module BABYLON {
  135743. /** @hidden */
  135744. export var gpuUpdateParticlesPixelShader: {
  135745. name: string;
  135746. shader: string;
  135747. };
  135748. }
  135749. declare module BABYLON {
  135750. /** @hidden */
  135751. export var gpuUpdateParticlesVertexShader: {
  135752. name: string;
  135753. shader: string;
  135754. };
  135755. }
  135756. declare module BABYLON {
  135757. /** @hidden */
  135758. export var clipPlaneFragmentDeclaration2: {
  135759. name: string;
  135760. shader: string;
  135761. };
  135762. }
  135763. declare module BABYLON {
  135764. /** @hidden */
  135765. export var gpuRenderParticlesPixelShader: {
  135766. name: string;
  135767. shader: string;
  135768. };
  135769. }
  135770. declare module BABYLON {
  135771. /** @hidden */
  135772. export var clipPlaneVertexDeclaration2: {
  135773. name: string;
  135774. shader: string;
  135775. };
  135776. }
  135777. declare module BABYLON {
  135778. /** @hidden */
  135779. export var gpuRenderParticlesVertexShader: {
  135780. name: string;
  135781. shader: string;
  135782. };
  135783. }
  135784. declare module BABYLON {
  135785. /**
  135786. * This represents a GPU particle system in Babylon
  135787. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135788. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135789. */
  135790. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135791. /**
  135792. * The layer mask we are rendering the particles through.
  135793. */
  135794. layerMask: number;
  135795. private _capacity;
  135796. private _activeCount;
  135797. private _currentActiveCount;
  135798. private _accumulatedCount;
  135799. private _renderEffect;
  135800. private _updateEffect;
  135801. private _buffer0;
  135802. private _buffer1;
  135803. private _spriteBuffer;
  135804. private _updateVAO;
  135805. private _renderVAO;
  135806. private _targetIndex;
  135807. private _sourceBuffer;
  135808. private _targetBuffer;
  135809. private _engine;
  135810. private _currentRenderId;
  135811. private _started;
  135812. private _stopped;
  135813. private _timeDelta;
  135814. private _randomTexture;
  135815. private _randomTexture2;
  135816. private _attributesStrideSize;
  135817. private _updateEffectOptions;
  135818. private _randomTextureSize;
  135819. private _actualFrame;
  135820. private readonly _rawTextureWidth;
  135821. /**
  135822. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135823. */
  135824. static get IsSupported(): boolean;
  135825. /**
  135826. * An event triggered when the system is disposed.
  135827. */
  135828. onDisposeObservable: Observable<GPUParticleSystem>;
  135829. /**
  135830. * Gets the maximum number of particles active at the same time.
  135831. * @returns The max number of active particles.
  135832. */
  135833. getCapacity(): number;
  135834. /**
  135835. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135836. * to override the particles.
  135837. */
  135838. forceDepthWrite: boolean;
  135839. /**
  135840. * Gets or set the number of active particles
  135841. */
  135842. get activeParticleCount(): number;
  135843. set activeParticleCount(value: number);
  135844. private _preWarmDone;
  135845. /**
  135846. * Is this system ready to be used/rendered
  135847. * @return true if the system is ready
  135848. */
  135849. isReady(): boolean;
  135850. /**
  135851. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135852. * @returns True if it has been started, otherwise false.
  135853. */
  135854. isStarted(): boolean;
  135855. /**
  135856. * Starts the particle system and begins to emit
  135857. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135858. */
  135859. start(delay?: number): void;
  135860. /**
  135861. * Stops the particle system.
  135862. */
  135863. stop(): void;
  135864. /**
  135865. * Remove all active particles
  135866. */
  135867. reset(): void;
  135868. /**
  135869. * Returns the string "GPUParticleSystem"
  135870. * @returns a string containing the class name
  135871. */
  135872. getClassName(): string;
  135873. private _colorGradientsTexture;
  135874. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135875. /**
  135876. * Adds a new color gradient
  135877. * @param gradient defines the gradient to use (between 0 and 1)
  135878. * @param color1 defines the color to affect to the specified gradient
  135879. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135880. * @returns the current particle system
  135881. */
  135882. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135883. /**
  135884. * Remove a specific color gradient
  135885. * @param gradient defines the gradient to remove
  135886. * @returns the current particle system
  135887. */
  135888. removeColorGradient(gradient: number): GPUParticleSystem;
  135889. private _angularSpeedGradientsTexture;
  135890. private _sizeGradientsTexture;
  135891. private _velocityGradientsTexture;
  135892. private _limitVelocityGradientsTexture;
  135893. private _dragGradientsTexture;
  135894. private _addFactorGradient;
  135895. /**
  135896. * Adds a new size gradient
  135897. * @param gradient defines the gradient to use (between 0 and 1)
  135898. * @param factor defines the size factor to affect to the specified gradient
  135899. * @returns the current particle system
  135900. */
  135901. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135902. /**
  135903. * Remove a specific size gradient
  135904. * @param gradient defines the gradient to remove
  135905. * @returns the current particle system
  135906. */
  135907. removeSizeGradient(gradient: number): GPUParticleSystem;
  135908. /**
  135909. * Adds a new angular speed gradient
  135910. * @param gradient defines the gradient to use (between 0 and 1)
  135911. * @param factor defines the angular speed to affect to the specified gradient
  135912. * @returns the current particle system
  135913. */
  135914. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135915. /**
  135916. * Remove a specific angular speed gradient
  135917. * @param gradient defines the gradient to remove
  135918. * @returns the current particle system
  135919. */
  135920. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135921. /**
  135922. * Adds a new velocity gradient
  135923. * @param gradient defines the gradient to use (between 0 and 1)
  135924. * @param factor defines the velocity to affect to the specified gradient
  135925. * @returns the current particle system
  135926. */
  135927. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135928. /**
  135929. * Remove a specific velocity gradient
  135930. * @param gradient defines the gradient to remove
  135931. * @returns the current particle system
  135932. */
  135933. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135934. /**
  135935. * Adds a new limit velocity gradient
  135936. * @param gradient defines the gradient to use (between 0 and 1)
  135937. * @param factor defines the limit velocity value to affect to the specified gradient
  135938. * @returns the current particle system
  135939. */
  135940. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135941. /**
  135942. * Remove a specific limit velocity gradient
  135943. * @param gradient defines the gradient to remove
  135944. * @returns the current particle system
  135945. */
  135946. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135947. /**
  135948. * Adds a new drag gradient
  135949. * @param gradient defines the gradient to use (between 0 and 1)
  135950. * @param factor defines the drag value to affect to the specified gradient
  135951. * @returns the current particle system
  135952. */
  135953. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135954. /**
  135955. * Remove a specific drag gradient
  135956. * @param gradient defines the gradient to remove
  135957. * @returns the current particle system
  135958. */
  135959. removeDragGradient(gradient: number): GPUParticleSystem;
  135960. /**
  135961. * Not supported by GPUParticleSystem
  135962. * @param gradient defines the gradient to use (between 0 and 1)
  135963. * @param factor defines the emit rate value to affect to the specified gradient
  135964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135965. * @returns the current particle system
  135966. */
  135967. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135968. /**
  135969. * Not supported by GPUParticleSystem
  135970. * @param gradient defines the gradient to remove
  135971. * @returns the current particle system
  135972. */
  135973. removeEmitRateGradient(gradient: number): IParticleSystem;
  135974. /**
  135975. * Not supported by GPUParticleSystem
  135976. * @param gradient defines the gradient to use (between 0 and 1)
  135977. * @param factor defines the start size value to affect to the specified gradient
  135978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135979. * @returns the current particle system
  135980. */
  135981. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135982. /**
  135983. * Not supported by GPUParticleSystem
  135984. * @param gradient defines the gradient to remove
  135985. * @returns the current particle system
  135986. */
  135987. removeStartSizeGradient(gradient: number): IParticleSystem;
  135988. /**
  135989. * Not supported by GPUParticleSystem
  135990. * @param gradient defines the gradient to use (between 0 and 1)
  135991. * @param min defines the color remap minimal range
  135992. * @param max defines the color remap maximal range
  135993. * @returns the current particle system
  135994. */
  135995. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135996. /**
  135997. * Not supported by GPUParticleSystem
  135998. * @param gradient defines the gradient to remove
  135999. * @returns the current particle system
  136000. */
  136001. removeColorRemapGradient(): IParticleSystem;
  136002. /**
  136003. * Not supported by GPUParticleSystem
  136004. * @param gradient defines the gradient to use (between 0 and 1)
  136005. * @param min defines the alpha remap minimal range
  136006. * @param max defines the alpha remap maximal range
  136007. * @returns the current particle system
  136008. */
  136009. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136010. /**
  136011. * Not supported by GPUParticleSystem
  136012. * @param gradient defines the gradient to remove
  136013. * @returns the current particle system
  136014. */
  136015. removeAlphaRemapGradient(): IParticleSystem;
  136016. /**
  136017. * Not supported by GPUParticleSystem
  136018. * @param gradient defines the gradient to use (between 0 and 1)
  136019. * @param color defines the color to affect to the specified gradient
  136020. * @returns the current particle system
  136021. */
  136022. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136023. /**
  136024. * Not supported by GPUParticleSystem
  136025. * @param gradient defines the gradient to remove
  136026. * @returns the current particle system
  136027. */
  136028. removeRampGradient(): IParticleSystem;
  136029. /**
  136030. * Not supported by GPUParticleSystem
  136031. * @returns the list of ramp gradients
  136032. */
  136033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136034. /**
  136035. * Not supported by GPUParticleSystem
  136036. * Gets or sets a boolean indicating that ramp gradients must be used
  136037. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136038. */
  136039. get useRampGradients(): boolean;
  136040. set useRampGradients(value: boolean);
  136041. /**
  136042. * Not supported by GPUParticleSystem
  136043. * @param gradient defines the gradient to use (between 0 and 1)
  136044. * @param factor defines the life time factor to affect to the specified gradient
  136045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136046. * @returns the current particle system
  136047. */
  136048. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136049. /**
  136050. * Not supported by GPUParticleSystem
  136051. * @param gradient defines the gradient to remove
  136052. * @returns the current particle system
  136053. */
  136054. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136055. /**
  136056. * Instantiates a GPU particle system.
  136057. * 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.
  136058. * @param name The name of the particle system
  136059. * @param options The options used to create the system
  136060. * @param scene The scene the particle system belongs to
  136061. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136062. */
  136063. constructor(name: string, options: Partial<{
  136064. capacity: number;
  136065. randomTextureSize: number;
  136066. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136067. protected _reset(): void;
  136068. private _createUpdateVAO;
  136069. private _createRenderVAO;
  136070. private _initialize;
  136071. /** @hidden */
  136072. _recreateUpdateEffect(): void;
  136073. /** @hidden */
  136074. _recreateRenderEffect(): void;
  136075. /**
  136076. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136077. * @param preWarm defines if we are in the pre-warmimg phase
  136078. */
  136079. animate(preWarm?: boolean): void;
  136080. private _createFactorGradientTexture;
  136081. private _createSizeGradientTexture;
  136082. private _createAngularSpeedGradientTexture;
  136083. private _createVelocityGradientTexture;
  136084. private _createLimitVelocityGradientTexture;
  136085. private _createDragGradientTexture;
  136086. private _createColorGradientTexture;
  136087. /**
  136088. * Renders the particle system in its current state
  136089. * @param preWarm defines if the system should only update the particles but not render them
  136090. * @returns the current number of particles
  136091. */
  136092. render(preWarm?: boolean): number;
  136093. /**
  136094. * Rebuilds the particle system
  136095. */
  136096. rebuild(): void;
  136097. private _releaseBuffers;
  136098. private _releaseVAOs;
  136099. /**
  136100. * Disposes the particle system and free the associated resources
  136101. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136102. */
  136103. dispose(disposeTexture?: boolean): void;
  136104. /**
  136105. * Clones the particle system.
  136106. * @param name The name of the cloned object
  136107. * @param newEmitter The new emitter to use
  136108. * @returns the cloned particle system
  136109. */
  136110. clone(name: string, newEmitter: any): GPUParticleSystem;
  136111. /**
  136112. * Serializes the particle system to a JSON object.
  136113. * @returns the JSON object
  136114. */
  136115. serialize(): any;
  136116. /**
  136117. * Parses a JSON object to create a GPU particle system.
  136118. * @param parsedParticleSystem The JSON object to parse
  136119. * @param scene The scene to create the particle system in
  136120. * @param rootUrl The root url to use to load external dependencies like texture
  136121. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136122. * @returns the parsed GPU particle system
  136123. */
  136124. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136125. }
  136126. }
  136127. declare module BABYLON {
  136128. /**
  136129. * Represents a set of particle systems working together to create a specific effect
  136130. */
  136131. export class ParticleSystemSet implements IDisposable {
  136132. /**
  136133. * Gets or sets base Assets URL
  136134. */
  136135. static BaseAssetsUrl: string;
  136136. private _emitterCreationOptions;
  136137. private _emitterNode;
  136138. /**
  136139. * Gets the particle system list
  136140. */
  136141. systems: IParticleSystem[];
  136142. /**
  136143. * Gets the emitter node used with this set
  136144. */
  136145. get emitterNode(): Nullable<TransformNode>;
  136146. /**
  136147. * Creates a new emitter mesh as a sphere
  136148. * @param options defines the options used to create the sphere
  136149. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136150. * @param scene defines the hosting scene
  136151. */
  136152. setEmitterAsSphere(options: {
  136153. diameter: number;
  136154. segments: number;
  136155. color: Color3;
  136156. }, renderingGroupId: number, scene: Scene): void;
  136157. /**
  136158. * Starts all particle systems of the set
  136159. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136160. */
  136161. start(emitter?: AbstractMesh): void;
  136162. /**
  136163. * Release all associated resources
  136164. */
  136165. dispose(): void;
  136166. /**
  136167. * Serialize the set into a JSON compatible object
  136168. * @returns a JSON compatible representation of the set
  136169. */
  136170. serialize(): any;
  136171. /**
  136172. * Parse a new ParticleSystemSet from a serialized source
  136173. * @param data defines a JSON compatible representation of the set
  136174. * @param scene defines the hosting scene
  136175. * @param gpu defines if we want GPU particles or CPU particles
  136176. * @returns a new ParticleSystemSet
  136177. */
  136178. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136179. }
  136180. }
  136181. declare module BABYLON {
  136182. /**
  136183. * This class is made for on one-liner static method to help creating particle system set.
  136184. */
  136185. export class ParticleHelper {
  136186. /**
  136187. * Gets or sets base Assets URL
  136188. */
  136189. static BaseAssetsUrl: string;
  136190. /**
  136191. * Create a default particle system that you can tweak
  136192. * @param emitter defines the emitter to use
  136193. * @param capacity defines the system capacity (default is 500 particles)
  136194. * @param scene defines the hosting scene
  136195. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136196. * @returns the new Particle system
  136197. */
  136198. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136199. /**
  136200. * This is the main static method (one-liner) of this helper to create different particle systems
  136201. * @param type This string represents the type to the particle system to create
  136202. * @param scene The scene where the particle system should live
  136203. * @param gpu If the system will use gpu
  136204. * @returns the ParticleSystemSet created
  136205. */
  136206. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136207. /**
  136208. * Static function used to export a particle system to a ParticleSystemSet variable.
  136209. * Please note that the emitter shape is not exported
  136210. * @param systems defines the particle systems to export
  136211. * @returns the created particle system set
  136212. */
  136213. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136214. }
  136215. }
  136216. declare module BABYLON {
  136217. interface Engine {
  136218. /**
  136219. * Create an effect to use with particle systems.
  136220. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136221. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136222. * @param uniformsNames defines a list of attribute names
  136223. * @param samplers defines an array of string used to represent textures
  136224. * @param defines defines the string containing the defines to use to compile the shaders
  136225. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136226. * @param onCompiled defines a function to call when the effect creation is successful
  136227. * @param onError defines a function to call when the effect creation has failed
  136228. * @returns the new Effect
  136229. */
  136230. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136231. }
  136232. interface Mesh {
  136233. /**
  136234. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136235. * @returns an array of IParticleSystem
  136236. */
  136237. getEmittedParticleSystems(): IParticleSystem[];
  136238. /**
  136239. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136240. * @returns an array of IParticleSystem
  136241. */
  136242. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136243. }
  136244. /**
  136245. * @hidden
  136246. */
  136247. export var _IDoNeedToBeInTheBuild: number;
  136248. }
  136249. declare module BABYLON {
  136250. /** Defines the 4 color options */
  136251. export enum PointColor {
  136252. /** color value */
  136253. Color = 2,
  136254. /** uv value */
  136255. UV = 1,
  136256. /** random value */
  136257. Random = 0,
  136258. /** stated value */
  136259. Stated = 3
  136260. }
  136261. /**
  136262. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136263. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  136264. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136265. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136266. *
  136267. * Full documentation here : TO BE ENTERED
  136268. */
  136269. export class PointsCloudSystem implements IDisposable {
  136270. /**
  136271. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136272. * Example : var p = SPS.particles[i];
  136273. */
  136274. particles: CloudPoint[];
  136275. /**
  136276. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136277. */
  136278. nbParticles: number;
  136279. /**
  136280. * This a counter for your own usage. It's not set by any SPS functions.
  136281. */
  136282. counter: number;
  136283. /**
  136284. * The PCS name. This name is also given to the underlying mesh.
  136285. */
  136286. name: string;
  136287. /**
  136288. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136289. */
  136290. mesh: Mesh;
  136291. /**
  136292. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136293. * Please read :
  136294. */
  136295. vars: any;
  136296. /**
  136297. * @hidden
  136298. */
  136299. _size: number;
  136300. private _scene;
  136301. private _promises;
  136302. private _positions;
  136303. private _indices;
  136304. private _normals;
  136305. private _colors;
  136306. private _uvs;
  136307. private _indices32;
  136308. private _positions32;
  136309. private _colors32;
  136310. private _uvs32;
  136311. private _updatable;
  136312. private _isVisibilityBoxLocked;
  136313. private _alwaysVisible;
  136314. private _groups;
  136315. private _groupCounter;
  136316. private _computeParticleColor;
  136317. private _computeParticleTexture;
  136318. private _computeParticleRotation;
  136319. private _computeBoundingBox;
  136320. private _isReady;
  136321. /**
  136322. * Creates a PCS (Points Cloud System) object
  136323. * @param name (String) is the PCS name, this will be the underlying mesh name
  136324. * @param pointSize (number) is the size for each point
  136325. * @param scene (Scene) is the scene in which the PCS is added
  136326. * @param options defines the options of the PCS e.g.
  136327. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136328. */
  136329. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136330. updatable?: boolean;
  136331. });
  136332. /**
  136333. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136334. * If no points were added to the PCS, the returned mesh is just a single point.
  136335. * @returns a promise for the created mesh
  136336. */
  136337. buildMeshAsync(): Promise<Mesh>;
  136338. /**
  136339. * @hidden
  136340. */
  136341. private _buildMesh;
  136342. private _addParticle;
  136343. private _randomUnitVector;
  136344. private _getColorIndicesForCoord;
  136345. private _setPointsColorOrUV;
  136346. private _colorFromTexture;
  136347. private _calculateDensity;
  136348. /**
  136349. * Adds points to the PCS in random positions within a unit sphere
  136350. * @param nb (positive integer) the number of particles to be created from this model
  136351. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136352. * @returns the number of groups in the system
  136353. */
  136354. addPoints(nb: number, pointFunction?: any): number;
  136355. /**
  136356. * Adds points to the PCS from the surface of the model shape
  136357. * @param mesh is any Mesh object that will be used as a surface model for the points
  136358. * @param nb (positive integer) the number of particles to be created from this model
  136359. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136360. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136361. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136362. * @returns the number of groups in the system
  136363. */
  136364. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136365. /**
  136366. * Adds points to the PCS inside the model shape
  136367. * @param mesh is any Mesh object that will be used as a surface model for the points
  136368. * @param nb (positive integer) the number of particles to be created from this model
  136369. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136370. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136371. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136372. * @returns the number of groups in the system
  136373. */
  136374. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136375. /**
  136376. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136377. * This method calls `updateParticle()` for each particle of the SPS.
  136378. * For an animated SPS, it is usually called within the render loop.
  136379. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136380. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136381. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136382. * @returns the PCS.
  136383. */
  136384. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136385. /**
  136386. * Disposes the PCS.
  136387. */
  136388. dispose(): void;
  136389. /**
  136390. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136391. * doc :
  136392. * @returns the PCS.
  136393. */
  136394. refreshVisibleSize(): PointsCloudSystem;
  136395. /**
  136396. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136397. * @param size the size (float) of the visibility box
  136398. * note : this doesn't lock the PCS mesh bounding box.
  136399. * doc :
  136400. */
  136401. setVisibilityBox(size: number): void;
  136402. /**
  136403. * Gets whether the PCS is always visible or not
  136404. * doc :
  136405. */
  136406. get isAlwaysVisible(): boolean;
  136407. /**
  136408. * Sets the PCS as always visible or not
  136409. * doc :
  136410. */
  136411. set isAlwaysVisible(val: boolean);
  136412. /**
  136413. * Tells to `setParticles()` to compute the particle rotations or not
  136414. * Default value : false. The PCS is faster when it's set to false
  136415. * Note : particle rotations are only applied to parent particles
  136416. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136417. */
  136418. set computeParticleRotation(val: boolean);
  136419. /**
  136420. * Tells to `setParticles()` to compute the particle colors or not.
  136421. * Default value : true. The PCS is faster when it's set to false.
  136422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136423. */
  136424. set computeParticleColor(val: boolean);
  136425. set computeParticleTexture(val: boolean);
  136426. /**
  136427. * Gets if `setParticles()` computes the particle colors or not.
  136428. * Default value : false. The PCS is faster when it's set to false.
  136429. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136430. */
  136431. get computeParticleColor(): boolean;
  136432. /**
  136433. * Gets if `setParticles()` computes the particle textures or not.
  136434. * Default value : false. The PCS is faster when it's set to false.
  136435. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136436. */
  136437. get computeParticleTexture(): boolean;
  136438. /**
  136439. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136440. */
  136441. set computeBoundingBox(val: boolean);
  136442. /**
  136443. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136444. */
  136445. get computeBoundingBox(): boolean;
  136446. /**
  136447. * This function does nothing. It may be overwritten to set all the particle first values.
  136448. * The PCS doesn't call this function, you may have to call it by your own.
  136449. * doc :
  136450. */
  136451. initParticles(): void;
  136452. /**
  136453. * This function does nothing. It may be overwritten to recycle a particle
  136454. * The PCS doesn't call this function, you can to call it
  136455. * doc :
  136456. * @param particle The particle to recycle
  136457. * @returns the recycled particle
  136458. */
  136459. recycleParticle(particle: CloudPoint): CloudPoint;
  136460. /**
  136461. * Updates a particle : this function should be overwritten by the user.
  136462. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136463. * doc :
  136464. * @example : just set a particle position or velocity and recycle conditions
  136465. * @param particle The particle to update
  136466. * @returns the updated particle
  136467. */
  136468. updateParticle(particle: CloudPoint): CloudPoint;
  136469. /**
  136470. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136471. * This does nothing and may be overwritten by the user.
  136472. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136473. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136474. * @param update the boolean update value actually passed to setParticles()
  136475. */
  136476. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136477. /**
  136478. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136479. * This will be passed three parameters.
  136480. * This does nothing and may be overwritten by the user.
  136481. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136482. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136483. * @param update the boolean update value actually passed to setParticles()
  136484. */
  136485. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136486. }
  136487. }
  136488. declare module BABYLON {
  136489. /**
  136490. * Represents one particle of a points cloud system.
  136491. */
  136492. export class CloudPoint {
  136493. /**
  136494. * particle global index
  136495. */
  136496. idx: number;
  136497. /**
  136498. * The color of the particle
  136499. */
  136500. color: Nullable<Color4>;
  136501. /**
  136502. * The world space position of the particle.
  136503. */
  136504. position: Vector3;
  136505. /**
  136506. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136507. */
  136508. rotation: Vector3;
  136509. /**
  136510. * The world space rotation quaternion of the particle.
  136511. */
  136512. rotationQuaternion: Nullable<Quaternion>;
  136513. /**
  136514. * The uv of the particle.
  136515. */
  136516. uv: Nullable<Vector2>;
  136517. /**
  136518. * The current speed of the particle.
  136519. */
  136520. velocity: Vector3;
  136521. /**
  136522. * The pivot point in the particle local space.
  136523. */
  136524. pivot: Vector3;
  136525. /**
  136526. * Must the particle be translated from its pivot point in its local space ?
  136527. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136528. * Default : false
  136529. */
  136530. translateFromPivot: boolean;
  136531. /**
  136532. * Index of this particle in the global "positions" array (Internal use)
  136533. * @hidden
  136534. */
  136535. _pos: number;
  136536. /**
  136537. * @hidden Index of this particle in the global "indices" array (Internal use)
  136538. */
  136539. _ind: number;
  136540. /**
  136541. * Group this particle belongs to
  136542. */
  136543. _group: PointsGroup;
  136544. /**
  136545. * Group id of this particle
  136546. */
  136547. groupId: number;
  136548. /**
  136549. * Index of the particle in its group id (Internal use)
  136550. */
  136551. idxInGroup: number;
  136552. /**
  136553. * @hidden Particle BoundingInfo object (Internal use)
  136554. */
  136555. _boundingInfo: BoundingInfo;
  136556. /**
  136557. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136558. */
  136559. _pcs: PointsCloudSystem;
  136560. /**
  136561. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136562. */
  136563. _stillInvisible: boolean;
  136564. /**
  136565. * @hidden Last computed particle rotation matrix
  136566. */
  136567. _rotationMatrix: number[];
  136568. /**
  136569. * Parent particle Id, if any.
  136570. * Default null.
  136571. */
  136572. parentId: Nullable<number>;
  136573. /**
  136574. * @hidden Internal global position in the PCS.
  136575. */
  136576. _globalPosition: Vector3;
  136577. /**
  136578. * Creates a Point Cloud object.
  136579. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136580. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136581. * @param group (PointsGroup) is the group the particle belongs to
  136582. * @param groupId (integer) is the group identifier in the PCS.
  136583. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136584. * @param pcs defines the PCS it is associated to
  136585. */
  136586. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136587. /**
  136588. * get point size
  136589. */
  136590. get size(): Vector3;
  136591. /**
  136592. * Set point size
  136593. */
  136594. set size(scale: Vector3);
  136595. /**
  136596. * Legacy support, changed quaternion to rotationQuaternion
  136597. */
  136598. get quaternion(): Nullable<Quaternion>;
  136599. /**
  136600. * Legacy support, changed quaternion to rotationQuaternion
  136601. */
  136602. set quaternion(q: Nullable<Quaternion>);
  136603. /**
  136604. * Returns a boolean. True if the particle intersects a mesh, else false
  136605. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136606. * @param target is the object (point or mesh) what the intersection is computed against
  136607. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136608. * @returns true if it intersects
  136609. */
  136610. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136611. /**
  136612. * get the rotation matrix of the particle
  136613. * @hidden
  136614. */
  136615. getRotationMatrix(m: Matrix): void;
  136616. }
  136617. /**
  136618. * Represents a group of points in a points cloud system
  136619. * * PCS internal tool, don't use it manually.
  136620. */
  136621. export class PointsGroup {
  136622. /**
  136623. * The group id
  136624. * @hidden
  136625. */
  136626. groupID: number;
  136627. /**
  136628. * image data for group (internal use)
  136629. * @hidden
  136630. */
  136631. _groupImageData: Nullable<ArrayBufferView>;
  136632. /**
  136633. * Image Width (internal use)
  136634. * @hidden
  136635. */
  136636. _groupImgWidth: number;
  136637. /**
  136638. * Image Height (internal use)
  136639. * @hidden
  136640. */
  136641. _groupImgHeight: number;
  136642. /**
  136643. * Custom position function (internal use)
  136644. * @hidden
  136645. */
  136646. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136647. /**
  136648. * density per facet for surface points
  136649. * @hidden
  136650. */
  136651. _groupDensity: number[];
  136652. /**
  136653. * Only when points are colored by texture carries pointer to texture list array
  136654. * @hidden
  136655. */
  136656. _textureNb: number;
  136657. /**
  136658. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136659. * PCS internal tool, don't use it manually.
  136660. * @hidden
  136661. */
  136662. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136663. }
  136664. }
  136665. declare module BABYLON {
  136666. interface Scene {
  136667. /** @hidden (Backing field) */
  136668. _physicsEngine: Nullable<IPhysicsEngine>;
  136669. /** @hidden */
  136670. _physicsTimeAccumulator: number;
  136671. /**
  136672. * Gets the current physics engine
  136673. * @returns a IPhysicsEngine or null if none attached
  136674. */
  136675. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136676. /**
  136677. * Enables physics to the current scene
  136678. * @param gravity defines the scene's gravity for the physics engine
  136679. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136680. * @return a boolean indicating if the physics engine was initialized
  136681. */
  136682. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136683. /**
  136684. * Disables and disposes the physics engine associated with the scene
  136685. */
  136686. disablePhysicsEngine(): void;
  136687. /**
  136688. * Gets a boolean indicating if there is an active physics engine
  136689. * @returns a boolean indicating if there is an active physics engine
  136690. */
  136691. isPhysicsEnabled(): boolean;
  136692. /**
  136693. * Deletes a physics compound impostor
  136694. * @param compound defines the compound to delete
  136695. */
  136696. deleteCompoundImpostor(compound: any): void;
  136697. /**
  136698. * An event triggered when physic simulation is about to be run
  136699. */
  136700. onBeforePhysicsObservable: Observable<Scene>;
  136701. /**
  136702. * An event triggered when physic simulation has been done
  136703. */
  136704. onAfterPhysicsObservable: Observable<Scene>;
  136705. }
  136706. interface AbstractMesh {
  136707. /** @hidden */
  136708. _physicsImpostor: Nullable<PhysicsImpostor>;
  136709. /**
  136710. * Gets or sets impostor used for physic simulation
  136711. * @see http://doc.babylonjs.com/features/physics_engine
  136712. */
  136713. physicsImpostor: Nullable<PhysicsImpostor>;
  136714. /**
  136715. * Gets the current physics impostor
  136716. * @see http://doc.babylonjs.com/features/physics_engine
  136717. * @returns a physics impostor or null
  136718. */
  136719. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136720. /** Apply a physic impulse to the mesh
  136721. * @param force defines the force to apply
  136722. * @param contactPoint defines where to apply the force
  136723. * @returns the current mesh
  136724. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136725. */
  136726. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136727. /**
  136728. * Creates a physic joint between two meshes
  136729. * @param otherMesh defines the other mesh to use
  136730. * @param pivot1 defines the pivot to use on this mesh
  136731. * @param pivot2 defines the pivot to use on the other mesh
  136732. * @param options defines additional options (can be plugin dependent)
  136733. * @returns the current mesh
  136734. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136735. */
  136736. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136737. /** @hidden */
  136738. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136739. }
  136740. /**
  136741. * Defines the physics engine scene component responsible to manage a physics engine
  136742. */
  136743. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136744. /**
  136745. * The component name helpful to identify the component in the list of scene components.
  136746. */
  136747. readonly name: string;
  136748. /**
  136749. * The scene the component belongs to.
  136750. */
  136751. scene: Scene;
  136752. /**
  136753. * Creates a new instance of the component for the given scene
  136754. * @param scene Defines the scene to register the component in
  136755. */
  136756. constructor(scene: Scene);
  136757. /**
  136758. * Registers the component in a given scene
  136759. */
  136760. register(): void;
  136761. /**
  136762. * Rebuilds the elements related to this component in case of
  136763. * context lost for instance.
  136764. */
  136765. rebuild(): void;
  136766. /**
  136767. * Disposes the component and the associated ressources
  136768. */
  136769. dispose(): void;
  136770. }
  136771. }
  136772. declare module BABYLON {
  136773. /**
  136774. * A helper for physics simulations
  136775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136776. */
  136777. export class PhysicsHelper {
  136778. private _scene;
  136779. private _physicsEngine;
  136780. /**
  136781. * Initializes the Physics helper
  136782. * @param scene Babylon.js scene
  136783. */
  136784. constructor(scene: Scene);
  136785. /**
  136786. * Applies a radial explosion impulse
  136787. * @param origin the origin of the explosion
  136788. * @param radiusOrEventOptions the radius or the options of radial explosion
  136789. * @param strength the explosion strength
  136790. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136791. * @returns A physics radial explosion event, or null
  136792. */
  136793. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136794. /**
  136795. * Applies a radial explosion force
  136796. * @param origin the origin of the explosion
  136797. * @param radiusOrEventOptions the radius or the options of radial explosion
  136798. * @param strength the explosion strength
  136799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136800. * @returns A physics radial explosion event, or null
  136801. */
  136802. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136803. /**
  136804. * Creates a gravitational field
  136805. * @param origin the origin of the explosion
  136806. * @param radiusOrEventOptions the radius or the options of radial explosion
  136807. * @param strength the explosion strength
  136808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136809. * @returns A physics gravitational field event, or null
  136810. */
  136811. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136812. /**
  136813. * Creates a physics updraft event
  136814. * @param origin the origin of the updraft
  136815. * @param radiusOrEventOptions the radius or the options of the updraft
  136816. * @param strength the strength of the updraft
  136817. * @param height the height of the updraft
  136818. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136819. * @returns A physics updraft event, or null
  136820. */
  136821. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136822. /**
  136823. * Creates a physics vortex event
  136824. * @param origin the of the vortex
  136825. * @param radiusOrEventOptions the radius or the options of the vortex
  136826. * @param strength the strength of the vortex
  136827. * @param height the height of the vortex
  136828. * @returns a Physics vortex event, or null
  136829. * A physics vortex event or null
  136830. */
  136831. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136832. }
  136833. /**
  136834. * Represents a physics radial explosion event
  136835. */
  136836. class PhysicsRadialExplosionEvent {
  136837. private _scene;
  136838. private _options;
  136839. private _sphere;
  136840. private _dataFetched;
  136841. /**
  136842. * Initializes a radial explosioin event
  136843. * @param _scene BabylonJS scene
  136844. * @param _options The options for the vortex event
  136845. */
  136846. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136847. /**
  136848. * Returns the data related to the radial explosion event (sphere).
  136849. * @returns The radial explosion event data
  136850. */
  136851. getData(): PhysicsRadialExplosionEventData;
  136852. /**
  136853. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136854. * @param impostor A physics imposter
  136855. * @param origin the origin of the explosion
  136856. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136857. */
  136858. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136859. /**
  136860. * Triggers affecterd impostors callbacks
  136861. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136862. */
  136863. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136864. /**
  136865. * Disposes the sphere.
  136866. * @param force Specifies if the sphere should be disposed by force
  136867. */
  136868. dispose(force?: boolean): void;
  136869. /*** Helpers ***/
  136870. private _prepareSphere;
  136871. private _intersectsWithSphere;
  136872. }
  136873. /**
  136874. * Represents a gravitational field event
  136875. */
  136876. class PhysicsGravitationalFieldEvent {
  136877. private _physicsHelper;
  136878. private _scene;
  136879. private _origin;
  136880. private _options;
  136881. private _tickCallback;
  136882. private _sphere;
  136883. private _dataFetched;
  136884. /**
  136885. * Initializes the physics gravitational field event
  136886. * @param _physicsHelper A physics helper
  136887. * @param _scene BabylonJS scene
  136888. * @param _origin The origin position of the gravitational field event
  136889. * @param _options The options for the vortex event
  136890. */
  136891. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136892. /**
  136893. * Returns the data related to the gravitational field event (sphere).
  136894. * @returns A gravitational field event
  136895. */
  136896. getData(): PhysicsGravitationalFieldEventData;
  136897. /**
  136898. * Enables the gravitational field.
  136899. */
  136900. enable(): void;
  136901. /**
  136902. * Disables the gravitational field.
  136903. */
  136904. disable(): void;
  136905. /**
  136906. * Disposes the sphere.
  136907. * @param force The force to dispose from the gravitational field event
  136908. */
  136909. dispose(force?: boolean): void;
  136910. private _tick;
  136911. }
  136912. /**
  136913. * Represents a physics updraft event
  136914. */
  136915. class PhysicsUpdraftEvent {
  136916. private _scene;
  136917. private _origin;
  136918. private _options;
  136919. private _physicsEngine;
  136920. private _originTop;
  136921. private _originDirection;
  136922. private _tickCallback;
  136923. private _cylinder;
  136924. private _cylinderPosition;
  136925. private _dataFetched;
  136926. /**
  136927. * Initializes the physics updraft event
  136928. * @param _scene BabylonJS scene
  136929. * @param _origin The origin position of the updraft
  136930. * @param _options The options for the updraft event
  136931. */
  136932. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136933. /**
  136934. * Returns the data related to the updraft event (cylinder).
  136935. * @returns A physics updraft event
  136936. */
  136937. getData(): PhysicsUpdraftEventData;
  136938. /**
  136939. * Enables the updraft.
  136940. */
  136941. enable(): void;
  136942. /**
  136943. * Disables the updraft.
  136944. */
  136945. disable(): void;
  136946. /**
  136947. * Disposes the cylinder.
  136948. * @param force Specifies if the updraft should be disposed by force
  136949. */
  136950. dispose(force?: boolean): void;
  136951. private getImpostorHitData;
  136952. private _tick;
  136953. /*** Helpers ***/
  136954. private _prepareCylinder;
  136955. private _intersectsWithCylinder;
  136956. }
  136957. /**
  136958. * Represents a physics vortex event
  136959. */
  136960. class PhysicsVortexEvent {
  136961. private _scene;
  136962. private _origin;
  136963. private _options;
  136964. private _physicsEngine;
  136965. private _originTop;
  136966. private _tickCallback;
  136967. private _cylinder;
  136968. private _cylinderPosition;
  136969. private _dataFetched;
  136970. /**
  136971. * Initializes the physics vortex event
  136972. * @param _scene The BabylonJS scene
  136973. * @param _origin The origin position of the vortex
  136974. * @param _options The options for the vortex event
  136975. */
  136976. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136977. /**
  136978. * Returns the data related to the vortex event (cylinder).
  136979. * @returns The physics vortex event data
  136980. */
  136981. getData(): PhysicsVortexEventData;
  136982. /**
  136983. * Enables the vortex.
  136984. */
  136985. enable(): void;
  136986. /**
  136987. * Disables the cortex.
  136988. */
  136989. disable(): void;
  136990. /**
  136991. * Disposes the sphere.
  136992. * @param force
  136993. */
  136994. dispose(force?: boolean): void;
  136995. private getImpostorHitData;
  136996. private _tick;
  136997. /*** Helpers ***/
  136998. private _prepareCylinder;
  136999. private _intersectsWithCylinder;
  137000. }
  137001. /**
  137002. * Options fot the radial explosion event
  137003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137004. */
  137005. export class PhysicsRadialExplosionEventOptions {
  137006. /**
  137007. * The radius of the sphere for the radial explosion.
  137008. */
  137009. radius: number;
  137010. /**
  137011. * The strenth of the explosion.
  137012. */
  137013. strength: number;
  137014. /**
  137015. * The strenght of the force in correspondence to the distance of the affected object
  137016. */
  137017. falloff: PhysicsRadialImpulseFalloff;
  137018. /**
  137019. * Sphere options for the radial explosion.
  137020. */
  137021. sphere: {
  137022. segments: number;
  137023. diameter: number;
  137024. };
  137025. /**
  137026. * Sphere options for the radial explosion.
  137027. */
  137028. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137029. }
  137030. /**
  137031. * Options fot the updraft event
  137032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137033. */
  137034. export class PhysicsUpdraftEventOptions {
  137035. /**
  137036. * The radius of the cylinder for the vortex
  137037. */
  137038. radius: number;
  137039. /**
  137040. * The strenth of the updraft.
  137041. */
  137042. strength: number;
  137043. /**
  137044. * The height of the cylinder for the updraft.
  137045. */
  137046. height: number;
  137047. /**
  137048. * The mode for the the updraft.
  137049. */
  137050. updraftMode: PhysicsUpdraftMode;
  137051. }
  137052. /**
  137053. * Options fot the vortex event
  137054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137055. */
  137056. export class PhysicsVortexEventOptions {
  137057. /**
  137058. * The radius of the cylinder for the vortex
  137059. */
  137060. radius: number;
  137061. /**
  137062. * The strenth of the vortex.
  137063. */
  137064. strength: number;
  137065. /**
  137066. * The height of the cylinder for the vortex.
  137067. */
  137068. height: number;
  137069. /**
  137070. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137071. */
  137072. centripetalForceThreshold: number;
  137073. /**
  137074. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137075. */
  137076. centripetalForceMultiplier: number;
  137077. /**
  137078. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137079. */
  137080. centrifugalForceMultiplier: number;
  137081. /**
  137082. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137083. */
  137084. updraftForceMultiplier: number;
  137085. }
  137086. /**
  137087. * The strenght of the force in correspondence to the distance of the affected object
  137088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137089. */
  137090. export enum PhysicsRadialImpulseFalloff {
  137091. /** Defines that impulse is constant in strength across it's whole radius */
  137092. Constant = 0,
  137093. /** Defines that impulse gets weaker if it's further from the origin */
  137094. Linear = 1
  137095. }
  137096. /**
  137097. * The strength of the force in correspondence to the distance of the affected object
  137098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137099. */
  137100. export enum PhysicsUpdraftMode {
  137101. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137102. Center = 0,
  137103. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137104. Perpendicular = 1
  137105. }
  137106. /**
  137107. * Interface for a physics hit data
  137108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137109. */
  137110. export interface PhysicsHitData {
  137111. /**
  137112. * The force applied at the contact point
  137113. */
  137114. force: Vector3;
  137115. /**
  137116. * The contact point
  137117. */
  137118. contactPoint: Vector3;
  137119. /**
  137120. * The distance from the origin to the contact point
  137121. */
  137122. distanceFromOrigin: number;
  137123. }
  137124. /**
  137125. * Interface for radial explosion event data
  137126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137127. */
  137128. export interface PhysicsRadialExplosionEventData {
  137129. /**
  137130. * A sphere used for the radial explosion event
  137131. */
  137132. sphere: Mesh;
  137133. }
  137134. /**
  137135. * Interface for gravitational field event data
  137136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137137. */
  137138. export interface PhysicsGravitationalFieldEventData {
  137139. /**
  137140. * A sphere mesh used for the gravitational field event
  137141. */
  137142. sphere: Mesh;
  137143. }
  137144. /**
  137145. * Interface for updraft event data
  137146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137147. */
  137148. export interface PhysicsUpdraftEventData {
  137149. /**
  137150. * A cylinder used for the updraft event
  137151. */
  137152. cylinder: Mesh;
  137153. }
  137154. /**
  137155. * Interface for vortex event data
  137156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137157. */
  137158. export interface PhysicsVortexEventData {
  137159. /**
  137160. * A cylinder used for the vortex event
  137161. */
  137162. cylinder: Mesh;
  137163. }
  137164. /**
  137165. * Interface for an affected physics impostor
  137166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137167. */
  137168. export interface PhysicsAffectedImpostorWithData {
  137169. /**
  137170. * The impostor affected by the effect
  137171. */
  137172. impostor: PhysicsImpostor;
  137173. /**
  137174. * The data about the hit/horce from the explosion
  137175. */
  137176. hitData: PhysicsHitData;
  137177. }
  137178. }
  137179. declare module BABYLON {
  137180. /** @hidden */
  137181. export var blackAndWhitePixelShader: {
  137182. name: string;
  137183. shader: string;
  137184. };
  137185. }
  137186. declare module BABYLON {
  137187. /**
  137188. * Post process used to render in black and white
  137189. */
  137190. export class BlackAndWhitePostProcess extends PostProcess {
  137191. /**
  137192. * Linear about to convert he result to black and white (default: 1)
  137193. */
  137194. degree: number;
  137195. /**
  137196. * Creates a black and white post process
  137197. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137198. * @param name The name of the effect.
  137199. * @param options The required width/height ratio to downsize to before computing the render pass.
  137200. * @param camera The camera to apply the render pass to.
  137201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137202. * @param engine The engine which the post process will be applied. (default: current engine)
  137203. * @param reusable If the post process can be reused on the same frame. (default: false)
  137204. */
  137205. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137206. }
  137207. }
  137208. declare module BABYLON {
  137209. /**
  137210. * This represents a set of one or more post processes in Babylon.
  137211. * A post process can be used to apply a shader to a texture after it is rendered.
  137212. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137213. */
  137214. export class PostProcessRenderEffect {
  137215. private _postProcesses;
  137216. private _getPostProcesses;
  137217. private _singleInstance;
  137218. private _cameras;
  137219. private _indicesForCamera;
  137220. /**
  137221. * Name of the effect
  137222. * @hidden
  137223. */
  137224. _name: string;
  137225. /**
  137226. * Instantiates a post process render effect.
  137227. * A post process can be used to apply a shader to a texture after it is rendered.
  137228. * @param engine The engine the effect is tied to
  137229. * @param name The name of the effect
  137230. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137231. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137232. */
  137233. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137234. /**
  137235. * Checks if all the post processes in the effect are supported.
  137236. */
  137237. get isSupported(): boolean;
  137238. /**
  137239. * Updates the current state of the effect
  137240. * @hidden
  137241. */
  137242. _update(): void;
  137243. /**
  137244. * Attaches the effect on cameras
  137245. * @param cameras The camera to attach to.
  137246. * @hidden
  137247. */
  137248. _attachCameras(cameras: Camera): void;
  137249. /**
  137250. * Attaches the effect on cameras
  137251. * @param cameras The camera to attach to.
  137252. * @hidden
  137253. */
  137254. _attachCameras(cameras: Camera[]): void;
  137255. /**
  137256. * Detaches the effect on cameras
  137257. * @param cameras The camera to detatch from.
  137258. * @hidden
  137259. */
  137260. _detachCameras(cameras: Camera): void;
  137261. /**
  137262. * Detatches the effect on cameras
  137263. * @param cameras The camera to detatch from.
  137264. * @hidden
  137265. */
  137266. _detachCameras(cameras: Camera[]): void;
  137267. /**
  137268. * Enables the effect on given cameras
  137269. * @param cameras The camera to enable.
  137270. * @hidden
  137271. */
  137272. _enable(cameras: Camera): void;
  137273. /**
  137274. * Enables the effect on given cameras
  137275. * @param cameras The camera to enable.
  137276. * @hidden
  137277. */
  137278. _enable(cameras: Nullable<Camera[]>): void;
  137279. /**
  137280. * Disables the effect on the given cameras
  137281. * @param cameras The camera to disable.
  137282. * @hidden
  137283. */
  137284. _disable(cameras: Camera): void;
  137285. /**
  137286. * Disables the effect on the given cameras
  137287. * @param cameras The camera to disable.
  137288. * @hidden
  137289. */
  137290. _disable(cameras: Nullable<Camera[]>): void;
  137291. /**
  137292. * Gets a list of the post processes contained in the effect.
  137293. * @param camera The camera to get the post processes on.
  137294. * @returns The list of the post processes in the effect.
  137295. */
  137296. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137297. }
  137298. }
  137299. declare module BABYLON {
  137300. /** @hidden */
  137301. export var extractHighlightsPixelShader: {
  137302. name: string;
  137303. shader: string;
  137304. };
  137305. }
  137306. declare module BABYLON {
  137307. /**
  137308. * 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.
  137309. */
  137310. export class ExtractHighlightsPostProcess extends PostProcess {
  137311. /**
  137312. * The luminance threshold, pixels below this value will be set to black.
  137313. */
  137314. threshold: number;
  137315. /** @hidden */
  137316. _exposure: number;
  137317. /**
  137318. * Post process which has the input texture to be used when performing highlight extraction
  137319. * @hidden
  137320. */
  137321. _inputPostProcess: Nullable<PostProcess>;
  137322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /** @hidden */
  137327. export var bloomMergePixelShader: {
  137328. name: string;
  137329. shader: string;
  137330. };
  137331. }
  137332. declare module BABYLON {
  137333. /**
  137334. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137335. */
  137336. export class BloomMergePostProcess extends PostProcess {
  137337. /** Weight of the bloom to be added to the original input. */
  137338. weight: number;
  137339. /**
  137340. * Creates a new instance of @see BloomMergePostProcess
  137341. * @param name The name of the effect.
  137342. * @param originalFromInput Post process which's input will be used for the merge.
  137343. * @param blurred Blurred highlights post process which's output will be used.
  137344. * @param weight Weight of the bloom to be added to the original input.
  137345. * @param options The required width/height ratio to downsize to before computing the render pass.
  137346. * @param camera The camera to apply the render pass to.
  137347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137348. * @param engine The engine which the post process will be applied. (default: current engine)
  137349. * @param reusable If the post process can be reused on the same frame. (default: false)
  137350. * @param textureType Type of textures used when performing the post process. (default: 0)
  137351. * @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)
  137352. */
  137353. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137354. /** Weight of the bloom to be added to the original input. */
  137355. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137356. }
  137357. }
  137358. declare module BABYLON {
  137359. /**
  137360. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137361. */
  137362. export class BloomEffect extends PostProcessRenderEffect {
  137363. private bloomScale;
  137364. /**
  137365. * @hidden Internal
  137366. */
  137367. _effects: Array<PostProcess>;
  137368. /**
  137369. * @hidden Internal
  137370. */
  137371. _downscale: ExtractHighlightsPostProcess;
  137372. private _blurX;
  137373. private _blurY;
  137374. private _merge;
  137375. /**
  137376. * The luminance threshold to find bright areas of the image to bloom.
  137377. */
  137378. get threshold(): number;
  137379. set threshold(value: number);
  137380. /**
  137381. * The strength of the bloom.
  137382. */
  137383. get weight(): number;
  137384. set weight(value: number);
  137385. /**
  137386. * Specifies the size of the bloom blur kernel, relative to the final output size
  137387. */
  137388. get kernel(): number;
  137389. set kernel(value: number);
  137390. /**
  137391. * Creates a new instance of @see BloomEffect
  137392. * @param scene The scene the effect belongs to.
  137393. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137394. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137395. * @param bloomWeight The the strength of bloom.
  137396. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137397. * @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)
  137398. */
  137399. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137400. /**
  137401. * Disposes each of the internal effects for a given camera.
  137402. * @param camera The camera to dispose the effect on.
  137403. */
  137404. disposeEffects(camera: Camera): void;
  137405. /**
  137406. * @hidden Internal
  137407. */
  137408. _updateEffects(): void;
  137409. /**
  137410. * Internal
  137411. * @returns if all the contained post processes are ready.
  137412. * @hidden
  137413. */
  137414. _isReady(): boolean;
  137415. }
  137416. }
  137417. declare module BABYLON {
  137418. /** @hidden */
  137419. export var chromaticAberrationPixelShader: {
  137420. name: string;
  137421. shader: string;
  137422. };
  137423. }
  137424. declare module BABYLON {
  137425. /**
  137426. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137427. */
  137428. export class ChromaticAberrationPostProcess extends PostProcess {
  137429. /**
  137430. * The amount of seperation of rgb channels (default: 30)
  137431. */
  137432. aberrationAmount: number;
  137433. /**
  137434. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137435. */
  137436. radialIntensity: number;
  137437. /**
  137438. * 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))
  137439. */
  137440. direction: Vector2;
  137441. /**
  137442. * 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))
  137443. */
  137444. centerPosition: Vector2;
  137445. /**
  137446. * Creates a new instance ChromaticAberrationPostProcess
  137447. * @param name The name of the effect.
  137448. * @param screenWidth The width of the screen to apply the effect on.
  137449. * @param screenHeight The height of the screen to apply the effect on.
  137450. * @param options The required width/height ratio to downsize to before computing the render pass.
  137451. * @param camera The camera to apply the render pass to.
  137452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137453. * @param engine The engine which the post process will be applied. (default: current engine)
  137454. * @param reusable If the post process can be reused on the same frame. (default: false)
  137455. * @param textureType Type of textures used when performing the post process. (default: 0)
  137456. * @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)
  137457. */
  137458. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137459. }
  137460. }
  137461. declare module BABYLON {
  137462. /** @hidden */
  137463. export var circleOfConfusionPixelShader: {
  137464. name: string;
  137465. shader: string;
  137466. };
  137467. }
  137468. declare module BABYLON {
  137469. /**
  137470. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137471. */
  137472. export class CircleOfConfusionPostProcess extends PostProcess {
  137473. /**
  137474. * 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.
  137475. */
  137476. lensSize: number;
  137477. /**
  137478. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137479. */
  137480. fStop: number;
  137481. /**
  137482. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137483. */
  137484. focusDistance: number;
  137485. /**
  137486. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137487. */
  137488. focalLength: number;
  137489. private _depthTexture;
  137490. /**
  137491. * Creates a new instance CircleOfConfusionPostProcess
  137492. * @param name The name of the effect.
  137493. * @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.
  137494. * @param options The required width/height ratio to downsize to before computing the render pass.
  137495. * @param camera The camera to apply the render pass to.
  137496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137497. * @param engine The engine which the post process will be applied. (default: current engine)
  137498. * @param reusable If the post process can be reused on the same frame. (default: false)
  137499. * @param textureType Type of textures used when performing the post process. (default: 0)
  137500. * @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)
  137501. */
  137502. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137503. /**
  137504. * 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.
  137505. */
  137506. set depthTexture(value: RenderTargetTexture);
  137507. }
  137508. }
  137509. declare module BABYLON {
  137510. /** @hidden */
  137511. export var colorCorrectionPixelShader: {
  137512. name: string;
  137513. shader: string;
  137514. };
  137515. }
  137516. declare module BABYLON {
  137517. /**
  137518. *
  137519. * This post-process allows the modification of rendered colors by using
  137520. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137521. *
  137522. * The object needs to be provided an url to a texture containing the color
  137523. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137524. * Use an image editing software to tweak the LUT to match your needs.
  137525. *
  137526. * For an example of a color LUT, see here:
  137527. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137528. * For explanations on color grading, see here:
  137529. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137530. *
  137531. */
  137532. export class ColorCorrectionPostProcess extends PostProcess {
  137533. private _colorTableTexture;
  137534. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137535. }
  137536. }
  137537. declare module BABYLON {
  137538. /** @hidden */
  137539. export var convolutionPixelShader: {
  137540. name: string;
  137541. shader: string;
  137542. };
  137543. }
  137544. declare module BABYLON {
  137545. /**
  137546. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137547. * input texture to perform effects such as edge detection or sharpening
  137548. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137549. */
  137550. export class ConvolutionPostProcess extends PostProcess {
  137551. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137552. kernel: number[];
  137553. /**
  137554. * Creates a new instance ConvolutionPostProcess
  137555. * @param name The name of the effect.
  137556. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137557. * @param options The required width/height ratio to downsize to before computing the render pass.
  137558. * @param camera The camera to apply the render pass to.
  137559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137560. * @param engine The engine which the post process will be applied. (default: current engine)
  137561. * @param reusable If the post process can be reused on the same frame. (default: false)
  137562. * @param textureType Type of textures used when performing the post process. (default: 0)
  137563. */
  137564. constructor(name: string,
  137565. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137566. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137567. /**
  137568. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137569. */
  137570. static EdgeDetect0Kernel: number[];
  137571. /**
  137572. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137573. */
  137574. static EdgeDetect1Kernel: number[];
  137575. /**
  137576. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137577. */
  137578. static EdgeDetect2Kernel: number[];
  137579. /**
  137580. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137581. */
  137582. static SharpenKernel: number[];
  137583. /**
  137584. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137585. */
  137586. static EmbossKernel: number[];
  137587. /**
  137588. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137589. */
  137590. static GaussianKernel: number[];
  137591. }
  137592. }
  137593. declare module BABYLON {
  137594. /**
  137595. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137596. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137597. * based on samples that have a large difference in distance than the center pixel.
  137598. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137599. */
  137600. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137601. direction: Vector2;
  137602. /**
  137603. * Creates a new instance CircleOfConfusionPostProcess
  137604. * @param name The name of the effect.
  137605. * @param scene The scene the effect belongs to.
  137606. * @param direction The direction the blur should be applied.
  137607. * @param kernel The size of the kernel used to blur.
  137608. * @param options The required width/height ratio to downsize to before computing the render pass.
  137609. * @param camera The camera to apply the render pass to.
  137610. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137611. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137613. * @param engine The engine which the post process will be applied. (default: current engine)
  137614. * @param reusable If the post process can be reused on the same frame. (default: false)
  137615. * @param textureType Type of textures used when performing the post process. (default: 0)
  137616. * @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)
  137617. */
  137618. 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);
  137619. }
  137620. }
  137621. declare module BABYLON {
  137622. /** @hidden */
  137623. export var depthOfFieldMergePixelShader: {
  137624. name: string;
  137625. shader: string;
  137626. };
  137627. }
  137628. declare module BABYLON {
  137629. /**
  137630. * Options to be set when merging outputs from the default pipeline.
  137631. */
  137632. export class DepthOfFieldMergePostProcessOptions {
  137633. /**
  137634. * The original image to merge on top of
  137635. */
  137636. originalFromInput: PostProcess;
  137637. /**
  137638. * Parameters to perform the merge of the depth of field effect
  137639. */
  137640. depthOfField?: {
  137641. circleOfConfusion: PostProcess;
  137642. blurSteps: Array<PostProcess>;
  137643. };
  137644. /**
  137645. * Parameters to perform the merge of bloom effect
  137646. */
  137647. bloom?: {
  137648. blurred: PostProcess;
  137649. weight: number;
  137650. };
  137651. }
  137652. /**
  137653. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137654. */
  137655. export class DepthOfFieldMergePostProcess extends PostProcess {
  137656. private blurSteps;
  137657. /**
  137658. * Creates a new instance of DepthOfFieldMergePostProcess
  137659. * @param name The name of the effect.
  137660. * @param originalFromInput Post process which's input will be used for the merge.
  137661. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137662. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137663. * @param options The required width/height ratio to downsize to before computing the render pass.
  137664. * @param camera The camera to apply the render pass to.
  137665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137666. * @param engine The engine which the post process will be applied. (default: current engine)
  137667. * @param reusable If the post process can be reused on the same frame. (default: false)
  137668. * @param textureType Type of textures used when performing the post process. (default: 0)
  137669. * @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)
  137670. */
  137671. 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);
  137672. /**
  137673. * Updates the effect with the current post process compile time values and recompiles the shader.
  137674. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137675. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137676. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137677. * @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
  137678. * @param onCompiled Called when the shader has been compiled.
  137679. * @param onError Called if there is an error when compiling a shader.
  137680. */
  137681. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137682. }
  137683. }
  137684. declare module BABYLON {
  137685. /**
  137686. * Specifies the level of max blur that should be applied when using the depth of field effect
  137687. */
  137688. export enum DepthOfFieldEffectBlurLevel {
  137689. /**
  137690. * Subtle blur
  137691. */
  137692. Low = 0,
  137693. /**
  137694. * Medium blur
  137695. */
  137696. Medium = 1,
  137697. /**
  137698. * Large blur
  137699. */
  137700. High = 2
  137701. }
  137702. /**
  137703. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137704. */
  137705. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137706. private _circleOfConfusion;
  137707. /**
  137708. * @hidden Internal, blurs from high to low
  137709. */
  137710. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137711. private _depthOfFieldBlurY;
  137712. private _dofMerge;
  137713. /**
  137714. * @hidden Internal post processes in depth of field effect
  137715. */
  137716. _effects: Array<PostProcess>;
  137717. /**
  137718. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137719. */
  137720. set focalLength(value: number);
  137721. get focalLength(): number;
  137722. /**
  137723. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137724. */
  137725. set fStop(value: number);
  137726. get fStop(): number;
  137727. /**
  137728. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137729. */
  137730. set focusDistance(value: number);
  137731. get focusDistance(): number;
  137732. /**
  137733. * 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.
  137734. */
  137735. set lensSize(value: number);
  137736. get lensSize(): number;
  137737. /**
  137738. * Creates a new instance DepthOfFieldEffect
  137739. * @param scene The scene the effect belongs to.
  137740. * @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.
  137741. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137742. * @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)
  137743. */
  137744. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137745. /**
  137746. * Get the current class name of the current effet
  137747. * @returns "DepthOfFieldEffect"
  137748. */
  137749. getClassName(): string;
  137750. /**
  137751. * 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.
  137752. */
  137753. set depthTexture(value: RenderTargetTexture);
  137754. /**
  137755. * Disposes each of the internal effects for a given camera.
  137756. * @param camera The camera to dispose the effect on.
  137757. */
  137758. disposeEffects(camera: Camera): void;
  137759. /**
  137760. * @hidden Internal
  137761. */
  137762. _updateEffects(): void;
  137763. /**
  137764. * Internal
  137765. * @returns if all the contained post processes are ready.
  137766. * @hidden
  137767. */
  137768. _isReady(): boolean;
  137769. }
  137770. }
  137771. declare module BABYLON {
  137772. /** @hidden */
  137773. export var displayPassPixelShader: {
  137774. name: string;
  137775. shader: string;
  137776. };
  137777. }
  137778. declare module BABYLON {
  137779. /**
  137780. * DisplayPassPostProcess which produces an output the same as it's input
  137781. */
  137782. export class DisplayPassPostProcess extends PostProcess {
  137783. /**
  137784. * Creates the DisplayPassPostProcess
  137785. * @param name The name of the effect.
  137786. * @param options The required width/height ratio to downsize to before computing the render pass.
  137787. * @param camera The camera to apply the render pass to.
  137788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137789. * @param engine The engine which the post process will be applied. (default: current engine)
  137790. * @param reusable If the post process can be reused on the same frame. (default: false)
  137791. */
  137792. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137793. }
  137794. }
  137795. declare module BABYLON {
  137796. /** @hidden */
  137797. export var filterPixelShader: {
  137798. name: string;
  137799. shader: string;
  137800. };
  137801. }
  137802. declare module BABYLON {
  137803. /**
  137804. * Applies a kernel filter to the image
  137805. */
  137806. export class FilterPostProcess extends PostProcess {
  137807. /** The matrix to be applied to the image */
  137808. kernelMatrix: Matrix;
  137809. /**
  137810. *
  137811. * @param name The name of the effect.
  137812. * @param kernelMatrix The matrix to be applied to the image
  137813. * @param options The required width/height ratio to downsize to before computing the render pass.
  137814. * @param camera The camera to apply the render pass to.
  137815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137816. * @param engine The engine which the post process will be applied. (default: current engine)
  137817. * @param reusable If the post process can be reused on the same frame. (default: false)
  137818. */
  137819. constructor(name: string,
  137820. /** The matrix to be applied to the image */
  137821. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137822. }
  137823. }
  137824. declare module BABYLON {
  137825. /** @hidden */
  137826. export var fxaaPixelShader: {
  137827. name: string;
  137828. shader: string;
  137829. };
  137830. }
  137831. declare module BABYLON {
  137832. /** @hidden */
  137833. export var fxaaVertexShader: {
  137834. name: string;
  137835. shader: string;
  137836. };
  137837. }
  137838. declare module BABYLON {
  137839. /**
  137840. * Fxaa post process
  137841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137842. */
  137843. export class FxaaPostProcess extends PostProcess {
  137844. /** @hidden */
  137845. texelWidth: number;
  137846. /** @hidden */
  137847. texelHeight: number;
  137848. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137849. private _getDefines;
  137850. }
  137851. }
  137852. declare module BABYLON {
  137853. /** @hidden */
  137854. export var grainPixelShader: {
  137855. name: string;
  137856. shader: string;
  137857. };
  137858. }
  137859. declare module BABYLON {
  137860. /**
  137861. * The GrainPostProcess adds noise to the image at mid luminance levels
  137862. */
  137863. export class GrainPostProcess extends PostProcess {
  137864. /**
  137865. * The intensity of the grain added (default: 30)
  137866. */
  137867. intensity: number;
  137868. /**
  137869. * If the grain should be randomized on every frame
  137870. */
  137871. animated: boolean;
  137872. /**
  137873. * Creates a new instance of @see GrainPostProcess
  137874. * @param name The name of the effect.
  137875. * @param options The required width/height ratio to downsize to before computing the render pass.
  137876. * @param camera The camera to apply the render pass to.
  137877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137878. * @param engine The engine which the post process will be applied. (default: current engine)
  137879. * @param reusable If the post process can be reused on the same frame. (default: false)
  137880. * @param textureType Type of textures used when performing the post process. (default: 0)
  137881. * @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)
  137882. */
  137883. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137884. }
  137885. }
  137886. declare module BABYLON {
  137887. /** @hidden */
  137888. export var highlightsPixelShader: {
  137889. name: string;
  137890. shader: string;
  137891. };
  137892. }
  137893. declare module BABYLON {
  137894. /**
  137895. * Extracts highlights from the image
  137896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137897. */
  137898. export class HighlightsPostProcess extends PostProcess {
  137899. /**
  137900. * Extracts highlights from the image
  137901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137902. * @param name The name of the effect.
  137903. * @param options The required width/height ratio to downsize to before computing the render pass.
  137904. * @param camera The camera to apply the render pass to.
  137905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137906. * @param engine The engine which the post process will be applied. (default: current engine)
  137907. * @param reusable If the post process can be reused on the same frame. (default: false)
  137908. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137909. */
  137910. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. /** @hidden */
  137915. export var mrtFragmentDeclaration: {
  137916. name: string;
  137917. shader: string;
  137918. };
  137919. }
  137920. declare module BABYLON {
  137921. /** @hidden */
  137922. export var geometryPixelShader: {
  137923. name: string;
  137924. shader: string;
  137925. };
  137926. }
  137927. declare module BABYLON {
  137928. /** @hidden */
  137929. export var geometryVertexShader: {
  137930. name: string;
  137931. shader: string;
  137932. };
  137933. }
  137934. declare module BABYLON {
  137935. /** @hidden */
  137936. interface ISavedTransformationMatrix {
  137937. world: Matrix;
  137938. viewProjection: Matrix;
  137939. }
  137940. /**
  137941. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137942. */
  137943. export class GeometryBufferRenderer {
  137944. /**
  137945. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137946. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137947. */
  137948. static readonly POSITION_TEXTURE_TYPE: number;
  137949. /**
  137950. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137951. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137952. */
  137953. static readonly VELOCITY_TEXTURE_TYPE: number;
  137954. /**
  137955. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137956. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137957. */
  137958. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137959. /**
  137960. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137961. * in order to compute objects velocities when enableVelocity is set to "true"
  137962. * @hidden
  137963. */
  137964. _previousTransformationMatrices: {
  137965. [index: number]: ISavedTransformationMatrix;
  137966. };
  137967. /**
  137968. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137969. * in order to compute objects velocities when enableVelocity is set to "true"
  137970. * @hidden
  137971. */
  137972. _previousBonesTransformationMatrices: {
  137973. [index: number]: Float32Array;
  137974. };
  137975. /**
  137976. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137977. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137978. */
  137979. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137980. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137981. renderTransparentMeshes: boolean;
  137982. private _scene;
  137983. private _multiRenderTarget;
  137984. private _ratio;
  137985. private _enablePosition;
  137986. private _enableVelocity;
  137987. private _enableReflectivity;
  137988. private _positionIndex;
  137989. private _velocityIndex;
  137990. private _reflectivityIndex;
  137991. protected _effect: Effect;
  137992. protected _cachedDefines: string;
  137993. /**
  137994. * Set the render list (meshes to be rendered) used in the G buffer.
  137995. */
  137996. set renderList(meshes: Mesh[]);
  137997. /**
  137998. * Gets wether or not G buffer are supported by the running hardware.
  137999. * This requires draw buffer supports
  138000. */
  138001. get isSupported(): boolean;
  138002. /**
  138003. * Returns the index of the given texture type in the G-Buffer textures array
  138004. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138005. * @returns the index of the given texture type in the G-Buffer textures array
  138006. */
  138007. getTextureIndex(textureType: number): number;
  138008. /**
  138009. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138010. */
  138011. get enablePosition(): boolean;
  138012. /**
  138013. * Sets whether or not objects positions are enabled for the G buffer.
  138014. */
  138015. set enablePosition(enable: boolean);
  138016. /**
  138017. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138018. */
  138019. get enableVelocity(): boolean;
  138020. /**
  138021. * Sets wether or not objects velocities are enabled for the G buffer.
  138022. */
  138023. set enableVelocity(enable: boolean);
  138024. /**
  138025. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138026. */
  138027. get enableReflectivity(): boolean;
  138028. /**
  138029. * Sets wether or not objects roughness are enabled for the G buffer.
  138030. */
  138031. set enableReflectivity(enable: boolean);
  138032. /**
  138033. * Gets the scene associated with the buffer.
  138034. */
  138035. get scene(): Scene;
  138036. /**
  138037. * Gets the ratio used by the buffer during its creation.
  138038. * How big is the buffer related to the main canvas.
  138039. */
  138040. get ratio(): number;
  138041. /** @hidden */
  138042. static _SceneComponentInitialization: (scene: Scene) => void;
  138043. /**
  138044. * Creates a new G Buffer for the scene
  138045. * @param scene The scene the buffer belongs to
  138046. * @param ratio How big is the buffer related to the main canvas.
  138047. */
  138048. constructor(scene: Scene, ratio?: number);
  138049. /**
  138050. * Checks wether everything is ready to render a submesh to the G buffer.
  138051. * @param subMesh the submesh to check readiness for
  138052. * @param useInstances is the mesh drawn using instance or not
  138053. * @returns true if ready otherwise false
  138054. */
  138055. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138056. /**
  138057. * Gets the current underlying G Buffer.
  138058. * @returns the buffer
  138059. */
  138060. getGBuffer(): MultiRenderTarget;
  138061. /**
  138062. * Gets the number of samples used to render the buffer (anti aliasing).
  138063. */
  138064. get samples(): number;
  138065. /**
  138066. * Sets the number of samples used to render the buffer (anti aliasing).
  138067. */
  138068. set samples(value: number);
  138069. /**
  138070. * Disposes the renderer and frees up associated resources.
  138071. */
  138072. dispose(): void;
  138073. protected _createRenderTargets(): void;
  138074. private _copyBonesTransformationMatrices;
  138075. }
  138076. }
  138077. declare module BABYLON {
  138078. interface Scene {
  138079. /** @hidden (Backing field) */
  138080. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138081. /**
  138082. * Gets or Sets the current geometry buffer associated to the scene.
  138083. */
  138084. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138085. /**
  138086. * Enables a GeometryBufferRender and associates it with the scene
  138087. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138088. * @returns the GeometryBufferRenderer
  138089. */
  138090. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138091. /**
  138092. * Disables the GeometryBufferRender associated with the scene
  138093. */
  138094. disableGeometryBufferRenderer(): void;
  138095. }
  138096. /**
  138097. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138098. * in several rendering techniques.
  138099. */
  138100. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138101. /**
  138102. * The component name helpful to identify the component in the list of scene components.
  138103. */
  138104. readonly name: string;
  138105. /**
  138106. * The scene the component belongs to.
  138107. */
  138108. scene: Scene;
  138109. /**
  138110. * Creates a new instance of the component for the given scene
  138111. * @param scene Defines the scene to register the component in
  138112. */
  138113. constructor(scene: Scene);
  138114. /**
  138115. * Registers the component in a given scene
  138116. */
  138117. register(): void;
  138118. /**
  138119. * Rebuilds the elements related to this component in case of
  138120. * context lost for instance.
  138121. */
  138122. rebuild(): void;
  138123. /**
  138124. * Disposes the component and the associated ressources
  138125. */
  138126. dispose(): void;
  138127. private _gatherRenderTargets;
  138128. }
  138129. }
  138130. declare module BABYLON {
  138131. /** @hidden */
  138132. export var motionBlurPixelShader: {
  138133. name: string;
  138134. shader: string;
  138135. };
  138136. }
  138137. declare module BABYLON {
  138138. /**
  138139. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138140. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138141. * As an example, all you have to do is to create the post-process:
  138142. * var mb = new BABYLON.MotionBlurPostProcess(
  138143. * 'mb', // The name of the effect.
  138144. * scene, // The scene containing the objects to blur according to their velocity.
  138145. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138146. * camera // The camera to apply the render pass to.
  138147. * );
  138148. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138149. */
  138150. export class MotionBlurPostProcess extends PostProcess {
  138151. /**
  138152. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138153. */
  138154. motionStrength: number;
  138155. /**
  138156. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138157. */
  138158. get motionBlurSamples(): number;
  138159. /**
  138160. * Sets the number of iterations to be used for motion blur quality
  138161. */
  138162. set motionBlurSamples(samples: number);
  138163. private _motionBlurSamples;
  138164. private _geometryBufferRenderer;
  138165. /**
  138166. * Creates a new instance MotionBlurPostProcess
  138167. * @param name The name of the effect.
  138168. * @param scene The scene containing the objects to blur according to their velocity.
  138169. * @param options The required width/height ratio to downsize to before computing the render pass.
  138170. * @param camera The camera to apply the render pass to.
  138171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138172. * @param engine The engine which the post process will be applied. (default: current engine)
  138173. * @param reusable If the post process can be reused on the same frame. (default: false)
  138174. * @param textureType Type of textures used when performing the post process. (default: 0)
  138175. * @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)
  138176. */
  138177. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138178. /**
  138179. * Excludes the given skinned mesh from computing bones velocities.
  138180. * 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.
  138181. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138182. */
  138183. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138184. /**
  138185. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138186. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138187. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138188. */
  138189. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138190. /**
  138191. * Disposes the post process.
  138192. * @param camera The camera to dispose the post process on.
  138193. */
  138194. dispose(camera?: Camera): void;
  138195. }
  138196. }
  138197. declare module BABYLON {
  138198. /** @hidden */
  138199. export var refractionPixelShader: {
  138200. name: string;
  138201. shader: string;
  138202. };
  138203. }
  138204. declare module BABYLON {
  138205. /**
  138206. * Post process which applies a refractin texture
  138207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138208. */
  138209. export class RefractionPostProcess extends PostProcess {
  138210. /** the base color of the refraction (used to taint the rendering) */
  138211. color: Color3;
  138212. /** simulated refraction depth */
  138213. depth: number;
  138214. /** the coefficient of the base color (0 to remove base color tainting) */
  138215. colorLevel: number;
  138216. private _refTexture;
  138217. private _ownRefractionTexture;
  138218. /**
  138219. * Gets or sets the refraction texture
  138220. * Please note that you are responsible for disposing the texture if you set it manually
  138221. */
  138222. get refractionTexture(): Texture;
  138223. set refractionTexture(value: Texture);
  138224. /**
  138225. * Initializes the RefractionPostProcess
  138226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138227. * @param name The name of the effect.
  138228. * @param refractionTextureUrl Url of the refraction texture to use
  138229. * @param color the base color of the refraction (used to taint the rendering)
  138230. * @param depth simulated refraction depth
  138231. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138232. * @param camera The camera to apply the render pass to.
  138233. * @param options The required width/height ratio to downsize to before computing the render pass.
  138234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138235. * @param engine The engine which the post process will be applied. (default: current engine)
  138236. * @param reusable If the post process can be reused on the same frame. (default: false)
  138237. */
  138238. constructor(name: string, refractionTextureUrl: string,
  138239. /** the base color of the refraction (used to taint the rendering) */
  138240. color: Color3,
  138241. /** simulated refraction depth */
  138242. depth: number,
  138243. /** the coefficient of the base color (0 to remove base color tainting) */
  138244. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138245. /**
  138246. * Disposes of the post process
  138247. * @param camera Camera to dispose post process on
  138248. */
  138249. dispose(camera: Camera): void;
  138250. }
  138251. }
  138252. declare module BABYLON {
  138253. /** @hidden */
  138254. export var sharpenPixelShader: {
  138255. name: string;
  138256. shader: string;
  138257. };
  138258. }
  138259. declare module BABYLON {
  138260. /**
  138261. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138262. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138263. */
  138264. export class SharpenPostProcess extends PostProcess {
  138265. /**
  138266. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138267. */
  138268. colorAmount: number;
  138269. /**
  138270. * How much sharpness should be applied (default: 0.3)
  138271. */
  138272. edgeAmount: number;
  138273. /**
  138274. * Creates a new instance ConvolutionPostProcess
  138275. * @param name The name of the effect.
  138276. * @param options The required width/height ratio to downsize to before computing the render pass.
  138277. * @param camera The camera to apply the render pass to.
  138278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138279. * @param engine The engine which the post process will be applied. (default: current engine)
  138280. * @param reusable If the post process can be reused on the same frame. (default: false)
  138281. * @param textureType Type of textures used when performing the post process. (default: 0)
  138282. * @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)
  138283. */
  138284. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138285. }
  138286. }
  138287. declare module BABYLON {
  138288. /**
  138289. * PostProcessRenderPipeline
  138290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138291. */
  138292. export class PostProcessRenderPipeline {
  138293. private engine;
  138294. private _renderEffects;
  138295. private _renderEffectsForIsolatedPass;
  138296. /**
  138297. * List of inspectable custom properties (used by the Inspector)
  138298. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138299. */
  138300. inspectableCustomProperties: IInspectable[];
  138301. /**
  138302. * @hidden
  138303. */
  138304. protected _cameras: Camera[];
  138305. /** @hidden */
  138306. _name: string;
  138307. /**
  138308. * Gets pipeline name
  138309. */
  138310. get name(): string;
  138311. /** Gets the list of attached cameras */
  138312. get cameras(): Camera[];
  138313. /**
  138314. * Initializes a PostProcessRenderPipeline
  138315. * @param engine engine to add the pipeline to
  138316. * @param name name of the pipeline
  138317. */
  138318. constructor(engine: Engine, name: string);
  138319. /**
  138320. * Gets the class name
  138321. * @returns "PostProcessRenderPipeline"
  138322. */
  138323. getClassName(): string;
  138324. /**
  138325. * If all the render effects in the pipeline are supported
  138326. */
  138327. get isSupported(): boolean;
  138328. /**
  138329. * Adds an effect to the pipeline
  138330. * @param renderEffect the effect to add
  138331. */
  138332. addEffect(renderEffect: PostProcessRenderEffect): void;
  138333. /** @hidden */
  138334. _rebuild(): void;
  138335. /** @hidden */
  138336. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138337. /** @hidden */
  138338. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138339. /** @hidden */
  138340. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138341. /** @hidden */
  138342. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138343. /** @hidden */
  138344. _attachCameras(cameras: Camera, unique: boolean): void;
  138345. /** @hidden */
  138346. _attachCameras(cameras: Camera[], unique: boolean): void;
  138347. /** @hidden */
  138348. _detachCameras(cameras: Camera): void;
  138349. /** @hidden */
  138350. _detachCameras(cameras: Nullable<Camera[]>): void;
  138351. /** @hidden */
  138352. _update(): void;
  138353. /** @hidden */
  138354. _reset(): void;
  138355. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138356. /**
  138357. * Disposes of the pipeline
  138358. */
  138359. dispose(): void;
  138360. }
  138361. }
  138362. declare module BABYLON {
  138363. /**
  138364. * PostProcessRenderPipelineManager class
  138365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138366. */
  138367. export class PostProcessRenderPipelineManager {
  138368. private _renderPipelines;
  138369. /**
  138370. * Initializes a PostProcessRenderPipelineManager
  138371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138372. */
  138373. constructor();
  138374. /**
  138375. * Gets the list of supported render pipelines
  138376. */
  138377. get supportedPipelines(): PostProcessRenderPipeline[];
  138378. /**
  138379. * Adds a pipeline to the manager
  138380. * @param renderPipeline The pipeline to add
  138381. */
  138382. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138383. /**
  138384. * Attaches a camera to the pipeline
  138385. * @param renderPipelineName The name of the pipeline to attach to
  138386. * @param cameras the camera to attach
  138387. * @param unique if the camera can be attached multiple times to the pipeline
  138388. */
  138389. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138390. /**
  138391. * Detaches a camera from the pipeline
  138392. * @param renderPipelineName The name of the pipeline to detach from
  138393. * @param cameras the camera to detach
  138394. */
  138395. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138396. /**
  138397. * Enables an effect by name on a pipeline
  138398. * @param renderPipelineName the name of the pipeline to enable the effect in
  138399. * @param renderEffectName the name of the effect to enable
  138400. * @param cameras the cameras that the effect should be enabled on
  138401. */
  138402. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138403. /**
  138404. * Disables an effect by name on a pipeline
  138405. * @param renderPipelineName the name of the pipeline to disable the effect in
  138406. * @param renderEffectName the name of the effect to disable
  138407. * @param cameras the cameras that the effect should be disabled on
  138408. */
  138409. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138410. /**
  138411. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138412. */
  138413. update(): void;
  138414. /** @hidden */
  138415. _rebuild(): void;
  138416. /**
  138417. * Disposes of the manager and pipelines
  138418. */
  138419. dispose(): void;
  138420. }
  138421. }
  138422. declare module BABYLON {
  138423. interface Scene {
  138424. /** @hidden (Backing field) */
  138425. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138426. /**
  138427. * Gets the postprocess render pipeline manager
  138428. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138429. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138430. */
  138431. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138432. }
  138433. /**
  138434. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138435. */
  138436. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138437. /**
  138438. * The component name helpfull to identify the component in the list of scene components.
  138439. */
  138440. readonly name: string;
  138441. /**
  138442. * The scene the component belongs to.
  138443. */
  138444. scene: Scene;
  138445. /**
  138446. * Creates a new instance of the component for the given scene
  138447. * @param scene Defines the scene to register the component in
  138448. */
  138449. constructor(scene: Scene);
  138450. /**
  138451. * Registers the component in a given scene
  138452. */
  138453. register(): void;
  138454. /**
  138455. * Rebuilds the elements related to this component in case of
  138456. * context lost for instance.
  138457. */
  138458. rebuild(): void;
  138459. /**
  138460. * Disposes the component and the associated ressources
  138461. */
  138462. dispose(): void;
  138463. private _gatherRenderTargets;
  138464. }
  138465. }
  138466. declare module BABYLON {
  138467. /**
  138468. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138469. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138470. */
  138471. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138472. private _scene;
  138473. private _camerasToBeAttached;
  138474. /**
  138475. * ID of the sharpen post process,
  138476. */
  138477. private readonly SharpenPostProcessId;
  138478. /**
  138479. * @ignore
  138480. * ID of the image processing post process;
  138481. */
  138482. readonly ImageProcessingPostProcessId: string;
  138483. /**
  138484. * @ignore
  138485. * ID of the Fast Approximate Anti-Aliasing post process;
  138486. */
  138487. readonly FxaaPostProcessId: string;
  138488. /**
  138489. * ID of the chromatic aberration post process,
  138490. */
  138491. private readonly ChromaticAberrationPostProcessId;
  138492. /**
  138493. * ID of the grain post process
  138494. */
  138495. private readonly GrainPostProcessId;
  138496. /**
  138497. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138498. */
  138499. sharpen: SharpenPostProcess;
  138500. private _sharpenEffect;
  138501. private bloom;
  138502. /**
  138503. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138504. */
  138505. depthOfField: DepthOfFieldEffect;
  138506. /**
  138507. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138508. */
  138509. fxaa: FxaaPostProcess;
  138510. /**
  138511. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138512. */
  138513. imageProcessing: ImageProcessingPostProcess;
  138514. /**
  138515. * Chromatic aberration post process which will shift rgb colors in the image
  138516. */
  138517. chromaticAberration: ChromaticAberrationPostProcess;
  138518. private _chromaticAberrationEffect;
  138519. /**
  138520. * Grain post process which add noise to the image
  138521. */
  138522. grain: GrainPostProcess;
  138523. private _grainEffect;
  138524. /**
  138525. * Glow post process which adds a glow to emissive areas of the image
  138526. */
  138527. private _glowLayer;
  138528. /**
  138529. * Animations which can be used to tweak settings over a period of time
  138530. */
  138531. animations: Animation[];
  138532. private _imageProcessingConfigurationObserver;
  138533. private _sharpenEnabled;
  138534. private _bloomEnabled;
  138535. private _depthOfFieldEnabled;
  138536. private _depthOfFieldBlurLevel;
  138537. private _fxaaEnabled;
  138538. private _imageProcessingEnabled;
  138539. private _defaultPipelineTextureType;
  138540. private _bloomScale;
  138541. private _chromaticAberrationEnabled;
  138542. private _grainEnabled;
  138543. private _buildAllowed;
  138544. /**
  138545. * Gets active scene
  138546. */
  138547. get scene(): Scene;
  138548. /**
  138549. * Enable or disable the sharpen process from the pipeline
  138550. */
  138551. set sharpenEnabled(enabled: boolean);
  138552. get sharpenEnabled(): boolean;
  138553. private _resizeObserver;
  138554. private _hardwareScaleLevel;
  138555. private _bloomKernel;
  138556. /**
  138557. * Specifies the size of the bloom blur kernel, relative to the final output size
  138558. */
  138559. get bloomKernel(): number;
  138560. set bloomKernel(value: number);
  138561. /**
  138562. * Specifies the weight of the bloom in the final rendering
  138563. */
  138564. private _bloomWeight;
  138565. /**
  138566. * Specifies the luma threshold for the area that will be blurred by the bloom
  138567. */
  138568. private _bloomThreshold;
  138569. private _hdr;
  138570. /**
  138571. * The strength of the bloom.
  138572. */
  138573. set bloomWeight(value: number);
  138574. get bloomWeight(): number;
  138575. /**
  138576. * The strength of the bloom.
  138577. */
  138578. set bloomThreshold(value: number);
  138579. get bloomThreshold(): number;
  138580. /**
  138581. * The scale of the bloom, lower value will provide better performance.
  138582. */
  138583. set bloomScale(value: number);
  138584. get bloomScale(): number;
  138585. /**
  138586. * Enable or disable the bloom from the pipeline
  138587. */
  138588. set bloomEnabled(enabled: boolean);
  138589. get bloomEnabled(): boolean;
  138590. private _rebuildBloom;
  138591. /**
  138592. * If the depth of field is enabled.
  138593. */
  138594. get depthOfFieldEnabled(): boolean;
  138595. set depthOfFieldEnabled(enabled: boolean);
  138596. /**
  138597. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138598. */
  138599. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138600. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138601. /**
  138602. * If the anti aliasing is enabled.
  138603. */
  138604. set fxaaEnabled(enabled: boolean);
  138605. get fxaaEnabled(): boolean;
  138606. private _samples;
  138607. /**
  138608. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138609. */
  138610. set samples(sampleCount: number);
  138611. get samples(): number;
  138612. /**
  138613. * If image processing is enabled.
  138614. */
  138615. set imageProcessingEnabled(enabled: boolean);
  138616. get imageProcessingEnabled(): boolean;
  138617. /**
  138618. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138619. */
  138620. set glowLayerEnabled(enabled: boolean);
  138621. get glowLayerEnabled(): boolean;
  138622. /**
  138623. * Gets the glow layer (or null if not defined)
  138624. */
  138625. get glowLayer(): Nullable<GlowLayer>;
  138626. /**
  138627. * Enable or disable the chromaticAberration process from the pipeline
  138628. */
  138629. set chromaticAberrationEnabled(enabled: boolean);
  138630. get chromaticAberrationEnabled(): boolean;
  138631. /**
  138632. * Enable or disable the grain process from the pipeline
  138633. */
  138634. set grainEnabled(enabled: boolean);
  138635. get grainEnabled(): boolean;
  138636. /**
  138637. * @constructor
  138638. * @param name - The rendering pipeline name (default: "")
  138639. * @param hdr - If high dynamic range textures should be used (default: true)
  138640. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138641. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138642. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138643. */
  138644. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138645. /**
  138646. * Get the class name
  138647. * @returns "DefaultRenderingPipeline"
  138648. */
  138649. getClassName(): string;
  138650. /**
  138651. * Force the compilation of the entire pipeline.
  138652. */
  138653. prepare(): void;
  138654. private _hasCleared;
  138655. private _prevPostProcess;
  138656. private _prevPrevPostProcess;
  138657. private _setAutoClearAndTextureSharing;
  138658. private _depthOfFieldSceneObserver;
  138659. private _buildPipeline;
  138660. private _disposePostProcesses;
  138661. /**
  138662. * Adds a camera to the pipeline
  138663. * @param camera the camera to be added
  138664. */
  138665. addCamera(camera: Camera): void;
  138666. /**
  138667. * Removes a camera from the pipeline
  138668. * @param camera the camera to remove
  138669. */
  138670. removeCamera(camera: Camera): void;
  138671. /**
  138672. * Dispose of the pipeline and stop all post processes
  138673. */
  138674. dispose(): void;
  138675. /**
  138676. * Serialize the rendering pipeline (Used when exporting)
  138677. * @returns the serialized object
  138678. */
  138679. serialize(): any;
  138680. /**
  138681. * Parse the serialized pipeline
  138682. * @param source Source pipeline.
  138683. * @param scene The scene to load the pipeline to.
  138684. * @param rootUrl The URL of the serialized pipeline.
  138685. * @returns An instantiated pipeline from the serialized object.
  138686. */
  138687. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138688. }
  138689. }
  138690. declare module BABYLON {
  138691. /** @hidden */
  138692. export var lensHighlightsPixelShader: {
  138693. name: string;
  138694. shader: string;
  138695. };
  138696. }
  138697. declare module BABYLON {
  138698. /** @hidden */
  138699. export var depthOfFieldPixelShader: {
  138700. name: string;
  138701. shader: string;
  138702. };
  138703. }
  138704. declare module BABYLON {
  138705. /**
  138706. * BABYLON.JS Chromatic Aberration GLSL Shader
  138707. * Author: Olivier Guyot
  138708. * Separates very slightly R, G and B colors on the edges of the screen
  138709. * Inspired by Francois Tarlier & Martins Upitis
  138710. */
  138711. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138712. /**
  138713. * @ignore
  138714. * The chromatic aberration PostProcess id in the pipeline
  138715. */
  138716. LensChromaticAberrationEffect: string;
  138717. /**
  138718. * @ignore
  138719. * The highlights enhancing PostProcess id in the pipeline
  138720. */
  138721. HighlightsEnhancingEffect: string;
  138722. /**
  138723. * @ignore
  138724. * The depth-of-field PostProcess id in the pipeline
  138725. */
  138726. LensDepthOfFieldEffect: string;
  138727. private _scene;
  138728. private _depthTexture;
  138729. private _grainTexture;
  138730. private _chromaticAberrationPostProcess;
  138731. private _highlightsPostProcess;
  138732. private _depthOfFieldPostProcess;
  138733. private _edgeBlur;
  138734. private _grainAmount;
  138735. private _chromaticAberration;
  138736. private _distortion;
  138737. private _highlightsGain;
  138738. private _highlightsThreshold;
  138739. private _dofDistance;
  138740. private _dofAperture;
  138741. private _dofDarken;
  138742. private _dofPentagon;
  138743. private _blurNoise;
  138744. /**
  138745. * @constructor
  138746. *
  138747. * Effect parameters are as follow:
  138748. * {
  138749. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138750. * edge_blur: number; // from 0 to x (1 for realism)
  138751. * distortion: number; // from 0 to x (1 for realism)
  138752. * grain_amount: number; // from 0 to 1
  138753. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138754. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138755. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138756. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138757. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138758. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138759. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138760. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138761. * }
  138762. * Note: if an effect parameter is unset, effect is disabled
  138763. *
  138764. * @param name The rendering pipeline name
  138765. * @param parameters - An object containing all parameters (see above)
  138766. * @param scene The scene linked to this pipeline
  138767. * @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)
  138768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138769. */
  138770. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138771. /**
  138772. * Get the class name
  138773. * @returns "LensRenderingPipeline"
  138774. */
  138775. getClassName(): string;
  138776. /**
  138777. * Gets associated scene
  138778. */
  138779. get scene(): Scene;
  138780. /**
  138781. * Gets or sets the edge blur
  138782. */
  138783. get edgeBlur(): number;
  138784. set edgeBlur(value: number);
  138785. /**
  138786. * Gets or sets the grain amount
  138787. */
  138788. get grainAmount(): number;
  138789. set grainAmount(value: number);
  138790. /**
  138791. * Gets or sets the chromatic aberration amount
  138792. */
  138793. get chromaticAberration(): number;
  138794. set chromaticAberration(value: number);
  138795. /**
  138796. * Gets or sets the depth of field aperture
  138797. */
  138798. get dofAperture(): number;
  138799. set dofAperture(value: number);
  138800. /**
  138801. * Gets or sets the edge distortion
  138802. */
  138803. get edgeDistortion(): number;
  138804. set edgeDistortion(value: number);
  138805. /**
  138806. * Gets or sets the depth of field distortion
  138807. */
  138808. get dofDistortion(): number;
  138809. set dofDistortion(value: number);
  138810. /**
  138811. * Gets or sets the darken out of focus amount
  138812. */
  138813. get darkenOutOfFocus(): number;
  138814. set darkenOutOfFocus(value: number);
  138815. /**
  138816. * Gets or sets a boolean indicating if blur noise is enabled
  138817. */
  138818. get blurNoise(): boolean;
  138819. set blurNoise(value: boolean);
  138820. /**
  138821. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138822. */
  138823. get pentagonBokeh(): boolean;
  138824. set pentagonBokeh(value: boolean);
  138825. /**
  138826. * Gets or sets the highlight grain amount
  138827. */
  138828. get highlightsGain(): number;
  138829. set highlightsGain(value: number);
  138830. /**
  138831. * Gets or sets the highlight threshold
  138832. */
  138833. get highlightsThreshold(): number;
  138834. set highlightsThreshold(value: number);
  138835. /**
  138836. * Sets the amount of blur at the edges
  138837. * @param amount blur amount
  138838. */
  138839. setEdgeBlur(amount: number): void;
  138840. /**
  138841. * Sets edge blur to 0
  138842. */
  138843. disableEdgeBlur(): void;
  138844. /**
  138845. * Sets the amout of grain
  138846. * @param amount Amount of grain
  138847. */
  138848. setGrainAmount(amount: number): void;
  138849. /**
  138850. * Set grain amount to 0
  138851. */
  138852. disableGrain(): void;
  138853. /**
  138854. * Sets the chromatic aberration amount
  138855. * @param amount amount of chromatic aberration
  138856. */
  138857. setChromaticAberration(amount: number): void;
  138858. /**
  138859. * Sets chromatic aberration amount to 0
  138860. */
  138861. disableChromaticAberration(): void;
  138862. /**
  138863. * Sets the EdgeDistortion amount
  138864. * @param amount amount of EdgeDistortion
  138865. */
  138866. setEdgeDistortion(amount: number): void;
  138867. /**
  138868. * Sets edge distortion to 0
  138869. */
  138870. disableEdgeDistortion(): void;
  138871. /**
  138872. * Sets the FocusDistance amount
  138873. * @param amount amount of FocusDistance
  138874. */
  138875. setFocusDistance(amount: number): void;
  138876. /**
  138877. * Disables depth of field
  138878. */
  138879. disableDepthOfField(): void;
  138880. /**
  138881. * Sets the Aperture amount
  138882. * @param amount amount of Aperture
  138883. */
  138884. setAperture(amount: number): void;
  138885. /**
  138886. * Sets the DarkenOutOfFocus amount
  138887. * @param amount amount of DarkenOutOfFocus
  138888. */
  138889. setDarkenOutOfFocus(amount: number): void;
  138890. private _pentagonBokehIsEnabled;
  138891. /**
  138892. * Creates a pentagon bokeh effect
  138893. */
  138894. enablePentagonBokeh(): void;
  138895. /**
  138896. * Disables the pentagon bokeh effect
  138897. */
  138898. disablePentagonBokeh(): void;
  138899. /**
  138900. * Enables noise blur
  138901. */
  138902. enableNoiseBlur(): void;
  138903. /**
  138904. * Disables noise blur
  138905. */
  138906. disableNoiseBlur(): void;
  138907. /**
  138908. * Sets the HighlightsGain amount
  138909. * @param amount amount of HighlightsGain
  138910. */
  138911. setHighlightsGain(amount: number): void;
  138912. /**
  138913. * Sets the HighlightsThreshold amount
  138914. * @param amount amount of HighlightsThreshold
  138915. */
  138916. setHighlightsThreshold(amount: number): void;
  138917. /**
  138918. * Disables highlights
  138919. */
  138920. disableHighlights(): void;
  138921. /**
  138922. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138923. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138924. */
  138925. dispose(disableDepthRender?: boolean): void;
  138926. private _createChromaticAberrationPostProcess;
  138927. private _createHighlightsPostProcess;
  138928. private _createDepthOfFieldPostProcess;
  138929. private _createGrainTexture;
  138930. }
  138931. }
  138932. declare module BABYLON {
  138933. /** @hidden */
  138934. export var ssao2PixelShader: {
  138935. name: string;
  138936. shader: string;
  138937. };
  138938. }
  138939. declare module BABYLON {
  138940. /** @hidden */
  138941. export var ssaoCombinePixelShader: {
  138942. name: string;
  138943. shader: string;
  138944. };
  138945. }
  138946. declare module BABYLON {
  138947. /**
  138948. * Render pipeline to produce ssao effect
  138949. */
  138950. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138951. /**
  138952. * @ignore
  138953. * The PassPostProcess id in the pipeline that contains the original scene color
  138954. */
  138955. SSAOOriginalSceneColorEffect: string;
  138956. /**
  138957. * @ignore
  138958. * The SSAO PostProcess id in the pipeline
  138959. */
  138960. SSAORenderEffect: string;
  138961. /**
  138962. * @ignore
  138963. * The horizontal blur PostProcess id in the pipeline
  138964. */
  138965. SSAOBlurHRenderEffect: string;
  138966. /**
  138967. * @ignore
  138968. * The vertical blur PostProcess id in the pipeline
  138969. */
  138970. SSAOBlurVRenderEffect: string;
  138971. /**
  138972. * @ignore
  138973. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138974. */
  138975. SSAOCombineRenderEffect: string;
  138976. /**
  138977. * The output strength of the SSAO post-process. Default value is 1.0.
  138978. */
  138979. totalStrength: number;
  138980. /**
  138981. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138982. */
  138983. maxZ: number;
  138984. /**
  138985. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138986. */
  138987. minZAspect: number;
  138988. private _samples;
  138989. /**
  138990. * Number of samples used for the SSAO calculations. Default value is 8
  138991. */
  138992. set samples(n: number);
  138993. get samples(): number;
  138994. private _textureSamples;
  138995. /**
  138996. * Number of samples to use for antialiasing
  138997. */
  138998. set textureSamples(n: number);
  138999. get textureSamples(): number;
  139000. /**
  139001. * Ratio object used for SSAO ratio and blur ratio
  139002. */
  139003. private _ratio;
  139004. /**
  139005. * Dynamically generated sphere sampler.
  139006. */
  139007. private _sampleSphere;
  139008. /**
  139009. * Blur filter offsets
  139010. */
  139011. private _samplerOffsets;
  139012. private _expensiveBlur;
  139013. /**
  139014. * If bilateral blur should be used
  139015. */
  139016. set expensiveBlur(b: boolean);
  139017. get expensiveBlur(): boolean;
  139018. /**
  139019. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139020. */
  139021. radius: number;
  139022. /**
  139023. * The base color of the SSAO post-process
  139024. * The final result is "base + ssao" between [0, 1]
  139025. */
  139026. base: number;
  139027. /**
  139028. * Support test.
  139029. */
  139030. static get IsSupported(): boolean;
  139031. private _scene;
  139032. private _depthTexture;
  139033. private _normalTexture;
  139034. private _randomTexture;
  139035. private _originalColorPostProcess;
  139036. private _ssaoPostProcess;
  139037. private _blurHPostProcess;
  139038. private _blurVPostProcess;
  139039. private _ssaoCombinePostProcess;
  139040. /**
  139041. * Gets active scene
  139042. */
  139043. get scene(): Scene;
  139044. /**
  139045. * @constructor
  139046. * @param name The rendering pipeline name
  139047. * @param scene The scene linked to this pipeline
  139048. * @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 }
  139049. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139050. */
  139051. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139052. /**
  139053. * Get the class name
  139054. * @returns "SSAO2RenderingPipeline"
  139055. */
  139056. getClassName(): string;
  139057. /**
  139058. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139059. */
  139060. dispose(disableGeometryBufferRenderer?: boolean): void;
  139061. private _createBlurPostProcess;
  139062. /** @hidden */
  139063. _rebuild(): void;
  139064. private _bits;
  139065. private _radicalInverse_VdC;
  139066. private _hammersley;
  139067. private _hemisphereSample_uniform;
  139068. private _generateHemisphere;
  139069. private _createSSAOPostProcess;
  139070. private _createSSAOCombinePostProcess;
  139071. private _createRandomTexture;
  139072. /**
  139073. * Serialize the rendering pipeline (Used when exporting)
  139074. * @returns the serialized object
  139075. */
  139076. serialize(): any;
  139077. /**
  139078. * Parse the serialized pipeline
  139079. * @param source Source pipeline.
  139080. * @param scene The scene to load the pipeline to.
  139081. * @param rootUrl The URL of the serialized pipeline.
  139082. * @returns An instantiated pipeline from the serialized object.
  139083. */
  139084. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139085. }
  139086. }
  139087. declare module BABYLON {
  139088. /** @hidden */
  139089. export var ssaoPixelShader: {
  139090. name: string;
  139091. shader: string;
  139092. };
  139093. }
  139094. declare module BABYLON {
  139095. /**
  139096. * Render pipeline to produce ssao effect
  139097. */
  139098. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139099. /**
  139100. * @ignore
  139101. * The PassPostProcess id in the pipeline that contains the original scene color
  139102. */
  139103. SSAOOriginalSceneColorEffect: string;
  139104. /**
  139105. * @ignore
  139106. * The SSAO PostProcess id in the pipeline
  139107. */
  139108. SSAORenderEffect: string;
  139109. /**
  139110. * @ignore
  139111. * The horizontal blur PostProcess id in the pipeline
  139112. */
  139113. SSAOBlurHRenderEffect: string;
  139114. /**
  139115. * @ignore
  139116. * The vertical blur PostProcess id in the pipeline
  139117. */
  139118. SSAOBlurVRenderEffect: string;
  139119. /**
  139120. * @ignore
  139121. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139122. */
  139123. SSAOCombineRenderEffect: string;
  139124. /**
  139125. * The output strength of the SSAO post-process. Default value is 1.0.
  139126. */
  139127. totalStrength: number;
  139128. /**
  139129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139130. */
  139131. radius: number;
  139132. /**
  139133. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139134. * Must not be equal to fallOff and superior to fallOff.
  139135. * Default value is 0.0075
  139136. */
  139137. area: number;
  139138. /**
  139139. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139140. * Must not be equal to area and inferior to area.
  139141. * Default value is 0.000001
  139142. */
  139143. fallOff: number;
  139144. /**
  139145. * The base color of the SSAO post-process
  139146. * The final result is "base + ssao" between [0, 1]
  139147. */
  139148. base: number;
  139149. private _scene;
  139150. private _depthTexture;
  139151. private _randomTexture;
  139152. private _originalColorPostProcess;
  139153. private _ssaoPostProcess;
  139154. private _blurHPostProcess;
  139155. private _blurVPostProcess;
  139156. private _ssaoCombinePostProcess;
  139157. private _firstUpdate;
  139158. /**
  139159. * Gets active scene
  139160. */
  139161. get scene(): Scene;
  139162. /**
  139163. * @constructor
  139164. * @param name - The rendering pipeline name
  139165. * @param scene - The scene linked to this pipeline
  139166. * @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 }
  139167. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139168. */
  139169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139170. /**
  139171. * Get the class name
  139172. * @returns "SSAORenderingPipeline"
  139173. */
  139174. getClassName(): string;
  139175. /**
  139176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139177. */
  139178. dispose(disableDepthRender?: boolean): void;
  139179. private _createBlurPostProcess;
  139180. /** @hidden */
  139181. _rebuild(): void;
  139182. private _createSSAOPostProcess;
  139183. private _createSSAOCombinePostProcess;
  139184. private _createRandomTexture;
  139185. }
  139186. }
  139187. declare module BABYLON {
  139188. /** @hidden */
  139189. export var screenSpaceReflectionPixelShader: {
  139190. name: string;
  139191. shader: string;
  139192. };
  139193. }
  139194. declare module BABYLON {
  139195. /**
  139196. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139197. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139198. */
  139199. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139200. /**
  139201. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139202. */
  139203. threshold: number;
  139204. /**
  139205. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139206. */
  139207. strength: number;
  139208. /**
  139209. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139210. */
  139211. reflectionSpecularFalloffExponent: number;
  139212. /**
  139213. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  139214. */
  139215. step: number;
  139216. /**
  139217. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139218. */
  139219. roughnessFactor: number;
  139220. private _geometryBufferRenderer;
  139221. private _enableSmoothReflections;
  139222. private _reflectionSamples;
  139223. private _smoothSteps;
  139224. /**
  139225. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139226. * @param name The name of the effect.
  139227. * @param scene The scene containing the objects to calculate reflections.
  139228. * @param options The required width/height ratio to downsize to before computing the render pass.
  139229. * @param camera The camera to apply the render pass to.
  139230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139231. * @param engine The engine which the post process will be applied. (default: current engine)
  139232. * @param reusable If the post process can be reused on the same frame. (default: false)
  139233. * @param textureType Type of textures used when performing the post process. (default: 0)
  139234. * @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)
  139235. */
  139236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139237. /**
  139238. * Gets wether or not smoothing reflections is enabled.
  139239. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139240. */
  139241. get enableSmoothReflections(): boolean;
  139242. /**
  139243. * Sets wether or not smoothing reflections is enabled.
  139244. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139245. */
  139246. set enableSmoothReflections(enabled: boolean);
  139247. /**
  139248. * Gets the number of samples taken while computing reflections. More samples count is high,
  139249. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139250. */
  139251. get reflectionSamples(): number;
  139252. /**
  139253. * Sets the number of samples taken while computing reflections. More samples count is high,
  139254. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139255. */
  139256. set reflectionSamples(samples: number);
  139257. /**
  139258. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139259. * more the post-process will require GPU power and can generate a drop in FPS.
  139260. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139261. */
  139262. get smoothSteps(): number;
  139263. set smoothSteps(steps: number);
  139264. private _updateEffectDefines;
  139265. }
  139266. }
  139267. declare module BABYLON {
  139268. /** @hidden */
  139269. export var standardPixelShader: {
  139270. name: string;
  139271. shader: string;
  139272. };
  139273. }
  139274. declare module BABYLON {
  139275. /**
  139276. * Standard rendering pipeline
  139277. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139278. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139279. */
  139280. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139281. /**
  139282. * Public members
  139283. */
  139284. /**
  139285. * Post-process which contains the original scene color before the pipeline applies all the effects
  139286. */
  139287. originalPostProcess: Nullable<PostProcess>;
  139288. /**
  139289. * Post-process used to down scale an image x4
  139290. */
  139291. downSampleX4PostProcess: Nullable<PostProcess>;
  139292. /**
  139293. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139294. */
  139295. brightPassPostProcess: Nullable<PostProcess>;
  139296. /**
  139297. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139298. */
  139299. blurHPostProcesses: PostProcess[];
  139300. /**
  139301. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139302. */
  139303. blurVPostProcesses: PostProcess[];
  139304. /**
  139305. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139306. */
  139307. textureAdderPostProcess: Nullable<PostProcess>;
  139308. /**
  139309. * Post-process used to create volumetric lighting effect
  139310. */
  139311. volumetricLightPostProcess: Nullable<PostProcess>;
  139312. /**
  139313. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139314. */
  139315. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139316. /**
  139317. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139318. */
  139319. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139320. /**
  139321. * Post-process used to merge the volumetric light effect and the real scene color
  139322. */
  139323. volumetricLightMergePostProces: Nullable<PostProcess>;
  139324. /**
  139325. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139326. */
  139327. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139328. /**
  139329. * Base post-process used to calculate the average luminance of the final image for HDR
  139330. */
  139331. luminancePostProcess: Nullable<PostProcess>;
  139332. /**
  139333. * Post-processes used to create down sample post-processes in order to get
  139334. * the average luminance of the final image for HDR
  139335. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139336. */
  139337. luminanceDownSamplePostProcesses: PostProcess[];
  139338. /**
  139339. * Post-process used to create a HDR effect (light adaptation)
  139340. */
  139341. hdrPostProcess: Nullable<PostProcess>;
  139342. /**
  139343. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139344. */
  139345. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139346. /**
  139347. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139348. */
  139349. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139350. /**
  139351. * Post-process used to merge the final HDR post-process and the real scene color
  139352. */
  139353. hdrFinalPostProcess: Nullable<PostProcess>;
  139354. /**
  139355. * Post-process used to create a lens flare effect
  139356. */
  139357. lensFlarePostProcess: Nullable<PostProcess>;
  139358. /**
  139359. * Post-process that merges the result of the lens flare post-process and the real scene color
  139360. */
  139361. lensFlareComposePostProcess: Nullable<PostProcess>;
  139362. /**
  139363. * Post-process used to create a motion blur effect
  139364. */
  139365. motionBlurPostProcess: Nullable<PostProcess>;
  139366. /**
  139367. * Post-process used to create a depth of field effect
  139368. */
  139369. depthOfFieldPostProcess: Nullable<PostProcess>;
  139370. /**
  139371. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139372. */
  139373. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139374. /**
  139375. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139376. */
  139377. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139378. /**
  139379. * Represents the brightness threshold in order to configure the illuminated surfaces
  139380. */
  139381. brightThreshold: number;
  139382. /**
  139383. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139384. */
  139385. blurWidth: number;
  139386. /**
  139387. * Sets if the blur for highlighted surfaces must be only horizontal
  139388. */
  139389. horizontalBlur: boolean;
  139390. /**
  139391. * Gets the overall exposure used by the pipeline
  139392. */
  139393. get exposure(): number;
  139394. /**
  139395. * Sets the overall exposure used by the pipeline
  139396. */
  139397. set exposure(value: number);
  139398. /**
  139399. * Texture used typically to simulate "dirty" on camera lens
  139400. */
  139401. lensTexture: Nullable<Texture>;
  139402. /**
  139403. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139404. */
  139405. volumetricLightCoefficient: number;
  139406. /**
  139407. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139408. */
  139409. volumetricLightPower: number;
  139410. /**
  139411. * Used the set the blur intensity to smooth the volumetric lights
  139412. */
  139413. volumetricLightBlurScale: number;
  139414. /**
  139415. * Light (spot or directional) used to generate the volumetric lights rays
  139416. * The source light must have a shadow generate so the pipeline can get its
  139417. * depth map
  139418. */
  139419. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139420. /**
  139421. * For eye adaptation, represents the minimum luminance the eye can see
  139422. */
  139423. hdrMinimumLuminance: number;
  139424. /**
  139425. * For eye adaptation, represents the decrease luminance speed
  139426. */
  139427. hdrDecreaseRate: number;
  139428. /**
  139429. * For eye adaptation, represents the increase luminance speed
  139430. */
  139431. hdrIncreaseRate: number;
  139432. /**
  139433. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139434. */
  139435. get hdrAutoExposure(): boolean;
  139436. /**
  139437. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139438. */
  139439. set hdrAutoExposure(value: boolean);
  139440. /**
  139441. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139442. */
  139443. lensColorTexture: Nullable<Texture>;
  139444. /**
  139445. * The overall strengh for the lens flare effect
  139446. */
  139447. lensFlareStrength: number;
  139448. /**
  139449. * Dispersion coefficient for lens flare ghosts
  139450. */
  139451. lensFlareGhostDispersal: number;
  139452. /**
  139453. * Main lens flare halo width
  139454. */
  139455. lensFlareHaloWidth: number;
  139456. /**
  139457. * Based on the lens distortion effect, defines how much the lens flare result
  139458. * is distorted
  139459. */
  139460. lensFlareDistortionStrength: number;
  139461. /**
  139462. * Configures the blur intensity used for for lens flare (halo)
  139463. */
  139464. lensFlareBlurWidth: number;
  139465. /**
  139466. * Lens star texture must be used to simulate rays on the flares and is available
  139467. * in the documentation
  139468. */
  139469. lensStarTexture: Nullable<Texture>;
  139470. /**
  139471. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139472. * flare effect by taking account of the dirt texture
  139473. */
  139474. lensFlareDirtTexture: Nullable<Texture>;
  139475. /**
  139476. * Represents the focal length for the depth of field effect
  139477. */
  139478. depthOfFieldDistance: number;
  139479. /**
  139480. * Represents the blur intensity for the blurred part of the depth of field effect
  139481. */
  139482. depthOfFieldBlurWidth: number;
  139483. /**
  139484. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139485. */
  139486. get motionStrength(): number;
  139487. /**
  139488. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139489. */
  139490. set motionStrength(strength: number);
  139491. /**
  139492. * Gets wether or not the motion blur post-process is object based or screen based.
  139493. */
  139494. get objectBasedMotionBlur(): boolean;
  139495. /**
  139496. * Sets wether or not the motion blur post-process should be object based or screen based
  139497. */
  139498. set objectBasedMotionBlur(value: boolean);
  139499. /**
  139500. * List of animations for the pipeline (IAnimatable implementation)
  139501. */
  139502. animations: Animation[];
  139503. /**
  139504. * Private members
  139505. */
  139506. private _scene;
  139507. private _currentDepthOfFieldSource;
  139508. private _basePostProcess;
  139509. private _fixedExposure;
  139510. private _currentExposure;
  139511. private _hdrAutoExposure;
  139512. private _hdrCurrentLuminance;
  139513. private _motionStrength;
  139514. private _isObjectBasedMotionBlur;
  139515. private _floatTextureType;
  139516. private _camerasToBeAttached;
  139517. private _ratio;
  139518. private _bloomEnabled;
  139519. private _depthOfFieldEnabled;
  139520. private _vlsEnabled;
  139521. private _lensFlareEnabled;
  139522. private _hdrEnabled;
  139523. private _motionBlurEnabled;
  139524. private _fxaaEnabled;
  139525. private _screenSpaceReflectionsEnabled;
  139526. private _motionBlurSamples;
  139527. private _volumetricLightStepsCount;
  139528. private _samples;
  139529. /**
  139530. * @ignore
  139531. * Specifies if the bloom pipeline is enabled
  139532. */
  139533. get BloomEnabled(): boolean;
  139534. set BloomEnabled(enabled: boolean);
  139535. /**
  139536. * @ignore
  139537. * Specifies if the depth of field pipeline is enabed
  139538. */
  139539. get DepthOfFieldEnabled(): boolean;
  139540. set DepthOfFieldEnabled(enabled: boolean);
  139541. /**
  139542. * @ignore
  139543. * Specifies if the lens flare pipeline is enabed
  139544. */
  139545. get LensFlareEnabled(): boolean;
  139546. set LensFlareEnabled(enabled: boolean);
  139547. /**
  139548. * @ignore
  139549. * Specifies if the HDR pipeline is enabled
  139550. */
  139551. get HDREnabled(): boolean;
  139552. set HDREnabled(enabled: boolean);
  139553. /**
  139554. * @ignore
  139555. * Specifies if the volumetric lights scattering effect is enabled
  139556. */
  139557. get VLSEnabled(): boolean;
  139558. set VLSEnabled(enabled: boolean);
  139559. /**
  139560. * @ignore
  139561. * Specifies if the motion blur effect is enabled
  139562. */
  139563. get MotionBlurEnabled(): boolean;
  139564. set MotionBlurEnabled(enabled: boolean);
  139565. /**
  139566. * Specifies if anti-aliasing is enabled
  139567. */
  139568. get fxaaEnabled(): boolean;
  139569. set fxaaEnabled(enabled: boolean);
  139570. /**
  139571. * Specifies if screen space reflections are enabled.
  139572. */
  139573. get screenSpaceReflectionsEnabled(): boolean;
  139574. set screenSpaceReflectionsEnabled(enabled: boolean);
  139575. /**
  139576. * Specifies the number of steps used to calculate the volumetric lights
  139577. * Typically in interval [50, 200]
  139578. */
  139579. get volumetricLightStepsCount(): number;
  139580. set volumetricLightStepsCount(count: number);
  139581. /**
  139582. * Specifies the number of samples used for the motion blur effect
  139583. * Typically in interval [16, 64]
  139584. */
  139585. get motionBlurSamples(): number;
  139586. set motionBlurSamples(samples: number);
  139587. /**
  139588. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139589. */
  139590. get samples(): number;
  139591. set samples(sampleCount: number);
  139592. /**
  139593. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139594. * @constructor
  139595. * @param name The rendering pipeline name
  139596. * @param scene The scene linked to this pipeline
  139597. * @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)
  139598. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139599. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139600. */
  139601. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139602. private _buildPipeline;
  139603. private _createDownSampleX4PostProcess;
  139604. private _createBrightPassPostProcess;
  139605. private _createBlurPostProcesses;
  139606. private _createTextureAdderPostProcess;
  139607. private _createVolumetricLightPostProcess;
  139608. private _createLuminancePostProcesses;
  139609. private _createHdrPostProcess;
  139610. private _createLensFlarePostProcess;
  139611. private _createDepthOfFieldPostProcess;
  139612. private _createMotionBlurPostProcess;
  139613. private _getDepthTexture;
  139614. private _disposePostProcesses;
  139615. /**
  139616. * Dispose of the pipeline and stop all post processes
  139617. */
  139618. dispose(): void;
  139619. /**
  139620. * Serialize the rendering pipeline (Used when exporting)
  139621. * @returns the serialized object
  139622. */
  139623. serialize(): any;
  139624. /**
  139625. * Parse the serialized pipeline
  139626. * @param source Source pipeline.
  139627. * @param scene The scene to load the pipeline to.
  139628. * @param rootUrl The URL of the serialized pipeline.
  139629. * @returns An instantiated pipeline from the serialized object.
  139630. */
  139631. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139632. /**
  139633. * Luminance steps
  139634. */
  139635. static LuminanceSteps: number;
  139636. }
  139637. }
  139638. declare module BABYLON {
  139639. /** @hidden */
  139640. export var tonemapPixelShader: {
  139641. name: string;
  139642. shader: string;
  139643. };
  139644. }
  139645. declare module BABYLON {
  139646. /** Defines operator used for tonemapping */
  139647. export enum TonemappingOperator {
  139648. /** Hable */
  139649. Hable = 0,
  139650. /** Reinhard */
  139651. Reinhard = 1,
  139652. /** HejiDawson */
  139653. HejiDawson = 2,
  139654. /** Photographic */
  139655. Photographic = 3
  139656. }
  139657. /**
  139658. * Defines a post process to apply tone mapping
  139659. */
  139660. export class TonemapPostProcess extends PostProcess {
  139661. private _operator;
  139662. /** Defines the required exposure adjustement */
  139663. exposureAdjustment: number;
  139664. /**
  139665. * Creates a new TonemapPostProcess
  139666. * @param name defines the name of the postprocess
  139667. * @param _operator defines the operator to use
  139668. * @param exposureAdjustment defines the required exposure adjustement
  139669. * @param camera defines the camera to use (can be null)
  139670. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139671. * @param engine defines the hosting engine (can be ignore if camera is set)
  139672. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139673. */
  139674. constructor(name: string, _operator: TonemappingOperator,
  139675. /** Defines the required exposure adjustement */
  139676. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139677. }
  139678. }
  139679. declare module BABYLON {
  139680. /** @hidden */
  139681. export var volumetricLightScatteringPixelShader: {
  139682. name: string;
  139683. shader: string;
  139684. };
  139685. }
  139686. declare module BABYLON {
  139687. /** @hidden */
  139688. export var volumetricLightScatteringPassVertexShader: {
  139689. name: string;
  139690. shader: string;
  139691. };
  139692. }
  139693. declare module BABYLON {
  139694. /** @hidden */
  139695. export var volumetricLightScatteringPassPixelShader: {
  139696. name: string;
  139697. shader: string;
  139698. };
  139699. }
  139700. declare module BABYLON {
  139701. /**
  139702. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139703. */
  139704. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139705. private _volumetricLightScatteringPass;
  139706. private _volumetricLightScatteringRTT;
  139707. private _viewPort;
  139708. private _screenCoordinates;
  139709. private _cachedDefines;
  139710. /**
  139711. * If not undefined, the mesh position is computed from the attached node position
  139712. */
  139713. attachedNode: {
  139714. position: Vector3;
  139715. };
  139716. /**
  139717. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139718. */
  139719. customMeshPosition: Vector3;
  139720. /**
  139721. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139722. */
  139723. useCustomMeshPosition: boolean;
  139724. /**
  139725. * If the post-process should inverse the light scattering direction
  139726. */
  139727. invert: boolean;
  139728. /**
  139729. * The internal mesh used by the post-process
  139730. */
  139731. mesh: Mesh;
  139732. /**
  139733. * @hidden
  139734. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139735. */
  139736. get useDiffuseColor(): boolean;
  139737. set useDiffuseColor(useDiffuseColor: boolean);
  139738. /**
  139739. * Array containing the excluded meshes not rendered in the internal pass
  139740. */
  139741. excludedMeshes: AbstractMesh[];
  139742. /**
  139743. * Controls the overall intensity of the post-process
  139744. */
  139745. exposure: number;
  139746. /**
  139747. * Dissipates each sample's contribution in range [0, 1]
  139748. */
  139749. decay: number;
  139750. /**
  139751. * Controls the overall intensity of each sample
  139752. */
  139753. weight: number;
  139754. /**
  139755. * Controls the density of each sample
  139756. */
  139757. density: number;
  139758. /**
  139759. * @constructor
  139760. * @param name The post-process name
  139761. * @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)
  139762. * @param camera The camera that the post-process will be attached to
  139763. * @param mesh The mesh used to create the light scattering
  139764. * @param samples The post-process quality, default 100
  139765. * @param samplingModeThe post-process filtering mode
  139766. * @param engine The babylon engine
  139767. * @param reusable If the post-process is reusable
  139768. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139769. */
  139770. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139771. /**
  139772. * Returns the string "VolumetricLightScatteringPostProcess"
  139773. * @returns "VolumetricLightScatteringPostProcess"
  139774. */
  139775. getClassName(): string;
  139776. private _isReady;
  139777. /**
  139778. * Sets the new light position for light scattering effect
  139779. * @param position The new custom light position
  139780. */
  139781. setCustomMeshPosition(position: Vector3): void;
  139782. /**
  139783. * Returns the light position for light scattering effect
  139784. * @return Vector3 The custom light position
  139785. */
  139786. getCustomMeshPosition(): Vector3;
  139787. /**
  139788. * Disposes the internal assets and detaches the post-process from the camera
  139789. */
  139790. dispose(camera: Camera): void;
  139791. /**
  139792. * Returns the render target texture used by the post-process
  139793. * @return the render target texture used by the post-process
  139794. */
  139795. getPass(): RenderTargetTexture;
  139796. private _meshExcluded;
  139797. private _createPass;
  139798. private _updateMeshScreenCoordinates;
  139799. /**
  139800. * Creates a default mesh for the Volumeric Light Scattering post-process
  139801. * @param name The mesh name
  139802. * @param scene The scene where to create the mesh
  139803. * @return the default mesh
  139804. */
  139805. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139806. }
  139807. }
  139808. declare module BABYLON {
  139809. interface Scene {
  139810. /** @hidden (Backing field) */
  139811. _boundingBoxRenderer: BoundingBoxRenderer;
  139812. /** @hidden (Backing field) */
  139813. _forceShowBoundingBoxes: boolean;
  139814. /**
  139815. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139816. */
  139817. forceShowBoundingBoxes: boolean;
  139818. /**
  139819. * Gets the bounding box renderer associated with the scene
  139820. * @returns a BoundingBoxRenderer
  139821. */
  139822. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139823. }
  139824. interface AbstractMesh {
  139825. /** @hidden (Backing field) */
  139826. _showBoundingBox: boolean;
  139827. /**
  139828. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139829. */
  139830. showBoundingBox: boolean;
  139831. }
  139832. /**
  139833. * Component responsible of rendering the bounding box of the meshes in a scene.
  139834. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139835. */
  139836. export class BoundingBoxRenderer implements ISceneComponent {
  139837. /**
  139838. * The component name helpfull to identify the component in the list of scene components.
  139839. */
  139840. readonly name: string;
  139841. /**
  139842. * The scene the component belongs to.
  139843. */
  139844. scene: Scene;
  139845. /**
  139846. * Color of the bounding box lines placed in front of an object
  139847. */
  139848. frontColor: Color3;
  139849. /**
  139850. * Color of the bounding box lines placed behind an object
  139851. */
  139852. backColor: Color3;
  139853. /**
  139854. * Defines if the renderer should show the back lines or not
  139855. */
  139856. showBackLines: boolean;
  139857. /**
  139858. * @hidden
  139859. */
  139860. renderList: SmartArray<BoundingBox>;
  139861. private _colorShader;
  139862. private _vertexBuffers;
  139863. private _indexBuffer;
  139864. private _fillIndexBuffer;
  139865. private _fillIndexData;
  139866. /**
  139867. * Instantiates a new bounding box renderer in a scene.
  139868. * @param scene the scene the renderer renders in
  139869. */
  139870. constructor(scene: Scene);
  139871. /**
  139872. * Registers the component in a given scene
  139873. */
  139874. register(): void;
  139875. private _evaluateSubMesh;
  139876. private _activeMesh;
  139877. private _prepareRessources;
  139878. private _createIndexBuffer;
  139879. /**
  139880. * Rebuilds the elements related to this component in case of
  139881. * context lost for instance.
  139882. */
  139883. rebuild(): void;
  139884. /**
  139885. * @hidden
  139886. */
  139887. reset(): void;
  139888. /**
  139889. * Render the bounding boxes of a specific rendering group
  139890. * @param renderingGroupId defines the rendering group to render
  139891. */
  139892. render(renderingGroupId: number): void;
  139893. /**
  139894. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139895. * @param mesh Define the mesh to render the occlusion bounding box for
  139896. */
  139897. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139898. /**
  139899. * Dispose and release the resources attached to this renderer.
  139900. */
  139901. dispose(): void;
  139902. }
  139903. }
  139904. declare module BABYLON {
  139905. interface Scene {
  139906. /** @hidden (Backing field) */
  139907. _depthRenderer: {
  139908. [id: string]: DepthRenderer;
  139909. };
  139910. /**
  139911. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139912. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139913. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139914. * @returns the created depth renderer
  139915. */
  139916. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139917. /**
  139918. * Disables a depth renderer for a given camera
  139919. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139920. */
  139921. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139922. }
  139923. /**
  139924. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139925. * in several rendering techniques.
  139926. */
  139927. export class DepthRendererSceneComponent implements ISceneComponent {
  139928. /**
  139929. * The component name helpfull to identify the component in the list of scene components.
  139930. */
  139931. readonly name: string;
  139932. /**
  139933. * The scene the component belongs to.
  139934. */
  139935. scene: Scene;
  139936. /**
  139937. * Creates a new instance of the component for the given scene
  139938. * @param scene Defines the scene to register the component in
  139939. */
  139940. constructor(scene: Scene);
  139941. /**
  139942. * Registers the component in a given scene
  139943. */
  139944. register(): void;
  139945. /**
  139946. * Rebuilds the elements related to this component in case of
  139947. * context lost for instance.
  139948. */
  139949. rebuild(): void;
  139950. /**
  139951. * Disposes the component and the associated ressources
  139952. */
  139953. dispose(): void;
  139954. private _gatherRenderTargets;
  139955. private _gatherActiveCameraRenderTargets;
  139956. }
  139957. }
  139958. declare module BABYLON {
  139959. /** @hidden */
  139960. export var outlinePixelShader: {
  139961. name: string;
  139962. shader: string;
  139963. };
  139964. }
  139965. declare module BABYLON {
  139966. /** @hidden */
  139967. export var outlineVertexShader: {
  139968. name: string;
  139969. shader: string;
  139970. };
  139971. }
  139972. declare module BABYLON {
  139973. interface Scene {
  139974. /** @hidden */
  139975. _outlineRenderer: OutlineRenderer;
  139976. /**
  139977. * Gets the outline renderer associated with the scene
  139978. * @returns a OutlineRenderer
  139979. */
  139980. getOutlineRenderer(): OutlineRenderer;
  139981. }
  139982. interface AbstractMesh {
  139983. /** @hidden (Backing field) */
  139984. _renderOutline: boolean;
  139985. /**
  139986. * Gets or sets a boolean indicating if the outline must be rendered as well
  139987. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139988. */
  139989. renderOutline: boolean;
  139990. /** @hidden (Backing field) */
  139991. _renderOverlay: boolean;
  139992. /**
  139993. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139994. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139995. */
  139996. renderOverlay: boolean;
  139997. }
  139998. /**
  139999. * This class is responsible to draw bothe outline/overlay of meshes.
  140000. * It should not be used directly but through the available method on mesh.
  140001. */
  140002. export class OutlineRenderer implements ISceneComponent {
  140003. /**
  140004. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140005. */
  140006. private static _StencilReference;
  140007. /**
  140008. * The name of the component. Each component must have a unique name.
  140009. */
  140010. name: string;
  140011. /**
  140012. * The scene the component belongs to.
  140013. */
  140014. scene: Scene;
  140015. /**
  140016. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140017. */
  140018. zOffset: number;
  140019. private _engine;
  140020. private _effect;
  140021. private _cachedDefines;
  140022. private _savedDepthWrite;
  140023. /**
  140024. * Instantiates a new outline renderer. (There could be only one per scene).
  140025. * @param scene Defines the scene it belongs to
  140026. */
  140027. constructor(scene: Scene);
  140028. /**
  140029. * Register the component to one instance of a scene.
  140030. */
  140031. register(): void;
  140032. /**
  140033. * Rebuilds the elements related to this component in case of
  140034. * context lost for instance.
  140035. */
  140036. rebuild(): void;
  140037. /**
  140038. * Disposes the component and the associated ressources.
  140039. */
  140040. dispose(): void;
  140041. /**
  140042. * Renders the outline in the canvas.
  140043. * @param subMesh Defines the sumesh to render
  140044. * @param batch Defines the batch of meshes in case of instances
  140045. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140046. */
  140047. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140048. /**
  140049. * Returns whether or not the outline renderer is ready for a given submesh.
  140050. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140051. * @param subMesh Defines the submesh to check readyness for
  140052. * @param useInstances Defines wheter wee are trying to render instances or not
  140053. * @returns true if ready otherwise false
  140054. */
  140055. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140056. private _beforeRenderingMesh;
  140057. private _afterRenderingMesh;
  140058. }
  140059. }
  140060. declare module BABYLON {
  140061. /**
  140062. * Defines the basic options interface of a Sprite Frame Source Size.
  140063. */
  140064. export interface ISpriteJSONSpriteSourceSize {
  140065. /**
  140066. * number of the original width of the Frame
  140067. */
  140068. w: number;
  140069. /**
  140070. * number of the original height of the Frame
  140071. */
  140072. h: number;
  140073. }
  140074. /**
  140075. * Defines the basic options interface of a Sprite Frame Data.
  140076. */
  140077. export interface ISpriteJSONSpriteFrameData {
  140078. /**
  140079. * number of the x offset of the Frame
  140080. */
  140081. x: number;
  140082. /**
  140083. * number of the y offset of the Frame
  140084. */
  140085. y: number;
  140086. /**
  140087. * number of the width of the Frame
  140088. */
  140089. w: number;
  140090. /**
  140091. * number of the height of the Frame
  140092. */
  140093. h: number;
  140094. }
  140095. /**
  140096. * Defines the basic options interface of a JSON Sprite.
  140097. */
  140098. export interface ISpriteJSONSprite {
  140099. /**
  140100. * string name of the Frame
  140101. */
  140102. filename: string;
  140103. /**
  140104. * ISpriteJSONSpriteFrame basic object of the frame data
  140105. */
  140106. frame: ISpriteJSONSpriteFrameData;
  140107. /**
  140108. * boolean to flag is the frame was rotated.
  140109. */
  140110. rotated: boolean;
  140111. /**
  140112. * boolean to flag is the frame was trimmed.
  140113. */
  140114. trimmed: boolean;
  140115. /**
  140116. * ISpriteJSONSpriteFrame basic object of the source data
  140117. */
  140118. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140119. /**
  140120. * ISpriteJSONSpriteFrame basic object of the source data
  140121. */
  140122. sourceSize: ISpriteJSONSpriteSourceSize;
  140123. }
  140124. /**
  140125. * Defines the basic options interface of a JSON atlas.
  140126. */
  140127. export interface ISpriteJSONAtlas {
  140128. /**
  140129. * Array of objects that contain the frame data.
  140130. */
  140131. frames: Array<ISpriteJSONSprite>;
  140132. /**
  140133. * object basic object containing the sprite meta data.
  140134. */
  140135. meta?: object;
  140136. }
  140137. }
  140138. declare module BABYLON {
  140139. /** @hidden */
  140140. export var spriteMapPixelShader: {
  140141. name: string;
  140142. shader: string;
  140143. };
  140144. }
  140145. declare module BABYLON {
  140146. /** @hidden */
  140147. export var spriteMapVertexShader: {
  140148. name: string;
  140149. shader: string;
  140150. };
  140151. }
  140152. declare module BABYLON {
  140153. /**
  140154. * Defines the basic options interface of a SpriteMap
  140155. */
  140156. export interface ISpriteMapOptions {
  140157. /**
  140158. * Vector2 of the number of cells in the grid.
  140159. */
  140160. stageSize?: Vector2;
  140161. /**
  140162. * Vector2 of the size of the output plane in World Units.
  140163. */
  140164. outputSize?: Vector2;
  140165. /**
  140166. * Vector3 of the position of the output plane in World Units.
  140167. */
  140168. outputPosition?: Vector3;
  140169. /**
  140170. * Vector3 of the rotation of the output plane.
  140171. */
  140172. outputRotation?: Vector3;
  140173. /**
  140174. * number of layers that the system will reserve in resources.
  140175. */
  140176. layerCount?: number;
  140177. /**
  140178. * number of max animation frames a single cell will reserve in resources.
  140179. */
  140180. maxAnimationFrames?: number;
  140181. /**
  140182. * number cell index of the base tile when the system compiles.
  140183. */
  140184. baseTile?: number;
  140185. /**
  140186. * boolean flip the sprite after its been repositioned by the framing data.
  140187. */
  140188. flipU?: boolean;
  140189. /**
  140190. * Vector3 scalar of the global RGB values of the SpriteMap.
  140191. */
  140192. colorMultiply?: Vector3;
  140193. }
  140194. /**
  140195. * Defines the IDisposable interface in order to be cleanable from resources.
  140196. */
  140197. export interface ISpriteMap extends IDisposable {
  140198. /**
  140199. * String name of the SpriteMap.
  140200. */
  140201. name: string;
  140202. /**
  140203. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140204. */
  140205. atlasJSON: ISpriteJSONAtlas;
  140206. /**
  140207. * Texture of the SpriteMap.
  140208. */
  140209. spriteSheet: Texture;
  140210. /**
  140211. * The parameters to initialize the SpriteMap with.
  140212. */
  140213. options: ISpriteMapOptions;
  140214. }
  140215. /**
  140216. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140217. */
  140218. export class SpriteMap implements ISpriteMap {
  140219. /** The Name of the spriteMap */
  140220. name: string;
  140221. /** The JSON file with the frame and meta data */
  140222. atlasJSON: ISpriteJSONAtlas;
  140223. /** The systems Sprite Sheet Texture */
  140224. spriteSheet: Texture;
  140225. /** Arguments passed with the Constructor */
  140226. options: ISpriteMapOptions;
  140227. /** Public Sprite Storage array, parsed from atlasJSON */
  140228. sprites: Array<ISpriteJSONSprite>;
  140229. /** Returns the Number of Sprites in the System */
  140230. get spriteCount(): number;
  140231. /** Returns the Position of Output Plane*/
  140232. get position(): Vector3;
  140233. /** Returns the Position of Output Plane*/
  140234. set position(v: Vector3);
  140235. /** Returns the Rotation of Output Plane*/
  140236. get rotation(): Vector3;
  140237. /** Returns the Rotation of Output Plane*/
  140238. set rotation(v: Vector3);
  140239. /** Sets the AnimationMap*/
  140240. get animationMap(): RawTexture;
  140241. /** Sets the AnimationMap*/
  140242. set animationMap(v: RawTexture);
  140243. /** Scene that the SpriteMap was created in */
  140244. private _scene;
  140245. /** Texture Buffer of Float32 that holds tile frame data*/
  140246. private _frameMap;
  140247. /** Texture Buffers of Float32 that holds tileMap data*/
  140248. private _tileMaps;
  140249. /** Texture Buffer of Float32 that holds Animation Data*/
  140250. private _animationMap;
  140251. /** Custom ShaderMaterial Central to the System*/
  140252. private _material;
  140253. /** Custom ShaderMaterial Central to the System*/
  140254. private _output;
  140255. /** Systems Time Ticker*/
  140256. private _time;
  140257. /**
  140258. * Creates a new SpriteMap
  140259. * @param name defines the SpriteMaps Name
  140260. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140261. * @param spriteSheet is the Texture that the Sprites are on.
  140262. * @param options a basic deployment configuration
  140263. * @param scene The Scene that the map is deployed on
  140264. */
  140265. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140266. /**
  140267. * Returns tileID location
  140268. * @returns Vector2 the cell position ID
  140269. */
  140270. getTileID(): Vector2;
  140271. /**
  140272. * Gets the UV location of the mouse over the SpriteMap.
  140273. * @returns Vector2 the UV position of the mouse interaction
  140274. */
  140275. getMousePosition(): Vector2;
  140276. /**
  140277. * Creates the "frame" texture Buffer
  140278. * -------------------------------------
  140279. * Structure of frames
  140280. * "filename": "Falling-Water-2.png",
  140281. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140282. * "rotated": true,
  140283. * "trimmed": true,
  140284. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140285. * "sourceSize": {"w":32,"h":32}
  140286. * @returns RawTexture of the frameMap
  140287. */
  140288. private _createFrameBuffer;
  140289. /**
  140290. * Creates the tileMap texture Buffer
  140291. * @param buffer normally and array of numbers, or a false to generate from scratch
  140292. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140293. * @returns RawTexture of the tileMap
  140294. */
  140295. private _createTileBuffer;
  140296. /**
  140297. * Modifies the data of the tileMaps
  140298. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140299. * @param pos is the iVector2 Coordinates of the Tile
  140300. * @param tile The SpriteIndex of the new Tile
  140301. */
  140302. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140303. /**
  140304. * Creates the animationMap texture Buffer
  140305. * @param buffer normally and array of numbers, or a false to generate from scratch
  140306. * @returns RawTexture of the animationMap
  140307. */
  140308. private _createTileAnimationBuffer;
  140309. /**
  140310. * Modifies the data of the animationMap
  140311. * @param cellID is the Index of the Sprite
  140312. * @param _frame is the target Animation frame
  140313. * @param toCell is the Target Index of the next frame of the animation
  140314. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140315. * @param speed is a global scalar of the time variable on the map.
  140316. */
  140317. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140318. /**
  140319. * Exports the .tilemaps file
  140320. */
  140321. saveTileMaps(): void;
  140322. /**
  140323. * Imports the .tilemaps file
  140324. * @param url of the .tilemaps file
  140325. */
  140326. loadTileMaps(url: string): void;
  140327. /**
  140328. * Release associated resources
  140329. */
  140330. dispose(): void;
  140331. }
  140332. }
  140333. declare module BABYLON {
  140334. /**
  140335. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140336. * @see http://doc.babylonjs.com/babylon101/sprites
  140337. */
  140338. export class SpritePackedManager extends SpriteManager {
  140339. /** defines the packed manager's name */
  140340. name: string;
  140341. /**
  140342. * Creates a new sprite manager from a packed sprite sheet
  140343. * @param name defines the manager's name
  140344. * @param imgUrl defines the sprite sheet url
  140345. * @param capacity defines the maximum allowed number of sprites
  140346. * @param scene defines the hosting scene
  140347. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140348. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140349. * @param samplingMode defines the smapling mode to use with spritesheet
  140350. * @param fromPacked set to true; do not alter
  140351. */
  140352. constructor(
  140353. /** defines the packed manager's name */
  140354. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140355. }
  140356. }
  140357. declare module BABYLON {
  140358. /**
  140359. * Defines the list of states available for a task inside a AssetsManager
  140360. */
  140361. export enum AssetTaskState {
  140362. /**
  140363. * Initialization
  140364. */
  140365. INIT = 0,
  140366. /**
  140367. * Running
  140368. */
  140369. RUNNING = 1,
  140370. /**
  140371. * Done
  140372. */
  140373. DONE = 2,
  140374. /**
  140375. * Error
  140376. */
  140377. ERROR = 3
  140378. }
  140379. /**
  140380. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140381. */
  140382. export abstract class AbstractAssetTask {
  140383. /**
  140384. * Task name
  140385. */ name: string;
  140386. /**
  140387. * Callback called when the task is successful
  140388. */
  140389. onSuccess: (task: any) => void;
  140390. /**
  140391. * Callback called when the task is not successful
  140392. */
  140393. onError: (task: any, message?: string, exception?: any) => void;
  140394. /**
  140395. * Creates a new AssetsManager
  140396. * @param name defines the name of the task
  140397. */
  140398. constructor(
  140399. /**
  140400. * Task name
  140401. */ name: string);
  140402. private _isCompleted;
  140403. private _taskState;
  140404. private _errorObject;
  140405. /**
  140406. * Get if the task is completed
  140407. */
  140408. get isCompleted(): boolean;
  140409. /**
  140410. * Gets the current state of the task
  140411. */
  140412. get taskState(): AssetTaskState;
  140413. /**
  140414. * Gets the current error object (if task is in error)
  140415. */
  140416. get errorObject(): {
  140417. message?: string;
  140418. exception?: any;
  140419. };
  140420. /**
  140421. * Internal only
  140422. * @hidden
  140423. */
  140424. _setErrorObject(message?: string, exception?: any): void;
  140425. /**
  140426. * Execute the current task
  140427. * @param scene defines the scene where you want your assets to be loaded
  140428. * @param onSuccess is a callback called when the task is successfully executed
  140429. * @param onError is a callback called if an error occurs
  140430. */
  140431. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140432. /**
  140433. * Execute the current task
  140434. * @param scene defines the scene where you want your assets to be loaded
  140435. * @param onSuccess is a callback called when the task is successfully executed
  140436. * @param onError is a callback called if an error occurs
  140437. */
  140438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140439. /**
  140440. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140441. * This can be used with failed tasks that have the reason for failure fixed.
  140442. */
  140443. reset(): void;
  140444. private onErrorCallback;
  140445. private onDoneCallback;
  140446. }
  140447. /**
  140448. * Define the interface used by progress events raised during assets loading
  140449. */
  140450. export interface IAssetsProgressEvent {
  140451. /**
  140452. * Defines the number of remaining tasks to process
  140453. */
  140454. remainingCount: number;
  140455. /**
  140456. * Defines the total number of tasks
  140457. */
  140458. totalCount: number;
  140459. /**
  140460. * Defines the task that was just processed
  140461. */
  140462. task: AbstractAssetTask;
  140463. }
  140464. /**
  140465. * Class used to share progress information about assets loading
  140466. */
  140467. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140468. /**
  140469. * Defines the number of remaining tasks to process
  140470. */
  140471. remainingCount: number;
  140472. /**
  140473. * Defines the total number of tasks
  140474. */
  140475. totalCount: number;
  140476. /**
  140477. * Defines the task that was just processed
  140478. */
  140479. task: AbstractAssetTask;
  140480. /**
  140481. * Creates a AssetsProgressEvent
  140482. * @param remainingCount defines the number of remaining tasks to process
  140483. * @param totalCount defines the total number of tasks
  140484. * @param task defines the task that was just processed
  140485. */
  140486. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140487. }
  140488. /**
  140489. * Define a task used by AssetsManager to load meshes
  140490. */
  140491. export class MeshAssetTask extends AbstractAssetTask {
  140492. /**
  140493. * Defines the name of the task
  140494. */
  140495. name: string;
  140496. /**
  140497. * Defines the list of mesh's names you want to load
  140498. */
  140499. meshesNames: any;
  140500. /**
  140501. * Defines the root url to use as a base to load your meshes and associated resources
  140502. */
  140503. rootUrl: string;
  140504. /**
  140505. * Defines the filename of the scene to load from
  140506. */
  140507. sceneFilename: string;
  140508. /**
  140509. * Gets the list of loaded meshes
  140510. */
  140511. loadedMeshes: Array<AbstractMesh>;
  140512. /**
  140513. * Gets the list of loaded particle systems
  140514. */
  140515. loadedParticleSystems: Array<IParticleSystem>;
  140516. /**
  140517. * Gets the list of loaded skeletons
  140518. */
  140519. loadedSkeletons: Array<Skeleton>;
  140520. /**
  140521. * Gets the list of loaded animation groups
  140522. */
  140523. loadedAnimationGroups: Array<AnimationGroup>;
  140524. /**
  140525. * Callback called when the task is successful
  140526. */
  140527. onSuccess: (task: MeshAssetTask) => void;
  140528. /**
  140529. * Callback called when the task is successful
  140530. */
  140531. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140532. /**
  140533. * Creates a new MeshAssetTask
  140534. * @param name defines the name of the task
  140535. * @param meshesNames defines the list of mesh's names you want to load
  140536. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140537. * @param sceneFilename defines the filename of the scene to load from
  140538. */
  140539. constructor(
  140540. /**
  140541. * Defines the name of the task
  140542. */
  140543. name: string,
  140544. /**
  140545. * Defines the list of mesh's names you want to load
  140546. */
  140547. meshesNames: any,
  140548. /**
  140549. * Defines the root url to use as a base to load your meshes and associated resources
  140550. */
  140551. rootUrl: string,
  140552. /**
  140553. * Defines the filename of the scene to load from
  140554. */
  140555. sceneFilename: string);
  140556. /**
  140557. * Execute the current task
  140558. * @param scene defines the scene where you want your assets to be loaded
  140559. * @param onSuccess is a callback called when the task is successfully executed
  140560. * @param onError is a callback called if an error occurs
  140561. */
  140562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140563. }
  140564. /**
  140565. * Define a task used by AssetsManager to load text content
  140566. */
  140567. export class TextFileAssetTask extends AbstractAssetTask {
  140568. /**
  140569. * Defines the name of the task
  140570. */
  140571. name: string;
  140572. /**
  140573. * Defines the location of the file to load
  140574. */
  140575. url: string;
  140576. /**
  140577. * Gets the loaded text string
  140578. */
  140579. text: string;
  140580. /**
  140581. * Callback called when the task is successful
  140582. */
  140583. onSuccess: (task: TextFileAssetTask) => void;
  140584. /**
  140585. * Callback called when the task is successful
  140586. */
  140587. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140588. /**
  140589. * Creates a new TextFileAssetTask object
  140590. * @param name defines the name of the task
  140591. * @param url defines the location of the file to load
  140592. */
  140593. constructor(
  140594. /**
  140595. * Defines the name of the task
  140596. */
  140597. name: string,
  140598. /**
  140599. * Defines the location of the file to load
  140600. */
  140601. url: string);
  140602. /**
  140603. * Execute the current task
  140604. * @param scene defines the scene where you want your assets to be loaded
  140605. * @param onSuccess is a callback called when the task is successfully executed
  140606. * @param onError is a callback called if an error occurs
  140607. */
  140608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140609. }
  140610. /**
  140611. * Define a task used by AssetsManager to load binary data
  140612. */
  140613. export class BinaryFileAssetTask extends AbstractAssetTask {
  140614. /**
  140615. * Defines the name of the task
  140616. */
  140617. name: string;
  140618. /**
  140619. * Defines the location of the file to load
  140620. */
  140621. url: string;
  140622. /**
  140623. * Gets the lodaded data (as an array buffer)
  140624. */
  140625. data: ArrayBuffer;
  140626. /**
  140627. * Callback called when the task is successful
  140628. */
  140629. onSuccess: (task: BinaryFileAssetTask) => void;
  140630. /**
  140631. * Callback called when the task is successful
  140632. */
  140633. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140634. /**
  140635. * Creates a new BinaryFileAssetTask object
  140636. * @param name defines the name of the new task
  140637. * @param url defines the location of the file to load
  140638. */
  140639. constructor(
  140640. /**
  140641. * Defines the name of the task
  140642. */
  140643. name: string,
  140644. /**
  140645. * Defines the location of the file to load
  140646. */
  140647. url: string);
  140648. /**
  140649. * Execute the current task
  140650. * @param scene defines the scene where you want your assets to be loaded
  140651. * @param onSuccess is a callback called when the task is successfully executed
  140652. * @param onError is a callback called if an error occurs
  140653. */
  140654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140655. }
  140656. /**
  140657. * Define a task used by AssetsManager to load images
  140658. */
  140659. export class ImageAssetTask extends AbstractAssetTask {
  140660. /**
  140661. * Defines the name of the task
  140662. */
  140663. name: string;
  140664. /**
  140665. * Defines the location of the image to load
  140666. */
  140667. url: string;
  140668. /**
  140669. * Gets the loaded images
  140670. */
  140671. image: HTMLImageElement;
  140672. /**
  140673. * Callback called when the task is successful
  140674. */
  140675. onSuccess: (task: ImageAssetTask) => void;
  140676. /**
  140677. * Callback called when the task is successful
  140678. */
  140679. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140680. /**
  140681. * Creates a new ImageAssetTask
  140682. * @param name defines the name of the task
  140683. * @param url defines the location of the image to load
  140684. */
  140685. constructor(
  140686. /**
  140687. * Defines the name of the task
  140688. */
  140689. name: string,
  140690. /**
  140691. * Defines the location of the image to load
  140692. */
  140693. url: string);
  140694. /**
  140695. * Execute the current task
  140696. * @param scene defines the scene where you want your assets to be loaded
  140697. * @param onSuccess is a callback called when the task is successfully executed
  140698. * @param onError is a callback called if an error occurs
  140699. */
  140700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140701. }
  140702. /**
  140703. * Defines the interface used by texture loading tasks
  140704. */
  140705. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140706. /**
  140707. * Gets the loaded texture
  140708. */
  140709. texture: TEX;
  140710. }
  140711. /**
  140712. * Define a task used by AssetsManager to load 2D textures
  140713. */
  140714. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140715. /**
  140716. * Defines the name of the task
  140717. */
  140718. name: string;
  140719. /**
  140720. * Defines the location of the file to load
  140721. */
  140722. url: string;
  140723. /**
  140724. * Defines if mipmap should not be generated (default is false)
  140725. */
  140726. noMipmap?: boolean | undefined;
  140727. /**
  140728. * Defines if texture must be inverted on Y axis (default is false)
  140729. */
  140730. invertY?: boolean | undefined;
  140731. /**
  140732. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140733. */
  140734. samplingMode: number;
  140735. /**
  140736. * Gets the loaded texture
  140737. */
  140738. texture: Texture;
  140739. /**
  140740. * Callback called when the task is successful
  140741. */
  140742. onSuccess: (task: TextureAssetTask) => void;
  140743. /**
  140744. * Callback called when the task is successful
  140745. */
  140746. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140747. /**
  140748. * Creates a new TextureAssetTask object
  140749. * @param name defines the name of the task
  140750. * @param url defines the location of the file to load
  140751. * @param noMipmap defines if mipmap should not be generated (default is false)
  140752. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140753. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140754. */
  140755. constructor(
  140756. /**
  140757. * Defines the name of the task
  140758. */
  140759. name: string,
  140760. /**
  140761. * Defines the location of the file to load
  140762. */
  140763. url: string,
  140764. /**
  140765. * Defines if mipmap should not be generated (default is false)
  140766. */
  140767. noMipmap?: boolean | undefined,
  140768. /**
  140769. * Defines if texture must be inverted on Y axis (default is false)
  140770. */
  140771. invertY?: boolean | undefined,
  140772. /**
  140773. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140774. */
  140775. samplingMode?: number);
  140776. /**
  140777. * Execute the current task
  140778. * @param scene defines the scene where you want your assets to be loaded
  140779. * @param onSuccess is a callback called when the task is successfully executed
  140780. * @param onError is a callback called if an error occurs
  140781. */
  140782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140783. }
  140784. /**
  140785. * Define a task used by AssetsManager to load cube textures
  140786. */
  140787. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140788. /**
  140789. * Defines the name of the task
  140790. */
  140791. name: string;
  140792. /**
  140793. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140794. */
  140795. url: string;
  140796. /**
  140797. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140798. */
  140799. extensions?: string[] | undefined;
  140800. /**
  140801. * Defines if mipmaps should not be generated (default is false)
  140802. */
  140803. noMipmap?: boolean | undefined;
  140804. /**
  140805. * Defines the explicit list of files (undefined by default)
  140806. */
  140807. files?: string[] | undefined;
  140808. /**
  140809. * Gets the loaded texture
  140810. */
  140811. texture: CubeTexture;
  140812. /**
  140813. * Callback called when the task is successful
  140814. */
  140815. onSuccess: (task: CubeTextureAssetTask) => void;
  140816. /**
  140817. * Callback called when the task is successful
  140818. */
  140819. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140820. /**
  140821. * Creates a new CubeTextureAssetTask
  140822. * @param name defines the name of the task
  140823. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140824. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140825. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140826. * @param files defines the explicit list of files (undefined by default)
  140827. */
  140828. constructor(
  140829. /**
  140830. * Defines the name of the task
  140831. */
  140832. name: string,
  140833. /**
  140834. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140835. */
  140836. url: string,
  140837. /**
  140838. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140839. */
  140840. extensions?: string[] | undefined,
  140841. /**
  140842. * Defines if mipmaps should not be generated (default is false)
  140843. */
  140844. noMipmap?: boolean | undefined,
  140845. /**
  140846. * Defines the explicit list of files (undefined by default)
  140847. */
  140848. files?: string[] | undefined);
  140849. /**
  140850. * Execute the current task
  140851. * @param scene defines the scene where you want your assets to be loaded
  140852. * @param onSuccess is a callback called when the task is successfully executed
  140853. * @param onError is a callback called if an error occurs
  140854. */
  140855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140856. }
  140857. /**
  140858. * Define a task used by AssetsManager to load HDR cube textures
  140859. */
  140860. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140861. /**
  140862. * Defines the name of the task
  140863. */
  140864. name: string;
  140865. /**
  140866. * Defines the location of the file to load
  140867. */
  140868. url: string;
  140869. /**
  140870. * Defines the desired size (the more it increases the longer the generation will be)
  140871. */
  140872. size: number;
  140873. /**
  140874. * Defines if mipmaps should not be generated (default is false)
  140875. */
  140876. noMipmap: boolean;
  140877. /**
  140878. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140879. */
  140880. generateHarmonics: boolean;
  140881. /**
  140882. * 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)
  140883. */
  140884. gammaSpace: boolean;
  140885. /**
  140886. * Internal Use Only
  140887. */
  140888. reserved: boolean;
  140889. /**
  140890. * Gets the loaded texture
  140891. */
  140892. texture: HDRCubeTexture;
  140893. /**
  140894. * Callback called when the task is successful
  140895. */
  140896. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140897. /**
  140898. * Callback called when the task is successful
  140899. */
  140900. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140901. /**
  140902. * Creates a new HDRCubeTextureAssetTask object
  140903. * @param name defines the name of the task
  140904. * @param url defines the location of the file to load
  140905. * @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.
  140906. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140907. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140908. * @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)
  140909. * @param reserved Internal use only
  140910. */
  140911. constructor(
  140912. /**
  140913. * Defines the name of the task
  140914. */
  140915. name: string,
  140916. /**
  140917. * Defines the location of the file to load
  140918. */
  140919. url: string,
  140920. /**
  140921. * Defines the desired size (the more it increases the longer the generation will be)
  140922. */
  140923. size: number,
  140924. /**
  140925. * Defines if mipmaps should not be generated (default is false)
  140926. */
  140927. noMipmap?: boolean,
  140928. /**
  140929. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140930. */
  140931. generateHarmonics?: boolean,
  140932. /**
  140933. * 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)
  140934. */
  140935. gammaSpace?: boolean,
  140936. /**
  140937. * Internal Use Only
  140938. */
  140939. reserved?: boolean);
  140940. /**
  140941. * Execute the current task
  140942. * @param scene defines the scene where you want your assets to be loaded
  140943. * @param onSuccess is a callback called when the task is successfully executed
  140944. * @param onError is a callback called if an error occurs
  140945. */
  140946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140947. }
  140948. /**
  140949. * Define a task used by AssetsManager to load Equirectangular cube textures
  140950. */
  140951. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140952. /**
  140953. * Defines the name of the task
  140954. */
  140955. name: string;
  140956. /**
  140957. * Defines the location of the file to load
  140958. */
  140959. url: string;
  140960. /**
  140961. * Defines the desired size (the more it increases the longer the generation will be)
  140962. */
  140963. size: number;
  140964. /**
  140965. * Defines if mipmaps should not be generated (default is false)
  140966. */
  140967. noMipmap: boolean;
  140968. /**
  140969. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140970. * but the standard material would require them in Gamma space) (default is true)
  140971. */
  140972. gammaSpace: boolean;
  140973. /**
  140974. * Gets the loaded texture
  140975. */
  140976. texture: EquiRectangularCubeTexture;
  140977. /**
  140978. * Callback called when the task is successful
  140979. */
  140980. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140981. /**
  140982. * Callback called when the task is successful
  140983. */
  140984. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140985. /**
  140986. * Creates a new EquiRectangularCubeTextureAssetTask object
  140987. * @param name defines the name of the task
  140988. * @param url defines the location of the file to load
  140989. * @param size defines the desired size (the more it increases the longer the generation will be)
  140990. * If the size is omitted this implies you are using a preprocessed cubemap.
  140991. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140992. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140993. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140994. * (default is true)
  140995. */
  140996. constructor(
  140997. /**
  140998. * Defines the name of the task
  140999. */
  141000. name: string,
  141001. /**
  141002. * Defines the location of the file to load
  141003. */
  141004. url: string,
  141005. /**
  141006. * Defines the desired size (the more it increases the longer the generation will be)
  141007. */
  141008. size: number,
  141009. /**
  141010. * Defines if mipmaps should not be generated (default is false)
  141011. */
  141012. noMipmap?: boolean,
  141013. /**
  141014. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141015. * but the standard material would require them in Gamma space) (default is true)
  141016. */
  141017. gammaSpace?: boolean);
  141018. /**
  141019. * Execute the current task
  141020. * @param scene defines the scene where you want your assets to be loaded
  141021. * @param onSuccess is a callback called when the task is successfully executed
  141022. * @param onError is a callback called if an error occurs
  141023. */
  141024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141025. }
  141026. /**
  141027. * This class can be used to easily import assets into a scene
  141028. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141029. */
  141030. export class AssetsManager {
  141031. private _scene;
  141032. private _isLoading;
  141033. protected _tasks: AbstractAssetTask[];
  141034. protected _waitingTasksCount: number;
  141035. protected _totalTasksCount: number;
  141036. /**
  141037. * Callback called when all tasks are processed
  141038. */
  141039. onFinish: (tasks: AbstractAssetTask[]) => void;
  141040. /**
  141041. * Callback called when a task is successful
  141042. */
  141043. onTaskSuccess: (task: AbstractAssetTask) => void;
  141044. /**
  141045. * Callback called when a task had an error
  141046. */
  141047. onTaskError: (task: AbstractAssetTask) => void;
  141048. /**
  141049. * Callback called when a task is done (whatever the result is)
  141050. */
  141051. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141052. /**
  141053. * Observable called when all tasks are processed
  141054. */
  141055. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141056. /**
  141057. * Observable called when a task had an error
  141058. */
  141059. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141060. /**
  141061. * Observable called when all tasks were executed
  141062. */
  141063. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141064. /**
  141065. * Observable called when a task is done (whatever the result is)
  141066. */
  141067. onProgressObservable: Observable<IAssetsProgressEvent>;
  141068. /**
  141069. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141071. */
  141072. useDefaultLoadingScreen: boolean;
  141073. /**
  141074. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141075. * when all assets have been downloaded.
  141076. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141077. */
  141078. autoHideLoadingUI: boolean;
  141079. /**
  141080. * Creates a new AssetsManager
  141081. * @param scene defines the scene to work on
  141082. */
  141083. constructor(scene: Scene);
  141084. /**
  141085. * Add a MeshAssetTask to the list of active tasks
  141086. * @param taskName defines the name of the new task
  141087. * @param meshesNames defines the name of meshes to load
  141088. * @param rootUrl defines the root url to use to locate files
  141089. * @param sceneFilename defines the filename of the scene file
  141090. * @returns a new MeshAssetTask object
  141091. */
  141092. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141093. /**
  141094. * Add a TextFileAssetTask to the list of active tasks
  141095. * @param taskName defines the name of the new task
  141096. * @param url defines the url of the file to load
  141097. * @returns a new TextFileAssetTask object
  141098. */
  141099. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141100. /**
  141101. * Add a BinaryFileAssetTask to the list of active tasks
  141102. * @param taskName defines the name of the new task
  141103. * @param url defines the url of the file to load
  141104. * @returns a new BinaryFileAssetTask object
  141105. */
  141106. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141107. /**
  141108. * Add a ImageAssetTask to the list of active tasks
  141109. * @param taskName defines the name of the new task
  141110. * @param url defines the url of the file to load
  141111. * @returns a new ImageAssetTask object
  141112. */
  141113. addImageTask(taskName: string, url: string): ImageAssetTask;
  141114. /**
  141115. * Add a TextureAssetTask to the list of active tasks
  141116. * @param taskName defines the name of the new task
  141117. * @param url defines the url of the file to load
  141118. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141119. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141120. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141121. * @returns a new TextureAssetTask object
  141122. */
  141123. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141124. /**
  141125. * Add a CubeTextureAssetTask to the list of active tasks
  141126. * @param taskName defines the name of the new task
  141127. * @param url defines the url of the file to load
  141128. * @param extensions defines the extension to use to load the cube map (can be null)
  141129. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141130. * @param files defines the list of files to load (can be null)
  141131. * @returns a new CubeTextureAssetTask object
  141132. */
  141133. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141134. /**
  141135. *
  141136. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141137. * @param taskName defines the name of the new task
  141138. * @param url defines the url of the file to load
  141139. * @param size defines the size you want for the cubemap (can be null)
  141140. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141141. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141142. * @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)
  141143. * @param reserved Internal use only
  141144. * @returns a new HDRCubeTextureAssetTask object
  141145. */
  141146. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141147. /**
  141148. *
  141149. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141150. * @param taskName defines the name of the new task
  141151. * @param url defines the url of the file to load
  141152. * @param size defines the size you want for the cubemap (can be null)
  141153. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141154. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141155. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141156. * @returns a new EquiRectangularCubeTextureAssetTask object
  141157. */
  141158. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141159. /**
  141160. * Remove a task from the assets manager.
  141161. * @param task the task to remove
  141162. */
  141163. removeTask(task: AbstractAssetTask): void;
  141164. private _decreaseWaitingTasksCount;
  141165. private _runTask;
  141166. /**
  141167. * Reset the AssetsManager and remove all tasks
  141168. * @return the current instance of the AssetsManager
  141169. */
  141170. reset(): AssetsManager;
  141171. /**
  141172. * Start the loading process
  141173. * @return the current instance of the AssetsManager
  141174. */
  141175. load(): AssetsManager;
  141176. /**
  141177. * Start the loading process as an async operation
  141178. * @return a promise returning the list of failed tasks
  141179. */
  141180. loadAsync(): Promise<void>;
  141181. }
  141182. }
  141183. declare module BABYLON {
  141184. /**
  141185. * Wrapper class for promise with external resolve and reject.
  141186. */
  141187. export class Deferred<T> {
  141188. /**
  141189. * The promise associated with this deferred object.
  141190. */
  141191. readonly promise: Promise<T>;
  141192. private _resolve;
  141193. private _reject;
  141194. /**
  141195. * The resolve method of the promise associated with this deferred object.
  141196. */
  141197. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141198. /**
  141199. * The reject method of the promise associated with this deferred object.
  141200. */
  141201. get reject(): (reason?: any) => void;
  141202. /**
  141203. * Constructor for this deferred object.
  141204. */
  141205. constructor();
  141206. }
  141207. }
  141208. declare module BABYLON {
  141209. /**
  141210. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141211. */
  141212. export class MeshExploder {
  141213. private _centerMesh;
  141214. private _meshes;
  141215. private _meshesOrigins;
  141216. private _toCenterVectors;
  141217. private _scaledDirection;
  141218. private _newPosition;
  141219. private _centerPosition;
  141220. /**
  141221. * Explodes meshes from a center mesh.
  141222. * @param meshes The meshes to explode.
  141223. * @param centerMesh The mesh to be center of explosion.
  141224. */
  141225. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141226. private _setCenterMesh;
  141227. /**
  141228. * Get class name
  141229. * @returns "MeshExploder"
  141230. */
  141231. getClassName(): string;
  141232. /**
  141233. * "Exploded meshes"
  141234. * @returns Array of meshes with the centerMesh at index 0.
  141235. */
  141236. getMeshes(): Array<Mesh>;
  141237. /**
  141238. * Explodes meshes giving a specific direction
  141239. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141240. */
  141241. explode(direction?: number): void;
  141242. }
  141243. }
  141244. declare module BABYLON {
  141245. /**
  141246. * Class used to help managing file picking and drag'n'drop
  141247. */
  141248. export class FilesInput {
  141249. /**
  141250. * List of files ready to be loaded
  141251. */
  141252. static get FilesToLoad(): {
  141253. [key: string]: File;
  141254. };
  141255. /**
  141256. * Callback called when a file is processed
  141257. */
  141258. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141259. private _engine;
  141260. private _currentScene;
  141261. private _sceneLoadedCallback;
  141262. private _progressCallback;
  141263. private _additionalRenderLoopLogicCallback;
  141264. private _textureLoadingCallback;
  141265. private _startingProcessingFilesCallback;
  141266. private _onReloadCallback;
  141267. private _errorCallback;
  141268. private _elementToMonitor;
  141269. private _sceneFileToLoad;
  141270. private _filesToLoad;
  141271. /**
  141272. * Creates a new FilesInput
  141273. * @param engine defines the rendering engine
  141274. * @param scene defines the hosting scene
  141275. * @param sceneLoadedCallback callback called when scene is loaded
  141276. * @param progressCallback callback called to track progress
  141277. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141278. * @param textureLoadingCallback callback called when a texture is loading
  141279. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141280. * @param onReloadCallback callback called when a reload is requested
  141281. * @param errorCallback callback call if an error occurs
  141282. */
  141283. 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);
  141284. private _dragEnterHandler;
  141285. private _dragOverHandler;
  141286. private _dropHandler;
  141287. /**
  141288. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141289. * @param elementToMonitor defines the DOM element to track
  141290. */
  141291. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141292. /**
  141293. * Release all associated resources
  141294. */
  141295. dispose(): void;
  141296. private renderFunction;
  141297. private drag;
  141298. private drop;
  141299. private _traverseFolder;
  141300. private _processFiles;
  141301. /**
  141302. * Load files from a drop event
  141303. * @param event defines the drop event to use as source
  141304. */
  141305. loadFiles(event: any): void;
  141306. private _processReload;
  141307. /**
  141308. * Reload the current scene from the loaded files
  141309. */
  141310. reload(): void;
  141311. }
  141312. }
  141313. declare module BABYLON {
  141314. /**
  141315. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141317. */
  141318. export class SceneOptimization {
  141319. /**
  141320. * Defines the priority of this optimization (0 by default which means first in the list)
  141321. */
  141322. priority: number;
  141323. /**
  141324. * Gets a string describing the action executed by the current optimization
  141325. * @returns description string
  141326. */
  141327. getDescription(): string;
  141328. /**
  141329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141330. * @param scene defines the current scene where to apply this optimization
  141331. * @param optimizer defines the current optimizer
  141332. * @returns true if everything that can be done was applied
  141333. */
  141334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141335. /**
  141336. * Creates the SceneOptimization object
  141337. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141338. * @param desc defines the description associated with the optimization
  141339. */
  141340. constructor(
  141341. /**
  141342. * Defines the priority of this optimization (0 by default which means first in the list)
  141343. */
  141344. priority?: number);
  141345. }
  141346. /**
  141347. * Defines an optimization used to reduce the size of render target textures
  141348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141349. */
  141350. export class TextureOptimization extends SceneOptimization {
  141351. /**
  141352. * Defines the priority of this optimization (0 by default which means first in the list)
  141353. */
  141354. priority: number;
  141355. /**
  141356. * 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
  141357. */
  141358. maximumSize: number;
  141359. /**
  141360. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141361. */
  141362. step: number;
  141363. /**
  141364. * Gets a string describing the action executed by the current optimization
  141365. * @returns description string
  141366. */
  141367. getDescription(): string;
  141368. /**
  141369. * Creates the TextureOptimization object
  141370. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141371. * @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
  141372. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141373. */
  141374. constructor(
  141375. /**
  141376. * Defines the priority of this optimization (0 by default which means first in the list)
  141377. */
  141378. priority?: number,
  141379. /**
  141380. * 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
  141381. */
  141382. maximumSize?: number,
  141383. /**
  141384. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141385. */
  141386. step?: number);
  141387. /**
  141388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141389. * @param scene defines the current scene where to apply this optimization
  141390. * @param optimizer defines the current optimizer
  141391. * @returns true if everything that can be done was applied
  141392. */
  141393. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141394. }
  141395. /**
  141396. * Defines an optimization used to increase or decrease the rendering resolution
  141397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141398. */
  141399. export class HardwareScalingOptimization extends SceneOptimization {
  141400. /**
  141401. * Defines the priority of this optimization (0 by default which means first in the list)
  141402. */
  141403. priority: number;
  141404. /**
  141405. * Defines the maximum scale to use (2 by default)
  141406. */
  141407. maximumScale: number;
  141408. /**
  141409. * Defines the step to use between two passes (0.5 by default)
  141410. */
  141411. step: number;
  141412. private _currentScale;
  141413. private _directionOffset;
  141414. /**
  141415. * Gets a string describing the action executed by the current optimization
  141416. * @return description string
  141417. */
  141418. getDescription(): string;
  141419. /**
  141420. * Creates the HardwareScalingOptimization object
  141421. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141422. * @param maximumScale defines the maximum scale to use (2 by default)
  141423. * @param step defines the step to use between two passes (0.5 by default)
  141424. */
  141425. constructor(
  141426. /**
  141427. * Defines the priority of this optimization (0 by default which means first in the list)
  141428. */
  141429. priority?: number,
  141430. /**
  141431. * Defines the maximum scale to use (2 by default)
  141432. */
  141433. maximumScale?: number,
  141434. /**
  141435. * Defines the step to use between two passes (0.5 by default)
  141436. */
  141437. step?: number);
  141438. /**
  141439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141440. * @param scene defines the current scene where to apply this optimization
  141441. * @param optimizer defines the current optimizer
  141442. * @returns true if everything that can be done was applied
  141443. */
  141444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141445. }
  141446. /**
  141447. * Defines an optimization used to remove shadows
  141448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141449. */
  141450. export class ShadowsOptimization extends SceneOptimization {
  141451. /**
  141452. * Gets a string describing the action executed by the current optimization
  141453. * @return description string
  141454. */
  141455. getDescription(): string;
  141456. /**
  141457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141458. * @param scene defines the current scene where to apply this optimization
  141459. * @param optimizer defines the current optimizer
  141460. * @returns true if everything that can be done was applied
  141461. */
  141462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141463. }
  141464. /**
  141465. * Defines an optimization used to turn post-processes off
  141466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141467. */
  141468. export class PostProcessesOptimization extends SceneOptimization {
  141469. /**
  141470. * Gets a string describing the action executed by the current optimization
  141471. * @return description string
  141472. */
  141473. getDescription(): string;
  141474. /**
  141475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141476. * @param scene defines the current scene where to apply this optimization
  141477. * @param optimizer defines the current optimizer
  141478. * @returns true if everything that can be done was applied
  141479. */
  141480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141481. }
  141482. /**
  141483. * Defines an optimization used to turn lens flares off
  141484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141485. */
  141486. export class LensFlaresOptimization extends SceneOptimization {
  141487. /**
  141488. * Gets a string describing the action executed by the current optimization
  141489. * @return description string
  141490. */
  141491. getDescription(): string;
  141492. /**
  141493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141494. * @param scene defines the current scene where to apply this optimization
  141495. * @param optimizer defines the current optimizer
  141496. * @returns true if everything that can be done was applied
  141497. */
  141498. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141499. }
  141500. /**
  141501. * Defines an optimization based on user defined callback.
  141502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141503. */
  141504. export class CustomOptimization extends SceneOptimization {
  141505. /**
  141506. * Callback called to apply the custom optimization.
  141507. */
  141508. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141509. /**
  141510. * Callback called to get custom description
  141511. */
  141512. onGetDescription: () => string;
  141513. /**
  141514. * Gets a string describing the action executed by the current optimization
  141515. * @returns description string
  141516. */
  141517. getDescription(): string;
  141518. /**
  141519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141520. * @param scene defines the current scene where to apply this optimization
  141521. * @param optimizer defines the current optimizer
  141522. * @returns true if everything that can be done was applied
  141523. */
  141524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141525. }
  141526. /**
  141527. * Defines an optimization used to turn particles off
  141528. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141529. */
  141530. export class ParticlesOptimization extends SceneOptimization {
  141531. /**
  141532. * Gets a string describing the action executed by the current optimization
  141533. * @return description string
  141534. */
  141535. getDescription(): string;
  141536. /**
  141537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141538. * @param scene defines the current scene where to apply this optimization
  141539. * @param optimizer defines the current optimizer
  141540. * @returns true if everything that can be done was applied
  141541. */
  141542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141543. }
  141544. /**
  141545. * Defines an optimization used to turn render targets off
  141546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141547. */
  141548. export class RenderTargetsOptimization extends SceneOptimization {
  141549. /**
  141550. * Gets a string describing the action executed by the current optimization
  141551. * @return description string
  141552. */
  141553. getDescription(): string;
  141554. /**
  141555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141556. * @param scene defines the current scene where to apply this optimization
  141557. * @param optimizer defines the current optimizer
  141558. * @returns true if everything that can be done was applied
  141559. */
  141560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141561. }
  141562. /**
  141563. * Defines an optimization used to merge meshes with compatible materials
  141564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141565. */
  141566. export class MergeMeshesOptimization extends SceneOptimization {
  141567. private static _UpdateSelectionTree;
  141568. /**
  141569. * Gets or sets a boolean which defines if optimization octree has to be updated
  141570. */
  141571. static get UpdateSelectionTree(): boolean;
  141572. /**
  141573. * Gets or sets a boolean which defines if optimization octree has to be updated
  141574. */
  141575. static set UpdateSelectionTree(value: boolean);
  141576. /**
  141577. * Gets a string describing the action executed by the current optimization
  141578. * @return description string
  141579. */
  141580. getDescription(): string;
  141581. private _canBeMerged;
  141582. /**
  141583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141584. * @param scene defines the current scene where to apply this optimization
  141585. * @param optimizer defines the current optimizer
  141586. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141587. * @returns true if everything that can be done was applied
  141588. */
  141589. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141590. }
  141591. /**
  141592. * Defines a list of options used by SceneOptimizer
  141593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141594. */
  141595. export class SceneOptimizerOptions {
  141596. /**
  141597. * Defines the target frame rate to reach (60 by default)
  141598. */
  141599. targetFrameRate: number;
  141600. /**
  141601. * Defines the interval between two checkes (2000ms by default)
  141602. */
  141603. trackerDuration: number;
  141604. /**
  141605. * Gets the list of optimizations to apply
  141606. */
  141607. optimizations: SceneOptimization[];
  141608. /**
  141609. * Creates a new list of options used by SceneOptimizer
  141610. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141611. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141612. */
  141613. constructor(
  141614. /**
  141615. * Defines the target frame rate to reach (60 by default)
  141616. */
  141617. targetFrameRate?: number,
  141618. /**
  141619. * Defines the interval between two checkes (2000ms by default)
  141620. */
  141621. trackerDuration?: number);
  141622. /**
  141623. * Add a new optimization
  141624. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141625. * @returns the current SceneOptimizerOptions
  141626. */
  141627. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141628. /**
  141629. * Add a new custom optimization
  141630. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141631. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141632. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141633. * @returns the current SceneOptimizerOptions
  141634. */
  141635. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141636. /**
  141637. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141638. * @param targetFrameRate defines the target frame rate (60 by default)
  141639. * @returns a SceneOptimizerOptions object
  141640. */
  141641. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141642. /**
  141643. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141644. * @param targetFrameRate defines the target frame rate (60 by default)
  141645. * @returns a SceneOptimizerOptions object
  141646. */
  141647. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141648. /**
  141649. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141650. * @param targetFrameRate defines the target frame rate (60 by default)
  141651. * @returns a SceneOptimizerOptions object
  141652. */
  141653. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141654. }
  141655. /**
  141656. * Class used to run optimizations in order to reach a target frame rate
  141657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141658. */
  141659. export class SceneOptimizer implements IDisposable {
  141660. private _isRunning;
  141661. private _options;
  141662. private _scene;
  141663. private _currentPriorityLevel;
  141664. private _targetFrameRate;
  141665. private _trackerDuration;
  141666. private _currentFrameRate;
  141667. private _sceneDisposeObserver;
  141668. private _improvementMode;
  141669. /**
  141670. * Defines an observable called when the optimizer reaches the target frame rate
  141671. */
  141672. onSuccessObservable: Observable<SceneOptimizer>;
  141673. /**
  141674. * Defines an observable called when the optimizer enables an optimization
  141675. */
  141676. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141677. /**
  141678. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141679. */
  141680. onFailureObservable: Observable<SceneOptimizer>;
  141681. /**
  141682. * Gets a boolean indicating if the optimizer is in improvement mode
  141683. */
  141684. get isInImprovementMode(): boolean;
  141685. /**
  141686. * Gets the current priority level (0 at start)
  141687. */
  141688. get currentPriorityLevel(): number;
  141689. /**
  141690. * Gets the current frame rate checked by the SceneOptimizer
  141691. */
  141692. get currentFrameRate(): number;
  141693. /**
  141694. * Gets or sets the current target frame rate (60 by default)
  141695. */
  141696. get targetFrameRate(): number;
  141697. /**
  141698. * Gets or sets the current target frame rate (60 by default)
  141699. */
  141700. set targetFrameRate(value: number);
  141701. /**
  141702. * Gets or sets the current interval between two checks (every 2000ms by default)
  141703. */
  141704. get trackerDuration(): number;
  141705. /**
  141706. * Gets or sets the current interval between two checks (every 2000ms by default)
  141707. */
  141708. set trackerDuration(value: number);
  141709. /**
  141710. * Gets the list of active optimizations
  141711. */
  141712. get optimizations(): SceneOptimization[];
  141713. /**
  141714. * Creates a new SceneOptimizer
  141715. * @param scene defines the scene to work on
  141716. * @param options defines the options to use with the SceneOptimizer
  141717. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141718. * @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)
  141719. */
  141720. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141721. /**
  141722. * Stops the current optimizer
  141723. */
  141724. stop(): void;
  141725. /**
  141726. * Reset the optimizer to initial step (current priority level = 0)
  141727. */
  141728. reset(): void;
  141729. /**
  141730. * Start the optimizer. By default it will try to reach a specific framerate
  141731. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141732. */
  141733. start(): void;
  141734. private _checkCurrentState;
  141735. /**
  141736. * Release all resources
  141737. */
  141738. dispose(): void;
  141739. /**
  141740. * Helper function to create a SceneOptimizer with one single line of code
  141741. * @param scene defines the scene to work on
  141742. * @param options defines the options to use with the SceneOptimizer
  141743. * @param onSuccess defines a callback to call on success
  141744. * @param onFailure defines a callback to call on failure
  141745. * @returns the new SceneOptimizer object
  141746. */
  141747. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141748. }
  141749. }
  141750. declare module BABYLON {
  141751. /**
  141752. * Class used to serialize a scene into a string
  141753. */
  141754. export class SceneSerializer {
  141755. /**
  141756. * Clear cache used by a previous serialization
  141757. */
  141758. static ClearCache(): void;
  141759. /**
  141760. * Serialize a scene into a JSON compatible object
  141761. * @param scene defines the scene to serialize
  141762. * @returns a JSON compatible object
  141763. */
  141764. static Serialize(scene: Scene): any;
  141765. /**
  141766. * Serialize a mesh into a JSON compatible object
  141767. * @param toSerialize defines the mesh to serialize
  141768. * @param withParents defines if parents must be serialized as well
  141769. * @param withChildren defines if children must be serialized as well
  141770. * @returns a JSON compatible object
  141771. */
  141772. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141773. }
  141774. }
  141775. declare module BABYLON {
  141776. /**
  141777. * Class used to host texture specific utilities
  141778. */
  141779. export class TextureTools {
  141780. /**
  141781. * Uses the GPU to create a copy texture rescaled at a given size
  141782. * @param texture Texture to copy from
  141783. * @param width defines the desired width
  141784. * @param height defines the desired height
  141785. * @param useBilinearMode defines if bilinear mode has to be used
  141786. * @return the generated texture
  141787. */
  141788. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141789. }
  141790. }
  141791. declare module BABYLON {
  141792. /**
  141793. * This represents the different options available for the video capture.
  141794. */
  141795. export interface VideoRecorderOptions {
  141796. /** Defines the mime type of the video. */
  141797. mimeType: string;
  141798. /** Defines the FPS the video should be recorded at. */
  141799. fps: number;
  141800. /** Defines the chunk size for the recording data. */
  141801. recordChunckSize: number;
  141802. /** The audio tracks to attach to the recording. */
  141803. audioTracks?: MediaStreamTrack[];
  141804. }
  141805. /**
  141806. * This can help with recording videos from BabylonJS.
  141807. * This is based on the available WebRTC functionalities of the browser.
  141808. *
  141809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141810. */
  141811. export class VideoRecorder {
  141812. private static readonly _defaultOptions;
  141813. /**
  141814. * Returns whether or not the VideoRecorder is available in your browser.
  141815. * @param engine Defines the Babylon Engine.
  141816. * @returns true if supported otherwise false.
  141817. */
  141818. static IsSupported(engine: Engine): boolean;
  141819. private readonly _options;
  141820. private _canvas;
  141821. private _mediaRecorder;
  141822. private _recordedChunks;
  141823. private _fileName;
  141824. private _resolve;
  141825. private _reject;
  141826. /**
  141827. * True when a recording is already in progress.
  141828. */
  141829. get isRecording(): boolean;
  141830. /**
  141831. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141832. * @param engine Defines the BabylonJS Engine you wish to record.
  141833. * @param options Defines options that can be used to customize the capture.
  141834. */
  141835. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141836. /**
  141837. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141838. */
  141839. stopRecording(): void;
  141840. /**
  141841. * Starts recording the canvas for a max duration specified in parameters.
  141842. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141843. * If null no automatic download will start and you can rely on the promise to get the data back.
  141844. * @param maxDuration Defines the maximum recording time in seconds.
  141845. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141846. * @return A promise callback at the end of the recording with the video data in Blob.
  141847. */
  141848. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141849. /**
  141850. * Releases internal resources used during the recording.
  141851. */
  141852. dispose(): void;
  141853. private _handleDataAvailable;
  141854. private _handleError;
  141855. private _handleStop;
  141856. }
  141857. }
  141858. declare module BABYLON {
  141859. /**
  141860. * Class containing a set of static utilities functions for screenshots
  141861. */
  141862. export class ScreenshotTools {
  141863. /**
  141864. * Captures a screenshot of the current rendering
  141865. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141866. * @param engine defines the rendering engine
  141867. * @param camera defines the source camera
  141868. * @param size This parameter can be set to a single number or to an object with the
  141869. * following (optional) properties: precision, width, height. If a single number is passed,
  141870. * it will be used for both width and height. If an object is passed, the screenshot size
  141871. * will be derived from the parameters. The precision property is a multiplier allowing
  141872. * rendering at a higher or lower resolution
  141873. * @param successCallback defines the callback receives a single parameter which contains the
  141874. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141875. * src parameter of an <img> to display it
  141876. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141877. * Check your browser for supported MIME types
  141878. */
  141879. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141880. /**
  141881. * Captures a screenshot of the current rendering
  141882. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141883. * @param engine defines the rendering engine
  141884. * @param camera defines the source camera
  141885. * @param size This parameter can be set to a single number or to an object with the
  141886. * following (optional) properties: precision, width, height. If a single number is passed,
  141887. * it will be used for both width and height. If an object is passed, the screenshot size
  141888. * will be derived from the parameters. The precision property is a multiplier allowing
  141889. * rendering at a higher or lower resolution
  141890. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141891. * Check your browser for supported MIME types
  141892. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141893. * to the src parameter of an <img> to display it
  141894. */
  141895. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141896. /**
  141897. * Generates an image screenshot from the specified camera.
  141898. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141899. * @param engine The engine to use for rendering
  141900. * @param camera The camera to use for rendering
  141901. * @param size This parameter can be set to a single number or to an object with the
  141902. * following (optional) properties: precision, width, height. If a single number is passed,
  141903. * it will be used for both width and height. If an object is passed, the screenshot size
  141904. * will be derived from the parameters. The precision property is a multiplier allowing
  141905. * rendering at a higher or lower resolution
  141906. * @param successCallback The callback receives a single parameter which contains the
  141907. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141908. * src parameter of an <img> to display it
  141909. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141910. * Check your browser for supported MIME types
  141911. * @param samples Texture samples (default: 1)
  141912. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141913. * @param fileName A name for for the downloaded file.
  141914. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141915. */
  141916. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141917. /**
  141918. * Generates an image screenshot from the specified camera.
  141919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141920. * @param engine The engine to use for rendering
  141921. * @param camera The camera to use for rendering
  141922. * @param size This parameter can be set to a single number or to an object with the
  141923. * following (optional) properties: precision, width, height. If a single number is passed,
  141924. * it will be used for both width and height. If an object is passed, the screenshot size
  141925. * will be derived from the parameters. The precision property is a multiplier allowing
  141926. * rendering at a higher or lower resolution
  141927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141928. * Check your browser for supported MIME types
  141929. * @param samples Texture samples (default: 1)
  141930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141931. * @param fileName A name for for the downloaded file.
  141932. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141933. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141934. * to the src parameter of an <img> to display it
  141935. */
  141936. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141937. /**
  141938. * Gets height and width for screenshot size
  141939. * @private
  141940. */
  141941. private static _getScreenshotSize;
  141942. }
  141943. }
  141944. declare module BABYLON {
  141945. /**
  141946. * Interface for a data buffer
  141947. */
  141948. export interface IDataBuffer {
  141949. /**
  141950. * Reads bytes from the data buffer.
  141951. * @param byteOffset The byte offset to read
  141952. * @param byteLength The byte length to read
  141953. * @returns A promise that resolves when the bytes are read
  141954. */
  141955. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141956. /**
  141957. * The byte length of the buffer.
  141958. */
  141959. readonly byteLength: number;
  141960. }
  141961. /**
  141962. * Utility class for reading from a data buffer
  141963. */
  141964. export class DataReader {
  141965. /**
  141966. * The data buffer associated with this data reader.
  141967. */
  141968. readonly buffer: IDataBuffer;
  141969. /**
  141970. * The current byte offset from the beginning of the data buffer.
  141971. */
  141972. byteOffset: number;
  141973. private _dataView;
  141974. private _dataByteOffset;
  141975. /**
  141976. * Constructor
  141977. * @param buffer The buffer to read
  141978. */
  141979. constructor(buffer: IDataBuffer);
  141980. /**
  141981. * Loads the given byte length.
  141982. * @param byteLength The byte length to load
  141983. * @returns A promise that resolves when the load is complete
  141984. */
  141985. loadAsync(byteLength: number): Promise<void>;
  141986. /**
  141987. * Read a unsigned 32-bit integer from the currently loaded data range.
  141988. * @returns The 32-bit integer read
  141989. */
  141990. readUint32(): number;
  141991. /**
  141992. * Read a byte array from the currently loaded data range.
  141993. * @param byteLength The byte length to read
  141994. * @returns The byte array read
  141995. */
  141996. readUint8Array(byteLength: number): Uint8Array;
  141997. /**
  141998. * Read a string from the currently loaded data range.
  141999. * @param byteLength The byte length to read
  142000. * @returns The string read
  142001. */
  142002. readString(byteLength: number): string;
  142003. /**
  142004. * Skips the given byte length the currently loaded data range.
  142005. * @param byteLength The byte length to skip
  142006. */
  142007. skipBytes(byteLength: number): void;
  142008. }
  142009. }
  142010. declare module BABYLON {
  142011. /**
  142012. * Options used for hit testing
  142013. */
  142014. export interface IWebXRHitTestOptions {
  142015. /**
  142016. * Only test when user interacted with the scene. Default - hit test every frame
  142017. */
  142018. testOnPointerDownOnly?: boolean;
  142019. /**
  142020. * The node to use to transform the local results to world coordinates
  142021. */
  142022. worldParentNode?: TransformNode;
  142023. }
  142024. /**
  142025. * Interface defining the babylon result of raycasting/hit-test
  142026. */
  142027. export interface IWebXRHitResult {
  142028. /**
  142029. * The native hit test result
  142030. */
  142031. xrHitResult: XRHitResult;
  142032. /**
  142033. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142034. */
  142035. transformationMatrix: Matrix;
  142036. }
  142037. /**
  142038. * The currently-working hit-test module.
  142039. * Hit test (or raycasting) is used to interact with the real world.
  142040. * For further information read here - https://github.com/immersive-web/hit-test
  142041. */
  142042. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142043. /**
  142044. * options to use when constructing this feature
  142045. */
  142046. readonly options: IWebXRHitTestOptions;
  142047. /**
  142048. * The module's name
  142049. */
  142050. static readonly Name: string;
  142051. /**
  142052. * The (Babylon) version of this module.
  142053. * This is an integer representing the implementation version.
  142054. * This number does not correspond to the webxr specs version
  142055. */
  142056. static readonly Version: number;
  142057. /**
  142058. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142059. * @param event the (select) event to use to select with
  142060. * @param referenceSpace the reference space to use for this hit test
  142061. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142062. */
  142063. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142064. /**
  142065. * execute a hit test with an XR Ray
  142066. *
  142067. * @param xrSession a native xrSession that will execute this hit test
  142068. * @param xrRay the ray (position and direction) to use for raycasting
  142069. * @param referenceSpace native XR reference space to use for the hit-test
  142070. * @param filter filter function that will filter the results
  142071. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142072. */
  142073. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142074. /**
  142075. * Triggered when new babylon (transformed) hit test results are available
  142076. */
  142077. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142078. private _onSelectEnabled;
  142079. /**
  142080. * Creates a new instance of the (legacy version) hit test feature
  142081. * @param _xrSessionManager an instance of WebXRSessionManager
  142082. * @param options options to use when constructing this feature
  142083. */
  142084. constructor(_xrSessionManager: WebXRSessionManager,
  142085. /**
  142086. * options to use when constructing this feature
  142087. */
  142088. options?: IWebXRHitTestOptions);
  142089. /**
  142090. * Populated with the last native XR Hit Results
  142091. */
  142092. lastNativeXRHitResults: XRHitResult[];
  142093. /**
  142094. * attach this feature
  142095. * Will usually be called by the features manager
  142096. *
  142097. * @returns true if successful.
  142098. */
  142099. attach(): boolean;
  142100. /**
  142101. * detach this feature.
  142102. * Will usually be called by the features manager
  142103. *
  142104. * @returns true if successful.
  142105. */
  142106. detach(): boolean;
  142107. private _onHitTestResults;
  142108. private _origin;
  142109. private _direction;
  142110. private _mat;
  142111. protected _onXRFrame(frame: XRFrame): void;
  142112. private _onSelect;
  142113. /**
  142114. * Dispose this feature and all of the resources attached
  142115. */
  142116. dispose(): void;
  142117. }
  142118. }
  142119. declare module BABYLON {
  142120. /**
  142121. * Options used in the plane detector module
  142122. */
  142123. export interface IWebXRPlaneDetectorOptions {
  142124. /**
  142125. * The node to use to transform the local results to world coordinates
  142126. */
  142127. worldParentNode?: TransformNode;
  142128. }
  142129. /**
  142130. * A babylon interface for a webxr plane.
  142131. * A Plane is actually a polygon, built from N points in space
  142132. *
  142133. * Supported in chrome 79, not supported in canary 81 ATM
  142134. */
  142135. export interface IWebXRPlane {
  142136. /**
  142137. * a babylon-assigned ID for this polygon
  142138. */
  142139. id: number;
  142140. /**
  142141. * the native xr-plane object
  142142. */
  142143. xrPlane: XRPlane;
  142144. /**
  142145. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142146. */
  142147. polygonDefinition: Array<Vector3>;
  142148. /**
  142149. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142150. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142151. */
  142152. transformationMatrix: Matrix;
  142153. }
  142154. /**
  142155. * The plane detector is used to detect planes in the real world when in AR
  142156. * For more information see https://github.com/immersive-web/real-world-geometry/
  142157. */
  142158. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142159. private _options;
  142160. /**
  142161. * The module's name
  142162. */
  142163. static readonly Name: string;
  142164. /**
  142165. * The (Babylon) version of this module.
  142166. * This is an integer representing the implementation version.
  142167. * This number does not correspond to the webxr specs version
  142168. */
  142169. static readonly Version: number;
  142170. /**
  142171. * Observers registered here will be executed when a new plane was added to the session
  142172. */
  142173. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142174. /**
  142175. * Observers registered here will be executed when a plane is no longer detected in the session
  142176. */
  142177. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142178. /**
  142179. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142180. * This can execute N times every frame
  142181. */
  142182. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142183. private _enabled;
  142184. private _detectedPlanes;
  142185. private _lastFrameDetected;
  142186. /**
  142187. * construct a new Plane Detector
  142188. * @param _xrSessionManager an instance of xr Session manager
  142189. * @param _options configuration to use when constructing this feature
  142190. */
  142191. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142192. private _init;
  142193. protected _onXRFrame(frame: XRFrame): void;
  142194. /**
  142195. * Dispose this feature and all of the resources attached
  142196. */
  142197. dispose(): void;
  142198. private _updatePlaneWithXRPlane;
  142199. /**
  142200. * avoiding using Array.find for global support.
  142201. * @param xrPlane the plane to find in the array
  142202. */
  142203. private findIndexInPlaneArray;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * Configuration options of the anchor system
  142209. */
  142210. export interface IWebXRAnchorSystemOptions {
  142211. /**
  142212. * a node that will be used to convert local to world coordinates
  142213. */
  142214. worldParentNode?: TransformNode;
  142215. /**
  142216. * should the anchor system use plane detection.
  142217. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142218. */
  142219. usePlaneDetection?: boolean;
  142220. /**
  142221. * Should a new anchor be added every time a select event is triggered
  142222. */
  142223. addAnchorOnSelect?: boolean;
  142224. }
  142225. /**
  142226. * A babylon container for an XR Anchor
  142227. */
  142228. export interface IWebXRAnchor {
  142229. /**
  142230. * A babylon-assigned ID for this anchor
  142231. */
  142232. id: number;
  142233. /**
  142234. * The native anchor object
  142235. */
  142236. xrAnchor: XRAnchor;
  142237. /**
  142238. * Transformation matrix to apply to an object attached to this anchor
  142239. */
  142240. transformationMatrix: Matrix;
  142241. }
  142242. /**
  142243. * An implementation of the anchor system of WebXR.
  142244. * Note that the current documented implementation is not available in any browser. Future implementations
  142245. * will use the frame to create an anchor and not the session or a detected plane
  142246. * For further information see https://github.com/immersive-web/anchors/
  142247. */
  142248. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142249. private _options;
  142250. /**
  142251. * The module's name
  142252. */
  142253. static readonly Name: string;
  142254. /**
  142255. * The (Babylon) version of this module.
  142256. * This is an integer representing the implementation version.
  142257. * This number does not correspond to the webxr specs version
  142258. */
  142259. static readonly Version: number;
  142260. /**
  142261. * Observers registered here will be executed when a new anchor was added to the session
  142262. */
  142263. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142264. /**
  142265. * Observers registered here will be executed when an existing anchor updates
  142266. * This can execute N times every frame
  142267. */
  142268. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142269. /**
  142270. * Observers registered here will be executed when an anchor was removed from the session
  142271. */
  142272. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142273. private _planeDetector;
  142274. private _hitTestModule;
  142275. private _enabled;
  142276. private _trackedAnchors;
  142277. private _lastFrameDetected;
  142278. /**
  142279. * constructs a new anchor system
  142280. * @param _xrSessionManager an instance of WebXRSessionManager
  142281. * @param _options configuration object for this feature
  142282. */
  142283. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142284. /**
  142285. * set the plane detector to use in order to create anchors from frames
  142286. * @param planeDetector the plane-detector module to use
  142287. * @param enable enable plane-anchors. default is true
  142288. */
  142289. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142290. /**
  142291. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142292. * @param hitTestModule the hit-test module to use.
  142293. */
  142294. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142295. /**
  142296. * attach this feature
  142297. * Will usually be called by the features manager
  142298. *
  142299. * @returns true if successful.
  142300. */
  142301. attach(): boolean;
  142302. /**
  142303. * detach this feature.
  142304. * Will usually be called by the features manager
  142305. *
  142306. * @returns true if successful.
  142307. */
  142308. detach(): boolean;
  142309. /**
  142310. * Dispose this feature and all of the resources attached
  142311. */
  142312. dispose(): void;
  142313. protected _onXRFrame(frame: XRFrame): void;
  142314. private _onSelect;
  142315. /**
  142316. * Add anchor at a specific XR point.
  142317. *
  142318. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142319. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142320. * @returns a promise the fulfills when the anchor was created
  142321. */
  142322. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142323. private _updateAnchorWithXRFrame;
  142324. /**
  142325. * avoiding using Array.find for global support.
  142326. * @param xrAnchor the plane to find in the array
  142327. */
  142328. private _findIndexInAnchorArray;
  142329. }
  142330. }
  142331. declare module BABYLON {
  142332. /**
  142333. * Options interface for the background remover plugin
  142334. */
  142335. export interface IWebXRBackgroundRemoverOptions {
  142336. /**
  142337. * don't disable the environment helper
  142338. */
  142339. ignoreEnvironmentHelper?: boolean;
  142340. /**
  142341. * flags to configure the removal of the environment helper.
  142342. * If not set, the entire background will be removed. If set, flags should be set as well.
  142343. */
  142344. environmentHelperRemovalFlags?: {
  142345. /**
  142346. * Should the skybox be removed (default false)
  142347. */
  142348. skyBox?: boolean;
  142349. /**
  142350. * Should the ground be removed (default false)
  142351. */
  142352. ground?: boolean;
  142353. };
  142354. /**
  142355. * Further background meshes to disable when entering AR
  142356. */
  142357. backgroundMeshes?: AbstractMesh[];
  142358. }
  142359. /**
  142360. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142361. */
  142362. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142363. /**
  142364. * read-only options to be used in this module
  142365. */
  142366. readonly options: IWebXRBackgroundRemoverOptions;
  142367. /**
  142368. * The module's name
  142369. */
  142370. static readonly Name: string;
  142371. /**
  142372. * The (Babylon) version of this module.
  142373. * This is an integer representing the implementation version.
  142374. * This number does not correspond to the webxr specs version
  142375. */
  142376. static readonly Version: number;
  142377. /**
  142378. * registered observers will be triggered when the background state changes
  142379. */
  142380. onBackgroundStateChangedObservable: Observable<boolean>;
  142381. /**
  142382. * constructs a new background remover module
  142383. * @param _xrSessionManager the session manager for this module
  142384. * @param options read-only options to be used in this module
  142385. */
  142386. constructor(_xrSessionManager: WebXRSessionManager,
  142387. /**
  142388. * read-only options to be used in this module
  142389. */
  142390. options?: IWebXRBackgroundRemoverOptions);
  142391. /**
  142392. * attach this feature
  142393. * Will usually be called by the features manager
  142394. *
  142395. * @returns true if successful.
  142396. */
  142397. attach(): boolean;
  142398. /**
  142399. * detach this feature.
  142400. * Will usually be called by the features manager
  142401. *
  142402. * @returns true if successful.
  142403. */
  142404. detach(): boolean;
  142405. private _setBackgroundState;
  142406. /**
  142407. * Dispose this feature and all of the resources attached
  142408. */
  142409. dispose(): void;
  142410. protected _onXRFrame(_xrFrame: XRFrame): void;
  142411. }
  142412. }
  142413. declare module BABYLON {
  142414. /**
  142415. * Options for the controller physics feature
  142416. */
  142417. export class IWebXRControllerPhysicsOptions {
  142418. /**
  142419. * the xr input to use with this pointer selection
  142420. */
  142421. xrInput: WebXRInput;
  142422. /**
  142423. * The physics properties of the future impostors
  142424. */
  142425. physicsProperties?: {
  142426. /**
  142427. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142428. * Note that this requires a physics engine that supports mesh impostors!
  142429. */
  142430. useControllerMesh?: boolean;
  142431. /**
  142432. * The type of impostor to create. Default is sphere
  142433. */
  142434. impostorType?: number;
  142435. /**
  142436. * the size of the impostor. Defaults to 10cm
  142437. */
  142438. impostorSize?: number | {
  142439. width: number;
  142440. height: number;
  142441. depth: number;
  142442. };
  142443. /**
  142444. * Friction definitions
  142445. */
  142446. friction?: number;
  142447. /**
  142448. * Restitution
  142449. */
  142450. restitution?: number;
  142451. };
  142452. /**
  142453. * Should the headset get its own impostor
  142454. */
  142455. enableHeadsetImpostor?: boolean;
  142456. /**
  142457. * Optional parameters for the headset impostor
  142458. */
  142459. headsetImpostorParams?: {
  142460. /**
  142461. * The type of impostor to create. Default is sphere
  142462. */
  142463. impostorType: number;
  142464. /**
  142465. * the size of the impostor. Defaults to 10cm
  142466. */
  142467. impostorSize?: number | {
  142468. width: number;
  142469. height: number;
  142470. depth: number;
  142471. };
  142472. /**
  142473. * Friction definitions
  142474. */
  142475. friction?: number;
  142476. /**
  142477. * Restitution
  142478. */
  142479. restitution?: number;
  142480. };
  142481. }
  142482. /**
  142483. * Add physics impostor to your webxr controllers,
  142484. * including naive calculation of their linear and angular velocity
  142485. */
  142486. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142487. private readonly _options;
  142488. /**
  142489. * The module's name
  142490. */
  142491. static readonly Name: string;
  142492. /**
  142493. * The (Babylon) version of this module.
  142494. * This is an integer representing the implementation version.
  142495. * This number does not correspond to the webxr specs version
  142496. */
  142497. static readonly Version: number;
  142498. private _lastTimestamp;
  142499. private _delta;
  142500. private _controllers;
  142501. private _headsetImpostor?;
  142502. private _headsetMesh?;
  142503. private _tmpVector;
  142504. private _tmpQuaternion;
  142505. /**
  142506. * Construct a new Controller Physics Feature
  142507. * @param _xrSessionManager the corresponding xr session manager
  142508. * @param _options options to create this feature with
  142509. */
  142510. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142511. /**
  142512. * Update the physics properties provided in the constructor
  142513. * @param newProperties the new properties object
  142514. */
  142515. setPhysicsProperties(newProperties: {
  142516. impostorType?: number;
  142517. impostorSize?: number | {
  142518. width: number;
  142519. height: number;
  142520. depth: number;
  142521. };
  142522. friction?: number;
  142523. restitution?: number;
  142524. }): void;
  142525. /**
  142526. * Get the physics impostor of a specific controller.
  142527. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142528. * @param controller the controller or the controller id of which to get the impostor
  142529. * @returns the impostor or null
  142530. */
  142531. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142532. /**
  142533. * Get the headset impostor, if enabled
  142534. * @returns the impostor
  142535. */
  142536. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142537. /**
  142538. * attach this feature
  142539. * Will usually be called by the features manager
  142540. *
  142541. * @returns true if successful.
  142542. */
  142543. attach(): boolean;
  142544. /**
  142545. * detach this feature.
  142546. * Will usually be called by the features manager
  142547. *
  142548. * @returns true if successful.
  142549. */
  142550. detach(): boolean;
  142551. /**
  142552. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142553. * @param xrController the controller to add
  142554. */
  142555. addController(xrController: WebXRInputSource): void;
  142556. private _debugMode;
  142557. /**
  142558. * @hidden
  142559. * enable debugging - will show console outputs and the impostor mesh
  142560. */
  142561. _enablePhysicsDebug(): void;
  142562. private _attachController;
  142563. private _detachController;
  142564. protected _onXRFrame(_xrFrame: any): void;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /**
  142569. * The motion controller class for all microsoft mixed reality controllers
  142570. */
  142571. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142572. /**
  142573. * The base url used to load the left and right controller models
  142574. */
  142575. static MODEL_BASE_URL: string;
  142576. /**
  142577. * The name of the left controller model file
  142578. */
  142579. static MODEL_LEFT_FILENAME: string;
  142580. /**
  142581. * The name of the right controller model file
  142582. */
  142583. static MODEL_RIGHT_FILENAME: string;
  142584. profileId: string;
  142585. protected readonly _mapping: {
  142586. defaultButton: {
  142587. "valueNodeName": string;
  142588. "unpressedNodeName": string;
  142589. "pressedNodeName": string;
  142590. };
  142591. defaultAxis: {
  142592. "valueNodeName": string;
  142593. "minNodeName": string;
  142594. "maxNodeName": string;
  142595. };
  142596. buttons: {
  142597. "xr-standard-trigger": {
  142598. "rootNodeName": string;
  142599. "componentProperty": string;
  142600. "states": string[];
  142601. };
  142602. "xr-standard-squeeze": {
  142603. "rootNodeName": string;
  142604. "componentProperty": string;
  142605. "states": string[];
  142606. };
  142607. "xr-standard-touchpad": {
  142608. "rootNodeName": string;
  142609. "labelAnchorNodeName": string;
  142610. "touchPointNodeName": string;
  142611. };
  142612. "xr-standard-thumbstick": {
  142613. "rootNodeName": string;
  142614. "componentProperty": string;
  142615. "states": string[];
  142616. };
  142617. };
  142618. axes: {
  142619. "xr-standard-touchpad": {
  142620. "x-axis": {
  142621. "rootNodeName": string;
  142622. };
  142623. "y-axis": {
  142624. "rootNodeName": string;
  142625. };
  142626. };
  142627. "xr-standard-thumbstick": {
  142628. "x-axis": {
  142629. "rootNodeName": string;
  142630. };
  142631. "y-axis": {
  142632. "rootNodeName": string;
  142633. };
  142634. };
  142635. };
  142636. };
  142637. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142638. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142639. protected _getFilenameAndPath(): {
  142640. filename: string;
  142641. path: string;
  142642. };
  142643. protected _updateModel(): void;
  142644. protected _getModelLoadingConstraints(): boolean;
  142645. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142646. }
  142647. }
  142648. declare module BABYLON {
  142649. /**
  142650. * The motion controller class for oculus touch (quest, rift).
  142651. * This class supports legacy mapping as well the standard xr mapping
  142652. */
  142653. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142654. private _forceLegacyControllers;
  142655. /**
  142656. * The base url used to load the left and right controller models
  142657. */
  142658. static MODEL_BASE_URL: string;
  142659. /**
  142660. * The name of the left controller model file
  142661. */
  142662. static MODEL_LEFT_FILENAME: string;
  142663. /**
  142664. * The name of the right controller model file
  142665. */
  142666. static MODEL_RIGHT_FILENAME: string;
  142667. /**
  142668. * Base Url for the Quest controller model.
  142669. */
  142670. static QUEST_MODEL_BASE_URL: string;
  142671. profileId: string;
  142672. private _modelRootNode;
  142673. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142674. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142675. protected _getFilenameAndPath(): {
  142676. filename: string;
  142677. path: string;
  142678. };
  142679. /**
  142680. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142681. * between the touch and touch 2.
  142682. */
  142683. private _isQuest;
  142684. protected _updateModel(): void;
  142685. protected _getModelLoadingConstraints(): boolean;
  142686. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142687. }
  142688. }
  142689. declare module BABYLON {
  142690. /**
  142691. * The motion controller class for the standard HTC-Vive controllers
  142692. */
  142693. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142694. /**
  142695. * The base url used to load the left and right controller models
  142696. */
  142697. static MODEL_BASE_URL: string;
  142698. /**
  142699. * File name for the controller model.
  142700. */
  142701. static MODEL_FILENAME: string;
  142702. profileId: string;
  142703. private _modelRootNode;
  142704. /**
  142705. * Create a new Vive motion controller object
  142706. * @param scene the scene to use to create this controller
  142707. * @param gamepadObject the corresponding gamepad object
  142708. * @param handness the handness of the controller
  142709. */
  142710. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142711. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142712. protected _getFilenameAndPath(): {
  142713. filename: string;
  142714. path: string;
  142715. };
  142716. protected _updateModel(): void;
  142717. protected _getModelLoadingConstraints(): boolean;
  142718. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142719. }
  142720. }
  142721. declare module BABYLON {
  142722. /**
  142723. * A cursor which tracks a point on a path
  142724. */
  142725. export class PathCursor {
  142726. private path;
  142727. /**
  142728. * Stores path cursor callbacks for when an onchange event is triggered
  142729. */
  142730. private _onchange;
  142731. /**
  142732. * The value of the path cursor
  142733. */
  142734. value: number;
  142735. /**
  142736. * The animation array of the path cursor
  142737. */
  142738. animations: Animation[];
  142739. /**
  142740. * Initializes the path cursor
  142741. * @param path The path to track
  142742. */
  142743. constructor(path: Path2);
  142744. /**
  142745. * Gets the cursor point on the path
  142746. * @returns A point on the path cursor at the cursor location
  142747. */
  142748. getPoint(): Vector3;
  142749. /**
  142750. * Moves the cursor ahead by the step amount
  142751. * @param step The amount to move the cursor forward
  142752. * @returns This path cursor
  142753. */
  142754. moveAhead(step?: number): PathCursor;
  142755. /**
  142756. * Moves the cursor behind by the step amount
  142757. * @param step The amount to move the cursor back
  142758. * @returns This path cursor
  142759. */
  142760. moveBack(step?: number): PathCursor;
  142761. /**
  142762. * Moves the cursor by the step amount
  142763. * If the step amount is greater than one, an exception is thrown
  142764. * @param step The amount to move the cursor
  142765. * @returns This path cursor
  142766. */
  142767. move(step: number): PathCursor;
  142768. /**
  142769. * Ensures that the value is limited between zero and one
  142770. * @returns This path cursor
  142771. */
  142772. private ensureLimits;
  142773. /**
  142774. * Runs onchange callbacks on change (used by the animation engine)
  142775. * @returns This path cursor
  142776. */
  142777. private raiseOnChange;
  142778. /**
  142779. * Executes a function on change
  142780. * @param f A path cursor onchange callback
  142781. * @returns This path cursor
  142782. */
  142783. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142784. }
  142785. }
  142786. declare module BABYLON {
  142787. /** @hidden */
  142788. export var blurPixelShader: {
  142789. name: string;
  142790. shader: string;
  142791. };
  142792. }
  142793. declare module BABYLON {
  142794. /** @hidden */
  142795. export var pointCloudVertexDeclaration: {
  142796. name: string;
  142797. shader: string;
  142798. };
  142799. }
  142800. // Mixins
  142801. interface Window {
  142802. mozIndexedDB: IDBFactory;
  142803. webkitIndexedDB: IDBFactory;
  142804. msIndexedDB: IDBFactory;
  142805. webkitURL: typeof URL;
  142806. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142807. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142808. WebGLRenderingContext: WebGLRenderingContext;
  142809. MSGesture: MSGesture;
  142810. CANNON: any;
  142811. AudioContext: AudioContext;
  142812. webkitAudioContext: AudioContext;
  142813. PointerEvent: any;
  142814. Math: Math;
  142815. Uint8Array: Uint8ArrayConstructor;
  142816. Float32Array: Float32ArrayConstructor;
  142817. mozURL: typeof URL;
  142818. msURL: typeof URL;
  142819. VRFrameData: any; // WebVR, from specs 1.1
  142820. DracoDecoderModule: any;
  142821. setImmediate(handler: (...args: any[]) => void): number;
  142822. }
  142823. interface HTMLCanvasElement {
  142824. requestPointerLock(): void;
  142825. msRequestPointerLock?(): void;
  142826. mozRequestPointerLock?(): void;
  142827. webkitRequestPointerLock?(): void;
  142828. /** Track wether a record is in progress */
  142829. isRecording: boolean;
  142830. /** Capture Stream method defined by some browsers */
  142831. captureStream(fps?: number): MediaStream;
  142832. }
  142833. interface CanvasRenderingContext2D {
  142834. msImageSmoothingEnabled: boolean;
  142835. }
  142836. interface MouseEvent {
  142837. mozMovementX: number;
  142838. mozMovementY: number;
  142839. webkitMovementX: number;
  142840. webkitMovementY: number;
  142841. msMovementX: number;
  142842. msMovementY: number;
  142843. }
  142844. interface Navigator {
  142845. mozGetVRDevices: (any: any) => any;
  142846. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142847. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142848. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142849. webkitGetGamepads(): Gamepad[];
  142850. msGetGamepads(): Gamepad[];
  142851. webkitGamepads(): Gamepad[];
  142852. }
  142853. interface HTMLVideoElement {
  142854. mozSrcObject: any;
  142855. }
  142856. interface Math {
  142857. fround(x: number): number;
  142858. imul(a: number, b: number): number;
  142859. }
  142860. interface WebGLRenderingContext {
  142861. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142862. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142863. vertexAttribDivisor(index: number, divisor: number): void;
  142864. createVertexArray(): any;
  142865. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142866. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142867. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142868. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142869. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142870. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142871. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142872. // Queries
  142873. createQuery(): WebGLQuery;
  142874. deleteQuery(query: WebGLQuery): void;
  142875. beginQuery(target: number, query: WebGLQuery): void;
  142876. endQuery(target: number): void;
  142877. getQueryParameter(query: WebGLQuery, pname: number): any;
  142878. getQuery(target: number, pname: number): any;
  142879. MAX_SAMPLES: number;
  142880. RGBA8: number;
  142881. READ_FRAMEBUFFER: number;
  142882. DRAW_FRAMEBUFFER: number;
  142883. UNIFORM_BUFFER: number;
  142884. HALF_FLOAT_OES: number;
  142885. RGBA16F: number;
  142886. RGBA32F: number;
  142887. R32F: number;
  142888. RG32F: number;
  142889. RGB32F: number;
  142890. R16F: number;
  142891. RG16F: number;
  142892. RGB16F: number;
  142893. RED: number;
  142894. RG: number;
  142895. R8: number;
  142896. RG8: number;
  142897. UNSIGNED_INT_24_8: number;
  142898. DEPTH24_STENCIL8: number;
  142899. MIN: number;
  142900. MAX: number;
  142901. /* Multiple Render Targets */
  142902. drawBuffers(buffers: number[]): void;
  142903. readBuffer(src: number): void;
  142904. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142905. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142906. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142907. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142908. // Occlusion Query
  142909. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142910. ANY_SAMPLES_PASSED: number;
  142911. QUERY_RESULT_AVAILABLE: number;
  142912. QUERY_RESULT: number;
  142913. }
  142914. interface WebGLProgram {
  142915. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142916. }
  142917. interface EXT_disjoint_timer_query {
  142918. QUERY_COUNTER_BITS_EXT: number;
  142919. TIME_ELAPSED_EXT: number;
  142920. TIMESTAMP_EXT: number;
  142921. GPU_DISJOINT_EXT: number;
  142922. QUERY_RESULT_EXT: number;
  142923. QUERY_RESULT_AVAILABLE_EXT: number;
  142924. queryCounterEXT(query: WebGLQuery, target: number): void;
  142925. createQueryEXT(): WebGLQuery;
  142926. beginQueryEXT(target: number, query: WebGLQuery): void;
  142927. endQueryEXT(target: number): void;
  142928. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142929. deleteQueryEXT(query: WebGLQuery): void;
  142930. }
  142931. interface WebGLUniformLocation {
  142932. _currentState: any;
  142933. }
  142934. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142935. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142936. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142937. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142938. interface WebGLRenderingContext {
  142939. readonly RASTERIZER_DISCARD: number;
  142940. readonly DEPTH_COMPONENT24: number;
  142941. readonly TEXTURE_3D: number;
  142942. readonly TEXTURE_2D_ARRAY: number;
  142943. readonly TEXTURE_COMPARE_FUNC: number;
  142944. readonly TEXTURE_COMPARE_MODE: number;
  142945. readonly COMPARE_REF_TO_TEXTURE: number;
  142946. readonly TEXTURE_WRAP_R: number;
  142947. readonly HALF_FLOAT: number;
  142948. readonly RGB8: number;
  142949. readonly RED_INTEGER: number;
  142950. readonly RG_INTEGER: number;
  142951. readonly RGB_INTEGER: number;
  142952. readonly RGBA_INTEGER: number;
  142953. readonly R8_SNORM: number;
  142954. readonly RG8_SNORM: number;
  142955. readonly RGB8_SNORM: number;
  142956. readonly RGBA8_SNORM: number;
  142957. readonly R8I: number;
  142958. readonly RG8I: number;
  142959. readonly RGB8I: number;
  142960. readonly RGBA8I: number;
  142961. readonly R8UI: number;
  142962. readonly RG8UI: number;
  142963. readonly RGB8UI: number;
  142964. readonly RGBA8UI: number;
  142965. readonly R16I: number;
  142966. readonly RG16I: number;
  142967. readonly RGB16I: number;
  142968. readonly RGBA16I: number;
  142969. readonly R16UI: number;
  142970. readonly RG16UI: number;
  142971. readonly RGB16UI: number;
  142972. readonly RGBA16UI: number;
  142973. readonly R32I: number;
  142974. readonly RG32I: number;
  142975. readonly RGB32I: number;
  142976. readonly RGBA32I: number;
  142977. readonly R32UI: number;
  142978. readonly RG32UI: number;
  142979. readonly RGB32UI: number;
  142980. readonly RGBA32UI: number;
  142981. readonly RGB10_A2UI: number;
  142982. readonly R11F_G11F_B10F: number;
  142983. readonly RGB9_E5: number;
  142984. readonly RGB10_A2: number;
  142985. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142986. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142987. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142988. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142989. readonly DEPTH_COMPONENT32F: number;
  142990. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142991. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142992. 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;
  142993. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142994. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142995. readonly TRANSFORM_FEEDBACK: number;
  142996. readonly INTERLEAVED_ATTRIBS: number;
  142997. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142998. createTransformFeedback(): WebGLTransformFeedback;
  142999. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143000. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143001. beginTransformFeedback(primitiveMode: number): void;
  143002. endTransformFeedback(): void;
  143003. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143004. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143005. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143006. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143007. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143008. }
  143009. interface ImageBitmap {
  143010. readonly width: number;
  143011. readonly height: number;
  143012. close(): void;
  143013. }
  143014. interface WebGLQuery extends WebGLObject {
  143015. }
  143016. declare var WebGLQuery: {
  143017. prototype: WebGLQuery;
  143018. new(): WebGLQuery;
  143019. };
  143020. interface WebGLSampler extends WebGLObject {
  143021. }
  143022. declare var WebGLSampler: {
  143023. prototype: WebGLSampler;
  143024. new(): WebGLSampler;
  143025. };
  143026. interface WebGLSync extends WebGLObject {
  143027. }
  143028. declare var WebGLSync: {
  143029. prototype: WebGLSync;
  143030. new(): WebGLSync;
  143031. };
  143032. interface WebGLTransformFeedback extends WebGLObject {
  143033. }
  143034. declare var WebGLTransformFeedback: {
  143035. prototype: WebGLTransformFeedback;
  143036. new(): WebGLTransformFeedback;
  143037. };
  143038. interface WebGLVertexArrayObject extends WebGLObject {
  143039. }
  143040. declare var WebGLVertexArrayObject: {
  143041. prototype: WebGLVertexArrayObject;
  143042. new(): WebGLVertexArrayObject;
  143043. };
  143044. // Type definitions for WebVR API
  143045. // Project: https://w3c.github.io/webvr/
  143046. // Definitions by: six a <https://github.com/lostfictions>
  143047. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143048. interface VRDisplay extends EventTarget {
  143049. /**
  143050. * Dictionary of capabilities describing the VRDisplay.
  143051. */
  143052. readonly capabilities: VRDisplayCapabilities;
  143053. /**
  143054. * z-depth defining the far plane of the eye view frustum
  143055. * enables mapping of values in the render target depth
  143056. * attachment to scene coordinates. Initially set to 10000.0.
  143057. */
  143058. depthFar: number;
  143059. /**
  143060. * z-depth defining the near plane of the eye view frustum
  143061. * enables mapping of values in the render target depth
  143062. * attachment to scene coordinates. Initially set to 0.01.
  143063. */
  143064. depthNear: number;
  143065. /**
  143066. * An identifier for this distinct VRDisplay. Used as an
  143067. * association point in the Gamepad API.
  143068. */
  143069. readonly displayId: number;
  143070. /**
  143071. * A display name, a user-readable name identifying it.
  143072. */
  143073. readonly displayName: string;
  143074. readonly isConnected: boolean;
  143075. readonly isPresenting: boolean;
  143076. /**
  143077. * If this VRDisplay supports room-scale experiences, the optional
  143078. * stage attribute contains details on the room-scale parameters.
  143079. */
  143080. readonly stageParameters: VRStageParameters | null;
  143081. /**
  143082. * Passing the value returned by `requestAnimationFrame` to
  143083. * `cancelAnimationFrame` will unregister the callback.
  143084. * @param handle Define the hanle of the request to cancel
  143085. */
  143086. cancelAnimationFrame(handle: number): void;
  143087. /**
  143088. * Stops presenting to the VRDisplay.
  143089. * @returns a promise to know when it stopped
  143090. */
  143091. exitPresent(): Promise<void>;
  143092. /**
  143093. * Return the current VREyeParameters for the given eye.
  143094. * @param whichEye Define the eye we want the parameter for
  143095. * @returns the eye parameters
  143096. */
  143097. getEyeParameters(whichEye: string): VREyeParameters;
  143098. /**
  143099. * Populates the passed VRFrameData with the information required to render
  143100. * the current frame.
  143101. * @param frameData Define the data structure to populate
  143102. * @returns true if ok otherwise false
  143103. */
  143104. getFrameData(frameData: VRFrameData): boolean;
  143105. /**
  143106. * Get the layers currently being presented.
  143107. * @returns the list of VR layers
  143108. */
  143109. getLayers(): VRLayer[];
  143110. /**
  143111. * Return a VRPose containing the future predicted pose of the VRDisplay
  143112. * when the current frame will be presented. The value returned will not
  143113. * change until JavaScript has returned control to the browser.
  143114. *
  143115. * The VRPose will contain the position, orientation, velocity,
  143116. * and acceleration of each of these properties.
  143117. * @returns the pose object
  143118. */
  143119. getPose(): VRPose;
  143120. /**
  143121. * Return the current instantaneous pose of the VRDisplay, with no
  143122. * prediction applied.
  143123. * @returns the current instantaneous pose
  143124. */
  143125. getImmediatePose(): VRPose;
  143126. /**
  143127. * The callback passed to `requestAnimationFrame` will be called
  143128. * any time a new frame should be rendered. When the VRDisplay is
  143129. * presenting the callback will be called at the native refresh
  143130. * rate of the HMD. When not presenting this function acts
  143131. * identically to how window.requestAnimationFrame acts. Content should
  143132. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143133. * asynchronously from other displays and at differing refresh rates.
  143134. * @param callback Define the eaction to run next frame
  143135. * @returns the request handle it
  143136. */
  143137. requestAnimationFrame(callback: FrameRequestCallback): number;
  143138. /**
  143139. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143140. * Repeat calls while already presenting will update the VRLayers being displayed.
  143141. * @param layers Define the list of layer to present
  143142. * @returns a promise to know when the request has been fulfilled
  143143. */
  143144. requestPresent(layers: VRLayer[]): Promise<void>;
  143145. /**
  143146. * Reset the pose for this display, treating its current position and
  143147. * orientation as the "origin/zero" values. VRPose.position,
  143148. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143149. * updated when calling resetPose(). This should be called in only
  143150. * sitting-space experiences.
  143151. */
  143152. resetPose(): void;
  143153. /**
  143154. * The VRLayer provided to the VRDisplay will be captured and presented
  143155. * in the HMD. Calling this function has the same effect on the source
  143156. * canvas as any other operation that uses its source image, and canvases
  143157. * created without preserveDrawingBuffer set to true will be cleared.
  143158. * @param pose Define the pose to submit
  143159. */
  143160. submitFrame(pose?: VRPose): void;
  143161. }
  143162. declare var VRDisplay: {
  143163. prototype: VRDisplay;
  143164. new(): VRDisplay;
  143165. };
  143166. interface VRLayer {
  143167. leftBounds?: number[] | Float32Array | null;
  143168. rightBounds?: number[] | Float32Array | null;
  143169. source?: HTMLCanvasElement | null;
  143170. }
  143171. interface VRDisplayCapabilities {
  143172. readonly canPresent: boolean;
  143173. readonly hasExternalDisplay: boolean;
  143174. readonly hasOrientation: boolean;
  143175. readonly hasPosition: boolean;
  143176. readonly maxLayers: number;
  143177. }
  143178. interface VREyeParameters {
  143179. /** @deprecated */
  143180. readonly fieldOfView: VRFieldOfView;
  143181. readonly offset: Float32Array;
  143182. readonly renderHeight: number;
  143183. readonly renderWidth: number;
  143184. }
  143185. interface VRFieldOfView {
  143186. readonly downDegrees: number;
  143187. readonly leftDegrees: number;
  143188. readonly rightDegrees: number;
  143189. readonly upDegrees: number;
  143190. }
  143191. interface VRFrameData {
  143192. readonly leftProjectionMatrix: Float32Array;
  143193. readonly leftViewMatrix: Float32Array;
  143194. readonly pose: VRPose;
  143195. readonly rightProjectionMatrix: Float32Array;
  143196. readonly rightViewMatrix: Float32Array;
  143197. readonly timestamp: number;
  143198. }
  143199. interface VRPose {
  143200. readonly angularAcceleration: Float32Array | null;
  143201. readonly angularVelocity: Float32Array | null;
  143202. readonly linearAcceleration: Float32Array | null;
  143203. readonly linearVelocity: Float32Array | null;
  143204. readonly orientation: Float32Array | null;
  143205. readonly position: Float32Array | null;
  143206. readonly timestamp: number;
  143207. }
  143208. interface VRStageParameters {
  143209. sittingToStandingTransform?: Float32Array;
  143210. sizeX?: number;
  143211. sizeY?: number;
  143212. }
  143213. interface Navigator {
  143214. getVRDisplays(): Promise<VRDisplay[]>;
  143215. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143216. }
  143217. interface Window {
  143218. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143219. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143220. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143221. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143222. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143223. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143224. }
  143225. interface Gamepad {
  143226. readonly displayId: number;
  143227. }
  143228. type XRSessionMode =
  143229. | "inline"
  143230. | "immersive-vr"
  143231. | "immersive-ar";
  143232. type XRReferenceSpaceType =
  143233. | "viewer"
  143234. | "local"
  143235. | "local-floor"
  143236. | "bounded-floor"
  143237. | "unbounded";
  143238. type XREnvironmentBlendMode =
  143239. | "opaque"
  143240. | "additive"
  143241. | "alpha-blend";
  143242. type XRVisibilityState =
  143243. | "visible"
  143244. | "visible-blurred"
  143245. | "hidden";
  143246. type XRHandedness =
  143247. | "none"
  143248. | "left"
  143249. | "right";
  143250. type XRTargetRayMode =
  143251. | "gaze"
  143252. | "tracked-pointer"
  143253. | "screen";
  143254. type XREye =
  143255. | "none"
  143256. | "left"
  143257. | "right";
  143258. interface XRSpace extends EventTarget {
  143259. }
  143260. interface XRRenderState {
  143261. depthNear?: number;
  143262. depthFar?: number;
  143263. inlineVerticalFieldOfView?: number;
  143264. baseLayer?: XRWebGLLayer;
  143265. }
  143266. interface XRInputSource {
  143267. handedness: XRHandedness;
  143268. targetRayMode: XRTargetRayMode;
  143269. targetRaySpace: XRSpace;
  143270. gripSpace: XRSpace | undefined;
  143271. gamepad: Gamepad | undefined;
  143272. profiles: Array<string>;
  143273. }
  143274. interface XRSessionInit {
  143275. optionalFeatures?: XRReferenceSpaceType[];
  143276. requiredFeatures?: XRReferenceSpaceType[];
  143277. }
  143278. interface XRSession extends XRAnchorCreator {
  143279. addEventListener: Function;
  143280. removeEventListener: Function;
  143281. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143282. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143283. requestAnimationFrame: Function;
  143284. end(): Promise<void>;
  143285. renderState: XRRenderState;
  143286. inputSources: Array<XRInputSource>;
  143287. // AR hit test
  143288. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143289. updateWorldTrackingState(options: {
  143290. planeDetectionState?: { enabled: boolean; }
  143291. }): void;
  143292. }
  143293. interface XRReferenceSpace extends XRSpace {
  143294. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143295. onreset: any;
  143296. }
  143297. type XRPlaneSet = Set<XRPlane>;
  143298. type XRAnchorSet = Set<XRAnchor>;
  143299. interface XRFrame {
  143300. session: XRSession;
  143301. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143302. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143303. // Anchors
  143304. trackedAnchors?: XRAnchorSet;
  143305. // Planes
  143306. worldInformation: {
  143307. detectedPlanes?: XRPlaneSet;
  143308. };
  143309. }
  143310. interface XRViewerPose extends XRPose {
  143311. views: Array<XRView>;
  143312. }
  143313. interface XRPose {
  143314. transform: XRRigidTransform;
  143315. emulatedPosition: boolean;
  143316. }
  143317. interface XRWebGLLayerOptions {
  143318. antialias?: boolean;
  143319. depth?: boolean;
  143320. stencil?: boolean;
  143321. alpha?: boolean;
  143322. multiview?: boolean;
  143323. framebufferScaleFactor?: number;
  143324. }
  143325. declare var XRWebGLLayer: {
  143326. prototype: XRWebGLLayer;
  143327. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143328. };
  143329. interface XRWebGLLayer {
  143330. framebuffer: WebGLFramebuffer;
  143331. framebufferWidth: number;
  143332. framebufferHeight: number;
  143333. getViewport: Function;
  143334. }
  143335. declare class XRRigidTransform {
  143336. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143337. position: DOMPointReadOnly;
  143338. orientation: DOMPointReadOnly;
  143339. matrix: Float32Array;
  143340. inverse: XRRigidTransform;
  143341. }
  143342. interface XRView {
  143343. eye: XREye;
  143344. projectionMatrix: Float32Array;
  143345. transform: XRRigidTransform;
  143346. }
  143347. interface XRInputSourceChangeEvent {
  143348. session: XRSession;
  143349. removed: Array<XRInputSource>;
  143350. added: Array<XRInputSource>;
  143351. }
  143352. interface XRInputSourceEvent extends Event {
  143353. readonly frame: XRFrame;
  143354. readonly inputSource: XRInputSource;
  143355. }
  143356. // Experimental(er) features
  143357. declare class XRRay {
  143358. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143359. origin: DOMPointReadOnly;
  143360. direction: DOMPointReadOnly;
  143361. matrix: Float32Array;
  143362. }
  143363. interface XRHitResult {
  143364. hitMatrix: Float32Array;
  143365. }
  143366. interface XRAnchor {
  143367. // remove?
  143368. id?: string;
  143369. anchorSpace: XRSpace;
  143370. lastChangedTime: number;
  143371. detach(): void;
  143372. }
  143373. interface XRPlane extends XRAnchorCreator {
  143374. orientation: "Horizontal" | "Vertical";
  143375. planeSpace: XRSpace;
  143376. polygon: Array<DOMPointReadOnly>;
  143377. lastChangedTime: number;
  143378. }
  143379. interface XRAnchorCreator {
  143380. // AR Anchors
  143381. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143382. }